akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	int N;
	cin >> N;
	REP(i, N) {
		int a1 = 0;
		int a2 = 0;
		int a3 = 0;
		int out = 0;
		int pt = 0;
		while (true) {

			string s;
			cin >> s;
			if (s[1] == 'I') {
				if (a3 == 1) {
					a3 = 0;
					pt++;
				}
				if (a2 == 1) {
					a2 = 0;
					a3 = 1;
				}
				if (a1 == 1) {
					a1 = 0;
					a2 = 1;
				}
				a1 = 1;
			}
			else
				if (s[1] == 'U') {
					out++;
					if (out == 3) {
						break;
					}
				}
				else {
					if (a1 == 1) {
						a1 = 0;
						pt++;
					}
					if (a2 == 1) {
						a2 = 0;
						pt++;
					}
					if (a3 == 1) {
						a3 = 0;
						pt++;
					}
					pt++;
				}
		}
		cout << pt << endl;
	}
}

Measured memory_bytes: 3004
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#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 Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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 <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

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

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    string s,t;
    cin >> s >> t;
    vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0));
    rep(i,s.size()){
        rep(j,t.size()){
            if(s[i]==t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],dp[i][j+1]);
            chmax(dp[i+1][j+1],dp[i+1][j]);
        }
    }
    string ans = "";
    int i = (int)s.size();
    int j = (int)t.size();
    while(i>0 && j>0){
        if(dp[i-1][j]==dp[i][j]) i--;
        else if(dp[i][j-1]==dp[i][j]) j--;
        else{
            ans =  s[i-1] + ans;
            i--;
            j--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 35584
program making_palindrome
  implicit none
  integer(8), parameter :: inf = 1e18
  integer :: n, i
  character(20) :: s(50, 2) = ''
  integer(8) :: c(50) = 0, m(50, 21, 2) = 0, x = inf
  logical :: u(50, 21, 2) = .false.
  read(*,*) n
  do i = 1, n
    read(*,*) s(i, 1), c(i)
    s(i, 2) = reverse(s(i, 1)(1:len_trim(s(i, 1))))
  end do
  do i = 1, n
    x = min(x, solve(i, 1, 1) + c(i))
  end do
  write(*,'(i0)') merge(x, -1_8, x < inf)
contains
  function reverse(s) result(res)
    character(*), intent(in) :: s
    character(len_trim(s)) :: res
    integer :: n, i
    n = len_trim(s)
    do i = 1, n
      res(i:i) = s(n - i + 1:n - i + 1)
    end do
  end
  recursive integer(8) function solve(i, j, k) result(res)
    integer, intent(in) :: i, j, k
    integer :: l, r, t
    logical :: f
    res = m(i, j, k)
    if (u(i, j, k)) return
    u(i, j, k) = .true.
    m(i, j, k) = inf
    l = j
    r = len_trim(s(i, k))
    f = .true.
    do while (l < r)
      if (s(i, k)(l:l) /= s(i, k)(r:r)) then
        f = .false.
        exit
      end if
      l = l + 1
      r = r - 1
    end do
    if (f) then
      m(i, j, k) = 0
      res = 0
      return
    end if
    do t = 1, n
      l = j
      r = 1
      do while (l <= len_trim(s(i, k)) .and. r <= len_trim(s(t, 3 - k)))
        if (s(i, k)(l:l) /= s(t, 3 - k)(r:r)) exit
        l = l + 1
        r = r + 1
      end do
      if (l == len_trim(s(i, k)) + 1) then
        m(i, j, k) = min(m(i, j, k), solve(t, r, 3 - k) + c(t))
      end if
      if (r == len_trim(s(t, 3 - k)) + 1) then
        m(i, j, k) = min(m(i, j, k), solve(i, l, k) + c(t))
      end if
    end do
    res = m(i, j, k)
  end
end program making_palindrome

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

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

	if (N % 2 == 1)
	{
		cout << "No" << endl;
		return 0;
	}

	string s;
	cin >> s;


	for (int i = 0; i < s.size() / 2; i++)
	{
		if (s[i] != s[i + s.size()/2])
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int a[100005], b[100005];
int asc(const void* x, const void* y)
{
	if (b[*(int*)x] > b[*(int*)y])return 1;
	if (b[*(int*)x] < b[*(int*)y])return -1;
	if (a[*(int*)x] > a[*(int*)y])return 1;
	if (a[*(int*)x] < a[*(int*)y])return -1;
	return 0;
}
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i;
	for (i = 0; i < m; i++)
		scanf("%d %d", &a[i], &b[i]);
	int c[100005];
	for (i = 0; i < m; i++)
		c[i] = i;
	qsort(c, m, sizeof(int), asc);
	int ans = 0;
	int p = -1;
	for (i = 0; i < m; i++)
	{
		if (a[c[i]] >= p)
		{
			ans++;
			p = b[c[i]];
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  std::vector<int> p(n);
  rep(i, n) std::cin >> p[i];

  int num = 0;
  rep(i, n) {
    if (i + 1 == p[i]) {
      int tmp = p[i + 1];
      p[i + 1] = p[i];
      p[i] = tmp;
      num++;
    }
  }

  std::cout << num << std::endl;
  return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
using vi=vector<int>;  using vs=vector<string>; using gi=greater<int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())



int main(){
    int N; cin>>N;
    int cakes=4,donuts=7;
    bool can=false;
    rep(i,26){
        rep(j,16){
            int total=cakes*i+donuts*j;
            if(total==N){
                can=true;
                break;
            } 
        }
    }
    if(can) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
a, b, c, k = list(map(int ,input().split()))

total = 0
plus_num = 0
per_num = 0
minus_num = 0

if a < k:
  plus_num = a
  k -= a
else:
  plus_num = k
  k = 0

if b < k:
  per_num = b
  k -= b
else:
  per_num = k
  k = 0

if c < k:
  minus_num = c
  k -= c
else:
  minus_num = k
  k = 0

# print(plus_num, per_num, minus_num)

total = plus_num - minus_num
    
print(total)



Measured memory_bytes: 9176
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
#include<iomanip>
#include<bitset>
#define mod 1000000007
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mad(a,b) a=(a+b)%mod
#define mul(a,b) a=a*b%mod
#define N 600010
ll fac[N],ivf[N],inv[N];
ll C(ll n,ll k){
    if(n<k)return 0;
    if(k<0)return 0;
    return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
ll P(ll n,ll k){
    if(n<k)return 0;
    if(k<0)return 0;
    return fac[n]*ivf[n-k]%mod;
}
ll H(ll n,ll k){
    return C(n+k-1,k);
}

ll beta(ll n,ll m,ll rem,ll upl){
    if(upl==-1){
	return 0;
    }
    ll ans=0;
    for(ll k=0;k*(upl+1)<=rem;k++){
	ll cur=C(n,m)*C(n-m,k)%mod;
	mul(cur,H(n+1,rem-k*(upl+1)));
	if(k%2==0)mad(ans,cur);
	if(k%2==1)mad(ans,-cur);
    }
    //cout<<"#"<<n<<" "<<m<<" "<<rem<<" "<<upl<<" "<<ans<<endl;
    return ans;
}
ll alpha(ll n,ll m,ll sum){//cout<<"---"<<n<<" "<<m<<" "<<sum<<endl;
    ll ans=H(n+1,sum); //cout<<"ans:"<<ans<<endl;
    for(ll x=0;;x++){
	ll rem=sum-(x+1)*m; if(rem<0)break;
	ll cur=beta(n,m,rem,x);
	mad(cur,-beta(n,m,rem,x-1));
	//cout<<x<<" "<<cur<<endl;
	mad(ans,-cur);
    }//cout<<ans<<endl;
    return ans;
}
int main(){
    fac[0]=ivf[0]=inv[1]=1;
    for(int i=1;i<N;i++){
	if(i>1)inv[i]=(mod-(mod/i*inv[mod%i]%mod))%mod;
	fac[i]=fac[i-1]*i%mod;
	ivf[i]=ivf[i-1]*inv[i]%mod;
    }
    
    ll n,m,l,r;
    cin>>n>>m>>l>>r;
    ll ans=alpha(n,m,r)-alpha(n,m,l-1);
    ans%=mod;
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
}




Measured memory_bytes: 14336
#include <iostream>
#include <string>
#define ll long long
using namespace std;

int main()
{
	int a;
	cin >> a;
	string s;
	cin >> s;

	if (3200 <= a) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
	return 0;
}

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

struct mat{
	long long m[55][55];
}init,iden;
long long n;
const long long mod=1e9+7;

mat matmul(mat a,mat b){
	mat c=init;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				c.m[i][j]+=((a.m[i][k]%mod)*(b.m[k][j]%mod));
				c.m[i][j]%=mod;
			}
		}
	}
	return c;
}

mat matpow(mat a,long long pangkat){
	if(pangkat==0) return iden;
	if(pangkat==1) return a;
	
	mat ret=matpow(a,pangkat/2);
	if(pangkat%2==0){
		return matmul(ret,ret);
	}
	else{
		return matmul(a,matmul(ret,ret));
	}
}

int main(){
	for(int i=0;i<55;i++){
		for(int j=0;j<55;j++){
			if(i==j) iden.m[i][j]=1;
			else iden.m[i][j]=0;
			init.m[i][j]=0;
		}
	}
	
	long long k;
	scanf("%lld%lld",&n,&k);
	mat base;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			scanf("%lld",&base.m[i][j]);
		}
	}
	
	long long answ=0;
	mat ans = matpow(base,k);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			answ+=ans.m[i][j];
			answ%=mod;
		}
	}
	printf("%lld\n",answ);
}

Measured memory_bytes: 10240
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int n; cin>>n;

    if(n == 1){
        cout << 1 << endl << 0 << endl;
    }
    else if(n == 2){
        cout << 2 << endl << 0 << endl << 11 << endl;
    }
    else{
        cout << n - 1 << endl;
        for(int i=0; i<n-1; i++){
            cout << 1;
            for(int j=0; j<i; j++) cout << 0;
            cout << 1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3212
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <numeric>
#define ll long  long
using namespace std;

int A[111111];
ll cumul[111111];

ll Solve(int N){
    if (N == 0) {
        if (A[0]!=1)
            return -1;
        return 1;
    }
    
    
    if (A[0]>0)return -1;
    
    cumul[0]=0;
    for(int i=1;i<=N;i++)
        cumul[i]=cumul[i-1]+A[i];
    
    
    ll nv =  1;
    ll ans = 1;

    for(int i=1;i<=N;i++) {
        
        // anywhere from nv to 2*nv
        
        // if x verts
        // x-A[i]-..A[N-1] <= A[N]
        
        // x <= cumul[N]-cumul[i-1]
        
        ll x = min(cumul[N]-cumul[i-1], 2*nv);
        
        if (x < nv) return -1;

        ans += x;
        
        nv = x-A[i];
        
        if (nv < 0) return -1;
        
        
    }
    
    if (nv  !=  0)
        return -1;
    
    
    return ans;
}

int main(){

    int N;
    cin>>N;
    for(int i=0;i<=N;i++)
        cin>>A[i];
    cout << Solve(N) <<endl;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int x, y, z;
    cin >> x >> y >> z;

    cout << ((x-z) / (y+z)) << endl;
}

int main() {
    solve();

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    ll res = 0;
    ll Amin = numeric_limits<ll>::max();
    ll Ai;
    int n_minus = 0;
    for(int i=0;i<N;i++){
        cin >> Ai;
        res += abs(Ai);
        Amin = min(Amin, abs(Ai));
        if(Ai < 0) n_minus++;
    }
    if(n_minus%2==1) res -= 2 * Amin;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main(){//kが要素の最大値                                                 
  unsigned short *A,*B;
  int N,C[VMAX+1],i,j,k=0;
  scanf("%d",&N);
  A = malloc(sizeof(short)*N+1);
  B = malloc(sizeof(short)*N+1);
  for(i=1;i<=N;i++){
    scanf("%d",&A[i]);
    if(A[i]>k)
      k=A[i];//最大値求めた                                                  
  }
  for(i=0;i<=k;i++)
    C[i]=0;//初期化                                                          

  for(j=1;j<=N;j++)
    C[A[j]]=C[A[j]]+1;//A[i]の出現数を記録する                               

  for(i=1;i<=k;i++)
    C[i]=C[i]+C[i-1];//前の数を足していく                                    
  for(j=N;j>0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]=C[A[j]]-1;
  }
  for(i=1;i<=N;i++){
    printf("%d",B[i]);
    if(i==N){
      printf("\n");
      break;
    }
    printf(" ");
  }
  return 0;
}






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

#define FasterIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main(){
    FasterIO;

    int n, h, w;

    while(cin>>n>>h>>w){
        int cnt=0;

        while(n--){
            int a,b;
            cin>>a>>b;

            if(a>=h && b>=w)
                cnt++;
        }

        cout<<cnt<<endl;
    }

    return 0;
}



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

//{ SFT
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bit(n) (1LL << (n))
#define bits(n) bitset(n)
#define pcnt(x) __builitin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end());
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
#define F first
#define S second
#define cauto (const auto &)
template <class A, class B>
using pii = vector<pair<A, B>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long mod1 = 1e9 + 7;
constexpr long long mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int a,b,ab,x,y,cnt,ans=INF;
    int zo = 0;
    cin>>a>>b>>ab>>x>>y;

    for(int i=0; i<=1e5; ++i){
        cnt = i * 2*ab + max(zo,x-i)*a + max(zo,y-i) * b;
        chmin(ans,cnt);
    }

    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    char[] s = scanner.next().toCharArray();
    int min = s.length;
    for (int i = 0; i < 2; i++) {
      int cnt = 0;
      for (int j = 0; j < s.length; j++) {
        if (s[j] - '0' + Math.abs(i - j % 2) == 1) cnt++;
      }
      min = Math.min(min, cnt);
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 27768
l, r = gets.split(" ").map(&:to_i)
ans = []
mod = 2019
 
for i in l..r-1 do
  for j in i+1..r do
    if i % mod == 0 or j % mod == 0
      puts "0"
      exit
    end
    ans << (i * j) % mod
  end
end
puts ans.min


Measured memory_bytes: 18684
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  std::vector<int> mozi(26,0);
  string S;
  std::cin >> S;
  for (size_t i = 0; i < S.size(); i++) {
    ++mozi[S[i]-97];
  }
  for (size_t i = 0; i < 26; i++) {
    if(mozi[i]%2!=0){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a, b, c, d;
    d = 0;

    cin >> a >> b >> c;

    if ( a == 7 && b == 5 && c == 5 )
	d = 1;
    else
	if ( a == 5 && b == 7 && c == 5 )
	d = 1;
        else
           if ( a == 5 && b == 5 && c == 7 )
	   d = 1; 
           else
            d = 0;

      if (d == 1) 
       cout << "YES" << endl;
      else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


 int main(){
int a,b;scanf("%d%d",&a,&b);
double ret=0;
for(int i=1;i<=a;i++){
double tmp=1.0/a;
int now=i;
while(now<b){
now*=2;
tmp/=2;
}
ret+=tmp;
}
printf("%.12f\n",ret);
}


Measured memory_bytes: 3804
#include<iostream>

int main() {
	long long n, a, b, c;
	std::cin >> n;
	for(a = 1; a <= 3500; a ++) {
		for(b = 1; b <= 3500; b ++) {
			if((4*a*b - n*b - n*a) != 0 and n*a*b % (4*a*b - n*b - n*a) == 0) {
				c = n*a*b / (4*a*b - n*b - n*a);
				if (c > 0) {
					std::cout << a << " " << b << " " << c << "\n";
					return 0;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
char s[500005];
void init(){
    scanf("%s", s);
}
void solve(){
    int n = strlen(s);
    ll ans = 1;
    int lst = 1;
    int len = 1, st = 1;
    for (int i = 0; i < n; ++i){
        if (s[i] == '<'){
            ans += lst + 1, ++lst;
            ans += (1ll * len * (len - 1) >> 1ll) + max(len - st, 0);
            len = 1, st = lst;
        }else {
            lst = 1, ++len;
        }
    }
    ans += (1ll * len * (len - 1) >> 1ll) + max(len - st, 0);
    printf("%lld\n", ans - n - 1);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 768
n = int(input())
a = list(map(int, input().split()))

l = len(a)
s = sorted(set(a))
if l % 2 == 0:
    if s == list(range(1, max(s)+1, 2)) and a.count(0) == 0:
        print(2 ** len(s) % (10 ** 9 + 7))
    else:
        print(0)
else:
    s = sorted(set(a))
    if s == list(range(0, max(s)+1, 2)) and a.count(0) == 1:
        print(2 ** (len(s)-1) % (10 ** 9 + 7))
    else:
        print(0)


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

int main() {
  long long n, t;
  std::cin >> n >> t;
  long long timings[n], intervals[n - 1];
  for (long long i = 0; i < n; i++) {
    std::cin >> timings[i];
    if (i > 0) {
      intervals[i - 1] = timings[i] - timings[i - 1];
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n - 1; i++) {
    ans += std::min(intervals[i], t);
  }
  ans += t;
  std::cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3328
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
from bisect import *
scores = []
last = [-1]*26
score = 0
points = [0]*26
dates = [[-1] for _ in range(26)]
T = [int(input())-1 for _ in range(D)]
for d in range(D):
    dates[T[d]].append(d)
    score += S[d][T[d]]
    last[T[d]] = d
    for j in range(26):
        score -= C[j]*(d-last[j])
for i in range(26):
  dates[i].append(D)
M = int(input())
for _ in range(M):
  d,after = map(int, input().split())
  d -= 1
  after -= 1
  before = T[d]
  T[d] = after
  insort_right(dates[after],d)
  score += S[d][after]-S[d][before]
  ind_bef = bisect_right(dates[before],d)-1
  score -= C[before]*(dates[before][ind_bef]-dates[before][ind_bef-1])*(dates[before][ind_bef+1]-dates[before][ind_bef])
  ind_aft = bisect_right(dates[after],d)-1
  score += C[after]*(dates[after][ind_aft]-dates[after][ind_aft-1])*(dates[after][ind_aft+1]-dates[after][ind_aft])
  dates[before].pop(ind_bef)
  scores.append(score)
print(*scores, sep='\n')

Measured memory_bytes: 15048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
int main(){
    int n,p;cin >> n >> p;
    string s;cin >> s;
    if(10%p==0){
        ll ans=0;
        for(int i=0;i<n;i++){
            int val=s[i]-'0';
            if(val%p==0) ans+=i+1;
        }
        cout << ans << endl;
        return 0;
    }
    ll ans=0;
    map<ll,ll> mp;
    ll now=0;
    mp[now]++;
    ll digit=1;
    for(int i=n-1;i>=0;i--){
        now+=digit*(s[i]-'0');
        now%=p;
        ans+=mp[now];
        mp[now]++;
        digit*=10;digit%=p;
    }
    cout << ans << endl;
    return 0;
}

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

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

    for (int i = 1; i <= B; i++) {
        if ((i * A) % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
}

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

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

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

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


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


int main(){
  int n;
  cin >> n;
  VI flagD(n,0);
  vector<PLL> A(n),B(n);
  VLL Ainput(n);
  VLL Binput(n);

  rep(i,n){
    ll a,b;
    cin >> a >> b;
    A[i] = make_pair(a+b,i);
    B[i] = make_pair(b+a,i);
    Ainput[i] = a;
    Binput[i] = b;
  }

  sort(B.rbegin(),B.rend());
  sort(A.rbegin(),A.rend());
  int indexA = 0,indexB = 0;
  rep(i,n){
    if(i % 2 == 0){//a
      while(true){
        if(flagD[A[indexA].second] == 0){
          flagD[A[indexA].second] = 1;
          indexA++;
          break;
        }
        indexA++;
      }
    }else{//b
      while(true){
        if(flagD[B[indexB].second] == 0){
          flagD[B[indexB].second] = 2;
          indexB++;
          break;
        }
        indexB++;

      }
    }
    //rep(i,n) cout << flagD[i] << " ";
    //cout << endl;
  }
  ll ans = 0;
  rep(i,n){
    if(flagD[i] == 1) ans += Ainput[i];
    else ans -= Binput[i];
  }
  cout << ans  << endl;
  return 0;
}


Measured memory_bytes: 5376
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>

using namespace std;
int main() {
   int a,b,c;

   cin>>a>>b>>c;

   if(a*b>c){

       cout<<c<<endl;
   }
   else{

       cout<<a*b<<endl;
   }

}


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

int N, M, a[100], b[100];
bool IsAlreadyWalk[100][100];
bool IsAlreadyReach[100];
int ans;

int f(int pos, int cou)
{
	int res = 0;
	if (cou == N)
	{
		return 1;
	}
	for (int i = 0; i < M; ++i)
	{
		if (a[i] == pos)
		{
			if (IsAlreadyWalk[a[i]][b[i]] == false
				&& IsAlreadyReach[b[i]] == false)
			{
				IsAlreadyWalk[a[i]][b[i]] = true;
				IsAlreadyReach[b[i]] = true;
				res += f(b[i], cou + 1);
				IsAlreadyWalk[a[i]][b[i]] = false;
				IsAlreadyReach[b[i]] = false;
			}
		}
		if (b[i] == pos)
		{
			if (IsAlreadyWalk[a[i]][b[i]] == false
				&& IsAlreadyReach[a[i]] == false)
			{
				IsAlreadyWalk[a[i]][b[i]] = true;
				IsAlreadyReach[a[i]] = true;
				res += f(a[i], cou + 1);
				IsAlreadyWalk[a[i]][b[i]] = false;
				IsAlreadyReach[a[i]] = false;
			}
		}
	}
	return res;
}

int main(void)
{
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; ++i) { scanf("%d%d", &a[i], &b[i]); }

	memset(IsAlreadyWalk, false, sizeof(IsAlreadyWalk));
	memset(IsAlreadyReach, false, sizeof(IsAlreadyReach));
	IsAlreadyReach[1] = true;

	printf("%d\n", f(1, 1));
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int area(int d){
    int s, x;
    s=0;
    x=d;
    while(x<600){
        s+=d*x*x;
        x+=d;
    }
    return s;
}

int main(void){
    int d;
    while(scanf("%d", &d)!=EOF) {
        printf("%d\n", area(d));
    }
    return 0;
}


Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,k,l,i=0;
    cin>>n>>m>>k;
    l=k;
    do{
        l+=m+k; 
        i++;
    }
    while(l<n);
    if(l>n) i--;
    cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

d = []
A = []
for i in range(K):
    d_ = int(input())
    A_ = list(map(int, input().split()))
    d.append(d_)
    A.append(A_)

import numpy as np

S = np.zeros(N)
for i in A:
    for j in i:
        S[j-1] += 1
    
count = 0
for i in S:
    if i == 0:
        count += 1
    
print(count)

Measured memory_bytes: 27156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	int n;
	scanf("%i",&n);
	vector<int>  a(n),b(n),c(n);
	ll sum=0;
	for(int i=0;i<n;i++) scanf("%i",&a[i]),sum+=a[i];
	for(int i=0;i<n;i++) scanf("%i",&b[i]),sum-=b[i];
	if(sum<0) return 0*printf("-1\n");
	vector<int> work;
	ll need=0;
	int ans=0;
	for(int i=0;i<n;i++) if(b[i]>a[i]) need+=b[i]-a[i],ans++;
	for(int i=0;i<n;i++) if(b[i]<a[i]) work.pb(a[i]-b[i]);
	sort(work.begin(),work.end());
	while(work.size() && need>0)
	{
		need-=work.back();
		work.pop_back();
		ans++;
	}
	printf("%i\n",ans);
	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>

int main() {
  int N, ans = 0;
  scanf("%d", &N);
  int L[N * 2];
  for (int i = 0; i < N * 2; i++) {
    scanf("%d", &L[i]);
  }
  std::sort(L, L + N * 2);
  for (int i = 0; i < N * 2; i++) {
    if (!(i % 2)) ans += L[i];
  }
  printf("%d\n", ans);
  return 0;
}


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

void Main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  map<int, int> c;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
    c[a[i]]++;
  }

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

  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j >= 0; j--) {
      if (b[j] != a[i] || c[b[j]] > 1) {
        cout << b[j] << endl;
        break;
      }
    }
  }
}

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


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

int main () {
    while (true) {
        string mountain;
        cin >> mountain;
        if ( mountain == "-" ) break;

        int n;
        cin >> n;
        for (int i=0; i<n; i++) {
            int h;
            cin >> h;
            string head = mountain.substr(0, h);
            mountain.erase(0, h);
            mountain += head;
        }
        cout << mountain << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
// https://atcoder.jp/contests/abc136/tasks/abc136_d

#include <cstdio>
#include <cstring>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int S_MAX = 100000;

char S[S_MAX + 2];

int N;
int A[S_MAX + 1];

void solve() {
  N = strlen(S);
  strcat(S, "R");
  int len, h;
  int prv = -1;
  REP(i, N) {
    if (S[i] == 'R' && S[i + 1] == 'L') {
      len = i - prv;
      h = len / 2;
      A[i + 1] += h;
      A[i] += len - h;
      prv = i;
    } else if (S[i] == 'L' && S[i + 1] == 'R') {
      len = i - prv;
      h = len / 2;
      A[prv] += h;
      A[prv + 1] += len - h;
      prv = i;
    }
    // DUMP(A, N);
  }
  REP(i, N) printf("%d%c", A[i], i + 1 == N ? '\n' : ' ');
}

void input() {
  scanf("%s", S);
}

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


Measured memory_bytes: 896
#include<stdio.h>

int main()
{
    int x1, y1, x2, y2, dy, dx, x3, y3, x4, y4;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    dy = y2 - y1;
    dx = x2 - x1;
    x3 = x2 - dy;
    x4 = x1 - dy;
    y3 = y2 + dx;
    y4 = y1 + dx;
    printf("%d %d %d %d\n", x3, y3, x4, y4);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  ll n;
  string s;
  cin >> n >> s;
  if (n >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
}

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


int main(){
  string s;
  cin>>s;
  vector<char> c;
  c.push_back('Z');
  int count=0;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='Z' && c[c.size()-1]=='A'){c.push_back('Z'); continue;}
    if(s[i]=='A' && c[c.size()-1]=='Z'){c.push_back('A'); continue;}
    count++;
  }
  if(c[c.size()-1]=='A'){count++; c.erase(--c.end());}

  if(c.size()==1){cout<<-1<<endl;}
  else{
    for(int i=1;i<(int)c.size();i++){
      cout<<c[i];
    }
    cout<<endl;
  }






  return 0;
}



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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }


int main(void){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);

    char alp;
    cin >> alp;

    if(65 <= alp && alp <= 90){
    	cout << "A";
    } else {
    	cout << "a";
    }

    return 0;
}


Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    public static class Tree {

        List<Edge>[] vertEdges;
        int numNodes;

        @SuppressWarnings("unchecked")
        public Tree(int n) {
            numNodes = n;
            vertEdges = new ArrayList[n];
            for (int i = 0; i < n; i++) {
                vertEdges[i] = new ArrayList<Edge>();
            }
        }

        class Edge {

            int v1;
            int v2;
            int weight;

            public Edge(int v1, int v2, int weight) {
                this.v1 = v1;
                this.v2 = v2;
                this.weight = weight;
            }

            public int otherVertex(int v) {
                return v1 == v ? v2 : v1;
            }

            public boolean equals(Object o) {
                if (o instanceof Edge) {
                    Edge edge = (Edge) o;
                    return ((v1 == edge.v1 && v2 == edge.v2) || (v1 == edge.v2 && v2 == edge.v1));
                }
                return false;
            }

        }

        public void addEdge(int n1, int n2, int weight) {
            Edge e = new Edge(n1, n2, weight);
            vertEdges[n1].add(e);
            vertEdges[n2].add(e);
        }

        public int diameter() {
            int vertRandom = 0;
            BFSNode node = bfsFarthest(vertRandom);
            node = bfsFarthest(node.vert);
            return node.distance;
        }

        private BFSNode bfsFarthest(int vert) {
            Queue<BFSNode> queue = new LinkedList<BFSNode>();
            queue.add(new BFSNode(vert, -1, 0));
            BFSNode fathest = new BFSNode(0, 0, 0);
            while (!queue.isEmpty()) {
                BFSNode node = queue.remove();
                if (node.distance > fathest.distance) {
                    fathest = node;
                }
                for (Edge e : vertEdges[node.vert]) {
                    int vertOther = e.otherVertex(node.vert);
                    if (vertOther != node.fromVert) {
                        queue.add(new BFSNode(vertOther, node.vert, node.distance + e.weight));
                    }
                }
            }
            return fathest;
        }

        class BFSNode {

            private int vert;
            private int fromVert;
            private int distance;

            public BFSNode(int vert, int fromVert, int distance) {
                this.vert = vert;
                this.fromVert = fromVert;
                this.distance = distance;
            }
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Tree tree = new Tree(n);
        for (int i = 0; i < n - 1; i++) {
            int s = scanner.nextInt();
            int t = scanner.nextInt();
            int weight = scanner.nextInt();
            tree.addEdge(s, t, weight);
        }
        System.out.println(tree.diameter());

    }
}

Measured memory_bytes: 122500
#include<stdio.h>
int main(){
  int n,m,d[30010]={0};
  int p[30010],a,b,t,i,j,max;
  scanf("%d %d",&n,&m);
  for(i=0;i<30010;i++)p[i]=100000000;
  for(i=0;i<n;i++){
    scanf("%d",&d[i]);
    for(j=i;j;j--){
      if(d[j]>d[j-1]){
	t=d[j-1];
	d[j-1]=d[j];
	d[j]=t;
      }
    }
  }
  for(i=p[0]=0;i<m;i++){
    scanf("%d %d",&a,&b);
    for(j=30005;j>=a;j--){
      if(p[j]>p[j-a]+b)p[j]=p[j-a]+b;
    }
  }
  for(i=max=a=0;i<=30005;i++){//printf("%d ",p[i+1]);
    a+=d[i];//printf("%d\n",a);
    if(max<a-p[i+1])max=a-p[i+1];
  }
  printf("%d\n",max);
  return 0;
}
	    

Measured memory_bytes: 840
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		StringBuffer bf  = new StringBuffer();
		String a=sc.next();
		String b=sc.next();
		String c=sc.next();

		bf.append(a.charAt(0));
		bf.append(b.charAt(1));
		bf.append(c.charAt(2));

		System.out.println(bf);

	}
}

Measured memory_bytes: 23636
N = int(input())
S = input()

count = 0
flag = False

for index, s in enumerate(S):
  if s == '(':
    flag = True
    count += 1

  if flag and s == ')' and count != 0:
    count -= 1

  if not flag:
    continue

if count > 0:
  S += ')' * count

count = 0
flag = False

for index, s in enumerate(S[::-1]):
  if s == ')':
    flag = True
    count += 1

  if flag and s == '(' and count != 0:
    count -= 1

  if not flag:
    continue

if count > 0:
  S = '(' * count + S

print(S)

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

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000
#define MOD 1000000007

int main() {
    int n;
    int a;
    cin >> n;
    llint ans = 0;
    int ma = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (ma < a) ma = a;
        else ans += (ma - a);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <list>
#include <numeric>
#include <bitset>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;
const size_t MAX_K = 5000;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

using Vb = bitset<MAX_K>;
using Mb = vector<Vb>;

bool isNotNeed(int n, int k, V& as, int i){
    int a = as[i];
    if(a >= k){
	return false;
    }

    Vb dp;
    dp[0] = true;

    for(int x = 1; x < n + 1; x++){
	int b = as[x - 1];
	if(b >= k){
	    break;
	}
	if(x - 1 == i){
	    continue;
	}
	for(int y = k - 1; y >= b; y--){
	    if(dp[y - b]){
		dp[y] = true;
	    }
	}
    }

    for(int y = max(k - a, 0); y < k; y++){
    	if(dp[y]){
	    return false;
	}
    }
    return true;
}

int solve(int n, int k, V& as){
    sort(begin(as), end(as));
    int l = 0, u = n;
    while(l != u){
	int c = (l + u) / 2;
	if(isNotNeed(n, k, as, c)){
	    l = c + 1;
	}else{
	    u = c;
	}
    }
    return l;
}

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

    int n, k;
    cin >> n >> k;
    V as(n);
    for(int i = 0; i < n; i++){
        cin >> as[i];
    }
    cout << solve(n, k, as) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, M;
    cin >> N >> M;
    vector<int>a(M*2);
    for(int i = 0; i < M*2; i++) {
        cin >> a.at(i);
    }
    
    for(int i = 1; i <= N; i++) {
        int count = 0;
        for(int j = 0; j < M*2; j++) {
            if(a.at(j) == i) {
                count++;
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
    int main() {
        int K,N;
        cin >> K >> N;
        vector<int> A(N);
        for (int i=0;i<N;i++){
            cin >> A.at(i);
        }
        vector<int> B(N-1);
        for (int i=0;i<N-1;i++){
            B.at(i) = A.at(i+1)-A.at(i);
        }
        sort(B.begin(),B.end());
        reverse(B.begin(),B.end());
        if(B.at(0)>(A.at(0)+K)-A.at(N-1))
        cout << K-B.at(0) << endl;
        else cout << K-((A.at(0)+K)-A.at(N-1)) << endl;
    }
  

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    ll sum=0;
    rep(i,n) sum+= a[i];
    ll bord = sum/4/m;//out
    if(bord * 4 * m == sum) bord--;
    rep(i,m) {
      if(a[i]<=bord) {
        cout << "No" << endl;
        return 0;
      }
    }
  cout << "Yes" << endl;
  return 0;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int m = a[0];
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(a[i] >= m){
            cnt++;
            m = a[i];
        }
    }
    cout << cnt;
}

Measured memory_bytes: 256
# AtCoder
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
m1 = Y[N//2]
m2 = Y[N//2-1]

for i in range(N):
    if m1 > X[i]:
        print(m1)  # left
    else:
        print(m2)  # right


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


int main()
{
/*	int xmax = 10000;     //1回目　×
	int x[10000];
	int xi;
	for (int i = 0; i < xmax; i++){
		cin >> x[i];

		if (x[i] == 0){
			xi = i;
			i = xmax;
		}
	}

	for (int j = 0; j < xi; j++){
		cout << "Case " << j + 1 << ": " << x[j] << endl;
	}
*/

	int i = 1, x;
	cin >> x;

	while (x != 0){
		cout << "Case " << i << ": " << x << endl;
		i++;
		cin >> x;
	}

	
	return 0;
}


Measured memory_bytes: 3012
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 9999999999999999


int main(){

	ll M,r_D,r_R,c_D,c_R,rest_D,rest_R;

	scanf("%lld %lld %lld %lld %lld",&M,&r_D,&r_R,&c_D,&c_R);

	ll left,right,m;

	ll ans,tmp;

	left = 0,right = M;m = (left+right);
	ans = NUM;

	while(left <= right){

		tmp = (r_D*m)/100;

		if(tmp >= c_D){
			ans = m;
			rest_D = c_D-tmp;
			right = m-1;
		}else{
			left = m+1;
		}
		m = (left+right)/2;
	}

	if(ans == NUM){
		printf("-1\n");
		return 0;
	}

	M -= ans;

	left = 0,right = M;m = (left+right);
	ans = NUM;

	while(left <= right){

		tmp = (r_R*m)/100;

		if(tmp >= c_R){
			ans = m;
			rest_R = c_R-tmp;
			right = m-1;
		}else{
			left = m+1;
		}
		m = (left+right)/2;
	}

	if(ans == NUM){
		printf("-1\n");
		return 0;
	}

	M -= ans;

	M += (rest_D*100)/r_D+(rest_R*100)/r_R;

	printf("%lld\n",M);

	return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  X -= Z;
  Y += Z;
  cout << X / Y << endl;
  return 0;
}


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

vector<int> to[200010];

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> pre(n);
  vector<int> dist(n, INF);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  queue<int> que;
  dist[0] = 0;
  que.push(0);
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int m : to[v]) {
      if (dist[m] != INF) continue;
      que.push(m);
      pre[m] = v;
      dist[m] = dist[v] + 1;
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < n; i++) {
    cout << pre[i] + 1 << endl;
  }
}

Measured memory_bytes: 12880
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll H,W;
    cin>>H>>W;
    
    
    char maze[55][55];
    ll white=0;
    
    rep(i,H){
        rep(j,W){
            cin>>maze[i+1][j+1];
            if(maze[i+1][j+1]=='.') white++;
        }
    }
    rep(i,H+1){
        maze[i][0]='#';
        maze[i][W+1]='#';
    }
    rep(i,W+1){
        maze[0][i]='#';
        maze[H+1][i]='#';
    }
    
    ll dist[55][55];
    rep(i,H){
        rep(j,W){
            dist[i+1][j+1]=-1;
        }
    }
    dist[1][1]=0;
    
    queue<ll> quex;
    queue<ll> quey;
    vector<ll> xmove={0,1,0,-1};
    vector<ll> ymove={1,0,-1,0};
    quex.push(1);
    quey.push(1);
    
    while(!quex.empty()){
        ll x=quex.front();
        ll y=quey.front();
        rep(i,4){
            if(maze[x+xmove.at(i)][y+ymove.at(i)]=='.' && dist[x+xmove.at(i)][y+ymove.at(i)]==-1){
                quex.push(x+xmove.at(i));
                quey.push(y+ymove.at(i));
                dist[x+xmove.at(i)][y+ymove.at(i)]=dist[x][y]+1;
            }
        }
        quex.pop();
        quey.pop();
        if(dist[H][W]!=-1){
            cout<<white-dist[H][W]-1<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    a_ind = bisect.bisect_left(A, b)
    c_ind = bisect.bisect_right(C, b)
    ans += a_ind*(n-c_ind)
    
print(ans)

Measured memory_bytes: 29196