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

int main(){
    bool nonprime[1000001] = {};
    nonprime[0] = nonprime[1] = true;
    for(int i = 2; i <= 1000000; i++){
        if(!nonprime[i]){
            for(int j = i+i; j <= 1000000; j += i){
                nonprime[j] = true;
            }
        }
    }
    
    while(1){
        int n, x;
        cin >> n >> x;
        
        if(n + x == 0)  break;
    
        bool valid[x+1] = {};
        valid[0] = true;
        
        int v;
        for(int i = 0; i < n; i++){
            cin >> v;
            for(int j = 0; j <= x-v; j++){
                if(valid[j])    valid[j+v] = true;
            }
        }
        
        int ans = -1;
        for(int i = x; i >= 1; i--){
            if(valid[i] && !nonprime[i]){
                ans = i;
                break;
            }
        }
        
        if(ans == -1)   cout << "NA" << endl;
        else            cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 5028
hw = Hash.new(0)
cost = []
width = 10
result = 0
onecost = []
s = gets.chomp.split(/\s+/)
hw[:h] = s[0].to_i
hw[:w] = s[1].to_i
width.times do |i|
  cost[i] = []
  s = gets.chomp.split(/\s+/)
  width.times do |ii|
    cost[i][ii] = s[ii].to_i
  end
end
#探索
def getmin(arr,alist)
  rsco = 2000
  ridx = alist[0]
  check = false
  alist.each do |idx|
    if(rsco > arr[idx] && arr[idx] != 0)
      rsco = arr[idx]
      ridx = idx
      check = true
    end
  end
  return ridx,rsco if check
  return ridx,0
end

width.times do |i|
  d = []
  width.times do |ij|
    d[ij] = cost[i][ij]
  end
  alist = [i]
  olist = []
  unfinish = true
  while(unfinish)
    v,s = getmin(d,alist)
    if (v == 1)
      onecost[i] = s
      unfinish = false
    else
      width.times do |w|
        next if (w == v || olist.include?(w))
        alist.push(w) unless alist.include?(w)
        if(d[w] > (d[v] + cost[v][w]))
          d[w] = d[v] + cost[v][w]
        end
      end
    end
    alist.delete(v)
    olist.push(v)
  end
end
hw[:h].times do |h|
  s = gets.chomp.split(/\s+/)
  hw[:w].times do |w|
    num = s[w].to_i
    next if (num == -1 || num ==1)
    result += onecost[num]
  end
end
print result,"\n"


Measured memory_bytes: 2300
s=input()
n=len(s)+1
arr=[0]*n
if s[len(s)-1]=='>':
    arr[len(arr)-2]=1
for i in range(len(s)-2,-1,-1):
    if s[i]=='>':
        arr[i]=arr[i+1]+1

for i in range(len(s)):
    if s[i]=='<' and arr[i]>=arr[i+1]:
        arr[i+1]=arr[i]+1
print(sum(arr))





Measured memory_bytes: 23336
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int x;
    cin >> x;
    x = gcd(x, 360);
    cout << 360 / x << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, k) for (int i = (s); i < (int)(k); i++)

int main(){
    int n,A,B;
    cin >> n;
    vector<int> a(n);
    rep(i,0,n) cin >> a.at(i);
    A = 0;
    B = 0;
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    rep(i,0,n){
        if(i%2==0){
             A += a.at(i);
        }else{
            B += a.at(i);
        }
        
    }
    cout << A-B << endl;
    
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn = 1e5 + 10;
using namespace std;
int n, m, k, t, h[maxn], tot, ans[maxn];
set<int>comp[maxn];
struct node
{
  int to, nxt, com;
} e[maxn << 2];
void add(int x, int y, int z)
{
  tot++;
  e[tot].to = y;
  e[tot].com = z;
  e[tot].nxt = h[x];
  h[x] = tot;
}
priority_queue<pair<int, int> >p;
int main()
{
  int i, j;
  while (scanf("%d %d", &n, &m) == 2)
  {
    //cout << n << " " << m << endl;
    for (int i = 1; i <= n; i++)
    {
      h[i] = 0;
      ans[i] = inf;
      comp[i].clear();
    }
    tot = 0;
    while (m--)
    {
      int a, b, c;
      scanf("%d%d%d", &a, &b, &c);
      add(a, b, c);
      add(b, a, c);
    }
    p.push({0, 1});
    ans[1] = 0;
    while (!p.empty())
    {
      int now = p.top().se, ca = -p.top().fi;
      p.pop();
      if (ans[now] < ca)
      {
        continue;
      }
      for (i = h[now]; i; i = e[i].nxt)
      {
        int to = e[i].to, to_com = e[i].com;
        int to_ca = ca + (!comp[now].count(to_com));
        if (ans[to] > to_ca)
        {
          ans[to] = to_ca;
          p.push({ -to_ca, to});
          comp[to].clear();
          comp[to].insert(to_com);
        }
        else if (ans[to] == to_ca)
        {
          comp[to].insert(to_com);
        }
      }
    }
    printf("%d\n", ans[n] == inf ? -1 : ans[n]);
  }
  //system("Pause");
  return 0;
}


Measured memory_bytes: 20216
#include<bits/stdc++.h>
int main()
{
    int N,a,b,counts = 0,sum;
    scanf("%d %d %d",&N,&a,&b);

    for(int i = 1;i <= N;i++){
        //printf("i %d\n",i);
        if(1 <= i && i < 10){
            if(a <= i && i <= b){
                counts += i;
                //printf("1 %d\n",counts);
            }
        }
        else if(10 <= i && i < 100){
            if(a <= i / 10 + i % 10 && i / 10 + i % 10 <= b){
                counts += i;
                //printf("10 %d\n",counts);
            }
        }
        else if(100 <= i && i < 1000){
            if(a <= i / 100 + i / 10 % 10 + i % 10 && i / 100 + i / 10 % 10 + i % 10 <= b){
                counts += i;
               //printf("100 %d\n",counts);
            }
        }
        else if(1000 <= i && i < 10000){
            if(a <= i / 1000 + i / 100 % 10 + i / 10 % 10 + i % 10 && i / 1000 + i / 100 % 10 + i / 10 % 10 + i % 10 <= b){
                counts += i;
               //printf("1000 %d\n",counts);
            }
        }
        else if(i == 10000){
            if(a <= 1 && 1 <= b){
                counts += i;
                //printf("10000 %d\n",counts);
            }
        }
    }
    printf("%d\n",counts);

    return 0;
}



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

int main() {
  
  int N1, N2, N3, N4;
  cin >> N1 >> N2 >> N3 >> N4;
  
  if( (N1==1 || N2==1 || N3==1 || N4==1) && (N1==9 || N2==9 || N3==9 || N4==9) && (N1==7 || N2==7 || N3==7 || N4==7) && (N1==4 || N2==4 || N3==4 || N4==4) ){ cout << "YES" << endl; }
  else{ cout << "NO" << endl; }
  
}


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

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


  int n = N.size()-1;

  for(int bit = 0; bit < (1<<n); bit++){

    int ans = N[0] - '0';
    string tmp;
    tmp = tmp + N[0];

    // 0 1 2
    for(int i = 0; i < n; i++){
      if(bit & (1<<i)){
        ans += N[i+1] - '0';
        tmp = tmp + "+" + N[i+1];
      } else {
        ans -= N[i+1] - '0';
        tmp = tmp + "-" + N[i+1];
      }
    }

    //cerr << ans << endl;

    if(ans == 7){
      cout << tmp << "=7" << endl;
      break;
    }

  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int howmany(int **a,int i,int j,int m,int n){
    int **dp=new int*[m];
    for(int i=0;i<m;i++) dp[i]=new int[n];
    dp[0][0]=1;
    for(int i=1;i<n;i++){
        if(a[0][i]!=0 && dp[0][i-1]!=0){
            dp[0][i]=1;
        }
        else dp[0][i]=0;
    } 
    for(int i=1;i<m;i++) {
        if(a[i][0]!=0 && dp[i-1][0]!=0){
            dp[i][0]=1;
        }
        else dp[i][0]=0;
    }
    for(int i=1;i<m;i++){
        for(int j=1;j<n;j++){
            if(a[i][j]==0) dp[i][j]=0;
            else {
                int ans1=0,ans2=0;
                if(i>=1) ans1=dp[i-1][j]%1000000007;
                if(j>=1) ans2=dp[i][j-1]%1000000007;
                dp[i][j]=(ans1+ans2)%1000000007;
            }
        }
    }
    return dp[m-1][n-1]%1000000007;
}
int main() {
    int m,n;
    cin>>m>>n;
    int **a=new int*[m];
    for(int i=0;i<m;i++){
        a[i]=new int[n];
        for(int j=0;j<n;j++){
            char b;
            cin>>b;
            if(b=='.') a[i][j]=1;
            else if(b=='#') a[i][j]=0;
        }
    }
    cout<<howmany(a,0,0,m,n)<<endl;
    return 0;
}


Measured memory_bytes: 8064
def euclid(A, B):
    c2 = 0
    for a,b in zip(A,B):
        c2 += (a-b)**2
    return c2**0.5

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in range(N):
    for j in range(i+1,N):
        c = euclid(X[i], X[j])
        if c.is_integer():
            cnt += 1
print(cnt) 


Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<sstream>
#include<algorithm>
 
using namespace std;
#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define sRead(x,y,z)  scanf("%d%d%d",&x,&y,&z)
#define gc(x)  scanf(" %c",&x);
#define  INF (ll)1e14//无穷设置的大着点
#define mmt(x,y)  memset(x,y,sizeof x)
#define write(x) printf("%d\n",x)
const int N = 11000;
const int M=  2e5+5;
using namespace std;
typedef long long ll;
struct Edge
{
    int next;
    int to;
    ll dis;
}edge[M*2];
int head[M],tot;
ll d[M];bool vis[M];
inline void add(int from,int to,ll dis){
    edge[++tot].next = head[from];
    edge[tot].to = to;
    edge[tot].dis = dis;
    head[from] = tot;
}
struct node
{
    ll val;int id;
    node(){}
    node(int a,ll b):id(a),val(b){}
    bool operator <(node A)const{
        return val > A.val;
    }
};
void dij(int u)
{
    mmt(vis,0);
    d[u] = 0;
    priority_queue<node> Q;
    Q.push({u,0});
    node tmp;
    while(Q.size()){
        tmp = Q.top();
        Q.pop();
        int x = tmp.id;
        if(vis[x]) continue;
        for(int i =  head[x];~i;i = edge[i].next){
            int y = edge[i].to;
            ll dis = edge[i].dis;
            if(d[y] > d[x] +dis){
                d[y] = d[x] + dis;
                Q.push({y,d[y]});
            }
        }
    }
}
inline void init(int n)
{
    mmt(head,-1);
    tot = 0;
    for(int i = 1;i <= n;++i) d[i] = INF;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    init(n);
    int u,v;ll dis;
    for(int i = 1;i <= n;++i){//加反向边
        add(i,i - 1,0);
    }
    for(int i = 1;i <= m;++i){//只把端点 加进去
        cin>>u >> v>>dis;
        add(u,v,dis);
    }
    dij(1);
    if(d[n] == INF) cout<<-1<<endl;
    else cout<<d[n]<<endl;
}

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

using namespace std;

const int b = 1e9 + 7;

typedef long long ll;

int main(){
  ll N,M; cin >> N >> M; vector<ll> dp(N + 10,0);//余裕持たせる
  vector<bool> flag(N + 10,true); //これも余裕を持たせる
  for(ll i = 0; i < M; i++){ ll a; cin >> a; flag[a] = false;}
  //壊れている階段の箇所はfalse;で flag dpともに1-indexed管理
  
  dp[0] = 1;
  if(flag[1] == true){ dp[1] = 1;}
  
 for(ll i = 2; i < N + 10; i++){
   if(flag[i] == true){ dp[i] = (dp[i-1] + dp[i-2]) % b; }}
  
  cout << dp[N] << endl; return 0;}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
using namespace std;

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

long long lcm(long long a,long long b){ 
  		return (a / gcd(a,b))*b;
}

int main(){
	int N;
	cin >> N;
  	long long c=1;
	for (long long i = 0; i < N; i++) {
			long long b;
      		cin >> b;
      		c = lcm(c,b);
	}

	cout << c << endl;

	
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main() {
	cout << fixed << setprecision(5);
	int n;
	while (cin >> n&&n) {
		int x[1000],sum=0,sum2=0;
		for (int i = 0; i < n; i++) {
			cin >> x[i];
			sum += x[i];
			sum2 += x[i] * x[i];
		}
		double ave = (double)sum / n;
		double ave2 = (double)sum2 / n;
		cout << sqrt(ave2 - ave*ave) << endl;

	}
	return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,k;
    cin >> n >> k;
    int a[n];
    REP(i,n)cin >> a[i];
    
    if(n <= k){
        cout << 1 << endl;
        return 0;
    }
    else if(n == k+1){
        cout << 2 << endl;
        return 0;
    }
    n--;
    int answer = n/(k-1);

    if(n%(k-1) != 0)answer++;
    cout << answer << endl;
    return 0;
}

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

int main(){
  int N;cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];
  sort(A.begin(),A.end());
  cout<<A[N-1]-A[0]<<endl;
}
  

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    string S; cin>>S;
    if(S.size()%2==1) dame;
    rep(i,S.size()){
        if(S[i]!='h') dame;
        if(S[i+1]!='i') dame;
        ++i;
    }
    cout<< "Yes" <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main()
{
    int N, M;
    string S;
    cin >> N >> M >> S;
    reverse(S.begin(), S.end());
    if (S.front() == 1 || S.back() == 1)
    {
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans;
    int pos = 0;
    while (pos < N)
    {
        bool is_ok = false;
        for (int i = M; i > 0; i--)
        {
            if (i + pos > N)
                continue;

            if (S[i + pos] == '0')
            {
                pos = i + pos;
                ans.push_back(i);
                is_ok = true;
                break;
            }
        }

        if (!is_ok)
        {
            cout << -1 << endl;
            return 0;
        }
    }

    rep(i, ans.size())
    {
        cout << ans[ans.size() - 1 - i] << " ";
    }
    cout << endl;
    return 0;
}

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

signed main(){
	string S;
	cin >> S;
	int ans = 0;
	for(int i = 0; i < 4; i++){
		if(S[i] == '+'){
			ans++;
		}
		else{
			ans--;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3720
#include<iostream>
#include<string>
using namespace std;
char winer;
int main(){
	string s;
	while(cin >> s){
		if(s == "0") break;
		int scoreA=0, scoreB=0;

		for(string::size_type i=1; i<s.size(); i++){
			if(s[i] == 'A') scoreA++;
			if(s[i] == 'B') scoreB++;
		}
		if(scoreA > scoreB)
			cout << scoreA+1 << " " << scoreB << endl;
		else
			cout << scoreA << " " << scoreB+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    ll N;
    cin >> N;

    ll Ntmp = N;
    ll ans = 0;
    bool isprime = true;
    for (ll i = 2; i * i <= Ntmp; ++i) {
        ll tmp = i;
        while (!(N % tmp)) {
            N /= tmp;
            tmp *= i;
            ans++;
        }
        while (!(N % i))
            N /= i;
    }
    if (N <= 1)
        isprime = false;
    cout << ans + isprime << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	while(s.size()>3){
		bool ok=0;
		for(int i=1;i<s.size()-3;i++){
			if(s.substr(i,3)=="mew"){
				s=s.substr(0,i)+s.substr(i+3);
				ok=1;
				break;
			}
		}
		if(!ok){
			break;
		}
	}
	if(s!="mew"){
		cout << "Rabbit" << endl;
	}
	else{
		cout << "Cat" << endl;
	}
}


Measured memory_bytes: 3228
function Main(input) {
    input = input.trim();    
    X = parseInt(input);


    const array = []

    for (var i = 0; i < 40000; i++) {
        array.push(Math.pow(i, 5))
    }

    var A = 0;
    var B = 0;

    var breakFlag = false;
    for (var i = 0; i < array.length; i++) {
        for (var j = 0; j < array.length; j++) {
            if (array[i] + array[j] == X) {
                A = i;
                B = - j;
                breakFlag = true;
                break;
            }
            if (array[i] - array[j] == X) {
                A = i;
                B = j;
                breakFlag = true;
                break;
            }
            if (-array[i] + array[j] == X) {
                A = -i;
                B = -j;
                breakFlag = true;
                break;
            }
            if (-array[i] - array[j] == X) {
                A = -i;
                B = +j;
                breakFlag = true;
                break;
            }
        }
        if (breakFlag) break;
    }

    console.log(A + " " + B)

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 34672
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

char c;

int main(){
	cin>>c;
	if(isupper(c)) cout<<'A'<<endl;
	else cout<<'a'<<endl;
}

Measured memory_bytes: 3588
import sys

counter = []
for i in range(0, 101):
	counter.append(0)

for line in sys.stdin:
	counter[int(line)] += 1

max = 0
for i in range(0, 101):
	if max < counter[i]: max = counter[i]
for i in range(0, 101):
	if max == counter[i]: print i


Measured memory_bytes: 4644
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int n, k;
vll a(5000, 1e18);
vvb dp(5010, vb(5010, false));
bool dp_judge(int p)
{
	rep(i, n+1){
		rep(j, k+1){
			dp[i][j]=false;
		}
	}
	dp[0][0]=true;

	rep(i, n){
		rep(j, k+1){
			if(i!=p){
				dp[i+1][j]=dp[i+1][j]|dp[i][j];
				if(j>=a[i]){
					dp[i+1][j]=dp[i+1][j]|dp[i][j-a[i]];
				}
			}else{
				dp[i+1][j]=dp[i][j];
			}
		}
	}
	
	bool flag=false;
	int k0=max((ll)0, k-a[p]);
	repr(j, k0, k){
		flag=flag||dp[n][j];
	}
	return flag;
}
int main(void)
{
	cin>>n>>k;

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

	sort(all(a));

	int low=0, high=n-1, mid;

	bool low_j=dp_judge(0);

	if(dp_judge(high)&&!low_j){
		while(low<high){
			mid=(low+high)/2;
			if(dp_judge(mid)){
				high=mid-1;
			}else{
				low=mid+1;
			}
		}
		//cout<<low<<" "<<high<<endl;
		if(dp_judge(low)){
			cout<<low<<endl;
		}else{
			cout<<low+1<<endl;
		}
	}else if(low_j){
		cout<<0<<endl;
	}else{
		cout<<n<<endl;
	}
}

Measured memory_bytes: 3584
#include<cstdio>
#include<cstring>
using namespace std;
long long f[510][510],a[510][510],b[510][510];
inline long long mymin(long long x,long long y){return x<y?x:y;}
inline long long CVN(int ll,int lr,int rl,int rr){return a[lr][rr]-a[ll-1][rr]-a[lr][rl-1]+a[ll-1][rl-1];}
int main()
{
	int n;scanf("%d",&n);
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i==j)continue;
			int c;scanf("%d",&c);
			a[i][j]=a[i-1][j]+a[i][j-1]+c-a[i-1][j-1];
		}
	}
	for(int j=2;j<=n;j++)
	{
		for(int i=1;i<j;i++)b[i][j]=b[i][j-1]+CVN(i,j-1,j,j);
	}
	memset(f,63,sizeof(f));f[0][1]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			for(int k=j+1;k<=n+1;k++)
			{
				f[j][k]=mymin(f[j][k],f[i][j]+b[j][k-1]+CVN(k,n,i,j-1));
			}
		}
	}
	long long ss=0x3f3f3f3f3f3f3f3fll;
	for(int i=1;i<=n;i++)if(f[i][n+1]<ss)ss=f[i][n+1];
	printf("%lld\n",ss);
	return 0;
}

Measured memory_bytes: 7812
#include<stdio.h>

int main(void){

	int n, b, f, r, v, i, j, k, info[4][3][10] = {};

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		info[b-1][f-1][r-1] += v;
	}
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 3; j++) {
			for (k = 0; k < 10; k++) {
				printf(" %d", info[i][j][k]);
			}
			printf("\n");
		}
		if(i != 3) printf("####################\n");
	}
    return 0;
}


Measured memory_bytes: 2080
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int d[210][210];
int V, E, R;

void shortest_path()
{
	rep(k, 0, V)rep(i, 0, V)rep(j, 0, V)if (d[i][k] != INF && d[k][j] != INF)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	//無向ならif文要らず？
}

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

	cin >> V >> E >> R;

	vector<int> T;
	int r;
	rep(i, 0, R)
	{
		cin >> r;
		r--;
		T.push_back(r);
	}

	rep(i, 0, V)rep(j, 0, V)if (i != j)d[i][j] = INF;

	rep(i, 0, E)
	{
		int s, t, c;
		cin >> s >> t >> c;
		s--, t--;
		d[s][t] = c;
		d[t][s] = c;
	}

	shortest_path();

	sort(all(T));

	int ans = INF;
	do {
		int res = 0;
		rep(i, 0, SZ(T) - 1)
		{
			res += d[T[i]][T[i + 1]];
		}
		chmin(ans, res);
	} while (next_permutation(all(T)));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
using Double = long double;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
int main() {
    Int n, k;
    cin >> n >> k;
    auto p = vector<int>();
    rep(i, n) {
        int a;
        cin >> a;
        p.push_back(a);
    }
    auto sum = 0LL;
    rep(i, k) {
        sum += 1 + p[i];
    }
    Int ans = sum;
    for (auto i = k; i < n; i++) {
        sum -= p[i - k];
        sum += p[i];
        ans = max(sum, ans);
    }
    printf("%.10Lf\n", ((long double)ans) / 2);
}


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

int main() {
	char b;
	cin>>b;
	
	if(b=='A')cout<<'T'<<endl;
	else if(b=='C')cout<<'G'<<endl;
	else if(b=='G')cout<<'C'<<endl;
	else if(b=='T')cout<<'A'<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main(){
    string s;
    cin>>s;
    long long n=s.size();
    vector<vector<long long>> dp(n+1, vector<long long>(13));
    dp.at(0).at(0)=1;
    for(int i=0; i<s.size() ; i++){
        vector<long long> tmp(13);
        for(int j=0; j<13; j++){
            tmp.at((j*10)%13) = dp.at(i).at(j);
        }
        for(int j=0; j<13; j++){
            dp.at(i).at(j)= tmp.at(j);
        }
        if(s.at(i)!='?'){
            long long N=s.at(i)-'0';
            for(int j=0; j<13; j++){
                dp.at(i+1).at((j+N)%13) += dp.at(i).at(j);
                dp.at(i+1).at((j+N)%13) %=mod;
            }
        }
        else{
            for(int j=0; j<10; j++){
                for(int k=0; k<13; k++){
                    dp.at(i+1).at((j+k)%13) += dp.at(i).at(k);
                    dp.at(i+1).at((j+k)%13) %=mod;
                }
            }
        }
    }
/*    for(int i=0;i<n;i++){
        for(int j=0;j<13;j++){
            cout<<i<<j<<" "<<dp.at(i).at(j)<<endl;
        }
    }*/
    cout<<dp[n][5]<<endl;
}

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

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

struct Node *root,*NIL;

void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);

int main(){
  int n,i,x;
  char c[10];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",&c);
    if(strcmp(c,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(c,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;
  z = malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z-> right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

void inorder(struct Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

    
    



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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n,ans=0; scanf("%d",&n);
    if(n>=65&&n<91)ans=1;
    if(n>=97&&n<123)ans=2;
    printf("%d\n",ans);
    return 0;
}


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

int N, K, fw[200005];
long long A[200005];
vector<long long> v;

void upd(int p) {
	p++;
	for (int i = p; i <= N; i += (i & (-i))) fw[i]++;
}

int qry(int p) {
	p++;
	int ans = 0;
	for (int i = p; i > 0; i-=(i&(-i))) ans += fw[i];
	return ans;
}

int main() {
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) scanf("%lld", &A[i]);
	for (int i = 0; i < N; i++) A[i] -= K;
	for (int i = 1; i < N; i++) A[i] += A[i - 1];
	for (int i = 0; i < N; i++) v.push_back(A[i]);
	sort(v.begin(), v.end());
	for (int i = 0; i < N; i++) A[i] = lower_bound(v.begin(), v.end(), A[i]) - v.begin();
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		ans += qry(A[i]);
		if (v[A[i]] >= 0) ans++;
		upd(A[i]);
	}
	printf("%lld\n", ans);
}


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

using namespace std;

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

typedef long long ll;

const int N = 4e5;
vector<int> row[N];
int col[N];

void solve() {
  int n, m, k; cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    int x, y; cin >> x >> y;
    row[x].push_back(y);
    col[y]++;
  }
  multiset<int, greater<int> > st;
  for (int y = 1; y <= m; y++) {
    st.insert(col[y]);
  }
  int ans = 0;
  for (int x = 1; x <= n; x++) {
    for (int y : row[x]) {
      st.erase(st.find(col[y]));
      col[y]--;
      st.insert(col[y]);
    }
    int res = *st.begin(), sz = row[x].size();
    ans = max(ans, res + sz);
    for (int y : row[x]) {
      st.erase(st.find(col[y]));
      col[y]++;
      st.insert(col[y]);
    }
  }
  cout << ans;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
    solve();
}


Measured memory_bytes: 37656
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
    int n, t, a;
    cin >> n >> t >> a;
    int h;
    double dif = 1e18;
    int ans = 0;
    for (int i=0; i<n; i++) {
        cin >> h;
        if (abs(a - t + h * 0.006) < dif) {
            dif = abs(a - t + h * 0.006);
            ans = i + 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
#endif
    crap;

    int x;
    cin >> x;

    int p = 100;
    for (int i = 1; i <= 5000; i++) {
        double total = (double)(p + 0.01 * p);
        if ((int)total >= x) {
            cout << i << endl;
            return 0;
        }
        p = total;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define vl vector<ll>
 
int main() {
 
    ll N, K;
    cin >> N >> K;
 
    vl A, F;
    ll a, f;
    ll sum = 0;
    for (ll i = 0; i < N; i++) {
        cin >> a;
        A.push_back(a);
        sum += a;
    }
    for (ll i = 0; i < N; i++) {
        cin >> f;
        F.push_back(f);
    }
 
    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<ll>());
 
    ll ans = 0;
    ll L = 0;
    ll R = 10e12;
    ll med, tmp;
    ll new_a;
 
    if (K >= sum) {
        cout << 0 << endl;
        return 0;
    }
 
    while (R-L > 1) {
        med = (L + R) / 2;
        tmp = 0;
        for (int i = 0; i < N; i++) {
            if (A[i] * F[i] > med) {
                new_a = med / F[i];
                tmp += (A[i] - new_a);
            }
        }
        if (tmp > K) L = med;
        else R = med;
    }
 
    cout << R << endl;
 
    return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define MOD 998244353LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

map<string,ll> dp;

ll solve(string s){
	if(s.size()==0)return 1;
	if(s.size()==1){
		if(s[0]=='1')return 2;
		else return 1;
	}
	if(dp.find(s)!=dp.end()){
		return dp[s];
	}
	ll sum=solve(s.substr(0,1))*solve(s.substr(1))%MOD;

	for(int i=1;i<=s.size();i++){
		string subs=s.substr(0,i);
		for(int j=1;j<=100;j++){
			if(i*(j+1)>s.size())break;
			for(int k=0;k<i;k++){
				if(s[i*j+k]=='0')subs[k]='0';
			}
			sum=(sum+solve(subs)*solve(s.substr(i*(j+1)))%MOD)%MOD;
		}
	}
	return (dp[s]=sum);
}

int main(void){
	string str;
	cin >> str;
	printf("%lld\n",solve(str));
	return 0;
}

Measured memory_bytes: 5632
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

  static final int N = 100000;
  static final int K = 100000;
  static int n, k;
  static int w[], c[];

  public static boolean check(int lmt) {
    int i, j;

    for (i=0; i<n; i++)
      if (lmt < w[i]) return false;

    Arrays.fill(c, 0);
    int full = -1;
    for (i=0; i<n; i++) {
      boolean is_put = false;
      for (j=full+1; j<k; j++) {
        if (lmt < c[j] + w[i])
          full++; 
        else {
          c[j] += w[i];
          if (c[j] == lmt) full++;
          is_put = true;
          break;
        }
      }
      if (!is_put) return false;
    }

    return true;
  }

  public static void main(String[] args) {
    int i;
    Scanner sc = new Scanner(System.in); 
    n = Integer.parseInt(sc.next());
    w = new int[n];
    k = Integer.parseInt(sc.next());
    c = new int[k];
    for (i=0; i<n; i++)
      w[i] = Integer.parseInt(sc.next());

    Arrays.fill(c, 0);

    //?±?????????????(l, u]????????????????????¨??????????????¢?´¢
    int l = 0, u = 0;
    for (i=0; i<n; i++) u += w[i];
    while (u-l > 1) {
      int m = (l + u)/2;
      if (check(m))
        u = m;
      else
        l = m;
    }

    System.out.println(u);
  }
}

Measured memory_bytes: 67392
#include<stdio.h>
int main(void)
{
	int a,b,c,d[7];
	for(;;)
	{
		for(b=0;b<7;b++)
			d[b]=0;
		scanf("%d",&a);
		if(a==0)
			break;
		for(b=0;b<a;b++)
		{
			scanf("%d",&c);
			if(c>=60)
				d[6]++;
			else
				d[c/10]++;
		}
		for(b=0;b<7;b++)
			printf("%d\n",d[b]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string s;
  cin>>s;
  int ans = 0;
  for(int i = 0; i < 6; i++)
  {
    if(s[i]=='1') ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n=input()
for i in range(2**3):
    ans=''
    for j in range(4):
        ans+=n[j]
        if j==3:
            continue
        if (i>>j)&1:
            ans+='+'
        else:
            ans+='-'
    if eval(ans)==7:
        print(ans+'=7')
        break

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

using namespace std;

using LL = long long;

int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);	
	
	int cnt = 0;

	LL N; 
	cin >> N;
	
	while (N > 0) {
		N /= 2;
		++cnt;
	}

	cout << ((1LL << cnt) -1) << '\n';

	return 0;
}
 

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map> 
#include<iostream>
#include<time.h>
using namespace std;
typedef long long ll;
const double pi=acos(-1.0);
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
//ll begin_time=clock();
//ll end_time=clock();printf("time=%lldms\n",end_time-begin_time);
/****************************************************************************/ 
bool z[100005];
int x[100005];

int main()
{
	int a,b,c,d,e;
	scanf("%d%d",&a,&b);
	memset(z,0,sizeof(z));
	for(int i=1;i<=a;i++)scanf("%d",&x[i]);
	while(b--)
	{
		scanf("%d%d",&c,&d);
		if(x[c]>=x[d])z[d]=1;
		if(x[d]>=x[c])z[c]=1;
	}
	e=0;
	for(int i=1;i<=a;i++)if(!z[i])e++;
	printf("%d\n",e);
}




Measured memory_bytes: 4312
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    for(int i = 0;i < 50000;i++){
        int x = i * 1.08;
        if(x == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int l,r,d;cin >> l >> r >> d;
    cout << (r)/d - (l-1)/d << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <limits>
#include <utility>
#include <bitset>
#include <sstream>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e9
string S;

int main()
{

	cin >> S;

	int n = S.size();

	int rest = 15 - n;
	int cnt = 0;
	rep(i,n){
		if (S[i] == 'o') cnt++;
	}

	if (rest + cnt >= 8) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;




	return 0;
}

Measured memory_bytes: 256
package main
 
import (
	"fmt"
)
 
func main() {
	var n int
	fmt.Scan(&n)
	if n%2 == 1 {
		fmt.Println(0)
		return
	}
	n /= 2
	var cnt int
	mul := 5
	for i := 0; i <= 25; i++ {
		num := int(n / mul)
		if num > 0 {
			cnt += num
		}
		mul *= 5
	}
	fmt.Println(cnt)
}

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

ll N;
ll Lucas[100];

int main() {
	cin >> N;
	Lucas[0] = 2;
	Lucas[1] = 1;
	if (N > 1) {
		for (int i = 2; i <= N; i++) {
			Lucas[i] = Lucas[i - 1] + Lucas[i - 2];
		}
	}

	cout << Lucas[N] << endl;
}

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

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

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

T=int(input())

for _ in range(N-1):
    T=lcm(int(input()),T)
print(T)

Measured memory_bytes: 2940
n,a,b=map(int,input().split())
S=input()

ab=0
f=0

for i in S:
  if i=="a":
    if ab < a+b:
      ab = ab+1
      print("Yes")
    else:
      print("No")
  elif i =="b":
    if ab < a+b and f <b:
      ab = ab+1
      f = f+1
      print("Yes")
    else:
      print("No")
  else:
    print("No")

Measured memory_bytes: 4016
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  int c1=0;
  int c2=0;
  rep(i,n){
    int a; cin>>a;
    if(a%4==0)
    c1++;
    else if(a%2==0)
    c2++;
  }
  if(n-c1*2<=c2||n-c1*2==1)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;

  return 0;
}


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

using namespace std;

#define ll long long int

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int h,w; cin >> h >> w;

	string s;

	for(int i = 0; i < h; i++) {
		cin >> s;
		cout << s << '\n' << s << '\n';
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <climits>
#include <cstring>
#include <bitset>
#include <cmath>

#define f first
#define s second
#define pb push_back
#define NMAX 100000
#define pii pair <int, int>

using namespace std;

char buffer[NMAX + 10];
int bufpoz = NMAX + 10;

inline void get (int &n);

int stac[200010], st[200010], dr[200010], v[200010];

int main ()
{
   // freopen ("file.in", "r", stdin);

    int n;
    get (n);

    int k = 0;
    for (int i = 1; i <= n; ++i)
    {
        get (v[i]);

        for (; k > 0 && v[i] < v[stac[k]]; --k);

        st[i] = stac[k] + 1;
        stac[++k] = i;
    }

    stac[0] = n + 1;
    k = 0;
    long long rez = 0LL;
    for (int i = n; i; --i)
    {
        for (; k > 0 && v[i] < v[stac[k]]; --k);

        dr[i] = stac[k] - 1;
        stac[++k] = i;

        rez += 1LL * v[i] * (i - st[i] + 1) * (dr[i] - i + 1);
    }

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

    return 0;
}


inline void get (int &n)
{
    n = 0;
    if (bufpoz > NMAX)
        fread (buffer, NMAX, 1, stdin), bufpoz = 0;

    int semn = 1;
    while ('0' > buffer[bufpoz] || buffer[bufpoz] > '9')
    {
        if (buffer[bufpoz] == '-') semn = -1;

        if (++bufpoz == NMAX)
            fread (buffer, 1, NMAX, stdin), bufpoz = 0;
    }

    while ('0' <= buffer[bufpoz] && buffer[bufpoz] <= '9')
    {
        n = n * 10 + buffer[bufpoz] - 48;
        if (++bufpoz == NMAX)
            fread (buffer, 1, NMAX, stdin), bufpoz = 0;
    }

    n *= semn;
}


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

int main(){
    
    ll a, b;
    cin >> a >> b;
    stringstream ss;
    ss << a << b;
    ll c;
    ss >> c;
    ll d = sqrt(c);
    if(d * d == c)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    return 0;
}


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

typedef long long ll;

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

int dp[3005][3005];

int main() {
  string s, t;
  cin >> s >> t;
  int m = s.size();
  int n = t.size();

  rep(i, 3005) {
    dp[0][i] = 0;
    dp[i][0] = 0;
  }

  string ans;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (s[i-1] == t[j-1]) {
        dp[i][j] = dp[i-1][j-1] + 1;
      } else {
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }

  // DP テーブルの末端から周囲を見て最適な行動をする
  int d = dp[m][n];
  int y = s.size();
  int x = t.size();
  while (d > 0) {
    if (dp[y-1][x] == d) y--;
    else if (dp[y][x-1] == d) x--;
    else {
      ans.push_back(s[y-1]);
      x--; y--; d--;
    }
  }

  // cerr << dp[m][n] << endl;
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int x;
cin>>x;
x%=1000;
int val=1000-x;
val%=1000;
cout<<val<<endl;
    return 0;
}

Measured memory_bytes: 3608
// ------------------------------------
// Date:2018/ 3/10
// Problem:ABC 072 Sandglass2 a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int x, t, tmp;
  cin >> x >> t;
  tmp = x - t;
  if (tmp < 0) tmp = 0;
  cout << tmp << endl;
  return 0;
}



Measured memory_bytes: 256