akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
A = LIST()

a = [2 - x%2 for x in A]
odd = 1
for x in a:
	odd *= x

print(3**N - odd)


Measured memory_bytes: 5460
#include <iostream>

void solve(){
    int n;
    std::cin>>n;
    std::cout<<n<<":";
    int t=n;
    for(int i=2;i*i<= n; ++i){
        while(t%i==0){
            std::cout<<" "<<i;
            t=t/i;
        }
    }
    if(t==n)std::cout<<" "<<n;
    else if(t!=1)std::cout<<" "<<t;

    std::cout<<std::endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 3104
n = gets.chomp.to_i
s = gets.chomp.split("")
min_count   = n
left_count  = 0
right_count = s.count("E")

s.each do |char|
    if char == "E"
        right_count -= 1
    end
    min_count = [min_count,left_count+right_count].min
    if char == "W"
        left_count += 1
    end
end
puts min_count


Measured memory_bytes: 27396
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w, n; cin >> h >> w >> n;
	vector<P>vec(n);
	rep(i, n)cin >> vec.at(i).first >> vec.at(i).second;
	sort(vec.begin(), vec.end());
	vector<int>ans(10, 0);
	ans.front() = (h - 2)*(w - 2);
	rep(i, n) {
		P p = vec.at(i);
		rep(j, 3)rep(k, 3) {
			int x = p.first - j, y = p.second - k;
			if (x <= 0 || y <= 0 || x + 2 > h || y + 2 > w)continue;
			int cnt = 0;
			rep(l, 3)rep(m, 3)if (binary_search(vec.begin(), vec.end(), P(x + l, y + m)))cnt++;
			ans.at(cnt)++;
		}
	}
	int sum = 0;
	for (int i = 1; i <= 9; i++) {
		ans.at(i) /= i;
		sum += ans.at(i);
	}
	cout << ans.front() - sum << endl;
	rep(i, 9)cout << ans.at(i + 1) << endl;
	return 0;
}

Measured memory_bytes: 1920
#include<cstdio>
typedef long long LL;
LL sum, ans, n, m;
int main()
{
	scanf("%lld%lld", &n, &m);
	if(n * 2 <= m)printf("%lld\n", n + (m - 2 * n) /4);
	else printf("%lld\n" , m /2);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
 
 
int main() {
    int a, b;
    cin >> a >> b;
    if(a+b<=16){
    if (a <= 8 && b <= 8)cout << "Yay!" << endl;
    else cout << ":("<< endl;}
    return 0;
}

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

using namespace std;

int main(void)

{
    string s;
    cin>>s;
    int i, flag = 1, a = s.size();
    for(i = 0; i < a; i++){
        if(i%2 != 0){
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){}
            else{
                flag  = 0;
                break;
            }
        }
        else{
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){}
            else{
                flag  = 0;
                break;
            }
        }
    }
    if(flag == 1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
C = []
A = []
ans = 0
for i in range(10):
    C.append(list(map(int, input().split())))
for n in range(H):
    A.append(list(map(int, input().split())))

for i in range(10):
    for n in range(10):
        for m in range(10):
            C[n][m] = min(C[n][m], C[n][i] + C[i][m])

for a in range(H):
    for b in range(W):
        if A[a][b] != -1:
            ans += C[A[a][b]][1]

print(ans)


Measured memory_bytes: 3444
N = int(input())
A = []
A = input().split()
A = [int(i) for i in A]

#print('N = ', N)
#print('A = ', A)

A.sort()
#print('sortA = ', A)

count = 0

for i in range(N-1):
  if A[i] == A[i+1]:
    count += 1
    break

if count > 0:
  print('NO')
else:
  print('YES')


Measured memory_bytes: 25172
cards = list(map(int, input().split()))
a = cards[0]
b = cards[1]

if a == 1:
  if b != 1:
    print("Alice")
  else:
    print("Draw")
if b == 1 and a != 1:
  print("Bob")
if b != 1 and a != 1:
  if a > b:
    print("Alice") 
  elif a < b:
    print("Bob")
  else:
    print("Draw")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;
    vector<int> a(10, 0);
    for (int i = 0; i < k; ++ i) {
        int x;
        cin >> x;
        a[x] = 1;
    }
    while (true) {
        int temp = n;
        while (temp) {
            int d = temp % 10;
            if (a[d]) goto here;
            temp /= 10;
        }
        cout << n;
        break;
        here:;
        n ++;
    }
}

Measured memory_bytes: 256
n,m,d=map(int,input().split())
 
#全パターンの平均を求める＝期待値を求めれば良い
#ある隣り合う数(a,b)の組について、全パターンはn^2
 
#d=0の時、隣り合う数の組は(a,a)でなければならない
if d==0:
  C=n
 
#d≠0の時、隣り合う組のパターンは(1,1+d),(2,2+d)...(n-d,n)のn-d通り
#逆に(d+1,1)....の時も成り立つ
if d!=0:
  C=2*(n-d)
  
#上の組のパターンがm-1個の組について成り立つ
print((m-1)*C/(n**2))

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(LL i=0; i<(n); i++)
#define FOR(i, m, n) for(LL i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back
#define INF INT_MAX

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	LL n;
	cin >> n;
	vector<LL> a(n);
	vector<LL> cnt(100000);
	REP(i, n) {
		cin >> a[i];
		cnt[a[i]]++;
	}

	LL max = 0;
	FOR(i, 1, 99999) {
		LL x = cnt[i - 1] + cnt[i] + cnt[i + 1];
		max = max < x ? x : max;
	}
	cout << max << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int a[51], b[51], counter[51] = {0};
  for (int i = 0; i < m; i++) cin >> a[i] >> b[i];
  for (int i = 0; i < m; i++) {
    if (a[i] != b[i]) {
      counter[a[i] - 1]++;
      counter[b[i] - 1]++;
    }
  }
  for (int i = 0; i < n; i++) cout << counter[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

bool ok(const vecint& a, const int th, vecint& v) {
  ll n = a.size();
  v.assign(n*4, 0);
  int offset = n*2;
  ll cnt = 0;
  ll sum = 0;
  REP(i,n) {
    v[offset] += 1;
    if (a[i] >= th) {
      offset -= 1;
      sum -= v[offset];
    } else {
      sum += v[offset];
      offset += 1;
    }
    cnt += sum;
  }
  ll m = n * (n+1) / 2;
  ll mid = m/2 + 1;
  return cnt >= mid;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vecint a(n);
  string line;
  getline(cin, line);
  getline(cin, line);
  size_t pos = 0;
  REP(i,n-1) {
    const auto next = line.find(' ', pos);
    a[i] = stoi(line.substr(pos, next-pos));
    pos = next+1;
  }
  a.back() = stoi(line.substr(pos));
  int hi = 1000000001;
  int lo = 0;
  vecint v(n*4);
  while ((hi - lo) > 1) {
    int mid = (hi + lo) / 2;
    if (ok(a, mid, v)) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  printf("%d\n", lo);
  return 0;
}


Measured memory_bytes: 3356
//B - Two Switches: 7Min;
//Assunto: AdHoc;
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int a, b, c, d, ans;
    cin >> a >> b >> c >> d;
    ans = min(d, b) - max(a, c);
    if(ans < 0) ans = 0;
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int main() {
    int n,k;
    double ans=0;
    cin>>n>>k;
    for (int i = 1; i <=n ; ++i) {
        int temp = i;
        int count = 0;

        while (temp<k){
            temp<<=1;
            count++;

        }
        ans+=1.0/n*pow(1.0/2,count);
    }
    printf("%.12f",ans);

}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000

int main(){
  int n,i,put,base,s=0,f=0;
  int a[N];

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  base = a[n-1];
  for(i = 0;i < n-1;i++){
    if(base == a[i]) f++;
    if(base >= a[i]){
      put = a[i];
      a[i] = a[s];
      a[s] = put;
      s++;
    }
  }
    put = a[n-1];
    a[n-1] = a[s];
    a[s] = put;

  for(i = 0;i < n;i++){
    if(i != 0) printf(" ");
    if(i == s) printf("[");
    printf("%d",a[i]);
    if(i == s) printf("]");
  }
  printf("\n");

  return 0;
}



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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  string head, tail;
  int sum = 0;
  REP(i,n){
    sum += s[i]=='('?1:-1;
    if(sum < 0){
      head += "(";
      sum++;
    }
  }
  while(sum){
    tail+=")";
    sum--;
  }
  cout<<head<<s<<tail<<endl;
  return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  int n;
  vector<int> p;
  cin >> n;
  int a;
  int ans = 0;
  REP(k, n){
      cin >> a;
      p.pb(a);
    }
    sort(p.begin(), p.end());
    p.back() /= 2;
    REP(i, p.size()){
        ans += p[i];
      }
      cout << ans << endl;
      return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), c(1e+5 + 10, 0);
    rep(i, n) {
        cin >> a[i];
        a[i]++;
    }

    rep(i, n) {
        int val = a[i];
        c[val - 1]++;
        c[val]++;
        c[val + 1]++;
    }

    int ans = 0;

    rep(i, 1e+5 + 5) ans = max(ans, c[i]);

    cout << ans << endl;

    return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;

int main() {
    string s;
    cin >> s;
    map<char, ll> m;
    for(auto c : s) {
        m[c]++;
    }
    ll res = s.size() * (s.size() - 1) / 2 + 1;
    for(auto& p : m) {
        res -= p.second * (p.second - 1) / 2;
    }
    cout << res << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin >> str ;
 
  if (str == "Sunny") {
    cout << "Cloudy" << endl;
  }
  if (str == "Cloudy") {
    cout << "Rainy" << endl;
  }
  if (str == "Rainy") {
    cout << "Sunny" << endl;
  }
 
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define fi first
#define sec second
#define pr priority_queue
ll maxn = 1000003;
vector<ll> v;
void sieve()
{
	vector<bool> is(maxn, true);
	for (ll i = 4; i < maxn; i += 2)
		is[i] = false;
	for (ll i = 3; i * i < maxn; i++)
	{
		if (is[i])
		{
			for (ll j = i * i; j < maxn; j += i)
				is[j] = false;
		}
	}
	for (ll i = 2; i < maxn; i++)
	{
		if (is[i])
			v.push_back(i);
	}
	return ;
}
vector<ll> spf(maxn);
void prime()
{
	for (ll i = 1; i < maxn; i++)
		spf[i] = i;
	for (ll i = 4; i < maxn; i += 2) spf[i] = 2;
	for (ll i = 3; i * i < maxn; i++)
	{
		if (spf[i] == i)
		{
			for (ll j = i * i; j < maxn; j += i)
				if (spf[j] == j)
					spf[j] = i;
		}
	}
	return ;
}
vector<ll> get(ll x)
{
	vector<ll> ftrs;
	while (x != 1)
	{
		ftrs.push_back(spf[x]);
		x = x / spf[x];
	}
	return ftrs;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	sieve();
	prime();
	ll n; cin >> n;
	vector<ll> vec(n);
	for (ll i = 0; i < n; i++)
		cin >> vec[i];
	set<ll> st;
	ll f = 0;
	for (ll i = 0; i < n; i++)
	{
		vector<ll> factors = get(vec[i]);
		ll sz = factors.size(), fl = 0;
		for (ll j = 0; j < sz; j++)
		{
			ll c = factors[j];
			if ((c != 1) && (st.find(c) != st.end()))
			{
				fl = 1;
				break;
			}
		}
		if (fl)
		{
			f = 1;
			break;
		}
		for (ll j = 0; j < sz; j++)
			st.insert(factors[j]);
	}
	if (f)
	{
		ll gd = vec[0];
		for (ll i = 1; i < n; i++)
			gd = __gcd(gd, vec[i]);
		if (gd == 1)
			cout << "setwise coprime\n";
		else
			cout << "not coprime\n";
	}
	else
		cout << "pairwise coprime\n";
	return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int64_t solve(uint64_t l, int64_t& n, int64_t& m, int64_t b) {
    if (l == 1) {
        n += 1;
        cout << n << " " << m << "\n";
        return 1;
    }

    if ((l & 1) == 0) {
        n += 1;
        m += 2;
        auto v = solve(l / 2, n, m, 2 * b);
        cout << v << " " << v + 1 << " " << b << "\n";
        cout << v << " " << v + 1 << " " << 0 << "\n";
        return v + 1;
    } else {
        m += 1;
        auto v = solve(l - 1, n, m, b);
        cout << 1 << " " << v << " " << (l - 1) * b << "\n";
        return v;
    }
}

int main() {
    int64_t l;
    cin >> l;

    int64_t n = 0, m = 0;
    solve(l, n, m, 1);
}

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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
const ll MAX = 1e6;
/* end defineing */

signed main()
{
  int n;
  vector<ll> v;
  cin >> n;

  int cnt_ = 0;
  for (int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;
    if (tmp < 0)
      cnt_++;
    v.push_back(tmp);
  }
  sort(ALL(v));

  ll sum = 0;

  if (cnt_ % 2)
  {
    auto itr = lower_bound(ALL(v), 0);
    int idx = itr - v.begin() - 1;
    // cout << v.end() - v.begin() << endl;

    if (itr != v.end() && abs(*itr) < abs(*(itr - 1)))
    {
      *itr *= -1;
      *(itr - 1) *= -1;
      idx++;
    }

    for (int i = 0; i < v.size(); i++)
    {
      if (i == idx)
      {
        // cout << abs(v[i]) << endl;
        sum -= abs(v[i]);
      }
      else
      {
        sum += abs(v[i]);
      }
    }
  }
  else
  {
    for (int i = 0; i < v.size(); i++)
      sum += abs(v[i]);
  }
  cout << sum << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    ll cand = 0;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (sum <= 0 && i % 2 == 0) {
            cand += abs(sum - 1);
            sum = 1;
        }
        if (sum >= 0 && i % 2 == 1) {
            cand += abs(sum + 1);
            sum = -1;
        }
    }
    ll ans = cand;
    
    sum = 0;
    cand = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (sum <= 0 && i % 2 == 1) {
            cand += abs(sum - 1);
            sum = 1;
        }
        if (sum >= 0 && i % 2 == 0) {
            cand += abs(sum + 1);
            sum = -1;
        }
    }
    
    ans = min(ans, cand);
    
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<ll> arr1(N), arr2(N);
  ll x, y;
  for(int i=0;i<N;++i) {
    cin>>x>>y;
    arr1[i] = x+y;
    arr2[i] = x-y;
  }
  sort(arr1.begin(), arr1.end());
  sort(arr2.begin(), arr2.end());
  cout<<max(arr1[N-1]-arr1[0], arr2[N-1]-arr2[0])<<endl;
}



Measured memory_bytes: 6424
#include <bits/stdc++.h> /*5D*/
using namespace std;

int main(){
  int n; cin >> n;
  int i = 0;

while (++i <= n){

  int x = i;
  if ( x % 3 == 0 )
    cout << " " << i;
    
    else if ( x % 10 == 3)
        cout << " " << i;

    else {
        while(x){
        x /= 10;
         if ( x % 10 == 3) {
        cout << " " << i;
        break;
        }
    }
    }
}
cout << endl;
}


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

using namespace std;

int main()
{
    int N,a;
    long long sum[200001];
    sum[0] = 0;
    long long min_num = 20000000000;//pow(10, 9.0);

    cin >> N;

    for (int i = 1; i <= N; i++) {
        cin >> a;
        sum[i] = sum[i - 1] + a;
    }
    
    for ( int i = 1; i < N; i++) {
        min_num = min(min_num, abs(sum[N] - (2 * sum[i])));
    }
    cout << min_num << '\n';

}

Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc079/tasks/abc079_a
#include <bits/stdc++.h>
using namespace std;

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

  if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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


	ll N;
	cin >> N;

	vector<ll> A(N),B(N);
	rep(i,N){
		cin >> A[i] >> B[i];
	}
	
	for(ll i = N-1; i >= 0; i-- ){
		A[i] += ans;
		if(A[i]<=B[i]){
			if(A[i]!=0){
				ans += B[i] - A[i];
				// A[i] += B[i] - A[i];
			}
		}
		else{
			if(A[i] % B[i] == 0){
				ans += B[i]*(A[i]/B[i]) - A[i];
				// A[i] += B[i]*(A[i]/B[i]) - A[i];
			}
			else{
				ans += B[i]*(A[i]/B[i] + 1) - A[i];
				// A[i] += B[i]*(A[i]/B[i] + 1) - A[i];
			}
		}
	}
	
	cout << ans << endl;

	// 間違っていたら表示
	// rep(i,N){
	// 	if(A[i] % B[i] != 0){
	// 		cout << "NG" << endl;
	// 		cout << i << ": " << A[i] << " " << B[i] << endl;
	// 	}
	// }

	return 0;
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int a[200001];
int mapData[200001];

signed main() {
	int N;
	cin >> N;
	if (N == 1) {
		cout << "Hello World\n";
	}
	else {
		int A, B;
		cin >> A >> B;
		cout << A + B << "\n";
	}


}

Measured memory_bytes: 256
import sys

lines = sys.stdin.readlines()
for line in lines:
    a = int(line)
    sets = 0
    for i in range(0, 10):
        for k in range(0, 10):
            for l in range(0, 10):
                for m in range(0, 10):
                    if(i+k+l+m == a):
                        sets += 1
    print(sets)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define int long long

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, m, k;
int a, b, c;
int t;
int s[3005];
vector<int> stop;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> k;
    cin >> a >> b >> c;
    cin >> t;
    rep(i, m) cin >> s[i];
    int ans = 0;
    rep(i, m - 1) {
        int tl = t - (s[i] - 1) * b;
        if (tl < 0) break;
        int now = s[i];
        int nx = now + tl / a;
        int cnt = 0;
        if (nx >= s[i + 1]) {
            ans += s[i + 1] - s[i] -1;
            continue;
        }
        else {
            ans += nx - s[i];
        }
        now = nx + 1;
        while (now < s[i + 1] && cnt < k - m) {
            int tll = tl - (now - s[i]) * c;
            if (tll < 0) break;
            nx = now + tll / a;
            cnt++;
            if (nx >= s[i + 1]) {
                stop.pb(s[i + 1] - now);
                break;
            }
            else {
                stop.pb(nx - now + 1);
            }
            now = nx + 1;
        }
    }
    sort(all(stop), greater<int>());
    int size = stop.size();
    rep(i, min(size, k - m)) ans += stop[i];
    rep2(i, 1, m) if (t - (s[i] - 1) * b > 0) ans++;
    cout << ans << endl;
}

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

typedef long long ll;

#define MOD 1000000007LL

string k;
int d;

ll dp[10010][2][110];

ll go(int pos, bool f, int s, int num) {
    if(pos == k.size()) {
//        cout << num << endl;
        return s == 0;
    }

    if(dp[pos][f][s] != -1) return dp[pos][f][s];

    ll ans = 0LL;

    //cout << (f ? k[pos] - '0' : 9) << endl;
    for(char c = 0; c <= (f ? (k[pos] - '0') : 9); c++) {
        ans += go(pos + 1, f && c == (k[pos] - '0'), (s + c) % d, num * 10 + c) % MOD;
        ans %= MOD;
    }

    return dp[pos][f][s] = ans;
}

int main() {
    ios_base::sync_with_stdio(false);

    cin >> k >> d;

    memset(dp, -1, sizeof dp);

    cout << (go(0, true, 0, 0) - 1 + MOD) % MOD << endl;
}

Measured memory_bytes: 18560
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    string s,t;
    cin >> s >> t;
    P(t+s);
    return  0;
}


Measured memory_bytes: 256
# B
N = int(input())

W = []
re = 'Yes'
last = ''
for i in range(N):
    W.append(input())
    if last != '' and last != W[i][0:1]:
        re = 'No'
    elif W.count(W[i]) >= 2:
        re = 'No'
    last = W[i][-1]
        
print(re)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
typedef long long int LL;
const int MAX = 105;
const int INF = 1e5;


int main() {
	long long x, y;
	cin >> x >> y;
	long long gcd = __gcd(x, y);
	if (gcd == 1) {
		puts ("1");
		return 0;
	}

	int ans = 1;
	long long limit = sqrt (gcd);
	for (int i = 2; i <= limit; i++) {
		int check = 1;
		while (gcd % i == 0) {
			if (check) {
				ans++;
				check = 0;
			}
			gcd /= i;
		}
	}
	if (gcd > 1) 
		ans++;
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    vector<bool> isPushed(N, false);
    rep(i, N) {
        cin >> a[i];
        a[i]--;
    }
    int pos = 0;
    int count = 0;
    while (!isPushed[pos]) {
        if (pos == 1) {
            cout << count << endl;
            return 0;
        }
        isPushed[pos] = true;
        pos = a[pos];
        count++;
    }

    cout << -1 << endl;


    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int d[2222][2222],ans[2222];
vector<int> g[2222];
queue<int> que;

int main(void){
	int n,i,j,u,v,x[2],d,p,q;
	cin >> n >> x[0] >> x[1]; --x[0]; --x[1];
	for(u=0; u<n; ++u){
		for(v=0; v<u; ++v){
			d = abs(u-v);
			for(p=0; p<2; ++p){
				for(q=0; q<2; ++q){
					d = min(d,abs(u-x[p])+abs(v-x[q])+(p^q));
				}
			}
			++ans[d];
		}
	}
	for(i=1; i<n; ++i){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
import heapq
N,C=map(int,input().split())
a=0
x=[0]*N
v=[0]*N
for i in range(N):
    x[i],v[i]=map(int,input().split())
h=[0]
s=t=sum(v)
for i in range(N-1,-1,-1):
    k=t-x[i]-h[0]
    if k>a:
        a=k
    t-=v[i]
    heapq.heappush(h,t-s+2*(C-x[i]))
h=[0]
t=s
for i in range(N):
    k=t-C+x[i]-h[0]
    if k>a:
        a=k
    t-=v[i]
    heapq.heappush(h,t-s+2*x[i])
print(a)

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	int H, W;
	cin >> H >> W;
	vector<vector<bool>> s(H, vector<bool>(W));
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			char tmp;
			cin >> tmp;
			s[i][j] = tmp == '.';
		}
		cin.ignore();
	}

	vector<int> history(H * W, -1);
	deque<pair<int, int>> q;
	bool goal = false;
	history[0] = 0;
	q.push_back(make_pair(1, 0));
	q.push_back(make_pair(W, 0));
	while (!q.empty())
	{
		auto p = q.front();
		q.pop_front();
		if (!s[p.first / W][p.first % W])	continue;
		if (history[p.first] >= 0)			continue;
		history[p.first] = p.second;
		if (p.first == W * H - 1)
		{
			goal = true;
			break;
		}
		if (p.first / W != 0)		q.push_back(make_pair(p.first - W, p.first));
		if (p.first / W != H - 1)	q.push_back(make_pair(p.first + W, p.first));
		if (p.first % W != 0)		q.push_back(make_pair(p.first - 1, p.first));
		if (p.first % W != W - 1)	q.push_back(make_pair(p.first + 1, p.first));
	}

	if (!goal)
	{
		cout << -1 << endl;
		return EXIT_SUCCESS;
	}

	int count = 0;
	vector<bool> point_map(H * W, true);
	int now = H * W - 1;
	while (now != 0)
	{
		point_map[now] = false;
		now = history[now];
	}
	point_map[0] = false;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			if (s[i][j] && point_map[i * W + j])	++count;
		}
	}
	cout << count << endl;
	return 0;
}


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

int top;
int S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];

	while( scanf("%s", s) != EOF ) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		} else if (s[0] == '-' ) {
			b = pop();
			a = pop();
			push(a - b);
		} else if ( s[0] == '*' ) {
			a = pop();
			b = pop();
			push(a * b);
		} else {
			push(atoi(s));
		}
	} 

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

	return 0;

}

Measured memory_bytes: 548
#include <stdio.h>

int main() {
    int N, D, X, ans = 0, tmp = 0;
    scanf("%d", &N);
    scanf("%d %d", &D, &X);

    for (int i = 0; i < N; i++) {
        scanf("%d", &tmp);
        if (D % tmp == 0) {
            ans += D / tmp;
        } else {
            ans += D / tmp + 1;
        }
    }
    printf("%d\n", ans + X);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int N, x[100010], y[100010], t[100010];
	cin >> N;
	bool ans=true;
	t[0] = x[0] = y[0] = 0;
	for (int i = 0; i < N; i++)cin >> t[i+1] >> x[i+1] >> y[i+1];
	for (int i = 0; i < N; i++) {
		int dx = abs(x[i + 1] - x[i]) + abs(y[i+1] - y[i]);
		int dt = t[i + 1] - t[i];
		if (dx> dt)ans = false;
		if (dx%2 != dt % 2)ans = false;
	}
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 1408
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define rep(i , n) for(int i=0 ; i<n ; i++)
#define rep1(i , n) for(int i=1 ; i<=n ; i++)

typedef long long int ll;


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

	int n,m,start;
	int arr[101];
	cin >> n >> m >> start;
	rep(i , m)
		cin >> arr[i];
    
    int left=0,right=0;
    for(int i=0 ; i<m ; i++)    
    {
        if(arr[i] < start)
            left++;
        else
            right++;
    }

	cout << min(left , right);
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  codeforces
//
//  Created by cfhaiteeh on 29/5/2018.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#define  LL long long

using namespace  std;
int n,c;
int ci[35][35];
int ai[567][567];
LL sum[5][35];
void init(){
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=c;i++){
        for(int j=1;j<=c;j++){
            scanf("%d",&ci[i][j]);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            int t=(i+j)%3;
            int d;
            scanf("%d",&d);
            for(int k=1;k<=c;k++){
                sum[t][k]+=ci[d][k];
            }
        }
    }
}

LL ans;
bool vis[35];
void DFS(int now,LL sum1){
    if(now==3){
      //  cout<<"ojbk"<<endl;
        ans=min(ans,sum1);
        return;
    }
    for(int i=1;i<=c;i++){
        if(!vis[i]){
            vis[i]=1;
            DFS(now+1, sum1+sum[now][i]);
            vis[i]=0;
        }
    }
}
void play(){
    memset(vis,0,sizeof(vis));
    ans=100000000000000LL;
    DFS(0,0);
}
void pri(){
  printf("%lld\n",ans);
}

int main() {
    
    while(scanf("%d%d",&n,&c)!=EOF){
        init();
        play();
        pri();
    }
    return 0;
}


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

int main() {
  int N, K;

  cin >> N >> K;

  int riders = 0;
  for (int i = 0; i < N; i++) {
    int F; cin >> F;
    if (F >= K) {
      riders++;
    }
  }

  cout << riders;

  return 0;
  
}

Measured memory_bytes: 256
#nはリンゴの数　lは味の係数
n, l = list(map(int, input().split()))
#味のリスト
tastes = [l+x for x in range(n)]
#味の総和
all_tas = sum(tastes)
#一つだけ食べた総和のリスト
ptn = [all_tas - x for x in tastes]
#総和との差
di  = [abs(all_tas - x) for x in ptn]
#差が一番小さいものを取得
val = min(di)
#答え
print (ptn[di.index(val)])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
string st,st1;
int t,k;
int main()
{
	getline(cin,st);
	getline(cin,st1);
	t=-1;
	k=-1;
	for(int i=0;i<=st.size()-1+st1.size();i++)
	{
		if((i+1)%2==1) cout<<st[++t];
		  else cout<<st1[++k];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var cards = new Dictionary<string, int>();
            int n = int.Parse(Console.ReadLine());
            string s;
            for(int i = 0; i < n; i++)
            {
                s = Console.ReadLine();
                if (!cards.ContainsKey(s)) cards[s] = 0;
                cards[s]++;
            }
            int m = int.Parse(Console.ReadLine());
            for(int i = 0; i < m; i++)
            {
                s = Console.ReadLine();
                if (!cards.ContainsKey(s)) cards[s] = 0;
                cards[s]--;
            }
            Console.WriteLine(Math.Max(cards.Values.Max(),0));
        }
    }
}

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

int main()
{
	string O, E;
	cin >> O >> E;

	int NO = O.size();
	int NE = E.size();
	string  ans;
	for( int i = 0; i < max( NO, NE ); i++ ) {
		ans += O[i];
		if( i >= NE ) continue;
		ans += E[i];
	}

	cout << ans << endl;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
bool R(){return true;}
template<typename T, typename ... Args>
bool R(T & x, Args & ... args){return cin >> x && R(args...);}
void init_io(){ios::sync_with_stdio(false);cin.tie(0);}

#define PB push_back
#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define ALL(vec) (vec).begin(), (vec).end()
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF   1000000007
#define INFLL 4000000000000000007LL

int a;

void solve ()
{
  R(a);
  printf("%d\n", a + a * a + a * a * a);
}

int main ()
{
  init_io();
  int T = 1;
  //R(T);
  while (T--) solve();
  return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <numeric>
#include <bitset>
#include <stack>
using namespace std;

int main()
{
  int n, m;
  while (cin >> n >> m ) {
    if (n == 0 && m == 0)
      break;

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

    vector<int> time(n);
    time[0] = (m / a[0]) * a[0];
    for (int i = 1; i < n; ++i) {
      int minIndex = 0;
      for (int j = 0; j < i; ++j) {
	if (time[minIndex] < time[j])
	  minIndex = j;
      }

      int tmp = (time[minIndex] / a[i]) * a[i];
      if (tmp < time[minIndex] && tmp+a[i] <= m)
	tmp += a[i];
      if (tmp == time[minIndex] && a[i] < a[minIndex] && tmp+a[i] <= m)
      tmp += a[i];
      time[i] = tmp;
    }

    int minIndex = 0, cnt = 1;
    for (int i = 1; i < n; ++i) {
      if (time[minIndex] == time[i]) {
	if (a[minIndex] == a[i]) {
	  ++cnt;
	} else {
	  if (a[i] < a[minIndex]) {
	    minIndex = i;
	    cnt = 1;
	  }
	}
      } else if (time[minIndex] > time[i]) {
	minIndex = i;
	cnt = 1;
      }
    }

    if (cnt == 1) {
      cout << minIndex+1 << endl;
    } else {
      cout << n << endl;
    }

  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<ios>
#include<string>
#include<map>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>

using namespace std;


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

	if (s.find("-") == s.rfind("-")&& s.find("-")==a && s.find("-") != -1) {
		cout << "Yes" << endl;
	}
	else { cout << "No" << endl; }

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int h[200001];
int n;
int k;
long long int sum;
int main()
{

	scanf("%d %d", &n, &k);
	if(k >= n)
		printf("0\n");
	else 
	{
		for(int i = 0; i < n; i++)
			scanf("%d",&h[i]);
		sort(h,h + n);
		for(int i = 0; i < n - k; i++)
			sum += h[i];
		printf("%lld\n", sum);
	}
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<queue>
using namespace std;
int main(){
    queue<char>Q;
    char a;
    while(cin>>a){
        Q.push(a);
    }
    while(Q.size()){
        char b;
        b=Q.front();
        Q.pop();
        if(b=='A')cout<<'X';
        else if(b=='B')cout<<'Y';
        else if(b=='C')cout<<'Z';
        else {
            b-=3;
            cout<<b;
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> cnt(n+1);
    int j=1;
    rep(i,n){
        cin>>a[i];
        if(a[i]==j){
            ++cnt[a[i]];
            ++j;
        }
    }
    int i=1;
    while(cnt[i]!=0){
        ++i;
    }
    if(cnt[1]==0)cout<<-1<<endl;
    else cout<<n-(i-1)<<endl;

    return 0;
}

Measured memory_bytes: 4812
#include<iostream>
using namespace std;
#define MAX 100
#define BLANK 0
#define LONG 4
#define SHORT 2
#define HORIZONTAL 0
#define VERTICAL 1
#define VISITED 9

int field[MAX+2][MAX+2];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void rec(int x,int y,int c)
{
  int i;
  if(field[x][y]!=c)return;
  field[x][y]=VISITED;
  for(i=0;i<4;i++)rec(x+dx[i],y+dy[i],c);
  return;
}

int main()
{
  int w,h,xs,ys,xg,yg,n,c,d,x,y;
  int i,j;
  while(cin>>w>>h>>xs>>ys>>xg>>yg>>n,w|h){
    for(j=1-1;j<=h+1;j++)for(i=1-1;i<=w+1;i++)field[i][j]=BLANK;
    while(n-->0){
      cin>>c>>d>>x>>y;
      if(d==HORIZONTAL)
	for(i=0;i<LONG;i++)for(j=0;j<SHORT;j++)field[x+i][y+j]=c;
      else
	for(i=0;i<SHORT;i++)for(j=0;j<LONG;j++)field[x+i][y+j]=c;
    }
    if(field[xs][ys]!=BLANK)rec(xs,ys,field[xs][ys]);
    puts(field[xg][yg]==VISITED?"OK":"NG");
  }
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int a;
	cin >> a;
	int b = a %10;
	int c = a / 10;
	cout << ((b == 9 || c == 9)? "Yes": "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
#define FF first
#define SS second
 
const int N = 200000 + 5;
const int INF = 1<<30;
class SegTree{
	private:
		int size;
		PII nodes[4*N];
		inline int lc(int x){return 2*x+1;}
		inline int rc(int x){return 2*x+2;}
		void build(int l, int r ,int id, PII arr[]){
			if(r-l==1){
				nodes[id]=arr[l];
				return;
			}
			int mid=(l+r)>>1;
			build(l, mid, lc(id), arr);
			build(mid, r, rc(id), arr);
			nodes[id] = min(nodes[lc(id)], nodes[rc(id)]);
		}
		PII query(int ql, int qr, int l, int r, int id){
			if(qr <= l or r <= ql) return {INF,INF};
			if(ql <= l and r <= qr) return nodes[id];
			int mid=(l+r)>>1;
			return min(query(ql, qr, l, mid, lc(id)), query(ql, qr, mid, r, rc(id)));
		}
		void modify(int ql, int qr, int l, int r, int id, PII v){
			if(qr <= l or r <= ql) return;
			if(ql <= l and r <= qr){
				nodes[id]=v;
				return;
			}
			int mid=(l+r)>>1;
			modify(ql, qr, l, mid, lc(id), v);
			modify(ql, qr, mid, r, rc(id), v);
			nodes[id] = min(nodes[lc(id)], nodes[rc(id)]);
		}
	public:
		void build(int n, PII arr[]){
			size=n;
			build(0, size, 0, arr);
		}
		PII query(int l, int r){
			return query(l, r, 0, size, 0);
		}
		void modify(int p, PII v){
			modify(p, p+1, 0, size, 0, v);
		}
} odd, even;
 
int arr[N], ans[N];
PII o[N], e[N];
 
int main(int argc, char* argv[]){
	int n; cin>>n;
	fill(o, o+n, (PII){INF,INF});
	fill(e, e+n, (PII){INF,INF});
	for(int i=0;i<n;i++){
		cin>>arr[i];
		if(i&1) o[i]={arr[i],i};
		else e[i]={arr[i],i};
	}
	odd.build(n, o);
	even.build(n, e);
	set<int> block;
	block.insert(0);
	block.insert(n);
	priority_queue<PII,vector<PII>,greater<PII>> pq;
	pq.push(even.query(0, n));
	for(int i=0;i<(n/2);i++){
		PII pos = pq.top();pq.pop();
		if(pos.SS & 1){
			PII sec = even.query(pos.SS, *block.upper_bound(pos.SS));
			odd.modify(pos.SS, {INF,INF});
			even.modify(sec.SS, {INF,INF});
			auto it = block.upper_bound(pos.SS);
			it--;
			pq.push(odd.query(*it, pos.SS));
			pq.push(even.query(pos.SS, sec.SS));
			pq.push(odd.query(sec.SS, *block.upper_bound(sec.SS)));
			block.insert(pos.SS);
			block.insert(sec.SS);
			ans[i*2]=pos.FF;
			ans[i*2+1]=sec.FF;
		}else{
			PII sec = odd.query(pos.SS, *block.upper_bound(pos.SS));
			even.modify(pos.SS, {INF,INF});
			odd.modify(sec.SS, {INF,INF});
			auto it = block.upper_bound(pos.SS);
			it--;
			pq.push(even.query(*it, pos.SS));
			pq.push(odd.query(pos.SS, sec.SS));
			pq.push(even.query(sec.SS, *block.upper_bound(sec.SS)));
			block.insert(pos.SS);
			block.insert(sec.SS);
			ans[i*2]=pos.FF;
			ans[i*2+1]=sec.FF;
		}
	}
	for(int i=0;i<n;i++) cout<<ans[i]<<" \n"[i==n-1];
	return 0;
}

Measured memory_bytes: 29680
import numpy as np

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
line = input().split()
N = int(line[0])
X = int(line[1])

line = input().split()

diff = [abs(int(x)-X) for x in line]

min_ = gcd(diff[0], diff[0])

for df in diff:
    min_ = min(min_, gcd(diff[0], df))

print(min_)


Measured memory_bytes: 23064