akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<set>
using namespace std;

int main()
{
    int n, q, x, y;

    set<int> a;

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        cin >> q >> x;
        if( q == 0 )
        {
            a.insert(x);
            cout << a.size() << endl;
        }
        else if( q == 1 )
            cout << a.count(x) << endl;                 //countという、指定された値の個数を返す関数もある。setは重複を許さないので0 or 1が返る。
        else if( q == 2 )
            a.erase(x);
        else
        {
            cin >> y;

            if( a.size() != 0 )
            {
                set<int>::iterator itr1 = a.end(), itr2 = a.end();
                while( itr1 == a.end() && x <= y )
                {
                    itr1 = a.find(x);
                    x++;
                }

                if( itr1 != a.end() )
                {
                    while( itr2 == a.end() )
                    {
                        itr2 = a.find(y);
                        y--;
                    }
                    itr2++;
                    for(; itr1 != itr2; itr1++ )
                        cout << *itr1 << endl;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 12444
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nx = readints;
    int n = nx[0], x = nx[1];
    int[] ms;
    for (int i = 0; i < n; i++) ms ~= readint;

    int min = ms.reduce!((a, b) => min(a, b));
    int ans = n + (x - ms.sum) / min;
    writeln(ans);
}


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

typedef struct _params params;
typedef uint Result;

struct _params {
    uint p,q,a,n;
}input;


// initialization
Result init(params* out){
    // p/q a n
    scanf("%u %u %u %u",&out->p,&out->q,&out->a,&out->n);

    if(out->n==0)
        return 0;

    return 1;
}





uint calc_all_sols(uint product,uint sum,uint start,uint recursion_level){
    uint ret=0;

    if(recursion_level>input.n)
        return 0;

    if (product*input.p==sum*input.q)
        return 1;

    if (product*input.p<sum*input.q)
        return 0;

    for(uint i=start;i*product<=input.a;i++)
        ret+=calc_all_sols(i*product,(sum*i)+product,i,recursion_level+1);

    return ret;
}


int main() {

    while(init(&input))
        printf("%u\n",calc_all_sols(1,0,0,0));

    return 0;
}


Measured memory_bytes: 1992
#include<stdio.h>
int main()
{
    int a,b;
  scanf("%d %d",&a,&b);
  if(a==1 && b==2)
       {
           printf("3");
        }
  else if(a==2 && b==1)
       {
           printf("3");
        }
 else if(a==2 && b==3)
       {
           printf("1");
        }
 else if(a==3 && b==2)
       {
           printf("1");
        }
 else if(a==3 && b==1)
       {
           printf("2");
        }
 else if(a==1 && b==3)
       {
           printf("2");
        }

return 0;
}

Measured memory_bytes: 128
def search
  n = gets.chomp.to_i
  values = gets.chomp.split(/\s/).map(&:to_i)
  costs = gets.chomp.split(/\s/).map(&:to_i)
  ans = 0
  n.times do |time|
    ans += values[time] - costs[time] if values[time] > costs[time]
  end
  puts ans
end
search


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

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

    int H,W; cin >> H >> W;
    ve_vec board(H, vec(W));

    int cnt = 0;
    rep(i,H) rep(j,W) {
        cin >> board[i][j];
        if(board[i][j] == '#') cnt++;
    }
    if(cnt == H+W-1) {cout << "Possible" << endl; return 0;}
    else {cout << "Impossible" << endl; return 0;}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int a, b;
	cin >> a >> b;
	if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 ==0){
			cout << "Possible" << endl;
	}else{
			cout << "Impossible" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define endl '\n'
#define all(x) x.begin(), x.end()
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    
    for(int i = 1; i <= 3; i++){
        if((a * b * i) & 1){
          cout << "Yes";
          return 0;
         }
    }
    
    cout <<"No";
    return 0;
}

Measured memory_bytes: 3628
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(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); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class CMaximumVolume {
public:
	void solve(std::istream& in, std::ostream& out) {
        ld l;
	    in >> l;
	    double res = l*l*l / 27.0;

	    out << fixed << setprecision(10) << res << endl;
	}
};


int main() {
	CMaximumVolume solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
n,a,b,c,t;
main(){
    for(scanf("%d",&n);n--;t=0){
        scanf("%d%d%d",&a,&b,&c);
        t+=a*=a;t+=b*=b;t+=c*=c;
      puts(t-2*a&&t-2*b&&t-2*c?"NO":"YES");
    }
}

Measured memory_bytes: 1860
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int n,x,N;
	scanf("%d",&N);
	x=sqrt(N);
	n=x*x;
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <limits>

constexpr int MAXN = 100;
int G[MAXN][MAXN];
int P[MAXN];
int D[MAXN];
int C[MAXN];

int main(){
    int n;
    std::cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            std::cin >> G[i][j];
            if (G[i][j] == -1) {
                G[i][j] = std::numeric_limits<int>::max();
            }
        }
    }

    for (int i = 0; i < n; i++) {
        D[i] = std::numeric_limits<int>::max();
    }

    D[0] = 0;
    P[0] = -1;
    while (true) {
        int m;
        int mincost = std::numeric_limits<int>::max();
        for (int i = 0; i < n; i++) {
            if ((C[i] == 0) && (D[i] < mincost)) {
                mincost = D[i];
                m = i;
            }
        }

        if (mincost == std::numeric_limits<int>::max()) {
            break;
        }

        C[m] = 1;
        D[m] = mincost;

        for (int i = 0; i < n; i++) {
            if ((G[m][i] < std::numeric_limits<int>::max()) && (C[i] == 0) && (G[m][i] < D[i])) {
                D[i] = G[m][i];
            }
        }
    }


    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (D[i] != std::numeric_limits<int>::max()) {
            sum += D[i];
        }
    }
//    for (int i = 0; i < n; i++) {
//        std::cout << i << ": " << D[i] << std::endl;
//    }
    std::cout << sum << std::endl;

}


Measured memory_bytes: 3148
_,*s=open(0);t=".";b=t*101;q=range(101);i=0
for s in s:
 a=[i];i+=1
 for x,y,z,c in zip(b,t+s,s,q):a+=min(c+(t==x>z),a[-1]+(t==y>z)),
 b,q=s,a[1:]
print(a[-2])

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+18
#define MOD 1000000007
using namespace std;



int main(){
    int N,A,B;
    cin >> N >> A >> B;
    cout<<min(A,B)<<" ";
    
    if(A+B<=N){
        cout<<0<<endl;
    }else{
        cout<<A+B-N<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    
    cin >> s;
    
    for(int i = 0; i < s.size()-1; i++){
        if(s[i] == 'A' && s[i+1] == 'C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a[3];
  int i,k;
  int tmp;
  scanf("%d%d%d",&a[0],&a[1],&a[2]);

  for(i=0;i<3;i++){
    for(k=i+1;k<3;k++){
      if(a[i]>a[k]){
        tmp=a[i];
        a[i]=a[k];
        a[k]=tmp;
      }
    }
  }

  a[2]*=10;
  printf("%d",a[0]+a[1]+a[2]);

  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    bool ck=0;
    
    cin>>N;
    rep(i,N){
        int x;cin>>x;
        if(x%2) ck^=1;
    }
    cout1((ck?"NO":"YES"))
}

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

int main() {
    long long N, D; cin >> N >> D;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        long long X, Y;
        cin >> X >> Y;
        long long dst = X*X + Y * Y;
        if (abs(dst) <= D*D) cnt++;
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

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

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

ll n,m,v,p;
vl a;
vl s;

bool check(int X){
  if(X <= p-1) return true;
  if(a[p-1] - a[X] > m) return false;

  // 票の受け皿の数
  ll num = n*m + (X-p+1)*a[X] - (s[X] - s[p-1]);
  return num >= m*v;
}


int main(){
  cin >> n >> m >> v >> p;
  a.resize(n);

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

  sort(all(a), greater<ll>());

  s.resize(n+1);
  rep(i,n) s[i+1] = s[i] + a[i];

  rrep(i,n) {
    if(check(i)){
      cout << i+1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import itertools

cn = []
for i in range(3):
    cn.append(list(map(int, input().split())))

sum = 0
for (a,b,c) in cn:
    sum += a+b+c

if sum % 3 != 0:
    print('No')
    exit()

c = list(itertools.combinations([0,1,2], 2))
for ((i1,i2),(j1,j2)) in itertools.product(c,c):
        sum2 = cn[i1][j1] + cn[i2][j1] + cn[i1][j2] + cn[i2][j2]
        if sum2 % 2 != 0:
            print('No')
            exit()

print('Yes')


Measured memory_bytes: 3064
def ascan; gets.split.map(&:to_i);end

loop do
    n,m = ascan
    break if n == 0 && m == 0
    
    rec = Array.new(m){[]}
    
    gets.to_i.times do
        t,i,j,s = ascan
        i -= 1; j -= 1
        rec[j] << [t,s,i]
    end
    
    # rec.each{|e| e.sort! }
    
    gets.to_i.times do
        b,e,j = ascan
        j -= 1
        ans = 0
        la = nil
        stk = 0
        rec[j].each do |t,s,i|
            t = b if t <= b
            t = e if e <= t
            if s == 1
                la = t if stk == 0
                stk += 1
            else
                stk -= 1
                ans += t - la if stk == 0
            end
        end
        p ans
    end
    
end


Measured memory_bytes: 7116
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

// ????????????????????????

#define MAX_N 15
#define INF 1e9

struct Prev {
	int n, state;
	Prev(int n, int state) : n(n), state(state) {}
	Prev() {}
};

double dp[MAX_N][1 << MAX_N]; //dp[???????????????][??????????????£??????] = ?§??????????(double)
Prev pre[MAX_N][1 << MAX_N];

struct Data {
	int n, x, w;
	Data(int n, int x, int num) : n(n), x(x) {
		w = num * 20;
	}
};

// ??????2,000???(70+w)????????????

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < (1 << MAX_N); ++j) {
			dp[i][j] = INF;
			pre[i][1 << i] = Prev(i, 0);
		}
	}

	vector<Data> data;
	for (int i = 0; i < n; ++i) {
		int n, x, num; cin >> n >> x >> num;
		data.push_back( Data(n, x, num) );
	}

	for (int i = 0; i < n; ++i) {
		double v = 2000.0 / 70;
		dp[i][1 << i] = data[i].x / v;
	}

	// ?????¢?????????
	int dist[MAX_N][MAX_N];
	for (int from = 0; from < n; ++from) {
		for (int to = 0; to < n; ++to) {
			if (from == to) dist[from][to] = 0;
			else dist[from][to] = dist[to][from] = abs(data[from].x - data[to].x);
		}
	}

	for (int t = 0; t < n; ++t) {
		for (int from = 0; from < n; ++from) {
			for (int prev = 0; prev < (1 << MAX_N); ++prev) {
				if (dp[from][prev] == INF) continue; // ???????¨??????????????????¶???

				int w = 0;
				for (int i = 0; i < n; ++i) {
					if (prev & (1 << i)) {
						w += data[i].w;
					}
				}
				double v = 2000.0/(70+w);

				for (int to = 0; to < n; ++to) {
					if (prev & (1 << to)) continue; // ??¢????¨???????

					int next = prev | (1 << to);
					if (dp[from][prev] + dist[from][to] / v < dp[to][next]) {
						dp[to][next] = dp[from][prev] + dist[from][to] / v;
						pre[to][next] = Prev( from, prev );
					}
				}
			}
		}
	}

	int aPrev = 0;
	for (int i = 0; i < n; ++i) aPrev |= 1 << i;

	double aTime = INF;
	int aid = -1;
	for (int i = 0; i < n; ++i) {
		if ( dp[i][aPrev] < aTime ) {
			aTime = dp[i][aPrev];
			aid = i;
		}
	}

	Prev now = Prev(aid, aPrev);
	vector<int> ans; ans.push_back(aid);
	while (1) {
		Prev prev = pre[now.n][now.state];

		// ????????????
		if (prev.n == now.n) break;

		ans.push_back(prev.n);
		now = prev;
	}

	reverse( ans.begin(), ans.end() );

	for (int i = 0; i < ans.size(); ++i) {
		if (i) cout << " ";
		cout << data[ans[i]].n;
	}
	cout << endl;
}

Measured memory_bytes: 8896
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


string s, t;
int dp[3010][3010];


signed main(){
    cin >> s >> t;

    rep(i, 0, SZ(s)) rep(j, 0, SZ(t)){
        if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j]+1;
        else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
    }

    string ans;
    int i = SZ(s), j = SZ(t);
    while(i > 0 and j > 0){
        if(dp[i][j] == dp[i-1][j]) i--;
        else if(dp[i][j] == dp[i][j-1]) j--;
        else ans = s[i-1]+ans, i--, j--;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  for (int i=0; i<n-2; i++) {
    if (s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C') {
      ans++;
    }
  }
   cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
 
int main()
{
    int d;
 
    while(cin >> d)
    {
        int y=0;
 
        for(int i=1; i*d<600; i++)
        {
            y += d*(d*i)*(d*i);
        }
 
       cout << y << endl;
    }
 
}

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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}

void chmax(ll &a,const ll &b){
    if(a<b) a=b;
}
void chmin(ll &a,const ll &b){
    if(a>b) a=b;
}


int main()
{

    ll N,K;
    cin >>N>>K;

    ll A[N],dp[K+1];

    rep(i,N) cin >> A[i];

    rep(i,K+1){
        dp[i]=0;
        if(i!=0){
            rep(j,N){
                if(i-A[j]>=0){
                    if(dp[i-A[j]]==0) dp[i]=1;
                }
            }
        }
    }

    if(dp[K]==0){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }




    return 0;


}

Measured memory_bytes: 4368
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

using namespace std;
long long int st[6000000];
vector<long long int> ss;
vector<long long int> es;
vector<long long int> xs;
vector<long long int> ds;
map<long long int,long long int> ms;
set<long long int> sets;

void f(int no,int p,long long int l,long long int r,long long int l2,long long int r2){
	if(r<l2){
		return ;
	}
	if(r2<l){
		return ;
	}
	if(r==l){
		if(st[p]==-1||st[p]>xs[no]){
			st[p]=xs[no];
		}
		return ;
	}else{
		if(l2<=l&&r<=r2){
			if(st[p]==-1||st[p]>xs[no]){
				st[p]=xs[no];
			}
			return ;
		}
		long long int m=(l+r)/2;
		f(no,p*2+1,l,m,l2,r2);
		f(no,p*2+2,(m+1),r,l2,r2);
	}
}
int f2(int p,long long int l,long long int r,long long int x){
	if(r<x){
		return -1;
	}
	if(x<l){
		return -1;
	}
	if(x<=l&&r<=x){
		return st[p];
	}
	if(l==r){
		return st[p];
	}else{
		
		long long int m=(l+r)/2;
		int t1=f2(p*2+1,l,m,x);
		int t2=f2(p*2+2,(m+1),r,x);
		//cout<<"("<<t1<<" "<<t2<<")"<<x<<" "<<l<<" "<<r<<"\n";
		int t3=-1;
		if(t1==-1&&t2==-1){
			t3= -1;
		}else if(t1==-1){
			t3= t2;
		}else if(t2==-1){
			t3= t1;
		}else{
			t3= min(t1,t2);
		}
		if(t3==-1){
			return st[p];
		}else if(st[p]!=-1&&t3>st[p]){
			return st[p];
		}else{
			return t3;
		}
	}
}
	
int main() {
	// your code goes here
	memset(st,-1,sizeof(st));
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n;i++){
		long long int s1,t1,x1;
		cin>>s1>>t1>>x1;
		ss.push_back(s1-x1);
		es.push_back(t1-x1-1);
		xs.push_back(x1);
		sets.insert(s1-x1);
		sets.insert(t1-x1-1);
	}
	for(int i=0;i<q;i++){
		long long int d;
		cin>>d;
		ds.push_back(d);
		sets.insert(d);
	}
	int i=0;
	long long int minX,maxX;
	for(set<long long int>::iterator it=sets.begin();it!=sets.end();it++){
		ms[(*it)]=i;
		i++;
		if(minX>(*it)||(it==sets.begin())){
			minX=(*it);
		}
		if(maxX<(*it)||(it==sets.begin())){
			maxX=(*it);
		}
	}
	
	for(int i=0;i<ss.size();i++){
		f(i,0,ms[minX],ms[maxX],ms[ss[i]],ms[es[i]]);
	}
	//cout<<"\n";
	//for(map<long long int,long long int>::iterator it=ms.begin();it!=ms.end();it++){
	//	cout<<(*it).first<<" "<<(*it).second<<"\n";
	//}
	for(int i=0;i<q;i++){
		cout<<f2(0,ms[minX],ms[maxX],ms[ds[i]])<<"\n";
	}
	return 0;
}

Measured memory_bytes: 120148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    int n;
    cin >> n;
    int x[n] = {}, y[n] = {};
    double dif[n] = {};
    double d1 = 0, d2 = 0, d3 = 0, dinf = 0;
    rep(i, 0, n) cin >> x[i];
    rep(i, 0, n) cin >> y[i];
    rep(i, 0, n) {
        dif[i] = abs(x[i] - y[i]);
        d1 += dif[i];
        d2 += dif[i] * dif[i];
        d3 += dif[i] * dif[i] * dif[i];
        dinf = max(dinf, dif[i]);
    }

    d2 = sqrt(d2);
    d3 = pow(d3, 1.0/3);

    cout << fixed << setprecision(10);
    cout << d1 << endl;
    cout << d2 << endl;
    cout << d3 << endl;
    cout << dinf << endl;

}



Measured memory_bytes: 3472
program A;
var
  s: String;
  cnt: array[0..25] of Integer;
  i: Integer;

begin
  ReadLn(s);
  for i := 1 to Length(s) do 
    Inc(cnt[Ord(s[i]) - Ord('a')]);
  for i := 0 to 25 do
    if cnt[i] mod 2 = 1 then
      begin
        WriteLn('No');
        Halt;
      end;
  WriteLn('Yes');
end.

Measured memory_bytes: 128
from collections import Counter
import sys
import math
from functools import cmp_to_key

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)


def main():
    n = int(input())
    p = [tuple(map(int, input().split())) for i in range(n)]
    a = {}
    b = {}
    c = 0
    for x, y in p:
        if x == y == 0:
            c += 1
            continue
        if y == 0:
            a[(0, 1)] = a.get((0, 1), 0) + 1
            continue
        if x == 0:
            b[(0, 1)] = b.get((0, 1), 0) + 1

        g = math.gcd(x, y)
        if x * y > 0:
            x = abs(x)
            y = abs(y)
            a[(x//g, y//g)] = a.get((x//g, y//g), 0) + 1
        else:
            x = abs(x)
            y = abs(y)
            b[(y//g, x//g)] = b.get((y//g, x//g), 0) + 1

    ans = 1
    s = 0
    for k, v in a.items():
        if k in b:
            s += v + b[k]
            ans *= pow(2, v) + pow(2, b[k]) - 1
            ans %= mod
    ans *= pow(2, n - s - c, mod)
    print((ans - 1 + c) % mod)

main()


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

typedef long long ll;
typedef int keytype;

int main(){
    ll x;

    scanf("%lld", &x);

    ll max = 0;
    max += (x / 500) * 1000;
    max += ((x % 500) / 5) * 5;
#if 0
    for(int i = 0; (500 * i) < x; ++i){
        for(int j = 0; (500 * i) + (5 * j) < x; ++j){
            if(max < ((1000 * i) + (5 * j))) max = ((1000 * i) + (5 * j));
        }
    }
#endif

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

    return 0;
}


Measured memory_bytes: 1704
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int K, A, B;
    cin >> K >> A >> B;
    if (B <= A + 2) {
        cout << K + 1 << endl;
    } else {
        K -= A - 1;
        int n = A;
        if (K % 2 == 0) {
            n += (B - A) * K / 2;
        } else {
            n += (B - A) * (K - 1) / 2;
            n += 1;
        }
        cout << n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	int t = n % 10;
	if (t == 2 || t == 4 || t == 5 || t == 7 || t == 9)
		cout << "hon" << endl;
	else if (t == 0 || t == 1 || t == 6 || t == 8)
		cout << "pon" << endl;
	else
		cout << "bon" << endl;
}

Measured memory_bytes: 3640
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define mod 1000000007
#define N 4055
#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,k,sum[N],f[N][N],ans;
inline void add(int &x,int k){
	x+=k;x-=(x>=mod)?mod:0;x+=(x<0)?mod:0;
}
signed main(){
	n=read();m=read()-1;k=read()-1;
	//f[i][j]表示前i项和为j的方案数
	f[0][0]=1;
	int t=(n+m)/k;
	F(i,1,t){
		F(j,0,n){
			sum[j]=sum[j-1]+f[i-1][j];
			f[i][j]=(sum[j]-((j>=k+1)?sum[j-k-1]:0)+mod)%mod;
			add(f[i][j],-f[i-1][j]);
			if (i*k-j<=m&&(i*k-j)%k==m%k&&j%k==n%k) add(ans,f[i][j]);
			add(f[i][j],f[i-1][j]);
		}
	}
	wrn(ans);
	return 0;
}

Measured memory_bytes: 126464
#include <bits/stdc++.h>
using namespace std;
char tab[105][105];
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int a,b; cin>>a>>b;
	for(int i = 1; i <= a; i ++){
		for(int j = 1; j <= b; j ++){
			cin >> tab[i][j];
		}
	}
	for(int i = 1; i <= a; i ++){
		bool czy = true;
		for(int j = 1; j <= b; j ++){
			if(tab[i][j] == '#'){
				czy = false;
				break;
			}
		}
		if(czy){
			for(int j = 1; j <= b; j ++){
				tab[i][j] = '?';
			}
		}
	}
	for(int i = 1; i <= b; i ++){
		bool czy = true;
		for(int j = 1; j <= a; j ++){
			if(tab[j][i] == '#'){
				czy = false;
				break;
			}
		}
		if(czy){
			for(int j = 1; j <= a; j ++){
				tab[j][i] = '?';
			}
		}
	}
	for(int i = 1; i <= a; i ++){
		bool xd = false;
		for(int j = 1; j <= b; j ++)
			if(tab[i][j] != '?') cout << tab[i][j], xd = true;
		if(xd) cout << '\n';
	}
}

Measured memory_bytes: 256
# Union Find 木
from sys import setrecursionlimit, stdin

def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t


def unite(parent, i, j):
    i = find(parent, i)
    j = find(parent, j)
    if i == j:
        return
    parent[j] += parent[i]
    parent[i] = j

readline = stdin.readline
setrecursionlimit(10 ** 6)

N, M = map(int, readline().split())

parent = [-1] * N
for _ in range(M):
    A, B = map(lambda x: int(x) - 1, readline().split())
    unite(parent, A, B)

print(-min(parent))


Measured memory_bytes: 16780
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
static const int mod = 1e9 + 7;
vector<ll> d(100001, -1);
vector<bool> a(100000, false);
ll fib(ll i) {
    if (!i) return d[i] = 1;
    if (i == 1) return d[i] = (a[i] ? 0 : 1);
    if (a[i]) return d[i] = 0;
    if (d[i] != -1) return d[i];
    return d[i] = (fib(i - 1) + fib(i - 2)) % mod;
}
int main() {
    ll N, M, A;
    cin >> N >> M;
    for (ll i = 0; i < M; i++) {
        cin >> A;
        a[A] = true;
    }
    cout << fib(N) << endl;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using T = tuple<int, int, int>;

int n;
vector<T> info;

int main() {
    cin >> n;

    for(int i = 0; i < n; i++) {
        int x, y, h;
        cin >> x >> y >> h;
        info.push_back( T(h, x, y) );
    }
    sort(info.begin(), info.end());

    for(int cx = 0; cx <= 100; cx++) {
        for(int cy = 0; cy <= 100; cy++) {
            int _h, _x, _y;
            tie(_h, _x, _y) = info[n-1]; // not ground
            int ch = _h + abs(_x - cx) + abs(_y - cy);

            bool ok = true;
            for(int i = 0; i < n; i++) {
                int h, x, y;
                tie(h, x, y) = info[i];

                if( max(ch - abs(x - cx) - abs(y - cy), 0) != h )
                    ok = false;
            }
            if(ok)
                cout << cx << " " << cy << " " << ch << endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  cin>>s;
  vi a(26,0);
  rep(i,s.size())
    a[s[i]-'a']++;
  rep(i,26)
    if(a[i]>=2){
      cout<<"no"<<endl;
      return 0;
    }
  cout<<"yes"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=1e5+1;
const int maxm=(1<<18)+1;
int dp[512][maxn];
int n,q;
int V[maxm],W[maxm];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d%d",&V[i],&W[i]);
	for(int i=0;i<maxn;i++)dp[0][i]=(i>=W[0]?V[0]:0);
	for(int i=1;i<512&&i<n;i++)
	{
		int f=(i-1)/2;
		for(int j=0;j<maxn;j++)dp[i][j]=dp[f][j];
		for(int j=W[i];j<maxn;j++)dp[i][j]=max(dp[i][j],dp[f][j-W[i]]+V[i]);
	}
	scanf("%d",&q);
	while(q--)
	{
		int v,L;
		scanf("%d%d",&v,&L);
		v--;
		vector<int> anc;
		anc.clear();
		while(v>=512)
		{
			anc.push_back(v);
			v=(v-1)/2;
		}
		int m=anc.size();
		int ans=0;
		for(int msk=0;msk<(1<<m);msk++)
		{
			int curv=0,curw=0;
			for(int i=0;i<m;i++)if(msk>>i&1)
			{
				curw+=W[anc[i]];
				curv+=V[anc[i]];
				if(curw>L)break;
			}
			if(curw<=L)
			{
				ans=max(ans,dp[v][L-curw]+curv);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

// bit全探索で書いてみる
// int main() {

//     vector<char> S(4);
//     for (int i = 0; i < 4; i++)
//     {
//         cin >> S[i];
//     }

//     for (int tmp = 0; tmp < (1 << 3); tmp++)
//     {
//         int sum = (int)(S[0] - '0');
//         string res = "";
//         res += S[0];

//         bitset<3> s(tmp);
//         for (int i = 0; i < 3; i++)
//         {
//             /* code */
//             if (s.test(i))
//             {
//                 sum += (int)(S[i+1] - '0');
//                 res += '+';
//                 res += S[i + 1];
//             }
//             else
//             {
//                 sum -=(int)(S[i+1] - '0');
//                 res += '-';
//                 res += S[i+1];
//             }
//         }

//         if (sum == 7) {
//             res += "=7";
//             cout << res << endl;
//             break;
//         }
//         }
// }


// dfsで書いてみる
string S;
string res;

void dfs(int pos, string x, int sum) {
    // base case
    if (pos == 4) {
        if (sum == 7) {
            res = x + "=7";
            return;
        }
        else
            return;
    }

    // +でつなぐ
    int sum1 = sum + (int)(S[pos] - '0');
    dfs(pos + 1, x + '+' + S[pos], sum1);

    // -でつなぐ
    int sum2 = sum - (int)(S[pos] - '0');
    dfs(pos + 1, x + '-' + S[pos], sum2);
}

int main() {
    cin >> S;

    string tmp = "";
    int sum = (int)(S[0] - '0');
    // cout << sum << endl;
    dfs(1, tmp + S[0], sum);
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
  REP(i,n)cin>>a[i];
SORT(a);
REP(i,n-1){
    if(a[i]==a[i+1]){
    cout <<"NO";
    return 0;
    }
}
cout << "YES";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int dp[11000][11000];
int main()
{
    string s,t;
    cin >> s;
    cin >> t;
    rep(i,s.size())rep(j,t.size()){
        if(s[i] == t[j])dp[i+1][j+1] = dp[i][j] +1;
        else{
            dp[i+1][j+1]  = max(dp[i][j+1],dp[i+1][j]);
        }
    }
    int i = s.size(),j = t.size();
    string ans = "";
    while (i >0 && j> 0){
        if(dp[i][j] == dp[i-1][j])i--;
        else if(dp[i][j] == dp[i][j-1])j--;
        else{
            ans = s[i-1] + ans;
            i--;j--;
        }
    
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 128000
#include <stdio.h>
int main(void)
{
int n, digit;
scanf("%d", &n);
digit = n;
while(n >= 10) {
  n %= 10;
  digit = n;
}
if (digit == 2 || digit == 4 || digit == 5 || digit == 7 || digit == 9 )
    printf("hon");
else if (digit == 0 || digit == 1 || digit == 6 || digit == 8) 
    printf("pon");
else 
    printf("bon");
return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,m,v,p,a[N];
    cin>>n>>m>>v>>p;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n,greater<ll>());
    ll ans=p;
    n-=(p-1);
    for(int i=0;i<n;i++)a[i]=a[i+p-1];
    v-=(p-1);
    ll rui=a[0];
    for(ll i=1;i<n;i++){
	if(not(a[0]<=a[i]+m))break;
	ll nin=v-(n-i); chmax(nin,0LL);
	if((a[i]+m)*i>=rui+m*nin)ans++;
	rui+=a[i];
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 1024
package main

import "fmt"

var N int

func main() {
	fmt.Scan(&N)
	ans := make(map[int]int)
	var k int
	for i := 1; i < N; i++ {
		fmt.Scan(&k)
		ans[k]++
	}
	for i := 1; i <= N; i++ {
		fmt.Println(ans[i])
	}
}


Measured memory_bytes: 15016
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int k = scan.nextInt();
		int n = scan.nextInt();
		int[] house = new int[n];
		for(int i = 0; i < n; i++) {
			house[i] = scan.nextInt();
		}
		
		int maxDist = k - (house[n-1] - house[0]);
		for(int i = 0; i < n-1; i++) {
			if(house[i+1]-house[i] > maxDist) maxDist = house[i+1]-house[i];
		}
		
		System.out.println(k-maxDist);
	}

}

Measured memory_bytes: 66344
N = int(input())
T = [int(input()) for _ in range(N)]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

l = 1

for i in T:
    l = lcm(l, i)

print(l)

Measured memory_bytes: 3060
n = gets.to_s.chomp.chars
k = gets.to_s.to_i

sz = n.size
dpj = Array.new(sz+1){ [0] * (k+1) }
dpl = Array.new(sz+1){ [0] * (k+1) }
dpj[0][0] = 1

n.each_with_index do |c, i|
  
  # justで数値が入っている場所は1箇所しかないはずだけど、どこにあってもいいように全部に計算式をやっている。
  (k+1).times do |j|
    dpj[i+1][j] += dpj[i][j] if c == '0' # justは0で留まるか、それ以外でスライドするか
    dpl[i+1][j] += dpj[i][j] if c >  '0' # c>0だとjust->lessに0があるので、just->lessで+1
    dpl[i+1][j] += dpl[i][j] # lessの分岐は10通りで、0で留まるのと、1-9で増えてスライド
  end
  
  k.times do |j|
    dpj[i+1][j+1] += dpj[i][j] if c >  '0' # justは0で留まるか、それ以外でスライドするか
    dpl[i+1][j+1] += dpj[i][j] * [0, c.to_i-1].max # c = 5 なら、1, 2, 3, 4が増える。
    dpl[i+1][j+1] += dpl[i][j] * 9 # lessの分岐は10通りで、0で留まるのと、1-9で増えてスライド
  end
end  

puts dpj[sz][k] + dpl[sz][k]

Measured memory_bytes: 1788
#include <stdio.h>
int main()
{
    int n,i,c = 1,m[20],d = 0, j=0,sal =0;
    scanf("%d",&n);
    for(i = 0;i<n;i++){
        scanf("%d",&m[i]);
    }
    for(i = 1;i<n;i++){
        for(j=i;j>0;j--){
            
            if(m[i] >= m[j - 1]){
                d++;
            }
        }
        if(d == i)
        {
            c++;
        }
        d = 0;
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	
	public int match(int[] s, int[] t) {
		
		int tsize = t.length;
		int ssize = s.length;
		int amount = 0;
		for(int i = 0; i < tsize; i++) {
			
			for(int j = 0; j < ssize; j++) {
				if(t[i] == s[j]) {
					++amount;
					break;
				}
			}
			
		}
                return amount;
		
	}

        public static void main(String[] args){
       
        	Main program = new Main();
		Scanner in = new Scanner(System.in);
		int ssize = in.nextInt();
		int[] s = new int[ssize];
		for(int i =0; i < ssize; i++) {
			s[i] = in.nextInt();
		}
		int tsize = in.nextInt();
		
		int[] t = new int[tsize];
		for(int i = 0; i < tsize; i++) {
			t[i] = in.nextInt();
		}
		
		System.out.println(program.match(s,t));
			

        }

}


Measured memory_bytes: 40288
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		double x1 = scanner.nextDouble();
		double y1 = scanner.nextDouble();
		double x2 = scanner.nextDouble();
		double y2 = scanner.nextDouble();

		double answer = Math.sqrt((x2 - x1) * (x2 - x1) + (y2- y1) * (y2 - y1));
		System.out.println(answer);
	}
}	

Measured memory_bytes: 18400
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    int N;
    cin >> N;
    int ans;
    for(int i = N; i <= 999; i ++){
        bool flag = true;
        int tmpI = i;
        while(tmpI){
            int tmp = tmpI % 10;
            if(tmp != i % 10){
                flag = false;
                break;
            }
            tmpI /= 10;
        }
        if(flag){
            cout << i << endl;
            return 0;
        }

    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    ll ans = 0;
    vector<ll>V(N);
    vector<ll>C(N);

    rep(i,N) cin>>V[i];

    rep(i,N) cin>>C[i];

    rep(i,N){
        ans+= max(V[i]-C[i],ll(0));
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int n, m, p, a, b;
double d[50][50], t[10];
double dp[50][300];
bool vis[50][300];

double solve(int pos, int used)
{
    if (vis[pos][used])
        return dp[pos][used];
    vis[pos][used] = true;
    if (pos == b)
        return dp[pos][used] = 0;
    double res = 1e9;
    rep(i, n)
    {
        if (!(used & (1 << i)))
            continue;
        rep(j, m)
        {
            if (d[pos][j] == 1e9)
                continue;
            res = min(res, solve(j, used - (1 << i)) + (d[pos][j] / t[i]));
        }
    }
    return dp[pos][used] = res;
}

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

    while (1)
    {
        cin >> n >> m >> p >> a >> b;
        if (n == 0)
            break;
        rep(i, 50) rep(j, 300) vis[i][j] = false;
        a--, b--;
        rep(i, n) cin >> t[i];
        rep(i, 50) rep(j, 50) d[i][j] = 1e9;
        rep(i, p)
        {
            int x, y;
            double z;
            cin >> x >> y >> z;
            x--, y--;
            d[x][y] = d[y][x] = z;
        }
        double ans = solve(a, (1 << n) - 1);
        bool f = false;
        rep(i, 300) if (vis[b][i]) f = true;
        if (!f)
            printf("Impossible\n");
        else
            printf("%.20lf\n", ans);
    }
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
  int64_t K,money;
  cin >> K;
  money = 100;
  for(int i = 0; i < 1000000; i++){
    money = money + (money/100);
    if(money >= K){
      cout << i + 1;
      break;
    }
  }
}

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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define no cout << "No" << endl
#define yes cout << "Yes" << endl
#define tc ll t; cin >> t; while (t--)
#define sz(c) (ll) (c).size()
#define trav(x,c) for(auto &x : c)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define _for(i,a,n) for(ll i = a ; i < n; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a; --i)
#define db(x) cout << #x << ": " << x << endl;
#define _db(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);
template<typename... T> void read(T&... x) {((cin >> x),...);}

int main() {
    godspeed;
    ll n; cin >> n;
    string s; cin >> s;
    ll cnt = 0;

    _for(i,0,n) {
        if(s[i] == 'A') if(s[i+1] == 'B') if(s[i+2] == 'C') {
                    cnt++; i+=2;
                }
    }

    cout << cnt;
}

Measured memory_bytes: 3604