akhauriyash/Code-Regression huggingface dataset:
c = [[int(i) for i in input().split()] for _ in range(3)]

ans = 'Yes'
if c[0][0] - c[0][1] != c[1][0] - c[1][1] or c[0][0] - c[0][1] != c[2][0] - c[2][1]:
    ans = 'No'
if c[0][0] - c[0][2] != c[1][0] - c[1][2] or c[0][0] - c[0][2] != c[2][0] - c[2][2]:
    ans = 'No'
if c[0][0] - c[1][0] != c[0][1] - c[1][1] or c[0][0] - c[1][0] != c[0][2] - c[1][2]:
    ans = 'No'
if c[0][0] - c[2][0] != c[0][1] - c[2][1] or c[0][0] - c[2][0] != c[0][2] - c[2][2]:
    ans = 'No'

print(ans)


Measured memory_bytes: 3064
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//WATLEPIYO
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,i,j,k,n;cin>>n;
	int can[21][21]={0};
	for(i=0;i<n;i++){for(j=0;j<n;j++){cin>>can[i][j];}}
	static llint dp[(1<<21)]={0};
	dp[0]=1;
	for(int bi=0;bi<(1<<n)-1;bi++){
		int ban=0;
		for(i=0;i<n;i++){if(bi&(1<<i)){ban++;}}
		for(i=0;i<n;i++){
			if((!(bi&(1<<i)))&&can[ban][i]){dp[bi+(1<<i)]+=dp[bi];dp[bi+(1<<i)]%=mod;}
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}


Measured memory_bytes: 16640
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

struct UnionFind {
	std::vector<int> par;
	std::vector<int> sizes;
	vl val;
	UnionFind(vl v) {
		int n = v.size();
		val = v;
		par.resize(n);
		sizes.resize(n);
		for (int i = 0; i < n; ++i) {
			par[i] = i;
			sizes[i] = 1;
		}
	}

	int root(int a) {
		return par[a] == a ? a : par[a] = root(par[a]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y)return;
		if (sizes[x] < sizes[y]) std::swap(x, y);

		par[y] = x;
		sizes[x] += sizes[y];
		val[x] += val[y];
	}
	int size(int x) {
		return sizes[root(x)];
	}
};

struct Edge {
	ll from, to, cost, index;
	bool operator <(const Edge &rhs) const {
		return this->cost < rhs.cost;
	}
};


using Graph = vector<vector<Edge>>;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	vl v(n);
	REP(i, n)cin >> v[i];
	vector<Edge> e(m);
	Graph g(n);
	REP(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		e[i] = Edge{ a,b,c,i };
		g[a].push_back(Edge{ a,b,c,i });
		g[b].push_back(Edge{ b,a,c,i });
	}
	UnionFind uf(v);
	sort(ALL(e));
	vi b(m, 0);
	REP(i, m) {
		uf.unite(e[i].from, e[i].to);
		if (uf.val[uf.root(e[i].from)] >= e[i].cost)b[e[i].index] = 1;
	}
	vi visited(n, 0);
	int ans = 0;
	RREP(i, m) {
		if (b[e[i].index] == 0) {
			ans++;
			continue;
		}
		queue<int> q;
		q.push(e[i].from);
		while (!q.empty()) {
			int p = q.front();
			q.pop();
			REP(j, g[p].size()) {
				if (e[i].cost < g[p][j].cost)continue;
				b[g[p][j].index] = 1;
				if (visited[g[p][j].to] == 0) {
					q.push(g[p][j].to);
					visited[g[p][j].to] = 1;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 17792
//ITP1_6_A:   Reversing Numbers
//n→数列の長さ
#include<stdio.h>

int main(){
	int n=0;
	int num[100]={0};
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%d",&num[i]);
	}
	for(int i=n-1; i>=0; i--){
		printf("%d",num[i]);
		if(!(i==0)){
			printf(" ");
		}else{
			printf("\n");
		}
	}
	return 0;
}



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

int Max(int a, int b) {
	return a < b ? b : a;
}

int main(void) {
	int n, c,grid[2][101] = {0};
	scanf("%d", &n);

	for (int i = 0; i < 2; i++) {
		for (int j = 1; j <= n; j++) {
			scanf("%d", &c);
			if (i == 0) {
				grid[i][j] = grid[i][j - 1] + c;
			}
			else {
				grid[i][j] = Max(grid[i][j - 1], grid[i - 1][j]) + c;
			}
		}
	}
	printf("%d\n", grid[1][n]);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int x,y,a,b,c; cin >> x >> y >> a >> b >> c;
    vint p(a),q(b),r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(all(p),greater<int>());
    sort(all(q),greater<int>());
    sort(all(r),greater<int>());

    priority_queue<int> pq;
    rep(i,x) pq.push(p[i]);
    rep(i,y) pq.push(q[i]);
    rep(i,c) pq.push(r[i]);

    int res=0;
    rep(i,x+y){
        res+=pq.top();
        pq.pop();
    }
    cout<<res<<endl;

}

Measured memory_bytes: 9748
using System;
class Program{
  static void Main(string[] args){
    int a = int.Parse(Console.ReadLine());
    int b = int.Parse(Console.ReadLine());
    int c = int.Parse(Console.ReadLine());
    int d = int.Parse(Console.ReadLine());
    int e = int.Parse(Console.ReadLine());
    int k = int.Parse(Console.ReadLine());
    Console.WriteLine(e-a>k?":(":"Yay!");
  }
}

Measured memory_bytes: 11092
import sys
readline = sys.stdin.readline

K = int(readline())
S = readline().rstrip()
S = len(S)
N = K + S

DIV = 10 ** 9 + 7
n = (10 ** 6) * 2
g1 = [1] * 2 + [0] * (n - 2) # 元テーブル
g2 = [1] * 2 + [0] * (n - 2) #逆元テーブル
inverse = [0, 1] + [0] * (n - 2) #逆元テーブル計算用テーブル

for i in range(2, n):
  g1[i] = (g1[i - 1] * i ) % DIV
  inverse[i] = (-inverse[DIV % i] * (DIV // i)) % DIV
  g2[i] = (g2[i - 1] * inverse[i]) % DIV

def nCr(n, r, DIV):
  if ( r<0 or r>n ):
      return 0
  r = min(r, n-r)
  return g1[n] * g2[r] * g2[n-r] % DIV

# K = 3, S = 5のとき
# ..X.X.X.
# Xが取る3か所を選んだ上で、
# 最も右のXよりも右のマス：各26通り
# 最も右のXを含む、それより左のマス：Xのマスは1通り、それ以外は各25通り
# 最も右のXが
# ..X.....　の状態から、
# .......X  
# の状態について、場合の数を求める

ans = 0
for xpos in range(S, N + 1):
  # xpos箇所からK箇所を選ぶ場合の数
  # 一番右に1個固定した状態で、残りのxpos - 1か所からS - 1個を選ぶ
  pat = nCr(xpos - 1, S - 1, DIV)
  # その場合の数に対して、X以外の文字の選び方は25 ** (X - S)通りある
  pat *= pow(25, xpos - S, DIV)
  pat %= DIV
  
  # 残りのマスに対しては26通りずつ選べる
  pat *= pow(26, N - xpos, DIV)
  pat %= DIV
  
  ans += pat
  ans %= DIV

print(ans)


Measured memory_bytes: 169652
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N, K, Q, A, correct[100001] = {};

int main() {
	cin >> N >> K >> Q;
	for (int i = 1; i <= Q; i++) {
		cin >> A;
		correct[A]++;
	}
	for (int i = 1; i <= N; i++) {
		if (K - Q + correct[i] > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#define N 10000

int isPrime(int);

int main(){

  int n, i, count=0;
  int a[N];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }


  for( i=0;i<n;i++ ) {

    if( isPrime(a[i]) )  count++;

  }
  printf("%d\n", count);

  return 0;
}

int isPrime(int x){

  int j;

  if(x < 2) return 0;
  if(x == 2) return 1;
  if(x%2==0) return 0;
  for(j=3; j*j<=x; j+=2){
    if(x%j == 0) return 0;
  }

  return 1;
    
}





Measured memory_bytes: 2104
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

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

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	double a, b, c, d, e, f;
	while(~scanf(" %lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f)) {
		printf("%.3f %.3f\n", (e * c - b * f) / (a * e - b * d) + 0.0, (a * f - c * d) / (a * e - b * d) + 0.0);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<unordered_map>
#include<map>
#include<string>
#include<cstring>
#include<stack>
#include<cmath>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 100000
#define M 1e18

using namespace std;

int main() {
	int h, w;
	int n;
	sfd(h);
	sfd(w);
	sfd(n);
	int num;
	int** ans = new int*[h];
	for( int i=0; i<h; i++ ) {
		ans[i] = new int[w];
	}
	bool f = false;
	int l = 0, k = 0;
	for( int i=1; i<=n; i++ ) {
		sfd(num);
		for( int j=0; j<num; j++ ) {
			ans[l][k] = i;
//			cout << "l = " << l << "    k = " << k << endl;
			if( l%2==0 ) {
				k++;
			}else {
				k--;
			}
			if( k>=w ) {
				k--;
				l++;
			}
			if( k<0 ) {
				k++;
				l++;
			}
			if( l>=h ) {
				f = true;
				break;
			}
		}
		if( f ) {
			break;
		}
	}
	for( int i=0; i<h; i++ ) {
		for( int j=0; j<w; j++ ) {
			pfd(ans[i][j]);
			if( j<w-1 ) {
				pfk;
			}
		}
		pfn;
	}

	return 0;
}

Measured memory_bytes: 384
alphabet_list = [0 for x in range(ord('a'),ord('z')+1)]

S = list(raw_input())

for x in S:
    alphabet_list[ord(x) - ord('a')] += 1

print_flag = False
for index in range(0,ord('z')-ord('a')+1):
    if alphabet_list[index] == 0:
        print(chr(index+ord('a')))
        print_flag = True
        break

if not(print_flag):
    print('None')


Measured memory_bytes: 3460
#include <stdio.h>
#include <set>
using namespace std;

multiset<int> U;
int N,A[200200];

int main()
{
	scanf ("%d",&N);
	for (int i=0;i<N;i++) scanf ("%d",&A[i]), U.insert(A[i]);

	int ans = 0;
	for (int k=30;k>=1;k--){
		auto I = U.begin();
		while (I != U.end()){
			if (*I * 2 >= (1<<k)) break;
			auto J = U.find((1<<k)-*I);
			if (J != U.end()){
				auto K = I; ++K;
				U.erase(I);
				if (K == J) ++K;
				U.erase(J);
				ans++;
				I = K;
			}
			else ++I;
		}

		while (1){
			auto I = U.find(1<<(k-1));
			if (I != U.end()){
				auto J = I; ++J;
				if (J != U.end() && *I == *J){
					U.erase(I);
					U.erase(J);
					ans++;
				}
				else break;
			}
			else break;
		}
	}

	printf ("%d\n",ans);

	return 0;
}

Measured memory_bytes: 10368
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string t; cin >> t;
    for(auto& c : t){
        if(c == '?'){
            c = 'D';
        }
    }
    cout << t << '\n';
}


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

using namespace std;

const int N = 1<<20;

int n,ans;
char a[N];
int stack_size;

int main() {
    int i;

    scanf("%s", a+1);
    n=strlen(a+1);
    ans=n;
    for(i=1;i<=n;i++) {
        if(a[i]=='S') ++stack_size;
        else if(a[i]=='T' && stack_size) --stack_size,ans-=2;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n,m,k;cin>>n>>m>>k;
	vector<ll> a(n);
	vector<ll> b(m);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	for(int i = 0; i < m; i++) {
		cin>>b[i];
	}
	vector<ll> sum_a(n + 1,0);
	vector<ll> sum_b(m + 1,0);
	for(int i = 0; i < n; i++) {
		sum_a[i + 1] = sum_a[i] + a[i];
	}
	for(int i = 0; i < m; i++) {
		sum_b[i + 1] = sum_b[i] + b[i];
	}
	ll res = 0;
	for(int i = 0; i < n + 1; i++) {
		if (sum_a[i] > k)break;
		ll ans = i;
		ll x = k - sum_a[i];
		auto ite = upper_bound(ALL(sum_b),x);
		ans += ite - sum_b.begin() - 1;
		chmax(res,ans);
	}	
	cout << res << endl;
	return 0;
}

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

int main(){
	int n;
	cin>>n;
	int currX=0, currY=0, currT=0;
	while(n--){
		int t, x, y;
		cin>>t>>x>>y;
		if(abs(currY - y)+abs(currX - x) > t-currT || (abs(currY - y)+abs(currX - x))%2 != (t-currT)%2 ){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes\n";
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

a, b = map(int, read().split())
ans = [1, 2, 3]
tmp = [a, b]
ans = set(ans) - set(tmp)

print(list(ans)[0])


Measured memory_bytes: 2940
X, Y, A, B, C = map(int, input().split())
p, q, r = [list(map(int, input().split())) for _ in range(3)]

p = sorted(p, reverse=True)[:X]
q = sorted(q, reverse=True)[:Y]

l = p+q+r

l.sort(reverse=True)

print(sum(l[:X+Y]))

Measured memory_bytes: 112492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  char x, y;
  cin >> x >> y;
  if (x < y) cout << "<" << endl;
  else if (x == y) cout << "=" << endl;
  else cout << ">" << endl;
}

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

int main(void){
  int n, k;
  cin >> n >> k;
  vector<long> x(n);
  long long ans = 1e+18;
  for(int i = 0; i < n; i++) cin >> x[i];
  for(int i = 0; i < n - k + 1; i++){
    int l = i;
    int r = i + k - 1;
    long long temp = min(abs(x[l]) + abs(x[r] - x[l]), abs(x[r]) + abs(x[r] - x[l]));
    ans = min(ans, temp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
a_list = list(map(int, input().split()))

one_count = 0
four_count = 0
two_count = 0
result = 'No'

for i in a_list:
    if i % 2 == 1:
        one_count += 1
    elif i % 4 == 0:
        four_count += 1
    else:
        two_count += 1

if one_count <= four_count or (one_count - 1  == four_count and two_count == 0):
    result = 'Yes'

print(result)


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

using namespace std;

int main(void) {
	int a, b;
	cin >> a >> b;
	int count = 0;
	int num[5];
	for (int i = a; i <= b; i++) {
		int t = i;
		for (int j = 0; j < 5; j++) {
			num[j] = t % 10;
			t /= 10;
		}
		if ((num[0]==num[4]&&num[1]==num[3])) {
			count++;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			int l = scan.nextInt();
			int r = scan.nextInt();
			if (n + l + r == 0)
				return;
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = scan.nextInt();
			
			int ans = 0;
			for (int year = l; year <= r; year++) {
				int idx = 1;
				for (int i = 0; i < n; i++) {
					if (year % a[i] == 0)
						break;
					idx++;
				}
				if (idx == n && n % 2 == 1)
					ans++;
				else if (idx % 2 == 1)
					ans++;
			}
			System.out.println(ans);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

}



Measured memory_bytes: 31432
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

n = inp[0]
(1..9).each do |i|
  (i..9).each do |j|
    if(n == i* j)
      puts "Yes"
      exit
    end
  end
end
puts "No"

#!?

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

using namespace std;

int main(){

	string in="",zo="",tmp="";
	vector<string> vs;
	int ans=-1;

	cin>>in;

	for(int i=0;i<in.size();){
		if(in[i]=='e'){
			zo+='0';
			i+=3;
		}
		else{
			zo+='1';
			i+=7;
		}
	}
	
	tmp+=zo[0];
	for(int i=1;i<zo.size();i++){
		if(zo[i]!=zo[i-1]) tmp+=zo[i];
		else{
			vs.push_back(tmp);
			tmp="";
			tmp+=zo[i];
		}
	}

	if(!tmp.empty()) vs.push_back(tmp);

	ans=0;
	for(int i=1;i<vs.size();i++){
		if(vs[i].size()>vs[ans].size()){
			ans=i;
		}
	}

	if(vs[ans][vs[ans].size()-1]=='0') cout<<"egg"<<endl;
	else cout<<"chicken"<<endl;

	return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>
 
int main(void){
    int i,hour,min,sec;
    scanf("%d",&i);
    hour = i/3600;
    min = (i%3600)/60;
    sec = i-(hour*60 + min)*60;
    printf("%d:%d:%d\n",hour, min,sec);
    
    return 0;
}


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

int main() {
  int N,K;
  cin>>N>>K;
  int a,c,i;
  vector<int>d(K);
  for(i=0;i<K;i++)cin>>d[i];
  for(i=0;;i++){
    a=N+i;
    c=0;
    for(a;a>0;a/=10){
      for(int j=0;j<K;j++){
        if(d[j]==a%10){c=1;break;}
      }
      if(c==1)break;
    }
    if(a==0)break;
  }
  cout<<N+i<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int main()
{
	int A, P;
	cin >> A >> P;
	int sum = 0;
	sum = A * 3 + P;
	int answer = 0;
	answer = sum / 2;

	cout << answer << endl;


	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define re register
#define pb push_back
#define fi first
#define se second
#define mp make_pair
const int N=2e6+10;
const int mod1=998244353;
const int mod2=19260811;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
bool solve(string s)
{
    //cout<<s<<endl;
    int l=0,r=s.size()-1;
    bool f=1;
    while(l<r)
    {
        if(s[l]==s[r])
        {
            l++;
            r--;
        }
        else
        {
            f=0;
            break;
        }
    }
    return f;
}
int main()
{
    string ss,s,t;
    cin>>ss;
    int n=ss.size();
    for(re int i=0;i<(n-1)/2;i++) s.pb(ss[i]);
    for(re int i=(n+3)/2-1;i<n;i++) t.pb(ss[i]);
    if(solve(s)&&solve(t)&&solve(ss)) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
s = gets.chomp
n = s.length
flag = true

flag = false if s[0] != 'A'
flag = false if [*'A'..'Z'].include?(s[1])

c_cnt = 0
2.upto(n-2) do |i|
  c_cnt += 1 if s[i] == 'C'

  flag = false if c_cnt > 1 || [*'A'..'Z'].include?(s[1])
end

flag = false if c_cnt == 0

flag = false if s[n-1] == 'C'
flag = false if [*'A'..'Z'].include?(s[n-1])


puts flag ? 'AC' : 'WA'


Measured memory_bytes: 1916
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
#define N 200020
#define M 2000020
struct Edge
{
    int to,nxt,vis;
} edge[M];
int head[N],dfn[N],low[N],vis[N],sta[N],id[N];
int tot,all,top,scc,bridge;
void addedge(int a,int b,int flag)
{
    edge[tot].to = b;
    edge[tot].nxt = head[a];
    edge[tot].vis = flag;
    head[a] = tot++;
}
void tarjan(int u)
{
    vis[u] = 1;
    dfn[u] = low[u] = ++all;
    sta[top++] = u;
    for(int i = head[u]; i != -1; i = edge[i].nxt)
    {
        if(edge[i].vis) continue;
        int v = edge[i].to;
        edge[i].vis = edge[i^1].vis = 1;
        if(!dfn[v])
        {
            tarjan(v);
            low[u] = min(low[u],low[v]);
            if(low[v] > dfn[u]) bridge++;
        }
        else if(vis[v]) low[u] = min(low[u],dfn[v]);
    }
    if(low[u] == dfn[u])
    {
        scc++;
        int num;
        do
        {
            num = sta[--top];
            id[num] = scc;
            vis[num] = 0;
        }
        while(u != num);
    }
}
vector<int> tree[N];
int treevis[N],maxdeep;
void dfs(int u,int deep)
{
    treevis[u] = 1;
    maxdeep = max(deep,maxdeep);
    int len = tree[u].size();
    for(int i = 0; i < len; i++)
    {
        int v = tree[u][i];
        if(!treevis[v])
        {
            dfs(v,deep+1);
        }
    }
}
void init()
{
    memset(vis,0,sizeof(vis));
    memset(dfn,0,sizeof(vis));
    memset(id,0,sizeof(id));
    memset(low,0,sizeof(low));
    all = 0;
    top = 0;
    scc = 0;
    bridge = 0;
}
int que[N];
int getstart()
{
    int front,rear;
    front = rear = 0;
    que[rear++] = 1;
    treevis[1] = 1;
    while(front != rear)
    {
        int now = que[front++];
        int len = tree[now].size();
        for(int i = 0; i < len; i++)
        {
            int nxt = tree[now][i];
            if(treevis[nxt]) continue;
            treevis[nxt] = 1;
            que[rear++] = nxt;
        }
    }
    return que[--rear];
}
int main()
{
    int n,m,a,b;
    while(~scanf("%d%d",&n,&m))
    {
        if(!n && !m) break;
        memset(head,-1,sizeof(head));
        tot = 0;
        for(int i = 0; i < m; i++)
        {
            scanf("%d%d",&a,&b);
            addedge(a,b,0);
            addedge(b,a,0);
        }
        init();
        tarjan(1);
        for(int i = 1; i <= scc; i++)
        {
            tree[i].clear();
        }
        for(int u = 1; u <= n; u++)
        {
            for(int i = head[u]; i != -1; i = edge[i].nxt)
            {
                int v = edge[i].to;
                if(id[u] != id[v])
                {
                    int uu = id[u];
                    int vv = id[v];
                    tree[uu].push_back(vv);
                    tree[vv].push_back(uu);
                }
            }
        }
        maxdeep = 0;
        memset(treevis,0,sizeof(treevis));
        int start = getstart();
        memset(treevis,0,sizeof(treevis));
        dfs(start,1);
        printf("%d\n",scc - 1);
    }
    return 0;
}

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

int main(){
    
    char s[5];
    cin >> s;
    
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        cout << "Bad\n";
    } else{
        cout << "Good\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
from math import sqrt
from collections import Counter

def gen_primes(X):
    D = [0] * (X+1)
    is_prime = [True for _ in range(0, X+1)]
    is_prime[0] = False
    is_prime[1] = False
    primes = []
    for n in range(2, int(sqrt(X))+1):
        if is_prime[n]:
            primes.append(n)
            j = n*2
            D[n] = n
            while j <= X:
                is_prime[j] = False
                if D[j] == 0:
                    D[j] = n
                j += n
    for n in range(int(sqrt(X)), X+1):
        if is_prime[n]:
            D[n] = n
            primes.append(n)
    return primes, D


def solve(A):
    N = len(A)
    primes, D = gen_primes(10**6)
    C = [0] * (primes[-1]+1)

    for a in A:
        a_ = a
        while a > 1:
            d = D[a]
            while a % d == 0:
                a //= d
            C[d] += 1
        
    M = max(C)
    if M <= 1:
        print("pairwise coprime")
    elif M != N:
        print("setwise coprime")
    else:
        print("not coprime")

#solve([x for x in range(1, 10**6+1)])
N = int(input())
A = [int(x) for x in input().split()]
solve(A)


Measured memory_bytes: 127764
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb emplace_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
int v[55];
int main(){
        int n,k;
        while(~getII(n,k)){
                F(i,0,n) getI(v[i]);
                int ans=0;
                F(i,0,n) F(j,i-1,n){//don't choose [i,j]
                        if(n-(j-i+1)>k) continue;//too much
                        vector<int> bad;
                        int poss=0;
                        F(kk,0,i){
                                poss+=v[kk];
                                if(v[kk]<0) bad.pb(v[kk]);
                        }
                        F(kk,j+1,n){
                                poss+=v[kk];
                                if(v[kk]<0) bad.pb(v[kk]);
                        }
                        int stepLeft=k-(n-(j-i+1)),ed=bad.size();
                        ed=min(ed,stepLeft);
                        sort(bad.begin(),bad.end());
                        F(kk,0,ed) poss-=bad[kk];
                        ans=max(ans,poss);
                }
                printf("%d\n",ans);
        }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
  char t[200002];
  scanf("%s", t);
  int l=strlen(t);
  
  for(int i=0;i<l;i++){
    if(t[i]=='?') t[i]='D';
  }

  printf("%s", t);
  return 0;
}


Measured memory_bytes: 1900
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: u64,
    }
    if let Some(v) = (1..(n as f64).sqrt() as u64 + 1).filter(|x| n % x == 0).map(|x| x + n / x - 2).min() {
        println!("{}", v);
    }
}


Measured memory_bytes: 4476
#include<iostream>
#include<boost/multiprecision/cpp_int.hpp>
#include<algorithm>
using namespace std;
using namespace boost::multiprecision;
int main()
{
  ios::sync_with_stdio(false);
  int256_t a, b, c, d;
  cin>>a>>b>>c>>d;
  int1024_t x, y;
  x = max(a*c, a*d);
  y =max(b*c, b*d);
  cout<<max(x, y);
  return 0;
}

Measured memory_bytes: 3720
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=998244353;
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
typedef unsigned long long ull;
unordered_map<ull, int> mpid;
int tot;
const int maxst = 10000111;
int dp[maxst];
int getid(const string &s)
{
	ull hs = 0;
	for (int i=0; i<s.size(); i++) hs = hs*23313+s[i];
	int &id = mpid[hs];
	if (id==0) id = ++tot, dp[id] = -1;
	return id;
}
string S;
int solve(string s)
{
	int p = getid(s);
	if (dp[p]!=-1) return dp[p];
	int &cur = dp[p];
	cur = 0;
	for (int l = 1; l*2<=s.size(); l++)
	{
		string ns;
		ns.resize(l);
		for (int i=0; i<l; i++) ns[i] = '1';
		for (int i=s.size()-l; i<s.size(); i++) if (s[i]=='0') ns[i-(s.size()-l)]='0';
		for (int i=s.size()-2*l; i>=0; i-=l)
		{
			for (int j=0; j<l; j++) if(s[i+j]=='0') ns[j]='0';
			cur = (cur+1ll*solve(s.substr(0,i))*solve(ns))%mod;
		}
	}
	char lst = s.back();
	s.pop_back();
	cur = (cur+(lst=='1'? 2ll: 1ll)*solve(s))%mod;
	return cur;
}
int main()
{
	dp[getid("")] = 1;
	cin>>S;
	cout<<solve(S)<<endl;
	return 0;
}


Measured memory_bytes: 2316
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  string s;
  cin>>s;
  cout << char(s[0]+1) << endl;
  return 0;
}


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

int main(void){
    int n, cnt4=0, cnt2=0;
    cin >> n;
    int a[100005];
    for(int i=0; i<n; i++){
        cin >> a[i];
        if (a[i] % 4 == 0){
            cnt4++;
        }else if(a[i]%2 == 0){
            cnt2++;
        }
    }
    long long cnt;
    if(cnt2 > 0){
        cnt = (cnt4*2) + (cnt2 - 1);
    }else{
        cnt = (cnt4*2);
    }
    if(cnt >= n-1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define clr(a, x) memset(a, x, sizeof(a))
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define X first
#define Y second
#define fastin                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;

multiset<int> s;
int t[1 << 18];
bool solve(int m)
{
    for (int i = 0; i < m; i++)
    {
        auto it = s.find(t[i]);
        if (it == s.end()) return false;
        s.erase(it);
    }
    return true;
}
int main()
{
#ifndef ONLINE_JUDGE
    // freopen("1.in", "r", stdin);
    // freopen("1.out", "w", stdout);
#endif
    int n, m;
    while (~scanf("%d", &n))
    {
        int tmp;
        s.clear();
        for (int i = 0; i < n; i++)
        {
            scanf("%d", &tmp);
            s.insert(tmp);
        }
        scanf("%d", &m);
        for (int i = 0; i < m; i++) scanf("%d", t + i);
        puts(solve(m) ? "YES" : "NO");
    }
    return 0;
}


Measured memory_bytes: 10368
f=input;n,l,q=int(f()),list(f()),int(f())
B=[[0]*-~n for i in range(26)]
def S(o,i):
  s=0
  while i: s+=B[o][i]; i-=i&-i
  return s
def A(o,i,x):
  while i<=n: B[o][i]+=x; i+=i&-i
for i in range(n): A(ord(l[i])-97,i+1,1)
for i in range(q):
  a,b,c=input().split(); b=int(b)
  if a>'1': print(sum(1 for o in range(26) if S(o,int(c))-S(o,b-1)))
  else: A(ord(l[b-1])-97,b,-1); l[b-1]=c; A(ord(c)-97,b,1)

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 100007;
int n;
struct robot {
    int x, l;
    bool operator<(const robot& other) const {
        return x+l < other.x+other.l;
    }
} r[N];

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> r[i].x >> r[i].l;
    }

    sort(r, r+n);

    int at = r[0].x+r[0].l, i = 1, ans = 1;

    while(i < n) {
        if(r[i].x-r[i].l >= at) {
            ++ans;
            at = r[i].x+r[i].l;
        }
        ++i;
    }

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


Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
   char str[11]={};
   char ans[11]={};
   int i,j=0;
   
   scanf("%10s",str);
   
   for(i=0;str[i]!='\0';i++){
       if(str[i] == '0' || str[i] == '1'){
           ans[j++] = str[i];
       }else if(str[i] == 'B'){
           if(j > 0){
               --j;
           }
       }
   }
   ans[j] = '\0';
   printf("%s\n",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  long long N,cnt,now,ans;
	cin>>N;
	vector<long long> H(N);
	rep(i,N) cin>>H[i];
	cnt=0;
	now=H[0];
	ans=0;
	rep(i,N-1){
		if(now<H[i+1]){
			if(ans<cnt) ans=cnt;
		  cnt=0;
		}
		else cnt++;
		now=H[i+1];
	}
	if(ans<cnt) ans=cnt;
	cout<<ans<<endl;
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, n)
    {
        cin >> a[i];
        mp[a[i]]++;
        mp[a[i]-1]++;
        mp[a[i] + 1]++;
    }
    int ans = 0;
    rep(i, 100004)
    {
        ans = max(ans, mp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5376
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = (n - 1); i >= 0; i--)
#define PI 3.141592653589793

using namespace std;
using ll = long long;

int main() {

	int n, k;
	

	cin >> n >> k;
	vector<int> p(n);


	rep(i, n)cin >> p[i];

	sort(p.begin(), p.end());

	int ans = 0;

	rep(i, k)ans += p[i];

	cout << ans << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1;i < n+1;i++) {
    if (to_string(i).size() % 2 == 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,s1,s2,s3,w,sum;
	char x[6];
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		s1=1; s2=2; s3=3;
		sum=s1;
		for(i=0;i<n;i++){
			scanf("%s",x);
			if(x[0]=='N'){
				w=s2; s2=7-s1; s1=w;
			}
			if(x[0]=='E'){
				w=s1; s1=7-s3; s3=w;
			}
			if(x[0]=='S'){
				w=s1; s1=7-s2; s2=w;
			}
			if(x[0]=='W'){
				w=s3; s3=7-s1; s1=w;
			}
			if(x[0]=='R'){
				w=s3; s3=7-s2; s2=w;
			}
			if(x[0]=='L'){
				w=s2; s2=7-s3; s3=w;
			}
			sum+=s1;
		//	printf("sum=%d s1=%d s2=%d s3=%d\n",sum,s1,s2,s3);
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 1744
s=input()
k=int(input())
code_list = 'abcdefghijklmnopqrstuvwxyz'

def c1(s):#len(s)>1
  count1=0
  S = list(s)
  l_s=len(S)
  for i in range(1,l_s):
    #print(S,count)
    if S[i]==S[i-1] and i<l_s-1:
      for j in code_list:
        if j != S[i+1] and j !=S[i-1]:
          S[i]=j
          count1+=1
          break
    elif S[i]==S[i-1]:
      for j in code_list:
        if j != S[i-1] and j !=S[0]:
          S[i]=j
          count1+=1
          break
  return count1,S[-1]

def c2(s,last):#k>2 and len(s)>1
  S=list(s)
  count2=0
  l_s=len(S)
  for i in range(0,l_s):
    #print(S,count)
    if i==0:
      if S[0]==last:
        for j in code_list:
          if j != S[i+1] and j !=last:
            S[i]=j
            count2+=1
            break
    elif S[i]==S[i-1] and i<l_s-1:
      for j in code_list:
        if j != S[i+1] and j !=S[i-1]:
          S[i]=j
          count2+=1
          break
    elif S[i]==S[i-1]:
      for j in code_list:
        if j != S[i-1] and j !=S[0]:
          S[i]=j
          count2+=1
          break
  return count2,S[-1]

def c3(s,last):#k>1 len(s)>1
  S=list(s)
  count3=0
  l_s=len(S)
  for i in range(0,l_s):
    #print(S,count)
    if i==0:
      if S[0]==last:
        for j in code_list:
          if j != S[i+1] and j !=last:
            S[i]=j
            count3+=1
            break
    elif S[i]==S[i-1] and i<l_s-1:
      for j in code_list:
        if j != S[i+1] and j !=S[i-1]:
          S[i]=j
          count3+=1
          break
    elif S[i]==S[i-1]:
      for j in code_list:
        if j != S[i-1]:
          S[i]=j
          count3+=1
          break
  return count3

if len(s)==1:
  print(k//2)
elif k==1:
  c,_=c1(s)
  print(c)
elif k==2:
  count1,last=c1(s)
  count3=c3(s,last)
  print(count1+count3)
else:
  if k%2==0:
    count1,last=c1(s)
    count21,last21=c2(s,last)
    count22,last22=c2(s,last21)
    count3=c3(s,last22)
    #print(count1,count2,count3)
    print(count1+count21*((k-2)//2)+count22*((k-2)//2)+count3)
  else:
    count1,last=c1(s)
    count21,last21=c2(s,last)
    if k>3:
      count22,last22=c2(s,last21)
    else:
      count22=0
    count3=c3(s,last21)
    #print(count1,count21,count22,count3)
    print(count1+count21*((k-2)//2+1)+count22*((k-2)//2)+count3)

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

int main(){
  int n,t;
  int sum=0;
  cin >> n;
  t=n;
  for(int i=0;i<10;i++){
    sum += t%10;
    t /= 10;
  }
  if(n%sum==0){
   cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();

        int result = (A + B)/2;

        if((A + B) % 2 == 0){
            System.out.println(result);
        }else{
            System.out.println("IMPOSSIBLE");
        }


    }
}


Measured memory_bytes: 21716
#include <stdio.h>

int main(void){
  double high=0;
  double low=10000001000;
  double h;
  while(scanf("%lf",&h)!=EOF){
    if(high<h)high=h;
    if(low>h)low=h;
  }
  printf("%lf",high-low);
  return 0;
}



Measured memory_bytes: 2052
# -*- coding: utf-8 -*-
import heapq
import itertools
import math
from collections import defaultdict

def factorization(m, flag=0):
    m0 = m
    hq = []
    F = defaultdict(int)
    for n in itertools.count(2) if flag else range(2,math.ceil(math.sqrt(m))+5):

        while hq and hq[0][0] == n:
            heapq.heapreplace(hq,(sum(hq[0]),hq[0][1]))
            if hq[0][0] > n:break
        else:
            while m > 1:
                if m%n:
                    break
                else:
                    m //= n
                    F[n] += 1
            hq.append((n*n,n))
            if m == 1:
                return F
    if not F or m > 1:
        F[m] += 1
    return F


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n;

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p;
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def solve():
    N, M = map(int, input().split())
    F = factorization(M)
    res = 1
    for n in F.values():
        res *= cmb(N+n-1, n)
    res %= (10**9+7)
    return str(res)

if __name__ == '__main__':
    print(solve())



Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int t[] = new int[] { s.nextInt(), s.nextInt(), s.nextInt(), s.nextInt(), s.nextInt() };

			int ret = 0;
			int min = 10;
			for (int i = 0; i < t.length; i++) {
				if (t[i] % 10 != 0) {
					ret += (t[i] / 10) + 1;
					min = Math.min(min, t[i] % 10);
				} else {
					ret += t[i] / 10;
				}
			}
			System.out.println(ret * 10 - (10 - min));
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int X, Y;
    cin >> X >> Y;
    bool bl = (X * 2 <= Y && X * 4 >= Y && Y % 2 == 0);
    puts(bl ? "Yes" : "No");
    return 0;
    // ll, 0, -, 1i, for s&g
}

Measured memory_bytes: 3524
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
         
        int m = stdIn.nextInt();
        for(int i=0;i<m;i++){
            Set<String> s = new HashSet<String>();
            String a = stdIn.next();
            s.add(a);
            for(int j=1;j<a.length();j++){
                String b = a.substring(0, j);
                String c = a.substring(j);
                StringBuffer d = new StringBuffer(b);
                StringBuffer e = new StringBuffer(c);
                String f = d.reverse().toString();
                String g = e.reverse().toString();
                s.add(b.concat(c));
                s.add(b.concat(g));
                s.add(c.concat(b));
                s.add(c.concat(f));
                s.add(f.concat(g));
                s.add(g.concat(b));
                s.add(f.concat(c));
            }
            System.out.println(s.size());
        }
    }
}

Measured memory_bytes: 37664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (ll)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    vector<pair<int, int>> s(n);
    REP(i, n) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        s[i] = {x, y};
    }
    
    sort(ALL(s));
    int k = 0;
    REP(i, n) {
        if (s[i].second + k > s[i].first - 1) {
            if (s[i].second + k == s[i].first) ++k;
            continue;
        }
        cout << s[i].first << "\n";
        return 0;
    }
    cout << h << "\n";
    return 0;
    return 0;
}


Measured memory_bytes: 4824
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(M);
  ll all_days = 0;
  for (int i = 0; i < M; i++) {
    cin >> A[i];
    all_days += A[i];
  }
  ll ans = 0;
  if (N < all_days) {
    ans = -1;
  } else {
    ans = N - all_days;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3672