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

long long int N;

int main() {
  cin >> N;

  long long int min = 10e18;
  for (int i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      if (i + (N / i) - 2 < min) {
        min = i + (N / i) - 2;
      }
    }
  }

  cout << min << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

ll BASE_NUM = 1000000007;
int main()
{
  // 整数の入力
  ll N, K;
  cin >> N >> K;
  ll total = 0;
  for (ll i = K; i <= N + 1; i++)
  {
    ll min_sum = i * (i - 1) / 2;
    ll max_sum = i * (N + (N - i) + 1) / 2;
    // cout << i << endl;
    // cout << min_sum << " " << max_sum << endl;
    total = (total + max_sum - min_sum + 1) % BASE_NUM;
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, k;
int seq[100010];
int diff[100010];

int main() {
  int test;
  scanf("%d", &test);
  while (test--) {
    scanf("%d %d", &n, &k);
    k = min(n, k);
    REP(i, n) {
      scanf("%d", seq + i);
      if (i != 0) {
        diff[i - 1] = seq[i] - seq[i - 1];
      }
    }
    int total = seq[n - 1] - seq[0];
    sort(diff, diff + n - 1);
    reverse(diff, diff + n - 1);
    REP(i, k - 1) {
      total -= diff[i];
    }
    printf("%d\n", total);
  }
}

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

int n;
double dp[3000][3000];
double arr[3000];

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>arr[i];
	}
	for(int i=0;i<=n;i++)
	{
		dp[0][i]=0;
	}
	
	dp[1][0]=1-arr[1];
	
	for(int i=2;i<=n;i++)
	{
		dp[i][0]=dp[i-1][0]*(1-arr[i]);
	}
	
	dp[1][1]=arr[1];
	
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			dp[i][j]=dp[i-1][j-1]*arr[i]+dp[i-1][j]*(1-arr[i]);
		}
	}
	
	double sum=0;

		for(int j=1;j<=n;j++)
		{
			if(j>n-j)
			{
				sum+=dp[n][j];
			}
		}

	
	/*for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
    cout<<fixed<<setprecision(11)<<sum<<endl;
    
    
	return 0;
}

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

using namespace std;

int dx[300010];
int dy[300010];

int main() {
    
    int h,w,m;
    cin >> h >> w >> m;
    
    set<pair<int,int> > s;
    for (int i = 0; i < m; ++i) {
        int x,y;
        cin >> x >> y;
        s.insert({x,y});
        dx[x]++;
        dy[y]++;
    }
    
    vector<pair<int,int> > a,b;

    for (int i = 0; i <= 300000; ++i) {
        a.push_back({dx[i], i});
        b.push_back({dy[i], i});
    }

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

    int ans = 0;

    for (int i = 0; i < 300010; ++i) {
        int total = a.back().first + b[i].first;
        if(s.count({a.back().second, b[i].second})) total--;
        int total2 = b.back().first + a[i].first;
        if(s.count({a[i].second, b.back().second})) total2--;
        ans = max({ans, total, total2});
    }

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


Measured memory_bytes: 26044
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    double R;
    cin >> R;
    cout << setprecision(10) << R*6.28318530717958623200 << endl;
}

Measured memory_bytes: 3784
// https://atcoder.jp/contests/abc103/tasks/abc103_d
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, a, b;
    cin >> n >> m;
    multimap<int, int> mp;
    REP(i, m) {
        cin >> a >> b;
        mp.insert({a, b});
    }
    int minv = INF, ans = 1;
    for (auto x : mp) {
        minv = min(minv, x.second);
        if (x.first >= minv) {
            minv = x.second;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int a[10000],n;
	cin >> n;
	int min, max;
	long int sum;
	for (int i = 0; i < n; ){
		cin >> a[i];
		i++;
	}
	sum = 0;
	min = a[0];
	max = a[0];
	for (int i = 0; i < n; i++){
		sum += (long int)a[i];
		if (max < a[i])max = a[i];
		if (min > a[i])min = a[i];
	}
	cout << min << ' ' << max << ' ' << sum << endl;
	return 0;
}


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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	int N,a = 1000;
  cin >> N;
  while(N > a){
    a += 1000;
  }
  cout << a - N << endl;

return 0;
}

Measured memory_bytes: 3676
import datetime

h1, m1, h2, m2, k = map(int, input().split())

wake_up = datetime.timedelta(hours=h1, minutes=m1)
go_to_bed = datetime.timedelta(hours=h2, minutes=m2)
study_time = datetime.timedelta(minutes=k)

ans = (go_to_bed - study_time) - wake_up
print(ans.seconds // 60)

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

int main(void) {
    int K,N;
    cin>>K>>N;
    vector<int> vc;
    for (int i = 0; i < N; i++) {
        int A;
        cin>>A;
        vc.push_back(A);
    }
    sort(vc.begin(), vc.end());

    vector<int> vcn;
    for (int i = 0; i < 3 * N; i++) {
        if (i < N) vcn.push_back(vc.at(i) - K);
        else if (i < 2 * N) vcn.push_back(vc.at(i - N));
        else vcn.push_back(vc.at(i - 2 * N) + K);
    }

    vector<int> distance;
    for (int i = 0; i < 2 * N; i++) {
        distance.push_back(vcn.at(i + N - 1) - vcn.at(i));
    }
    sort(distance.begin(), distance.end());
    cout << distance.at(0) << endl; 
    return 0;
}

Measured memory_bytes: 8556
#include <bits/stdc++.h>
using namespace std;
bool ispalin(string s)
{
	string t=s;
	reverse(t.begin(),t.end());
	return s==t;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s,s1,s2;
	cin>>s;
	int l=s.size();
	s1=s.substr(0,l/2);
	s2=s.substr((l/2+1),l/2);
	//cout<<s1<<" "<<s2<<endl;
	if(ispalin(s)&&ispalin(s1)&&ispalin(s2)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*ILTH      ILTH            ILTHILTHILTH    ILTH        ILTH
  ILTH      ILTH                ILTH        ILTH        ILTH
  ILTH      ILTH                ILTH        ILTHILTHILTHILTH
  ILTH      ILTH                ILTH        ILTH        ILTH
  ILTH      ILTHILTHILTH        ILTH        ILTH        ILTH

  */
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const int maxN=65;

bool f[maxN];
int L,hs,cnt,d[maxN];
vector<int> h[maxN];
int dfs(int u){
    if (f[u]) return d[u];

    for (int i=0; i<h[u].size(); ++i){
        int v=h[u][i];
        cout << u << " " << v << " " << d[u] << "\n";
        d[u]+=dfs(v);
    }
    f[u]=true;
    return d[u];
}
int main()
{
    cin >> L;
    if (L==1){
        cout << "2 1\n1 2 0";
        return 0;
    }
    int mu=1;hs=1;
    while (mu*2<=L){
        mu*=2;
        hs++;
    }
    for (int i=1; i<=hs-1; ++i){
        h[i].pb(i+1);h[i].pb(i+1);cnt+=2;
        if (L & (1<<(i-1))) h[i].pb(hs),cnt++;
    }
    f[hs]=true;d[hs]=1;
    cout << hs << " " << cnt << "\n";
    dfs(1);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
#pragma warning(disable:4996)
vector<pair<int, int>>x[7], y[7]; int H, W; char S[1005];
vector<int>dp[7];
int main() {
	while (true) {
		cin >> W >> H; for (int i = 0; i < 7; i++)x[i].clear(); if (H == 0 && W == 0)break;
		for (int i = 0; i < H; i++) {
			scanf("%s", &S);
			for (int j = 0; j < W; j++) {
				if (S[j] == 'S') { x[0].push_back(make_pair(i, j)); }
				if (S[j] >= '1' && S[j] <= '5') { x[S[j] - '0'].push_back(make_pair(i, j)); }
				if (S[j] == 'G') { x[6].push_back(make_pair(i, j)); }
			}
		}
		int minx = 999999999, minid = -1;
		for (int i = 0; i < 5; i++) {
			vector<pair<int, int>>H = x[1]; x[1].clear(); x[1].push_back(x[0][0]);
			for (int j = 0; j < 7; j++) {
				dp[j].resize(x[j].size());
				for (int k = 0; k < dp[j].size(); k++)dp[j][k] = 999999999;
			}
			dp[1][0] = 0;
			for (int j = 2; j < 7; j++) {
				for (int k = 0; k < x[j - 1].size(); k++) {
					for (int l = 0; l < x[j].size(); l++) {
						int d = abs(x[j - 1][k].first - x[j][l].first) + abs(x[j - 1][k].second - x[j][l].second);
						dp[j][l] = min(dp[j][l], dp[j - 1][k] + d);
					}
				}
			}
			x[1] = H;
			for (int j = 1; j <= 5; j++)y[j] = x[j];
			for (int j = 1; j <= 5; j++)x[j] = y[j % 5 + 1];
			if (minx > dp[6][0]) { minx = dp[6][0]; minid = i + 1; }
		}
		if (minx == 999999999)cout << "NA" << endl;
		else cout << minid << ' ' << minx << endl;
	}
	return 0;
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int n;
    string s;
    cin >> n >> s;

    vector<int> dp(n+1);
    for (int i=1; i<n; i++) {
        dp[i] = dp[i % __builtin_popcount(i)]+1;
    }

    int cnt = 0;
    for (char c : s) {
        cnt += c - '0';
    }

    int cnt2 = max(1, cnt-1);
    int cnt3 = cnt+1;
    int x = 0, x2 = 0, duh = 1, duh2 = 1;
    for (auto c = s.rbegin(); c != s.rend(); c++) {
        if (*c == '1') {
            x = (x+duh) % cnt2;
            x2 = (x2+duh2) % cnt3;
        }
        duh = duh*2 % cnt2;
        duh2 = duh2*2 % cnt3;
    }

    vector<int> ans(n);
    duh = 1, duh2 = 1;
    for (int i=0; i<n; i++) {
        if (s[n-1-i] == '0') {
            ans[n-1-i] = dp[ (x2 + duh2) % cnt3 ];
        } else {
            if (cnt == 1) ans[n-1-i] = -1;
            else {
                auto idk = (x - duh) % cnt2;
                if (idk < 0) idk += cnt2;
                ans[n-1-i] = dp[idk];
            }
        }
        duh = duh*2 % cnt2;
        duh2 = duh2*2 % cnt3;
    }
    for (int e : ans) cout << e+1 << "\n";
}


Measured memory_bytes: 5196
#include<bits/stdc++.h>
using namespace std;
const int64_t maxn=100, maxv=100001, maxw=1e9+1;
int64_t n,W,memo[maxv][maxn],v[maxn],w[maxn];
int64_t td(int64_t rv, int64_t i){
  //cout<<rv<<' '<<i<<endl;
  if(rv<=0) return 0;
  if(i==n) return maxw;
  if(memo[rv][i]!=-1) return memo[rv][i];
  return memo[rv][i]=min(td(rv,i+1),w[i]+td(rv-v[i],i+1));
}
int main(){
  cin>>n>>W;
  for (size_t i = 0; i < n; i++) {
    cin>>w[i]>>v[i];
    for (size_t j = 0; j < maxv; j++) {
      memo[j][i]=-1;
    }
  }
  int64_t lb=0, ub=1e5;
  while((ub-lb)>1){
    int64_t m=(ub+lb)/2;
    int64_t cw=td(m,0);
    //cout<<m<<' '<<cw<<endl;
    if(cw<=W) lb=m;
    else ub=m;
  }
  if(td(lb+1,0)<=W) lb++;
  cout<<lb<<'\n';
  return 0;
}


Measured memory_bytes: 81696
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
typedef vector<P> vP;
typedef vector<ll> vl;
typedef vector<int> vi;
int main() {
	int n;
	ll D;
	cin >> n >> D;
	vl d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	int m;
	cin >> m;
	vi q(m);
	for (int i = 0; i < m; i++) {
		cin >> q[i];
		q[i]--;
	}
	int md = 1;
	vl B(n + 1);
	B[n] = 1;
	for (int i = n-1; i >= 0; i--) {
		if (B[i + 1] * 2 <= d[i]) {
			B[i] = B[i + 1];
		}
		else {
			B[i] = B[i + 1] + d[i];
		}
	}
	
	vl C(n+1);
	C[0] = D;
	for (int i = 1; i <= n;i++) {
		ll x = abs(C[i - 1] - d[i-1]);
		C[i] = min(C[i-1], x);
	}
	if (C[n] != 0) {
		for (int i = 0; i < m; i++) {
			cout << "YES" << endl;
		}
		return 0;
	}
	//for (int i = 0; i < n; i++) {
	//	cout << B[i] << " " << C[i]  <<" "<<d[i]<< endl;
	//}
	for (int i = 0; i < m; i++) {
		if (C[q[i]] >= B[1+q[i]]) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

}

Measured memory_bytes: 17280
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	int a; cin >> a;
	if (a > 999)cout << "ABD" << endl;
	else cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a = [input() for _ in range(h)]

row = [False] * h
col = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end = "")
    print()

Measured memory_bytes: 4468
#include <iostream>
#include <algorithm>
#include <climits>
#define N 2010
#define LL long long
using namespace std;

LL a[N];
LL b[N][N];
int main(int argc, char* argv[])
{
    int n, x;
    while(cin >> n >> x) {
        for(int i = 0; i < n ; ++i ) {
            cin >> a[i];
        }
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < n; ++j) {
                if(j == 0) b[i][j] = a[i];
                else b[i][j] = min(b[i][j-1], a[(i + n - j) % n]);
            }
        }
        LL re = LLONG_MAX;
        for(int i = 0; i < n; ++i) {
            LL ans = (LL)i * x;
            for(int j = 0; j < n; ++j) {
                ans += b[j][i];
            }
            re = min(re, ans);
        }
        cout << re << endl;
    }
    return 0;
}

Measured memory_bytes: 31616
function Main(arg) {
  var k = arg.split("\n")[0] - 0;

  if (k <= 12) {
    console.log(k);
    return;
  }

  var ans = 12;
  var answer = new Array(k+1);
  for (var i = 13; i <= k; i++) {
    ans++;
    while (1) {
      var tmp = ans.toString().split("").map(Number);
      var f = true;
      for (var j = 0; j < tmp.length-1; j++) {
        if (Math.abs(tmp[j] - tmp[j + 1]) > 1) {
          f = false;
          if (tmp[j] - tmp[j + 1] > 1) {
            tmp[j + 1]++;
          }
          else if (tmp[j] - tmp[j + 1] < -1) {
            tmp[j]++;
            tmp[j + 1] = 0;
          }
          ans = tmp.join('') - 0;
          break;
        }
      }

      if (f) {
        break;
      }
    }
    answer[i] = ans;
  }

  console.log(answer[k]);
  return;
}

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

Measured memory_bytes: 24164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    ll a, v, b, w, t; cin >> a >> v >> b >> w >> t;
    ll distance = abs(b - a);
    ll dif_velocity = v - w;
    if(dif_velocity > 0 && dif_velocity * t >= distance) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



int main(){
    int n; cin >> n;
    vi l(n); cin >> l;
    sort(l.begin(),l.end());
    //cout << l << endl;

    ll ans = 0;

    rep(i,n-2){
        rep(j,i+2,n){
            int s = l[j] - l[i];
            int L = l[j] + l[i];

            auto ss = upper_bound((l.begin()+i+1),(l.begin()+j),s);
            auto ll = lower_bound((l.begin()+i+1),(l.begin()+j),L);

            //cout << *ss <<" " << *ll << endl;
            //cout << ll-ss << endl;

            ans += (ll - ss);

        }
    }

    cout << ans << endl;
    //cout << *(l.end()-1) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

void solve() {
  vector<int> v(5);

  int ans = 0;
  int m = 10;
  for (int &x : v) {
    cin >> x;

    if (x % 10 == 0) {
      ans += x;
    } else {
      ans += x - (x % 10) + 10;
      m = min(x % 10, m);
    }
  }

  if (m != 10) {
    ans -= 10 - m;
  }

  cout << ans << endl;
}

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


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

#define ll long long
#define ar array

int n, m, k, ans=0;
string g[6], gc[6];

void chk(int a, int b) {
	for (int i=0; i<n; ++i) gc[i]=g[i];
	for (int i=0; i<n; ++i)
		if (a&(1<<i))
			for (int j=0; j<m; ++j) gc[i][j]='0';
	for (int i=0; i<m; ++i)
		if (b&(1<<i))
			for (int j=0; j<n; ++j) gc[j][i]='0';
	int cnt=0;
	for (int i=0; i<n; ++i)
		cnt+=count(gc[i].begin(), gc[i].end(), '#');
	ans+=cnt==k;
}

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

	cin >> n >> m >> k;
	for (int i=0; i<n; ++i)
		cin >> g[i];
	for (int i=0; i<(1<<n); ++i)
		for (int j=0; j<(1<<m); ++j)
			chk(i, j);
	cout << ans;
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 3656
import math
import string


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


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


r, D, x = map(int, input().split())
xx = []
xx.append(r*x-D)
print(r*x-D)
for i in range(9):
    a = r*xx[i]-D
    print(a)
    xx.append(a)


Measured memory_bytes: 4084
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

// Element for Deque
type Element struct {
	value int
}

// Stack based on array
type Stack struct {
	array []Element
}

// NewStack is constructer of Stack
func NewStack() *Stack {
	s := new(Stack)
	return s
}

func (s *Stack) push(x int) {
	element := Element{value: x}
	s.array = append(s.array, element)
}

func (s *Stack) top() (bool, int) {
	if len(s.array) == 0 {
		return false, -1
	}

	top := s.array[len(s.array)-1]
	return true, top.value
}

func (s *Stack) pop() (bool, int) {
	if len(s.array) == 0 {
		return false, -1
	}

	l := len(s.array) - 1
	top := s.array[l]
	s.array = s.array[:l]
	return true, top.value
}

func main() {
	scanner.Split(bufio.ScanWords)
	nStacks := nextInt()
	nQueries := nextInt()

	stacks := make([]Stack, nStacks)

	for i := 0; i < nQueries; i++ {
		queryType := nextInt()
		iStack := nextInt()

		if queryType == 0 {
			x := nextInt()
			stacks[iStack].push(x)
		} else if queryType == 1 {
			ok, value := stacks[iStack].top()
			if ok {
				fmt.Println(value)
			}
		} else {
			stacks[iStack].pop()
		}
	}
}



Measured memory_bytes: 8788
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  vector< int > a;
  int i = 0;
  while(i < n){
    int j = i + 1;
    while(j < n && s[i] == s[j]){
      ++j;
    }
    a.push_back(j - i);
    i = j;
  }

  int m = a.size();

  int d = (s[0] == '1' ? 1 : 0);

  i = 0;
  int j = 0;
  int ans = 0;
  int sum = 0;
  while(i < m){
    while(j < m && j < i + 2 * k + d){
      sum += a[j];
      ++j;
    }
    ans = max(ans, sum);
    sum -= a[i];
    d = (d == 0 ? 1 : 0);
    ++i;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1020
import java.util.ArrayList;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Double> stdDev = new ArrayList<>();
		while(true) {
			int n = sc.nextInt();
			if(n == 0) {
				break;
			}
			double[] num = new double[n];
			for(int i = 0; i < n; i++) {
				num[i] = sc.nextDouble();
			}
			stdDev.add(sd(num));
		}
		for(double value: stdDev) {
			System.out.println(value);
		}
	}

	public static double sd(double[] num) {
		double sum = 0;
		for(double value: num) {
			sum += value;
		}
		double mean = sum / num.length;
		
		double sd = 0;
		for(double value: num) {
			sd += Math.pow(value - mean, 2);
		}
		sd = Math.sqrt(sd / num.length);
		return sd;
	}
}



Measured memory_bytes: 38912
/*
 * AtCoder Beginner Contest 166 C - Peaks
 *
 * Time: 296ms
 * Memory: 3624KB
 *
 * Author: DragonLee
 */

#include <iostream>
#include <map>
#include <set>

using namespace std;
typedef long long LL;
const int LEN = 1e5 + 10;
int height[LEN];

int main() {
    int N, M;
    cin >> N >> M;
    map<int, set<int> > m;
    for (int i = 1; i <= N; i++) {
        cin >> height[i];
    }

    while (M--) {
        int posl, posr;
        cin >> posl >> posr;
        m[posl].insert(posr);
        m[posr].insert(posl);
    }
    set<int> s;
    map<int, set<int> >::iterator it = m.begin();
    int ans = 0;
    for (; it != m.end(); it++) {
        int flag = 1;
        set<int>::iterator it_s = it->second.begin();
        for (; it_s != it->second.end(); it_s++) {
            s.insert(*it_s);
            if (height[it->first] <= height[*it_s]) {
                flag = 0;
            }
        }
        if (flag) {
            ans += 1;
        }
    }
    cout << ans + (N - s.size()) << endl;
    return 0;
}


Measured memory_bytes: 25528
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define vi vector<ll>
#define pb push_back
#define pi pair<vi, vi>
#define F first
#define S second

int main() {
  ll n, a, b, W;
  cin >> n >> W;
  ll values[n], weights[n];
  for (ll i = 0; i < n; i++) {
    cin >> a >> b;
    weights[i] = a;
    values[i] = b;
  }
  ll dp[n + 1][W + 1];
  for (ll i = 0; i <= n; i++) {
    for (ll j = 0; j <= W; j++) {
      if (i == 0 || j == 0) {
        dp[i][j] = 0;
      } else if (weights[i - 1] <= j) {
        dp[i][j] = max(values[i - 1] + dp[i-1][j - weights[i - 1]], dp[i - 1][j]);
      } else {
        dp[i][j] = dp[i - 1][j];
      }
    }
  }
  // for (ll i = 0; i <= n; i++) {
  //   for (ll j = 0; j <= W; j++) {
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  cout << dp[n][W] << endl;
  return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <cmath>
#include <sstream>
using namespace std;

bool isPrime(int n){
	for(int k=2;k<n;k++){
		if(n%k==0){
			return false;
		}
	}
	return true;
}

int main() {
	int n,min,max;
	while(cin>>n){
		bool f1=false,f2=false;
		for(int i=1;i<n;i++){
			if(!f1){
				f1=isPrime(n-i);
				if(f1){min=n-i;}
			}
			if(!f2){
				f2=isPrime(n+i);
				if(f2){max=n+i;}
			}
		}cout<<min<<" "<<max<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T>
class Comvex_Hull_Trick{
private:
    typedef pair<T,T> line; //y切片,傾き
    deque<line> D;
    
    inline T point(const line &L,const T &x) const {return L.F+L.S*x;}
    
    inline bool is_need(const line &A,const line &B,const line &C) const {
        return (C.F-A.F)*(A.S-B.S)>(B.F-A.F)*(A.S-C.S);
    }
    
public:
    Comvex_Hull_Trick(){}
    
    void add_line(const line &L){
        //while(!D.empty() && D.back().S==D.back().S){L.F=min(L.F,D.back().F); D.pop_back();}
        while(D.size()>=2 && !is_need(D[D.size()-2],D.back(),L)){D.pop_back();}
        D.push_back(L);
    }
    
    T search(const T &x) const {
        ll l=0;
        ll r=D.size()-1;
        while(l+1<r){
            ll m=l+(r-l)/2;
            if(point(D[m],x)<point(D[m+1],x)){r=m;}
            else{l=m+1;}
        }
        for(ll i=l;i<r;i++){
            if(point(D[i],x)<point(D[i+1],x)){return point(D[i],x);}
        }
        return point(D[r],x);
    }
    
    pair<T,T> search_line(const T &x) const {
        ll l=0;
        ll r=D.size()-1;
        while(l+1<r){
            ll m=l+(r-l)/2;
            if(point(D[m],x)<point(D[m+1],x)){r=m;}
            else{l=m+1;}
        }
        for(ll i=l;i<r;i++){
            if(point(D[i],x)<point(D[i+1],x)){return D[i];}
        }
        return D[r];
    }
    
    pair<T,T> back() const {return D.back();}
    
    unsigned long size() const {return D.size();}
    
    bool empty() const {return D.empty();}
};


int main(){
    ll s,n,m;
    cin>>s>>n>>m;
    vector<ll> A(s);
    for(auto &I:A){cin>>I;}
    vector<ll> time(n);
    for(auto &I:time){
        ll b;
        cin>>I>>b;
        b--; I-=A[b];
    }
    sort(time.begin(),time.end());
    ll sum=0;
    for(ll i=n-1;i>=0;i--){time[i]-=time[0]; sum+=time[i];}
    vector<ll> dp(m+1,E);
    vector<Comvex_Hull_Trick<ll>> C(m+1);
    C[0].add_line({0,0});
    for(int i=1;i<=n;i++){
        for(auto &I:dp){I=E;}
        for(int t=1;t<=m;t++){
            if(C[t-1].empty()){continue;}
            dp[t]=C[t-1].search(time[i-1]);
            dp[t]+=time[i-1]*i;
            C[t].add_line({dp[t],-1*i});
        }
    }
    ll ans=E;
    for(int i=0;i<=m;i++){
        ans=min(ans,dp[i]);
    }
    ans-=sum;
    cout<<ans<<endl;
    
    
    return 0;
}



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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CStrangeDance {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n;
      cin >> n;
      string t;
      cin >> t;

      // initialize vector size
      vector<vector<vector<int>>> v(3, vector<vector<int>>(n));
      int k = 1;
      rep(i, n) {
        rep(j, 3) {
          v[j][i].resize(k);
        }
        k *= 3;
      }
      int K = k;

      // initialize vector
      rep(i, n) {
        int idx = 0;
        rep(j, 3) {
          for(auto& e: v[j][i]) {
            e = idx;
            idx++;
          }
        }
      }

      for(auto c: t) {
        if (c=='S') {
          // swap vector
          swap(v[1], v[2]);
        } else {
          // swap by point
          int w = 0;
          rep(i, n) {
            auto v0 = v[0][i][w];
            auto v1 = v[1][i][w];
            auto v2 = v[2][i][w];
            v[1][i][w] = v0;
            v[2][i][w] = v1;
            v[0][i][w] = v2;
            w = v2;
          }
        }
      }

      // recover
      vector<int> ans(K);
      k = 1;
      rep(i, n) {
        for(int j=1; j<=2; j++) {
          for(auto e: v[j][i]) {
            for(int idx=e; idx<K; idx+=(k*3)) {
              ans[idx] += j*k;
            }
          }
        }
        k *= 3;
      }

      for(auto e: ans) {
        cout << e << ' ';
      }
      cout << endl;

    }
};

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

Measured memory_bytes: 9368
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         998244353 
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}
void solve(){   
    char x;
    cin >> x;
    if(x >= 'A' && x <= 'Z')cout << "A";
    else cout << "a";
}

signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){   
        solve();
        //cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...


Measured memory_bytes: 3652
#include <iostream>
#include <math.h>
using namespace std;

bool range(int x, int min, int max){
    if(x >= min && x <= max){
        return true;
    }
    else{
        return false;
    }
}
int main(void){
    
    int K, S;
    cin >> K >> S;
    
    int ans = 0;
    for(int i=0; i<K+1; i++){
        for(int j=0; j<K+1; j++){
            int k = S - i - j;
            if(range(k, 0, K)){
                ans++;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  long long a;
  string b;
  cin >> a >> b;
  long long b2 = (b.at(0) - '0') * 100 + (b.at(2) - '0') * 10 + (b.at(3) - '0');
  cout << a * b2 / 100ll << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(void)
{
	int h1,h2,k1,k2,a,b,c,d,h,k;
	scanf("%d %d %d %d %d %d %d %d",&h1,&h2,&k1,&k2,&a,&b,&c,&d,&h,&k);
	h=(h1/10)*c+h1*a+(h2/20)*d+h2*b;
	k=(k1/10)*c+k1*a+(k2/20)*d+k2*b;
	if(h<k)
	printf("kenjiro\n");
	if(h>k)
	printf("hiroshi\n");
	if(h==k)
	printf("even\n");
	return 0;
}

Measured memory_bytes: 584
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　| 　_　 _ l
　 　　　／` ミ＿xノ
　　 　 /　　　 　 |　見ちゃだめだよ！
　　　 /　 ヽ　　 ﾉ　　
　 　 │　　|　|　|　　
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)__)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  int T = 0;
  int X = 0;
  int Y = 0;
  bool ans = true;
  rep(i, n) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t - T < abs(x - X) + abs(y - Y)) ans = false;
    if ((t - T) % 2 != (abs(x - X) + abs(y - Y)) % 2) ans = false;
    T = t;
    X = x;
    Y = y;
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
use std::io;

fn main() {
  let mut s = String::new();
  io::stdin()
    .read_line(&mut s)
    .expect("");

  let s: i32 = s.trim().parse().unwrap();

  let (h, m, s) = (s / 3600, s / 60 % 60, s % 60);

  println!("{}:{}:{}", h, m, s);
}



Measured memory_bytes: 5032
#include<bits/stdc++.h>
#define scan($) scanf("%d",&$)
using namespace std;
int main()
{
    int n;string ch;
    scan(n);
    int AC=0,TLE=0,WA=0,RE=0;
    for(auto i=0; i<n; i++)
    {
        cin>>ch;
        if(ch=="AC")
            AC++;
        if(ch=="TLE")
            TLE++;
        if(ch=="WA")
            WA++;
        if(ch=="RE")
            RE++;
    }
    cout<<"AC x "<<AC<<'\n'<<"WA x "<<WA<<'\n'<<"TLE x "<<TLE<<'\n'<<"RE x "<<RE<<'\n';
    return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

const int WHITE = 0, GREY = 1, BLACK = 2;

struct DFS {
    int n;
    vector<vector<int>> g;
    vector<int> color;
    int ct = 1; //current time
    vector<int> dt; //discover time
    vector<int> ft; //finish time
    
    DFS(int n) : n(n) {
        g.assign(n, vector<int>());
        color.assign(n, WHITE);
        dt.assign(n, -1);
        ft.assign(n, -1);
    }
    
    void addEdge(int u, int v) {
        g[u].push_back(v);
    }
    
    void dfs() {
        for (int i = 0; i < n; i++) {
            if (color[i] == WHITE) {
                dfsVisit(i);
            }
        }
    }
    
    void dfsVisit(int u) {
        //cout << "visited: " << u << endl;
        color[u] = GREY;
        dt[u] = ct++; //first assign ct to dt[u], then ++
        for (int v : g[u]) {
            if (color[v] == WHITE) {
                dfsVisit(v);
            }
        }
        color[u] = BLACK;
        ft[u] = ct++;
    }
    
    void printGraph() {
        for (int i = 0; i < n; i++) {
            cout << i << ": ";
            for (int j : g[i]) {
                cout << j << " ";
            }
            cout << endl;
        }
    }
    
    void printResults() {
        for (int i = 0; i < n; i++) {
            cout << i + 1 << " " << dt[i] << " " << ft[i] << endl;
        }
    }
};

int main() {
    int n;
    cin >> n;
    DFS dfs(n);
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            dfs.addEdge(u - 1, v - 1);
        }
    }
    
    //dfs.printGraph();
    dfs.dfs();
    dfs.printResults();
    
    return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int digit(int n){
    int count = 0;
    while(n!=0){
        n /= 10;
        count++;
    }
    return count;
}

int main(){
    string s;
    cin >> s;
    int ans1=0,ans2=0;//ans1は'0'start,ans2は'1'start;
    REP(i,s.size()){
        if(i%2==0){
            if(s[i]=='0')ans2++;
            else ans1++;
        }
        else{
            if(s[i]=='0')ans1++;
            else ans2++;
        }
    }
    COUT(min(ans1,ans2));
    return 0;
} 


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) { cin >> a[i]; }
    ll s = a[0];
    for(int i = 1; i < N; i++) {
        s ^= a[i];
    }
    // cout << s << endl;
    if(s == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
  long long X,Y;
  cin >> X >> Y;
  string check = "No";
  if (Y % 2 == 0){
    if (2*X-Y/2>=0 && -X+Y/2>=0){
      check = "Yes";
    }
  }
  cout << check;
}

Measured memory_bytes: 3628
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

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

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

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

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

    llong N, K;
    cin >> N >> K;

    vecllong H(N + 1);
    FOR(i, N) {
        cin >> H[i];
    }

    vecllong dp(N + 1, INF);
    dp[0] = 0;

    FOR(i, N) {
        FORS(k, 1, K + 1) {
            if(i + k > N) {
                break;
            }
            dp[i + k] = min(dp[i + k], dp[i] + abs(H[i] - H[i + k]));
        }
    }

    cout << dp[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mod 1000000007
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, a;
    cin >> h >> a;
    int ans = (h + a - 1)/a;
    cout << ans << "\n";
    
	return 0;
}



Measured memory_bytes: 256
#B

import math

n,d = (int(x) for x in input().split())
x = []

for i in range(n):
    temp = [int(x) for x in input().split()]
    x.append(temp)

count = 0
for i in range(n):
    for j in range(i+1,n):
        temp = 0
        for k in range(d):
            temp += (x[i][k] - x[j][k]) ** 2
        temp = math.sqrt(temp)    
        if temp == int(temp):
            count += 1
            
print(count)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  string S;
  cin >> S;
  ll N = S.size();

  ll ans = 0;
  for (ll i = 0; i < N; i++)
  {
    for (ll j = i; j < N; j++)
    {
      bool ok = true;
      for (ll k = i; k <= j; k++)
      {
        const string T = "ACGT";
        bool ok2 = false;
        for (ll l = 0; l < 4; l++)
        {
          if (S.at(k) == T.at(l))
          {
            ok2 = true;
            break;
          }
        }
        if (!ok2)
        {
          ok = false;
          break;
        }
      }
      
      if (ok)
        chmax(ans, j - i + 1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 998244353

def solve():
    n,s = LI()
    a = LI()
    ans = 0
    dp = [0]*(s+1)
    for i in range(n):
        ai = a[i]
        for j in range(s+1)[::-1]:
            nj = j+ai
            if nj > s:
                continue
            dp[nj] += dp[j]
            dp[nj] %= mod
        if ai <= s:
            dp[ai] += i+1
            dp[ai] %= mod
        ans += dp[s]
        ans %= mod
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


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

int main()
{
	string arg, arg2;
	
	cin >> arg;
	cin >> arg2;
	arg += arg;
	
	if (arg.find(arg2) == string::npos)
	{
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	return 0;
}

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


int dig(long long N){
	
	if(N == 0)
		return 1;
	
	int cnt = 0;
	while(N > 0){
		N /= 10;
		cnt++;
	}
	
	return cnt;
}

int main(){
	
	long long N; scanf("%lld", &N);
	
	int ans = dig(N);
	
	for(long long i = 1; i * i <= N; ++i){
		if(N % i != 0)
			continue;
			
		int r = dig(N / i);
		
		if(r < ans)
			ans = r;
	}
	
	printf("%d", ans);
	
return 0;	
}


Measured memory_bytes: 128
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using static System.Console;
using static System.Math;
public class Program
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int div = 2;
        int ans = -1;
        bool fin = true;
        while(fin){
            foreach (var item in input)
            {
                if ((item % div) != 0){
                    fin = false;
                }
            }
            div *= 2;
            ans++;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
from copy import copy
N, *A = open(0).read().split()
N = int(N)
S = ['S', 'H', 'D', 'C']
T = [0 for _ in range(N)]
for id, s in enumerate(A):
    T[id] = S.index(s[0]) * 9 + int(s[1]) - 1
B, C = copy(T), copy(T)
for i in range(N):
    for j in range(N-1, i, -1):
        if B[j] % 9 < B[j-1] % 9:
            B[j], B[j-1] = B[j-1], B[j]
B = list(map(lambda n: S[n // 9] + str(n % 9 + 1), B))
print(' '.join(B))
print('Stable')
for i in range(N):
    minj = i
    for j in range(i, N):
        if C[j] % 9 < C[minj] % 9:
            minj = j
    if i != minj:
        C[i], C[minj] = C[minj], C[i]
C = list(map(lambda n: S[n // 9] + str(n % 9 + 1), C))
print(' '.join(C))
print('Stable' if B == C else 'Not stable')


Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
 #define int long long
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
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;};

int cnt(int n) {
  string s = to_string(n);
  return s.size();
}

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

  int N;
  cin >> N;
  int res = cnt(N);
  int end = sqrt(N) + 2;
  REP(i, 1, end) {
    if(N % i == 0) {
      int t = max(cnt(i), cnt(N / i));
      res = min(res, t);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

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

Measured memory_bytes: 888