akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#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())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	string s;
	cin >> s;
	if(s.size() < 26){
		for(int i = 0 ; i < 26 ; i ++){
			bool t = true;
			for(int j = 0 ; j < s.size() ; j ++){
				t &= s[j] != 'a'+i;
			}
			if(!t)continue;
			s += 'a'+i;
			cout << s << endl;
			return 0;
		}
	}
	if(s == "zyxwvutsrqponmlkjihgfedcba"){
		puts("-1");
		return 0;
	}
	int t = 25;
	do{
		t --;
	}while(s[t]>s[t+1]);
	int u = 25;
	while(s[t]>s[u])u --;
	swap(s[t],s[u]);
	for(int i = 0 ; i <= t ; i ++){
		cout << s[i];
	}cout << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

    /* チェックリスト
     * 結果はintの範囲を超えていませんか？(必要な時以外はlongを使いましょう)
     * TLEしそうな処理はありませんか？
     */
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.nextLine());
        long prev = 0;
        long r = 0;
        long max = 0;
        for(long i = 0;i < n;i++){
            long now = Long.parseLong(sc.next());
            if(prev < now){
                if(r > max){
                    max = r;
                }
                r = 0;
            }else{
                r++;
            }
            prev = now;
        }
        if(r > max){
            max = r;
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 46728
N, M = input().split()
A = input().split()

N = int(N)
M = int(M)
#print(N,M,A)

sum = 0
for i in A:
    sum += int(i)

#print(sum)

ans = N - sum
if(ans >= 0):
    print(ans)
else:
    print(-1)

Measured memory_bytes: 67936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


int main(){
    ll a, b, c; cin >> a >> b >> c;
    set<ll> s;
    s.insert(a), s.insert(b), s.insert(c);
    cout << s.size() << endl;
}


Measured memory_bytes: 3592
#include<stdio.h>

int main(){
    int a,b,c,i;
    int k=0;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a; i<=b; i++){
        if(c%i == 0) k++;
    }
    printf("%d\n",k);
    return 0;
}


Measured memory_bytes: 2108
void main() {
  problem();
}

void problem() {
  auto N = scan!int;
  auto A = scan!long(N);
  
  long solve() {
    
    long[long] dp;
    dp[0] = 1_000;
    foreach(price; A) {
      foreach(kabu; dp.keys) {
        auto kabuToBuy = dp[kabu] / price;
        auto maxKabu = kabu + kabuToBuy;
        auto boughtMoney = dp[kabu] - kabuToBuy*price;
        
        if (maxKabu in dp) {
          if (dp[maxKabu] < boughtMoney) dp[maxKabu] = boughtMoney;
        } else {
          dp[maxKabu] = boughtMoney;
        }

        auto selledMoney = dp[maxKabu] + maxKabu*price;
        if (selledMoney > dp[0]) dp[0] = selledMoney;
      }
    }

    return dp[0];
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


Measured memory_bytes: 2720
#include<iostream>
using namespace std;
int main()
{
    int l, r;
    cin >> l >> r;

    int zero_f = 0;
    if (l/2019 != r/2019 || l%2019 == 0) {
      cout << 0 << endl;
      return 0;
    }
    l %= 2019;
    r %= 2019;
  	int min = 2019;
    int tmp;
    for (int i = l; i <= r-1; i++) {
      for (int j = i+1; j <= r; j++) {
        tmp = (i * j) % 2019;
        if (tmp < min) {
          min = tmp;
        }
      }
    }
  
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
mod = 998244353

dp = []
for i in range(c + 1):
    temp = [0] * (d + 1)
    dp.append(temp)
dp[a][b] = 1
for i in range(a, c+1):
    for j in range(b, d+1):
        if i == a and j == b:
            dp[i][j] = 1
        else:
            dp[i][j] = dp[i-1][j] * j + dp[i][j-1] * i - dp[i-1][j-1] * ((i-1) * (j-1))
            dp[i][j] %= mod
print(dp[c][d])

Measured memory_bytes: 133644
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <iomanip>
using namespace std;

const long long MAX_N = 1e2 + 2, MAX_K = 1e5 + 5, MOD = 1e9 + 7;
long long n, k;
long long a[MAX_N];
long long dp[MAX_N][MAX_K];

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (long long i = 1; i <= n; i++)
		cin >> a[i];

	for (long long i = 0; i < MAX_K; i++)
		dp[0][i] = 1;

	for (long long i = 1; i <= n; i++) {
		dp[i][0] = 1;
		for (long long j = 1; j <= k; j++)
			dp[i][j] = (((dp[i][j - 1] + dp[i - 1][j] - (a[i] < j? dp[i - 1][j - a[i] - 1]: 0)) % MOD) + MOD) % MOD;
	}

	cout << (((dp[n][k] - (k? dp[n][k - 1]: 0)) % MOD) + MOD) % MOD << "\n";
	return 0;
}

Measured memory_bytes: 79232
#include<iostream>
#include<set>
#include<queue> // priority_queue
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;


int main(){
  if(df) printf("*debug mode*\n");
  li n,k; cin >>n >>k;
  multiset<li>  pl;
  multiset<li>  mn;
  rep(i,n){
    li  a; cin >>a;
    if(a>0) pl.insert(a);
    else mn.insert(a);
  }
  if(df){
    for(auto x: pl) cout << x << " ";
    printf("\n");
    for(auto x: mn) cout << x << " ";
    printf("\n");
  }
  auto calc=
    [&](li a){
      if(df)printf("calc(%ld)\n",a);
      if(a<=0){
	if(mn.size()==0)return (li)0;
	int sp=pl.size(),sm=mn.size();
	int i=0,j=0;
	auto itp=pl.begin(),itm=mn.begin();
	li cnt=0;
	while(itm!=mn.end()){
	  while(i<sp and (*itp)*(*itm)>=a){ i++; itp++; }
	  cnt+=pl.size()-i;
	  if(df)printf("+%ld",pl.size()-i);
	  itm++;
	}
	if(df)printf("->%ld\n",cnt);
	return cnt;
      }
      li cnt=(li)pl.size()*mn.size();
      if(pl.size()>0){
	auto head=(pl.begin()),tail=--(pl.end());
	int i=0,j=pl.size()-1;
	if(df)printf("pl");
	while(head!=tail){
	  while(head!=tail and (*head)*(*tail)>=a){ j--; tail--; }
	  if(head==tail)break;
	  cnt+=j-i;
	  if(df)printf("+%ld",j-i);
	  head++; i++;
	}
      }
      if(mn.size()>0){
	auto head=(mn.begin()),tail=--(mn.end());
	int i=0,j=mn.size()-1;
	if(df)printf("\nmn");
	while(head!=tail){
	  while(head!=tail and (*head)*(*tail)>=a){ i++; head++; }
	  if(head==tail)break;
	  cnt+=j-i;
	  if(df)printf("+%ld",j-i);
	  tail--; j--;
	}
      }
      if(df)printf("->%ld\n",cnt);
      return cnt;
    };
  li ok=-1000000000000000000,ng=1000000000000000001;
  while(ng-ok>1){
    li temp=(ng+ok)/2;
    ((calc(temp)<k)?ok:ng)=temp;
  }
  if(df)printf("\n");
  printf("%ld",ok);
}

/// confirm df==0 ///


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		double AA = 0;
		for(int i = 0;i < N;i++) {
			long a = scn.nextLong();
			AA += 1/(double)(a);
		}
		System.out.println(1/AA);
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll N, M; cin >> N >> M;
	vector<ll> A(N+1,0LL);
	for (int i = 1; i <= (int)N; ++i){
		cin >> A[i];
	} // end for
	for (int i = 1; i <= (int)N; ++i){
		A[i] += A[i-1];
	} //  end for

	map<int,int> cnt; cnt.clear();
	cnt[0] = 1;
	for (int i = 1; i <= (int)N; ++i){
		++cnt[(int)(A[i] % M)];
	} // end for

	ll res = 0LL;
	map<int,int>::iterator it = cnt.begin();
	for (; it != cnt.end(); ++it){
		int c = (*it).second;
		res += (ll)c * ((ll)c - 1LL) / 2LL;
	} // end for

	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 3968
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

N, k = map(int, input().split())
prev_arr = list(map(int, input().split()))

count = 0
for i in range(min(k, 3*int(math.log(N))+10)):
    arr = [0]*N
    for j in range(N):
        left = max(0, j-prev_arr[j])
        right = min(N-1, j+prev_arr[j])
        arr[left] += 1
        if right < N-1:
            arr[right+1] -= 1

    # print(arr)
    for j in range(1, N):
        arr[j] += arr[j-1]

    # print(arr)
    prev_arr = arr
    count += 1

# print(count)
print(*prev_arr)


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

string tmp;
int main(){
  cin >> tmp;
  int index = 0;

  for (int i = 0; i < tmp.size(); i++){
    if (tmp[i] == '?'){
      index = i;
      break;
    }
  }

  int count = 0;
  int ans = 0;
  
  for (int i = 0; i < 10; i++){
    string str = tmp;
    str[index] = i + '0';
    
    int Q = 0;
    
    for (int j = 0; j < str.size() - 1; j++){
      const int ind = 11 - j;

      if(ind <= 6){
	Q += (ind + 1) * (str[j] - '0');
	Q %= 11;
      }else{
	Q += (ind - 5) * (str[j] - '0');
	Q %= 11;
      }
    }

    if(Q > 1){
      Q = 11 - Q;
    }else{
      Q = 0;
    }

    // cout << i << " " << str[11] << " " << Q << endl;
    if(str[11] == (Q + '0')){
      count++;
      ans = i;
    }
  }

  if(count > 1){
    cout << "MULTIPLE" << endl;
  }else{
    cout << ans << endl;
  }
}

Measured memory_bytes: 1184
#include <algorithm>
#include <bits/stdc++.h>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <type_traits>
#include <vector>

// lib/pow2.hpp
#ifndef POW2_HPP
#define POW2_HPP

/*
usage:

tools::pow2(5) => 32
*/


namespace tools {
  template <typename T, typename std::enable_if<std::is_unsigned<T>::value, std::nullptr_t>::type = nullptr>
  constexpr T pow2(const T x) {
    return static_cast<T>(1) << x;
  }

  template <typename T, typename std::enable_if<std::is_signed<T>::value, std::nullptr_t>::type = nullptr>
  constexpr T pow2(const T x) {
    return static_cast<T>(static_cast<typename std::make_unsigned<T>::type>(1) << static_cast<typename std::make_unsigned<T>::type>(x));
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

class textbook {
public:
  i64 cost;
  std::vector<i64> points;
};

int main() {
  i64 N, M, X;
  std::cin >> N >> M >> X;
  std::vector<textbook> textbooks(N);
  for (i64 i = 0; i < N; ++i) {
    std::cin >> textbooks[i].cost;
    textbooks[i].points.reserve(M);
    std::copy_n(std::istream_iterator<i64>(std::cin), M, std::back_inserter(textbooks[i].points));
  }

  i64 answer = std::numeric_limits<i64>::max();
  for (i64 state = 0; state < tools::pow2(N); ++state) {
    i64 possible_answer = 0;
    std::vector<i64> points(M, 0);
    for (i64 i = 0; i < N; ++i) {
      const textbook& textbook = textbooks[i];
      bool bought = ((state >> i) & 1) == 1;
      if (bought) {
        possible_answer += textbook.cost;
        for (i64 j = 0; j < M; ++j) {
          points[j] += textbook.points[j];
        }
      }
    }
    if (std::all_of(points.begin(), points.end(), [&X](const i64& point) { return point >= X; })) {
      answer = std::min(answer, possible_answer);
    }
  }

  std::cout << (answer < std::numeric_limits<i64>::max() ? answer : -1) << std::endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int counta = 0;
  int countb= -1;
  while(a>0){
    a -= d;
    counta += 1;
  }
  while(c>0){
    c -= b;
    countb += 1;
  }
  string ans;
  if(counta > countb){
    ans = "Yes";
  }
  else{
    ans = "No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
S =input()
output_length = 0
for i,s in enumerate(S):
    if s not in ["A","C","G","T"]:
        continue
    partial_str = s
    if i+1 > len(S):
        break

    for s2 in S[i+1:]:
        if s2 not in ["A","C","G","T"]:
            break
        partial_str +=s2
    if len(partial_str) >  output_length:
        output_length =len(partial_str)
print(output_length)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int a,b,c;
  cin >> a >> b >> c;
  int maxx,sa;
  maxx = max({a,b,c});
  sa = 3*maxx - a - b - c;
  
  if(sa%2 == 1) sa += 3;
  cout << sa/2 << endl;
}


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

int main()
{
  int a[N],b=0;
  while(1)
    {
      cin >> a[b];
      if(a[b]==0) break;
      b++;
    }
  for(int i=0;i<b;i++)
    {
      cout << "Case " << i+1 << ": " << a[i] << endl;
    }
  return 0;
}

Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; i++) {
            if (a[i] == 0) {
                System.out.println(0);
                return;
            }
        }
        long sum = 1;
        for (int i = 0; i < n; i++) {
            if (sum >= (double) Long.MAX_VALUE / a[i]) {
                System.out.println(-1);
                return;
            }
            sum *= a[i];
            if (sum > 1000000000000000000L) {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(sum);
    }

}


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

using namespace std;

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 200200;

vector<int>cnt[N];
int res[N];
string s;

int nxt[26][N];
int n;
inline bool check(int x)
{
	for(int i=0;i<26;++i)
	{
		int ok=1;
		for(int j=0;ok&&j<n-x;++j)
		{
			if(nxt[i][j]-j>x)
				ok=0;
		}
		if(ok)
			return 1;
	}
	return 0;
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> s;
	n=s.length();
	for(int i=0;i<26;++i)
		nxt[i][n]=n;
	for(int i=n-1;i>=0;--i)
		for(int j=0;j<26;++j)
			if(j==s[i]-'a')
				nxt[j][i]=i;
			else
				nxt[j][i]=nxt[j][i+1];
	int l=-1,r=n;
	while(l+1<r)
	{
		int m=(l+r)>>1;
		if(check(m))r=m;
		else l=m;
	}
	cout<<r;
	return 0;
}


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

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define all(a) (a).begin(),(a).end()

using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Poly;

const D EPS = 1e-8;
const D PI = acos(-1);

inline D dot(P x, P y){return real(conj(x)*y);}
inline D cross(P x, P y){return imag(conj(x)*y);}

inline P unit(P p){return p/abs(p);}
inline pair<P,P> norm(P p){return make_pair(p*P(0,1),p*P(0,-1));}

//for line(segment)
inline int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)+EPS<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

inline P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

//vertexes are in the counter-clockwise order.
inline Poly convex_cut(Poly p,L l){
  Poly res;
  rep(i,p.sz){
    int nxt = (i+1)%p.sz;
    if(ccw(l.fs,l.sc,p[i]) != -1)res.pb(p[i]);
    if(ccw(l.fs,l.sc,p[i]) * ccw(l.fs,l.sc,p[nxt]) < 0){
      res.pb( line_cp(l, L(p[i],p[nxt]) ) );
    }
  }
  return res;
}

bool check(D dis, const Poly &p){
  Poly U(4);
  U[0] = P(-1e6, -1e6);
  U[1] = P(+1e6, -1e6);
  U[2] = P(+1e6, +1e6);
  U[3] = P(-1e6, +1e6);

  int n = p.size();
  for(int i=0;i<n;i++){
    L l = L(p[i],p[(i+1)%n]);
    P vec = norm(l.sc-l.fs).fs, move = dis*unit(vec);
    l.fs += move; l.sc += move;
    U = convex_cut(U,l);
  }
  return !U.empty();
}

int main(){
  int n;
  while(cin >> n,n){
    Poly p(n);
    for(int i=0;i<n;i++){
      D x,y;
      cin >> x >> y;
      p[i] = P(x,y);
    }

    D l = 0, r = 1e6;
    for(int i=0;i<50;i++){
      D mid = (l+r)/2;
      if(check(mid,p))l = mid;
      else r = mid;
    }
    cout << fixed << setprecision(10) << l << endl;
  }
}

Measured memory_bytes: 1328
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e10
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
using namespace std;

int main()
{
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> v(n, 0);
    rep(i, q){
        ll tmp;
        cin >> tmp;
        v[tmp-1]++;
    }

    rep(i, n-1){
        if(v[i] > (q-k)) cout << "Yes" << "\n";
        else cout << "No" << "\n";
    }

    if(v[n-1] > (q-k)) cout << "Yes";
    else cout << "No";


}

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

using namespace std;
const long long INF = 1LL <<60;  

int main(void){
  long long res=0;
  long long bus_t,bus_c;
  long long i,j;
  long long n,c,k;
  
  cin>>n>>c>>k;
  long t[n];
  
  for(i=0;i<n;i++){
    cin>>t[i];
  }
  sort(t,t+n);
  /*
  for(i=0;i<n;i++){
    cout<<t[i]<<endl;
  }*/
  
  
  bus_t=t[0];
  bus_c=1;
  res=1;
  for(i=1;i<n;i++){
    if(t[i]<=(bus_t+k)){
      if(bus_c==c){
        bus_t=t[i];
        bus_c=1;
        res++;
      }
      else{
        bus_c++;
      }
    }
    else{
      bus_t=t[i];
      bus_c=1;
      res++;
    }
  }
  

  
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 4424
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> b(n);
  rep1(i,n-1)cin>>b[i];
  int res=b[1]+b[n-1];
  rep1(i,n-2){
      res+=min(b[i],b[i+1]);
  }
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 3600
def BC133_D():
    n = int(input())
    a = list(map(int, input().split()))
    b = 0
    for i in range(n):
        if i % 2 == 0:
            b += a[i]
        else:
            b -= a[i]
    res = [b] * n
    for i in range(1, n):
        res[i] = a[i - 1] * 2 - res[i - 1]
    print(' '.join(list(map(str, res))))


BC133_D()

Measured memory_bytes: 19224
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int a,b,h;
  cin >> a >> b >> h;

  pr((a+b)*h/2);


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {

	int a, b, c=1, GCD, LCM ,  d ,e;

	while (cin >> a >> b) {
		d = a;
		e = b;
		while (c) {
			c = a % b;
			if (c == 0) {
				GCD = b;
				break;
			}
			else {
				a = b;
				b = c;
			}
		}
		d /= GCD;
		e /= GCD;
		LCM = d * e * GCD;

		cout << GCD << " " << LCM << endl;
		c = 1;
	}

	return 0;

}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
#define int long long

using namespace std;

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

	int n; cin >> n;
	vector<int> v(n);
	for(int i =0; i < n; i++) cin >> v[i];
	int ans = 0;
	for(int i = 0; i < n ; i++)
		for(int j = i + 1 ; j < n; j++)
			for(int k = j + 1; k < n; k++)
				if(v[i] + v[j] > v[k] && v[i] != v[j] && v[i] != v[k] && v[j] != v[k] && v[i] + v[k] > v[j] && v[j] + v[k] > v[i]) ans++;

	cout << ans;

  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int dist[35][35];
vector<i_i> pathes[35][35];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int H, W;
        cin >> W >> H;
        if(H == 0) break;
    for(int h = 1; h <= H; h++) {
        for(int w = 1; w <= W; w++) {
            dist[h][w] = INF;
            pathes[h][w].clear();
        }
    }
    for(int h = 1; h <= H; h++) {
        for(int w = 1; w < W; w++) {
            int in;
            cin >> in;
            if(in == 0) {
                pathes[h][w].push_back({h, w + 1});
                pathes[h][w+1].push_back({h, w});
            }
        }
        if(h == H) break;
        for(int w = 1; w <= W; w++) {
            int in;
            cin >> in;
            if(in == 0) {
                pathes[h][w].push_back({h + 1, w});
                pathes[h+1][w].push_back({h, w});
            }
        }
    }
        dist[1][1] = 1;
        queue<i_i> que;
        que.push({1, 1});
        while(!que.empty()) {
            i_i now = que.front();
            que.pop();
            //cerr << now.first << " " << now.second << " " << dist[now.first][now.second] << endl;
            int nowdist = dist[now.first][now.second];
            for(int i = 0; i < pathes[now.first][now.second].size(); i++) {
                i_i next = pathes[now.first][now.second][i];
                if(dist[next.first][next.second] != INF) continue;
                dist[next.first][next.second] = nowdist + 1;
                que.push(next);
            }
        }
        if(dist[H][W] == INF) dist[H][W] = 0;
        cout << dist[H][W] << endl;
    }
    return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>    
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<ll> a){
	for(int i=0; i<a.size(); i++) printf("%lld ",a[i]);
	printf("\n");
}
void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}
/*
bool ord(ii a, ii b){
	if(a.first == b.first){
		return a.second < b.second;
	}
	return a.first < b.first;
}*/

bool ord(ll a, ll b){
	return a>b;
}

ll ans = 0;
int a,n,w,t,k,m,z,q,l,r,x,b,y;
int A[200005];
char S[200005];
int P2[100];


int main(){
	scanf("%d%d",&m,&k);
	P2[0]=1;
	F0R(i,1,19) P2[i] = P2[i-1]*2; 

	int tope = P2[m]-1;

	if(k>tope) return !printf("-1\n");

	if(m==1 && k == 1){
		return !printf("-1\n");
	}

	if(k==0){

	for(int i=1; i<=tope; i++)
		if(i!=k)
			printf("%d ",i);

	printf("0 0 ");


	for(int i=tope; i>0; i--)
		if(i!=k)
			printf("%d ",i);
	}  else {

	for(int i=0; i<=tope; i++)
		if(i!=k)
			printf("%d ",i);

	printf("%d ",k);


	for(int i=tope; i>-1; i--)
		if(i!=k)
			printf("%d ",i);

	printf("%d ",k);
		
	}


}




// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?

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

int main(void){
  int N;
  string S;
  int cnt, min_cnt = 300010;
  int cnt_EW[2][300010];
  cin >> N >> S;
  //配列に持っておく。
  for(int i = 0; i < N; i++){
    cnt = 0;
    if(i == 0){
      if(S[i] == 'E') cnt_EW[0][0] = 1, cnt_EW[1][0] = 0;
      else cnt_EW[0][0] = 0, cnt_EW[1][0] = 1;
    }
    else if(S[i] == 'E'){
      cnt_EW[0][i] = cnt_EW[0][i - 1] + 1;
      cnt_EW[1][i] = cnt_EW[1][i - 1];
    }
    else if(S[i] == 'W'){
      cnt_EW[0][i] = cnt_EW[0][i - 1];
      cnt_EW[1][i] = cnt_EW[1][i - 1] + 1;
    }
     // cout << cnt_EW[0][i] << " " << cnt_EW[1][i] << endl;
  }
  //得られた配列を参照しながら，最小値を求める。
  for(int i = 0; i < N; i++){
    if(i == 0) cnt = cnt_EW[0][N - 1];
    else cnt = cnt_EW[1][i - 1] + (cnt_EW[0][N - 1] - cnt_EW[0][i]);
    //cout << cnt << endl;
    if(min_cnt > cnt) min_cnt = cnt;
  }

  cout << min_cnt << endl;
  return 0;
}


Measured memory_bytes: 3076
#include "bits/stdc++.h"
using namespace std;

bool calc1(int& n1, int& n2, int& plus)		// plusはどちらの数値がプラスされたかを示す。
{
	if (n1 == 0 && n2 == 0) {
		return false;
	} else {
		if (n1 >= n2) {
			n1--;
			n2++;
			plus = 2;
		} else {
			n1++;
			n2--;
			plus = 1;
		}
		return true;
	}
}

bool calc2(string s, int& a, int& b, int& c, vector<char>& select)
{
	int plus;
	if (s == "AB") {
		if (calc1(a, b, plus) == true) {
			if (plus == 1) {
				select.push_back('A');
			} else {
				select.push_back('B');
			}
			return true;
		} else {
			return false;
		}
	}
	if (s == "AC") {
		if (calc1(a, c, plus) == true) {
			if (plus == 1) {
				select.push_back('A');
			} else {
				select.push_back('C');
			}
			return true;
		} else {
			return false;
		}
	}
	if (s == "BC") {
		if (calc1(b, c, plus) == true) {
			if (plus == 1) {
				select.push_back('B');
			} else {
				select.push_back('C');
			}
			return true;
		} else {
			return false;
		}
	}
}

bool calc3(string s, int a, int b, int c)
{
	bool ret = false;
	if (s == "AB") {
		if (a == 1 && b == 1) {
			ret = true;
		}
	}
	if (s == "AC") {
		if (a == 1 && c == 1) {
			ret = true;
		}
	}
	if (s == "BC") {
		if (b == 1 && c == 1) {
			ret = true;
		}
	}
	return ret;
}

void calc4(string si, string sip, int& a, int& b, int& c, vector<char>& select)
{
	if (si == "AB") {
		if (sip == "AC") {
			a++;
			b--;
			select.push_back('A');
		} else {
			a--;
			b++;
			select.push_back('B');
		}
	}
	if (si == "AC") {
		if (sip == "AB") {
			a++;
			c--;
			select.push_back('A');
		} else {
			a--;
			c++;
			select.push_back('C');
		}
	}
	if (si == "BC") {
		if (sip == "AB") {
			b++;
			c--;
			select.push_back('B');
		} else {
			b--;
			c++;
			select.push_back('C');
		}
	}
}

int main()
{
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s.at(i);
	}

	string ans = "Yes";
	vector<char> select;
	if (a + b + c == 0) {
		ans = "No";
	}
	if (a + b + c == 1) {
		for (int i = 0; i < n; i++) {
			if (calc2(s.at(i), a, b, c, select) == false) {
				ans = "No";
				break;
			}			
		}
	}
	if (a + b + c >= 2) {
		for (int i = 0; i < n; i++) {
			if (a + b + c == 2 && calc3(s.at(i), a, b, c) == true && i != n - 1 && s.at(i) != s.at(i + 1)) {
				calc4(s.at(i), s.at(i + 1), a, b, c, select);
			} else {
				if (calc2(s.at(i), a, b, c, select) == false) {
					ans = "No";
					break;
				}
			}
		}
	}

	cout << ans << endl;
	if (ans == "Yes") {
		for (auto select_ele : select) {
			cout << select_ele << endl;
		}
	}
}


Measured memory_bytes: 6712
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int n = (int)s.length();
	bool res = (s[0] == s[n - 1]) ^ (n % 2 == 0);

	cout << (res ? "Second" : "First") << endl;
 
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int num[4];
	for(int i = 0;i < 4;i++){
		num[i] = n%10;
		n/=10;
	}
	if(num[0]==num[1]&&num[1]==num[2])
		cout << "Yes"<<endl;
	else if(num[1]==num[2]&&num[2]==num[3])
		cout << "Yes"<<endl;
	else cout << "No"<<endl; 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

ll N, K, misiz;
vector<ll> A;

ll cnt(ll x) {
    ll tmp = 0;
    for (int i = misiz; i < N; ++i) {
        if (A[i] == 0) {
            if (x >= 0)
                tmp += i;
            continue;
        }
        ll x2 = (x > 0 ? x : x - A[i] + 1);
        auto itr = upper_bound(A.begin(), A.begin() + i, x2 / A[i]);
        tmp += itr - A.begin();
    }
    for (int i = 0; i < misiz; ++i) {
        ll x2 = (x > 0 ? x : x + A[i] + 1);
        auto itr = lower_bound(A.begin(), A.begin() + i, x2 / A[i]);
        tmp += A.begin() + i - itr;
    }
    return tmp;
}

inline bool isok(ll x) {
    return cnt(x) >= K;
}

ll search() {
    ll ok = 2e18, ng = -2e18;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        (isok(mid) ? ok : ng) = mid;
    }
    return ok;
}

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

    cin >> N >> K;
    A.resize(N);
    for (int i = 0; i < N; ++i)
        cin >> A[i];
    sort(A.begin(), A.end());
    misiz = lower_bound(A.begin(), A.end(), 0) - A.begin();

    cout << search() << endl;

    return 0;
}


Measured memory_bytes: 1792
<?php
list($n, $k) = ints();
$a = ints();
$cusum[0] = 0;
for ($i = 1; $i <= $n; ++$i) $cusum[$i] = $cusum[$i - 1] + $a[$i - 1];
for ($l = 1; $l <= $n; ++$l)
    for ($r = $l; $r <= $n; ++$r)
        $beauty[] = $cusum[$r] - $cusum[$l - 1];
$ans = 0;
for ($t = strlen(decbin(max($beauty))) - 1; $t >= 0; --$t) {
    $cnt = 0;
    foreach ($beauty as $b)
        if ((($ans + (1 << $t)) & $b) === ($ans + (1 << $t))) ++$cnt;
    if ($cnt >= $k) $ans += 1 << $t;
}
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 33612
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 998244353
#define NUM 200010

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int pid=0,pnum=0,rpid[NUM];LL cost[NUM],cpid[NUM],que[NUM];
int judge(int a,int b){if(pnum<b||b==1)return 0;return cpid[que[a]]>cpid[que[b]]?1:0;}
void push(LL a,int n){int i=++pid,j=++pnum;rpid[i]=n,cpid[i]=a,que[j]=i;while(judge(j/2,j))que[j]=que[j/2],que[j/=2]=i;}
int pop(){int ans=rpid[que[1]],i=1,j;LL n=que[pnum--];que[1]=n;while(judge(i,j=i*2+judge(i*2,i*2+1)))que[i]=que[j],que[i=j]=n;return ans;}
void Dijkstra(int v,int e,int* a,int* b,int* l,int ver){int i,flag[NUM]={0},pre[e+1],last[e+1];FOR(i,1,v+1)cost[i]=LNF,last[i]=-1;cost[ver]=0;FOR(i,0,e)pre[i]=last[a[i]],last[a[i]]=i;while(flag[ver]==0){flag[ver]++;for(i=last[ver];i+1;i=pre[i])if(cost[b[i]]>cost[ver]+l[i]){cost[b[i]]=cost[ver]+l[i];push(cost[b[i]],b[i]);}while(flag[ver]&&pnum)ver=pop();}}


int main(){
  int N,i;
  scanf("%d",&N);
  int u[N*2-2],v[N*2-2],w[N*2-2];
  FOR(i,0,N-1)scanf("%d%d%d",&u[i],&v[i],&w[i]);
  FOR(i,0,N-1)u[i+N-1]=v[i],v[i+N-1]=u[i],w[i+N-1]=w[i];
  FOR(i,0,N-1)w[i]%=2;
  Dijkstra(N,2*N-2,u,v,w,1);
  FOR(i,1,N+1)printf("%lld\n",cost[i]%2);

	return 0;
}


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

#define REP(i, n) for(int 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0); //cinとcoutの同期切り
    ios::sync_with_stdio(false); //iostreamとstdioの同期切り

    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int ans = 0;
    if(A + B <= C*2){
        ans = X*A + Y*B;
    }
    else{
        int m = min(X, Y);
        ans += m*C*2;
        if(X > m) ans += (X - m)*A;
        else if (Y > m) ans += (Y - m)*B;
        
        ans = min(ans, C*2*max(X, Y));
    }

    cout << ans << endl;

    return 0;
}

/*****************************************************************************/
/*****   1秒間で処理できるfor文ループの回数                                 *****/
/*****   → 10^8 = 100,000,000 回程度                                      *****/
/*****                                                                   *****/
/*****   sort(a, a+N, greater<int>()); // a[0:N) を大きい順にソート        *****/
/*****                                                                   *****/
/*****                                                                   *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3"                *****/
/*****   std::cout << std::fixed;                                        *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3.00"             *****/
/*****                                                                   *****/
/*****************************************************************************/

Measured memory_bytes: 256
// #include<bits/stdc++.h>
// #define IOS ios::sync_with_stdio(0);cin.tie(0);
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)

#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;

bool dp[10000010];
int arr[2000010];

int main() {
    // IOS
    int n;
    cin >> n;
    int p;
    int max = -1;
    for (int i = 1; i <= n; i++) {
        cin >> p;
        if (p > max)
            max = p;
        arr[i] = p;
    }
    sort(arr+1, arr+1+n);
    for (int i = 1; i <= n; i++) {
        if (arr[i] == arr[i-1]) {
            dp[arr[i]] = true;
        }
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (dp[arr[i]] == false) {
            cnt++;
        }
        if (arr[i] != arr[i-1]) {
            for (int j = 2 * arr[i]; j <= max; j+=arr[i]) {
                dp[j] = true;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 5288
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

void solve(){

	ll ans=0;
	ll n;
	cin>>n;
	vector<string> s(n);
	vector<ll> a(4,0);
	for(ll i=0;i<n;i++){
		cin>>s[i];
		if(s[i]=="AC"){
			a[0]++;
		}
		else if(s[i]=="WA"){
			a[1]++;
		}
		else if(s[i]=="TLE"){
			a[2]++;
		}
		else{
			a[3]++;
		}
	}
	
	cout<<"AC x "<<a[0]<<endl;
	cout<<"WA x "<<a[1]<<endl;
	cout<<"TLE x "<<a[2]<<endl;
	cout<<"RE x "<<a[3]<<endl;
}


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



Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    rep(i,s.length() -1) {
        if(s[i] != s[i+1]){
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, M;
  cin >> N >> M;

  int sum = 0;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
    sum += A[i];
  }

  int cnt = 0;
  REP(i, N){
    if(A[i]*4*M >= sum) cnt++;
  }

  if(cnt >= M) Yes;
  else No;

  return 0;
}


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

int main(){
	int N, W;
	cin >> N >> W;
	int dp[N+1][W+1], v[N], w[N];
	for (int i = 0; i < N; ++i){
		cin >> v[i] >> w[i];
	}
	for (int i = 0; i < N + 1; ++i){
		for (int j = 0; j < W + 1; ++j){
			dp[i][j] = 0;
		}
	}
	for (int i = 1; i < N + 1; ++i){
		for (int j = 0; j < W + 1; ++j){
			if (j >= w[i-1]){
				dp[i][j] = max(dp[i-1][j-w[i-1]]+v[i-1], dp[i-1][j]);
			}else{
				dp[i][j] = dp[i-1][j];
			}
			if(j) dp[i][j] = max(dp[i][j], dp[i][j-1]);
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}

Measured memory_bytes: 7016
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

def main():
    n = II()
    a = II()
    if n%500 <= a: print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()


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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

int cnt[50][1000000];

signed main()
{
	int n;
	cin >> n;
	rep(i, n) {
		CIN(string, s);
		rep(j, s.length()) {
			cnt[i][(unsigned int)s[j]]++;
		}
	}
	for (char c = 'a'; c <= 'z'; c++) {
		int mi = 1e9;
		rep(i, n) mi = min(mi, cnt[i][(unsigned int) c]);
		rep(i, mi) cout << c;
	}
	cout << endl;
}




Measured memory_bytes: 100608
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (c > b) {
    swap(c, b);
  }
  if (a < b) {
    swap(a, b);
    if (b < c)
      swap(b, c);
  }
  cout << a * 10 + b + c << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
//import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static int cnt = 0;
	public static void main(String[] args) throws NumberFormatException, IOException {
		//System.setIn(new FileInputStream("./input.txt"));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] s = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		
		mergeSort(s, 0, n);
		
		StringBuilder sb = new StringBuilder();
		sb.append(s[0]);
		for(int i = 1; i < n; ++i) {
			sb.append(" " + s[i]);
		}
		System.out.println(sb);
		System.out.println(cnt);
	}
	public static void mergeSort(int[] s, int left, int right) {
		if(left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(s, left, mid);
			mergeSort(s, mid, right);
			merge(s, left, mid, right);
		}
	}
	public static void merge(int[] s, int left, int mid, int right) {
		int[] s1 = Arrays.copyOfRange(s, left, mid + 1);
		int[] s2 = Arrays.copyOfRange(s, mid, right + 1);
		
		s1[mid - left] = Integer.MAX_VALUE;
		s2[right - mid] = Integer.MAX_VALUE;
		int i = 0;
		int j = 0;
		for(int k = left; k < right; ++k) {
			cnt += 1;
			if(s1[i] <= s2[j]){
				s[k] = s1[i];
				i += 1;
			}else{
				s[k] = s2[j];
				j += 1;
			}
		}
		
	}
	
}

Measured memory_bytes: 161312
def solve():
    [N, K] = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    import collections
    count = collections.Counter(A)
    pq = sorted([(v, k) for k, v in count.items()], key=lambda x: x[0])
    ans = 0

    if len(count) <= K:
        return 0

    for v, k in pq:
        ans += v
        del count[k]
        if len(count) <= K:
            return ans
    return -1


print(solve())

Measured memory_bytes: 40836
#include<stdio.h>

int main(void)
{
    int a,b,c,d[100],i,j=0,k;

    scanf("%d%d%d",&a,&b,&k);
    c=a;
    if(a<b)  c=b;
    for(i=c;i>0;i--){
    if((a%i==0)&&(b%i==0)){
    d[j]=i;
    j++;
    }}
    printf("%d\n",d[k-1]);
    return 0;
}


Measured memory_bytes: 128