akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int x,a,b;
	cin >> x >> a >> b;
	int foo = b-a;
	if(foo<=0)cout<<"delicious";
	else
	{
		if(foo<=x)cout<<"safe";
		else cout<<"dangerous";
	}
	
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::max;
use std::collections::BinaryHeap;

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut menu: Vec<Vec<i64>> = vec![];
    let mut maxv = 0;

    for _ in 0..n {
        let x: i64 = read();
        let y: i64 = read();
        let z: i64 = read();
        menu.push(vec![x, y, z]);
    }
    for a in [-1, 1].iter() {
        for b in [-1, 1].iter() {
            for c in [-1, 1].iter() {
                let mut iroha = vec![0; n];
                for i in 0..n {
                    iroha[i] = a * menu[i][0] + b * menu[i][1] + c * menu[i][2];
                }
                iroha.sort();
                iroha.reverse();
                let tot = iroha[0..m].iter().sum();
                maxv = max(maxv, tot);
            }
        }
    }

    // for i in 0..2_u32.pow(3) {
    //     let mut bh: BinaryHeap<i64> = BinaryHeap::new();
    //     let mut ans = 0;
    //
    //     for j in 0..menu.len() {
    //         let mut item = 0;
    //         for k in 0..3 {
    //             if i & 1 << k == 0 {
    //                 item += menu[j][k];
    //             } else {
    //                 item -= menu[j][k];
    //             }
    //         }
    //         bh.push(item);
    //     }
    //
    //     for _ in 0..m {
    //         ans += bh.pop().unwrap().abs();
    //     }
    //     // println!("{}", ans);
    //     maxv = max(maxv, ans);
    // }
    println!("{}", maxv);
}


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

int main(){
    //input
    string b;
    cin >> b;
    string ans;
    if (b == "A"){
        ans = "T";
    }
    else if (b == "C"){
        ans = "G";
    }
    else if (b == "G"){
        ans = "C";
    }
    else{
        ans = "A";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
l = [0]*(N+1)

for i in range(M):
        L, R = map(int, input().split())
        l[L-1] += 1
        l[R] -= 1
        

k = 0
ans = 0
for i in l:
        k += i
        if k == M:
                ans += 1
print(ans)


Measured memory_bytes: 3956
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr);
  console.log(arr.reduce((s, e) => s += ' ' + e, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    const left = 2 * i + 1, right = 2 * i + 2;
    let largest;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 140160
#include <stdio.h>
int main()
{
	int n;
	int ans=0;
	char slime[100000];
	scanf("%d",&n);
	scanf("%s",slime);
	for(int i=0;i<n-1;i++){
		if(slime[i]==slime[i+1])ans++;
	}
	printf("%d",n-ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target("avx,avx2,fma")

#define prev ddd

using namespace std;
using pi = pair<int,int>;
using pii = pair<pi,int>;
vector<pi> v;
vector<pii> w;
int n,sqrtn,m,a[555555],check[555555],ans[555555],ret;
void add(int x){ret += ++check[x]==1;}
void del(int x){ret -= !--check[x];}
void go(int x){
    pi prev = {0,0},now = v[w[x].second];
    if(x) prev = v[w[x-1].second];
    for(int i=prev.first-1; i>=now.first; i--) add(a[i]);
    for(int i=prev.second+1; i<=now.second; i++) add(a[i]);
    for(int i=prev.first; i<now.first; i++) del(a[i]);
    for(int i=prev.second; i>now.second; i--) del(a[i]);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    cin>>n>>m;
    sqrtn = sqrt(n);
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int i=0,x,y; i<m; i++){
        cin>>x>>y;
        v.push_back({x,y});
        w.push_back({{x/sqrtn,y},i});
    }
    sort(w.begin(),w.end());
    for(int i=0; i<m; i++){
        go(i);
        ans[w[i].second] = ret;
    }
    for(int i=0; i<m; i++) cout<<ans[i]<<'\n';
}


Measured memory_bytes: 19504
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> s[m];
    vector<int> p(m,0);
    for(int i=0; i<m; ++i){
        int k; cin>>k;
        for(int j=0; j<k; ++j){
            int tmp; cin>>tmp;
            s[i].push_back(tmp-1);
        }
    }
    for(int i=0; i<m; ++i){
        cin >> p[i];
    }
    int cnt=0;
    //スイッチn個をn桁の2進数として1ならon,0ならoffとして全探索
    for(int mask=0; mask<(1<<n); ++mask){
        int flash=0;
        for(int i=0; i<m; ++i){
            //s[i]行目のスイッチがonの個数を調べる
            int on=0;
            for(int j=0; j<s[i].size(); ++j){
                if(mask&(1<<s[i][j])) ++on;
            }
            //ここにはp[i]とon%2の比較を書く
            //スイッチが1個もついていなくても、電球はつく
            //のでon>0は書かなくていい。（ここで詰まってた…）
            if(p[i]==on%2) ++flash;
        }
        if(flash==m) ++cnt;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
x, y = map(int, input().split())

if x == y:
  print(-1)
  exit()

if y == 1:
  print(-1)
  exit()

for i in range(1, y):
  temp = x * i
  if temp <= 10 ** 18 and temp % y != 0:
    print(x*i)
    exit()

print(-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const char com[4] = {'R', 'U', 'L', 'D'};

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, ll>> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;

  ll t = (abs(p[0].first) + abs(p[0].second)) % 2;
  rep(i, n) {
    if ((abs(p[i].first) + abs(p[i].second)) % 2 != t) {
      cout << -1 << endl;
      return 0;
    }
  }
  ll m = 31;
  if (t == 0) m++;
  vector<ll> d(m);
  d[0] = 1;
  if (t == 1) {
    rep(i, 30) d[i + 1] = d[i] * 2;
  }
  else {
    d[1] = 1;
    rep(i, 30) d[i + 2] = d[i + 1] * 2;
  }
  cout << m << endl;
  rep(i, m) {
    cout << d[i];
    if (i == m - 1) cout << endl;
    else cout << " ";
  }
  rep(i, n) {
    ll x = p[i].first, y = p[i].second;
    string ans = "";
    vector<bool> change(3, false);
    if (x < 0) {
      change[0] = true;
      x = -x;
    }
    if (y < 0) {
      change[1] = true;
      y = -y;
    }
    if (x < y) {
      change[2] = true;
      swap(x, y);
    }
    if (t == 0) {
      x++;
      ll dir = 2;
      if (change[2]) {
        dir++;
        if (change[1]) dir -= 2;
      }
      else if (change[0]) dir -= 2;
      ans.push_back(com[dir]);
    }
    ll dist = x + y, sum = (1LL << 31) - 1;
    vector<int> sgn(31, 1), dir(31, -1);
    ll rest = (sum - dist) / 2;
    rep(i, 31) {
      if (rest >> i & 1) sgn[i] = -1;
    }
    sum = 1LL << 30;
    dir[30] = 0;
    rep(i, 31) {
      if (sgn[i] == -1) {
        sum -= (1LL << i);
        dir[i] = 2;
      }
    }
    rest = x - sum;
    rep(i, 31) {
      if (rest >> i & 1) {
        if (dir[i] == -1) dir[i] = 0;
        else dir[i] = -1;
      }
      if (dir[i] == -1) {
        if (sgn[i] == 1) dir[i] = 1;
        else dir[i] = 3;
      }
    }
    if (change[2]) {
      rep(i, 31) {
        if (dir[i] % 2 == 0) dir[i]++;
        else dir[i]--;
      }
    }
    if (change[0]) {
      rep(i, 31) {
        if (dir[i] % 2 == 0) dir[i] = (dir[i] + 2) % 4;
      }
    }
    if (change[1]) {
      rep(i, 31) {
        if (dir[i] % 2 == 1) dir[i] = (dir[i] + 2) % 4;
      }
    }
    rep(i, 31) ans.push_back(com[dir[i]]);
    cout << ans << endl;
  }




  


  
  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<vector>
#include<iostream>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};


template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}


extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<> void print<string>(const string& container)
{
	cout<<container<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}


template<typename T, typename U>
ostream& operator << (ostream& os, const pair<T, U>& p)
{
	os<<'('<<p.first<<", "<<p.second<<')';
	return os;
}

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}


template<unsigned int N> struct IsPrime {
	static const int size=(N>>5) + 1;
	unsigned int is_prime[size];
	constexpr IsPrime() : is_prime() {
		is_prime[0]=0x3;
		for(unsigned int i=2;i<N;i++)
		{
			if((is_prime[i>>5] & (1u<<(i&0x1f))) > 0)  continue;
			for(int j=i+i;j<N;j+=i)
				is_prime[j>>5]|=(1u<<(j&0x1f));
		}
	}
	constexpr bool operator[] (const int p) const
	{
		return (is_prime[p>>5] & (1u<<(p&0x1f))) == 0;
	}
};

template<int N> struct LikelyPrime {
	unsigned short sum[N+1];
	constexpr LikelyPrime(const IsPrime<N> pr) : sum() {
		for(int i=3;i<N;i++)
			sum[i+1]=sum[i]+(unsigned short)((pr[i] && pr[(i+1)/2])?1:0 );
	}
};

int q;
int l,r;
int main()
{
	constexpr IsPrime<100001> pr;
	constexpr LikelyPrime<100001> s(pr);
	scanf("%d",&q);
	while(q--)
	{
		scanf("%d%d", &l, &r);
		printf("%d\n", s.sum[r+1]-s.sum[l]);
	}
}


Measured memory_bytes: 768
#include<stdio.h>
int main()
{
	int A,B,C;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	if(A+B+1>C){
		printf("%d",B+C);
	}else{
		printf("%d",A+2*B+1);
	}
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int a,b,k;
  cin>>a>>b>>k;
  
  int c=a;
  if(a>b)c=b;
  int cnt=0;
  int ans=0;
  rreps(i,c){
    if(a%i==0&&b%i==0)cnt++;
    if(cnt==k){
      ans=i;
      break;
    }
  }
 
  cout<<ans<<endl;
 
  return 0;
}

Measured memory_bytes: 125568
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  rep(i, s.size()-1){
    if(s[i] != s[2]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#define NIL -2000000001

int A[1000002];
int heap_size;

int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
void swap(int x,int y){
  int temp;
  temp=A[x];
  A[x]=A[y];
  A[y]=temp;
}

void maxHeapify(int i){
  int l = left(i);
  int r = right(i);
  int largest;
  if (l <= heap_size && A[l] > A[i])largest = l;
  else largest = i;
  if (r <= heap_size && A[r] > A[largest])largest = r;
  if (largest != i){
    swap(i,largest);
    maxHeapify(largest);
  }
}
void buildMaxHeap(){
  int i;
  for(i=heap_size/2;i!=0;i--)maxHeapify(i);
}


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

  for(i=0;i<502;i++){
    A[i]=NIL;
  }
  for(i=1;i<=heap_size;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap();
  for(i=1;i<=heap_size;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int k; cin >> k;
  string s; cin >> s;

  if (s.size() <= k) {
    cout << s << endl;
  } else {
    rep(i, k) printf("%c", s[i]);
    printf("...\n");
  }

  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

void END(){cout << 0 << endl; exit(0);}


int main()
{
 cin.tie(0);
 ios::sync_with_stdio(false);
 double n;
 cin >> n;
 REP2(i, 1, 50000)
 {
  if ((int)(i * 1.08) == n)
  {
    cout << i << endl;
    exit(0);
  }
 }
 cout << ":(" << endl;

 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	
  	long long int n,k;
  	cin>>n>>k;
  	int a[n];
  	for(int i=0;i<n;i++) cin >> a[i];
  
  	for(int i=0;i<n-k;i++) {
    	if(a[i] < a[i+k]) cout << "Yes" << endl;
      	else cout << "No" << endl;
    }
}

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

int A[102], B[102];

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

    int N;
    cin >> N;

    for(int i=1; i<=N-1; i++)
        cin >> B[i];
    
    int ans = B[N-1], curr = B[N-1];

    for(int i=N-2; i>=1; i--)
    {
        curr = min(B[i+1], B[i]);
        ans += curr;
    }

    cout << ans + B[1] << "\n";
    return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}


/*{
  }*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

//constexpr int mod = 1e9+7;
//constexpr int inf = 1<<30;

signed main(){
  int n;
  cin >> n;

  int x;
  for(x = 1; x <= n; x++){
    if((int)(x*1.08) == n){
      cout << x << endl;
      return 0;
    }
  }

  cout << ":(" << endl;

  return 0;
}



Measured memory_bytes: 256
s = input()
n = len(s)
pre2, pre1 = 0, 0

if n == 2 and s[0] == s[1]:
    print(1, 2)
    exit()
for j in range(n):
    i = s[j]
    if i == pre2 or i == pre1:
        print(j-1, j+1)
        exit()
    else:
        pre2 = pre1
        pre1 = i
else:
    print("-1 -1")


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <utility>
#include <tuple>
#include <queue>

using namespace std;

int main()
{
    int h, w, x, y;
    cin>>h>>w>>x>>y;
    if ((h*w)%2==1 && (x+y)%2==1) cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}



Measured memory_bytes: 3092
import numpy as np
import sys
H,W = [int(i) for i in input().split()]

s = []
for i in range(H):
    s.append(list(input()))
#print('hogehoge\n')
#print(s)
for i in range(1,H-2):
    for j in range(1,W-2):
        if s[i][j]=='#':
            if s[i-1][j]=='.'and s[i+1][j]=='.'and s[i][j-1]=='.'and s[i][j+1]=='.':
                print('No')
                sys.exit()
for i in range(1,H-2):
    if s[i][0] == '#':
        if s[i-1][0]=='.'and s[i+1][0]=='.'and s[i][1]=='.':
            print('No')
            sys.exit()
    if s[i][W-1]=='#':
        if s[i-1][W-1]=='.'and s[i+1][W-1]=='.'and s[i][W-2]=='.':
            print('No')
            sys.exit()

for i in range(1,W-2):
    if s[0][i] == '#':
        if s[0][i-1]=='.'and s[0][i+1]=='.'and s[1][i]=='.':
            print('No')
            sys.exit()
    if s[H-1][i]=='#':
        if s[H-1][i+1]=='.'and s[H-1][i-1]=='.'and s[H-2][i]=='.':
            print('No')
            sys.exit()
if s[0][0]=='#' and s[0][1]=='.' and s[1][0]=='.':
    print('No')
    sys.exit()    
if s[0][W-1]=='#' and s[0][W-2]=='.' and s[1][W-1]=='.':
    print('No')
    sys.exit()    
if s[H-1][0]=='#' and s[H-2][0]=='.' and s[H-1][1]=='.':
    print('No')
    sys.exit()    
if s[H-1][W-1]=='#' and s[H-1][W-2]=='.' and s[H-2][W-1]=='.':
    print('No')
    sys.exit()   

print('Yes') 





Measured memory_bytes: 12532
IN = list(map(int, input().split()))
X, K, D = IN[0], IN[1], IN[2]

#mv = int(-X / D + 0.5)
mv = round(-X / D, 0)
if (abs(mv)>K): mv = mv * K / abs(mv)
residual_moves = K - abs(mv)

if residual_moves % 2 == 0:
    print (int(abs(X + D * mv)))
else:
    posa = abs(X+D*(mv+1))
    posb = abs(X+D*(mv-1))
    posc = abs(X+D*(mv+2))
    posd = abs(X+D*(mv-2))
    print(int(min(posa, posb, posc, posd)))


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

typedef long long ll;
typedef long double ld;

const int N=2e5+10;

int a[3][3];

int main(){
    //freopen("a.txt", "r", stdin);
    //freopen("answers.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++)
            cin>>a[i][j];
    }
    for(int a1=0;a1<=100;a1++){
        for(int a2=0;a2<=100;a2++){
            for(int a3=0;a3<=100;a3++){
                bool ok=((a[0][0]-a1)==(a[1][0]-a2) and (a[0][0]-a1)==(a[2][0]-a3));
                ok&=((a[0][1]-a1)==(a[1][1]-a2) and (a[0][1]-a1)==(a[2][1]-a3));
                ok&=((a[0][2]-a1)==(a[1][2]-a2) and (a[0][2]-a1)==(a[2][2]-a3));
                if(ok){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
long long rgb_triplets(int n, string s) {
  if(n<3)
    return 0;
  long long r_count = 0;
  long long g_count = 0;
  long long b_count = 0;
  
  for(int i=0;i<n;i++) {
    if(s[i] == 'R')
      r_count++;
    if(s[i] == 'G')
      g_count++;
    if(s[i] == 'B')
      b_count++;
  }
  long long ans = r_count * g_count * b_count;

  for(long long i=0;i<n-1;i++) {
    for(long long k=i+1;k<n;k++) {
      if((k+i) % 2 != 0)
	continue;
      long long j = (k+i) / 2;
      //cout << i << " " << j << " " <<  k << " -> " << j-i << " " << k-j << endl;
      if(s[i] != s[j] && s[j] != s[k] && s[i] != s[k])
	ans--;
    }
  }
  return ans;
}

int main() {
  int n;
  string s;

  cin >> n;
  cin >> s;

  cout << rgb_triplets(n, s);
}



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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    string s; cin >> s;
    vector<ll> sumv;
    sumv.push_back(0);
    sumv.push_back(0);
    char c = s[0];
    ll cnt = 0;
    for(ll i=0;i<n;i++){
        if(s[i] == c){
            cnt++;
        }else{
            c = s[i];
            sumv.push_back(sumv.back() + cnt);
            cnt = 0;
            cnt++;
        }
    }
    sumv.push_back(sumv.back() + cnt);
    sumv.push_back(sumv.back());

    ll sz = sumv.size();
    ll ans = 0;
    if(s[0] == '1'){
        if(2 + 2*k >= sz){
            ans = n;
        }
        // 1 0 1 ...
        for(ll i=2;i+2*k<sz;i+=2){
            ans = max(ans, sumv[i+2*k] - sumv[i-1]);
        }   
    }else{
        if(1 + 2*k >= sz){
            ans = n;
        }
        // 0 1 0 ...
        for(ll i=1;i+2*k<sz;i+=2){
            ans = max(ans, sumv[i+2*k] - sumv[i-1]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1528
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    a = list(map(int, input().split()))
    d = c
    for j in range(m):
        d += a[j] * b[j]
    if (d > 0):
        ans += 1
print(ans)


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n, x;

    int count = 0;

    while (1)
    {
        cin >> n >> x;
        if (n == 0 && x == 0)
        {
            break;
        }
        for (int i = 1; i <= n; i++)
        {
            for (int j = i + 1; j <= n; j++)
            {
                for (int k = j + 1; k <= n; k++)
                {
                    if (i + j + k == x)
                    {
                        count++;
                    }
                }
            }
        }
        OP(count)
        count = 0;
    }

    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<vector>
#include<complex>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define chmin(a,b) a=min(a,b);
#define N 200010
namespace Genius{
    class Segtree{
      public:
      ll dat[2*N];
      void init(){
	  for(int i=0;i<2*N;i++)dat[i]=1e17;
      }
      void upd(ll i,ll x){
	  i+=N;
	  for(;i;i>>=1)chmin(dat[i],x);
      }
      ll qry(ll l,ll r){
	  l+=N,r+=N+1; ll res=1e17;
	  for(ll a=l,b=r;a<b;a>>=1,b>>=1){
	      if(a&1)chmin(res,dat[a++]);
	      if(b&1)chmin(res,dat[--b]);
	  }
	  return res;
      }
    };
    
    ll dat[N];
    Segtree tap1,tap2; 
    void init(){
	tap1.init(); tap2.init();
	for(int i=0;i<N;i++)dat[i]=1e17;
    }
    void upd(ll x,ll val){
	dat[x]=val;
	tap1.upd(x,val+x);
	tap2.upd(x,val-x);
    }
    ll info(ll x){return dat[x];}
    ll qry(ll x,ll tei){
	ll vl=tap1.qry(x,N-1)-tei;
	ll vr=tap2.qry(0,x)+tei;
	return min(vl,vr);
    }
};

ll n,q,sl,sr,a[N];
int main(){
    cin>>n>>q>>sl>>sr;
    for(int i=0;i<q;i++)cin>>a[i+1];
    a[0]=sl;
    Genius::init();
    Genius::upd(sr,0);
    for(int i=0;i<q;i++){
	ll cur=Genius::info(a[i]);
	//ll cur=1e17;
	chmin(cur,Genius::qry(a[i+1],a[i+1])-abs(a[i+1]-a[i]));
	Genius::upd(a[i],cur);
	//for(int i=1;i<=n;i++)cout<<Genius::info(i)<<" ";cout<<endl;
    }
    
    ll ans=1e17;
    for(int i=1;i<=n;i++)chmin(ans,Genius::info(i)); //cout<<ans<<endl;
    for(int i=0;i<q;i++)ans+=abs(a[i+1]-a[i]);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 9600
#include<stdio.h>
#include<math.h>

int main(void) {
    int a, b;
    char op;
    
    while(1) {
        scanf("%d %c %d", &a, &op, &b);

        if(op == '+') printf("%d\n", a + b);
        else if(op == '-') printf("%d\n", a - b);
        else if(op == '*') printf("%d\n", a * b);
        else if(op == '/') printf("%d\n", a / b);
        else if(op == '?') break;
        else return 1;
    }
    

    return 0;
}



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

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var str = Console.ReadLine();
            var proc = new Dictionary<string, Action<string[]>> {
                { "print", v => Console.WriteLine(str.Substring(int.Parse(v[1]), int.Parse(v[2]) - int.Parse(v[1]) + 1)) },
                { "reverse", v => str = str.Substring(0, int.Parse(v[1])) + new String(str.Substring(int.Parse(v[1]), int.Parse(v[2]) - int.Parse(v[1]) + 1).Reverse().ToArray()) + str.Substring(int.Parse(v[2]) + 1) },
                { "replace", v => str = str.Substring(0, int.Parse(v[1])) + v[3] + str.Substring(int.Parse(v[2]) + 1) }
            };
            for(int i = int.Parse(Console.ReadLine()); i > 0 ; --i){
                var d = Console.ReadLine().Split();
                proc[d[0]](d);
            }
        }
    }
}

Measured memory_bytes: 5932
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        long start = System.nanoTime();
        System.out.println(solve(n,h));
        long end = System.nanoTime();
        System.err.println("execution time: " + ((end-start)/1_000_000) + "ms");
    }
    private static int solve(int n, int[] h) {
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(h[1]-h[0]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i-1]+Math.abs(h[i]-h[i-1]),dp[i-2]+Math.abs(h[i]-h[i-2]));
        }
        return dp[n-1];
    }
}

Measured memory_bytes: 51960
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    string S;
    cin >> S;

    ll cnt1 = 0, cnt2 = 0;
    rep (i, S.size()) {
        char c1 = i % 2 ? '1' : '0';
        char c2 = i % 2 ? '0' : '1';
        if (S[i] != c1) ++cnt1;
        if (S[i] != c2) ++cnt2;
    }
    cout << min(cnt1, cnt2) << endl;
}


Measured memory_bytes: 888
//JSD
#include<iostream>
#include<vector>
#include<set>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<limits.h>
#define ll long long 
using namespace std;

int main(){
	ll int n;	
	ll m;
	cin>>n>>m;
	if(n==m){
		for(int i=0;i<m;i++) cout<<n;
	}	
	else{
		if(n<m)	{
			swap(n,m);
		}
		for(int i=0;i<n;i++)	
			cout<<m;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
ll dp[401][401];
int A[401];
ll S[401];
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> A[i];
  }
  S[0] = A[0];
  for(int i = 1;i < n;i++)
    S[i] = S[i - 1] + A[i];
  for(int l = 2;l <= n;l++){
    for(int i = 0;i + l - 1 < n;i++){
      int j = i + l - 1;
      dp[i][j] = 1e18;
      if(l == 2)
        dp[i][j] = A[i] + A[j];
      else
        for(int k = i;k < j;k++){
          dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + S[j] - (i ? S[i - 1] : 0));
        }
    }
  }
  cout << dp[0][n - 1];
  return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
int main(int argc, char const *argv[])
{
  int N;
  scanf("%d",&N);
  int a[N];
  int i,j,tmp;
  int x=0,y=0,z;
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<N-1;i++){
    for(j=i+1;j<N;j++){
      if(a[i]<a[j]){
        tmp=a[i];
        a[i]=a[j];
        a[j]=tmp;
      }
    }
  }
  for(i=0;i<N;i++){
    if(i%2==0) x+=a[i];
    else y+=a[i];
  }
  z=x-y;
  printf("%d",z);
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int h = reader.nextInt();
    int a = reader.nextInt();
    out.println(h / a + (h % a > 0 ? 1 : 0));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i,n) cin >> x[i] >> y[i];
  auto dist = [&](int i, int j) {
    double dx = x[i]-x[j];
    double dy = y[i]-y[j];
    return sqrt(dx*dx+dy*dy);
  };
  //n!通りの経路の長さの合計
  double len = 0;
  rep(i,n)rep(j,i) {
    len += dist(i,j);
  }
  /*  (pdfの解説見て)  */
  double ans = len*2/n;
  printf("%.10f\n", ans);
  return 0;
}


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

int n, k;
int l[50];

int main(){
    cin >> n >> k;
    rep(i, n){
        cin >> l[i];
    }

    sort(l, l + n, greater<int>());
    int s = 0;
    rep(i, k){
        s += l[i];
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int dfs(int i, int n, std::vector< std::vector<std::pair<int, int>> > &gr, std::vector<bool> &is_visited, std::vector<int> &colors) {
	// visit i-th node
	is_visited[i] = true;
	int my_color = colors[i];
	for(int i_node = 0; i_node < gr[i].size(); ++i_node) {
		int num_node = gr[i][i_node].first;
		int weight = gr[i][i_node].second;
		if(weight == 0) continue;
		if(is_visited[num_node]) continue;
		if(colors[num_node] < 0) {
			if(weight % 2 == 1) colors[num_node] = (my_color == 0 ? 1 : 0);
			else colors[num_node] = (my_color == 0 ? 0 : 1);
			dfs(num_node, n, gr, is_visited, colors);
		}
	}
	return 0;
}

int main(void) {
	// input
	int n;
	std::cin >> n;
	std::vector<int> u(n-1), v(n-1), w(n-1);
	for(int i = 0; i < n-1; ++i) std::cin >> u[i] >> v[i] >> w[i];

	// adjacent list
	std::vector< std::vector<std::pair<int, int>> > gr(n);
	for(int j = 0; j < n-1; ++j) {
		gr[u[j]-1].push_back(std::make_pair(v[j]-1, w[j]));
		gr[v[j]-1].push_back(std::make_pair(u[j]-1, w[j]));
	}

	std::vector<bool> is_visited(n);
	std::vector<int> colors(n, -1);

	colors[0] = 0;
	dfs(0, n, gr, is_visited, colors);

	for(int i = 0; i < n; ++i) {
		std::cout << colors[i] << std::endl;
	}

	return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int N;
set<P> point;
vector<P> v;
set<P> temp;
ll gcd (ll a, ll b){
    if (b==0) return a;
    return gcd(b, a%b);
}
ll solve(ll p, ll q){
    ll cnt=0;
    while(sz(temp)){
        cnt++;
        ll x=(*temp.begin()).fr, y=(*temp.begin()).sc;
        while(temp.count(P(x-p,y-q))){
            x-=p;
            y-=q;
        }
        while(temp.count(P(x,y))){
            temp.erase(P(x,y));
            x+=p;
            y+=q;
        }
    }
    return cnt;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    v.resize(N);
    rep(i,0,N){
        ll x,y;
        cin>>x>>y;
        v[i].fr=x;
        v[i].sc=y;
        point.insert(P(x,y));
    }
    ll ans=N;
    rep(i,0,N){
        rep(j,i+1,N){
            ll p=v[i].fr-v[j].fr, q=v[i].sc-v[j].sc;
            temp=point;
            ans=min(ans, solve(p, q));
        }
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 256
from collections import deque
K = int(input())
d = deque()
for i in range(1,10):
    d.append(i)
for i in range(K):
    x = d.popleft()
    y = x%10
    z = 10*x+y
    if y != 0:
        d.append(z-1)
    d.append(z)
    if y != 9:
        d.append(z+1)
print(x)

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

vector<UL> E[100000];
UL D[100000];

int main() {
 UL N,M; scanf("%u%u",&N,&M);
 rep(i,M){
  UL u,v; scanf("%u%u",&u,&v);
  E[u].push_back(v);
  E[v].push_back(u);
 }
 rep(i,N) D[i]=~0u;
 rep(s,N){
  if(D[s]!=~0u) continue;
  queue<UL> Q; Q.push(s); D[s]=s;
  while(Q.size()){
   UL p=Q.front(); Q.pop();
   for(UL e:E[p]){
    if(D[e]!=~0u) continue;
    D[e]=D[p];
    Q.push(e);
   }
  }
 }
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  UL s,t; scanf("%u%u",&s,&t);
  if(D[s]==D[t]) printf("yes\n");
  else printf("no\n");
 }
 return 0;
}



Measured memory_bytes: 9076
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n;
	cin >> n;
	ll ans = 0;
	vector<int>a(n);
	repp(i, 0, n)cin >> a[i];
	vector<ll>dp(n,INF);//最後がaiの最長増加部分列の長さ
	repp(i, 0, n) {
		*lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
		}
	cout << lower_bound(dp.begin(), dp.end(), INF) - dp.begin() << endl;
	}



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

using namespace std;

int main()
{
  int n;

  scanf("%d", &n);

  vector<int> a(n);

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

  sort(a.begin(), a.end(), greater<int>());

  int A = 0, B = 0;

  for (int i = 0; i < n; i++)
  {
    if (i % 2 == 0)
    {
      A += a[i];
    }
    else
    {
      B += a[i];
    }
  }

  printf("%d", A - B);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> food(m,0);
  rep(i,0,n) {
    int k;
    cin >> k;
    rep(j,0,k) {
      int a;
      cin >> a;
      food[a-1]++;
    }
  }
  int ans = 0;
  rep(i,0,m) {
    if (food[i] == n) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3580
def input_int():
    return(int(input()))

def input_int_list():
    return(list(map(int,input().split())))

def input_int_map():
    return(map(int,input().split()))

def run():

    n, k = input_int_map()

    nums = input_int_list()


    in_list_count = 0
    for i in range(len(nums)):
        for j in range(i, len(nums)):
            if nums[i] > nums[j]:
                in_list_count += 1

    in_list_count_sum = in_list_count * k

    other_list_count = 0

    for num in nums:
        for num2 in nums:
            if num > num2:
                other_list_count += 1


    other_list_count_sum = other_list_count * k * (k - 1) // 2

    result = (in_list_count_sum + other_list_count_sum) % (10 ** 9 + 7)
    print(result)

run()

# RRLRL
# 0 2 1 1 1

# 1 1 2 2 0




















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

int main(){
  int N;cin>>N;
  int A;
  vector<int> S(N,0);
  for(int i=0;i<N-1;i++){
    cin>>A;
    S[--A]++;
  }
  for(int i=0;i<N;i++){
    cout<<S[i]<<endl;
  }
  return 0;
}

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

int a[1005];
ll b[1000005];
int k;
ll work(ll *c, int m, int b)
{
    if (b < 0)
        return 0;

    // printf("Now c = ");
    // for (int i = m; i--;)
    //     printf("%d ", c[i]);
    // puts("");

    int cnt = 0;
    for (int i = m; i--;)
        cnt += c[i] >> b & 1;
    if (cnt >= k)
    {
        // printf("Get %d\n", b);

        int j = m;
        for (int i = m; i--;)
            if (c[i] >> b & 1)
                c[--j] = c[i];
        return (1ll << b) | work(c + j, m - j, b - 1);
    }
    else
        return work(c, m, b - 1);
}
int main()
{
    int n;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i)
        scanf("%d", a + i);

    int m = 0;
    for (int i = 1; i <= n; ++i)
    {
        ll s = 0;
        for (int j = i; j <= n; ++j)
        {
            s += a[j];
            b[m++] = s;
        }
    }

    printf("%lld\n", work(b, m, 40));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define oo 100005
using namespace std;
int a[oo], n, t[oo], t1, ans, t2, t3, t4, t5, t6, t7, t8;
struct node {int x, id;} p[oo];
inline bool cmp (node i, node j)
{return i.x > j.x;}
void work (int lim)
{
    
}
int main ()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; ++ i)
    scanf("%d", &a[i]);
    for(int i = 1; i < oo; ++ i) p[i].id = i;
    for(int i = 1; i <= n; i += 2) ++ p[a[i]].x;
    int lim = n + 1 >> 1;
    sort(p + 1, p + oo, cmp);
    t1 = lim - p[1].x; t2 = p[1].id;
    t3 = lim - p[2].x;
    for(int i = 1; i < oo; ++ i) p[i].x = 0;
    for(int i = 1; i < oo; ++ i) p[i].id = i;
    for(int i = 2; i <= n; i += 2) ++ p[a[i]].x;
    lim = n >> 1;
    sort(p + 1, p + oo, cmp);
    t4 = lim - p[1].x; t5 = p[1].id;
    t6 = lim - p[2].x;
    if(t2 != t5) printf("%d", t1 + t4);
    else printf("%d", min(t1 + t6, t3 + t4));
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool G[8][8];

int dfs(int v, int N, bool vis[8]) {
    
    bool all_vis = true;
    rep(i, N) {
        if(vis[i] == false) all_vis = false;
    }

    if(all_vis) return 1;

    int ret = 0;

    for (int i = 0; i < N; i++) {
        if (G[v][i] == false) continue;
        if (vis[i]) continue;

        vis[i] = true;
        ret += dfs(i, N, vis);
        vis[i] =false;
    }

    return ret;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;

    rep(i, M) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        G[A][B] = true; G[B][A]= true;
    }

    bool vis[8];
    rep(i, 8) vis[i] = false;

    vis[0] = true;
    cout << dfs(0, N, vis) << endl;
    return 0;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
A.sort()
freq = [0] * (10**6+1)
for a in A:
    freq[a] += 1
m = A[-1]
ans = n
for i in range(n):
    a = A[i]
    if freq[a] > 1:
        ans -= freq[a]
        freq[a] = 0
    for j in range(2 * a, m+1, a):
        if freq[j] > 0 and j % a == 0:
            ans -= freq[j]
            freq[j] = 0
print (ans)


Measured memory_bytes: 132440
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      int N=int.Parse(Console.ReadLine());
      int flg=0;
      for(int i=1;i<=9;i++){
        if(((N/i)<10)&&((N%i)==0)){
          flg=1;
        }
           
           }
           if(flg==1){
             Console.WriteLine("Yes");
           }else{
             Console.WriteLine("No");
           }
    }
  }
}

Measured memory_bytes: 13140