akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;

struct edge{
    int from, to;
    int64_t cost;
    edge(int a=0, int b=0, int64_t c=0LL):from(a), to(b), cost(c) {}
};

// サイズ,辺の情報,初期化の必要あり
vector<edge> es;

const int64_t INF = INT64_MAX/10LL;

// sは始点,vは頂点数
vector<int64_t> bellman(int s, int v) {
    vector<int64_t> d(v, INF);
    int E = es.size();
    d[s] = 0LL;
    int cou = 0;
    while(true) {
        bool update = false;
        bool ch = false;
        for(int i = 0; i < E; ++i) {
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
                if(e.to == v-1) ch = true;
            }
        }
        if(!update) break;
        if(cou == 2*v) {
            if(ch) d[s] = INF;
            break;
        }
        cou++;
    }
    return d;
}



int main() {
    int n, m;
    cin >> n >> m;
    es.resize(m);
    rep(i, m) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        --a;
        --b;
        es[i] = edge(a, b, -c);
    } 

    vector<ll> d = bellman(0, n);
    if(d[0] == INF) {
        cout << "inf" << endl;
    } else {
        cout << -d[n-1] << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int a, b, c; cin >> a >> b >> c;
    req(i, a, b+1)if (i<a + c || i>b - c)cout << i << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    string s,t;
   cin>>s>>t;
   cout<<t+s<<e;


}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::vector<ll> vll;
typedef std::vector<vll> vvll;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n;
  scan(n);
  vi l(n);
  scan(l);
  sort(all(l));
  int sum = 0;
  rep (i, n-1) {
    sum += l[i];
  }
  if (sum > l[n-1]) {
    print("Yes");
  } else {
    print("No");
  }
  return 0;
}


Measured memory_bytes: 888
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n;
	cin >> n;
	
	cout << (n + 1) / 2 << endl;
}

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


int main(){

    int x,y;
    for(int i = 0;i<3000;i++){
        scanf("%d%d",&x,&y);
        if(x == 0 && y == 0){
            break;
        }
        if(x<y){
            printf("%d %d\n",x,y);
        }else{
            printf("%d %d\n",y,x);
        }
    }
    return 0;
}



Measured memory_bytes: 2604
#include <bits/stdc++.h>
using namespace std;
struct E{
	int to;
	int clr;
	int len;
};
vector<E> g[100005];
int anc[18][100005],d[100005];
void dfs(int u,int fa){
	for(auto v:g[u]){
		if(v.to==fa){
			continue;
		}
		anc[0][v.to]=u;
		d[v.to]=d[u]+1;
		dfs(v.to,u);
	}
}
int LCA(int x,int y){
	if(d[x]>d[y]){
		swap(x,y);
	}
	for(int ind=0;d[x]<d[y];++ind){
		if((d[y]-d[x])>>ind&1){
			y=anc[ind][y];
		}
	}
	if(x==y){
		return x;
	}
	for(int ind=18;ind--;){
		if(anc[ind][x]!=anc[ind][y]){
			x=anc[ind][x],y=anc[ind][y];
		}
	}
	return anc[0][x];
}
struct info{
	int ind;
	char typ;
	int clr;
	int cnt;
	info(){}
	info(int in,char ty,int cl,int cn){
		ind=in,typ=ty,clr=cl,cnt=cn;
	}
}; 
vector<info> q[100005];
int sum[100005];
int cnt[100005];
int ans[100005];
void DFS(int u,int fa,int len){
	for(auto now:q[u]){
		if(now.typ=='d'){
			ans[now.ind]+=len*now.cnt;
		}
		else if(now.typ=='s'){
			ans[now.ind]+=sum[now.clr]*now.cnt;
		}
		else{
			ans[now.ind]+=cnt[now.clr]*now.cnt;
		}
	}
	for(auto v:g[u]){
		if(v.to==fa){
			continue;
		}
		sum[v.clr]+=v.len;
		cnt[v.clr]++;
		DFS(v.to,u,len+v.len);
		sum[v.clr]-=v.len;
		cnt[v.clr]--;
	}
}
int main(){
	int n,Q;
	cin>>n>>Q;
	for(int i=1;i<n;++i){
		int u,v,clr,leng;
		cin>>u>>v>>clr>>leng; 
		u--,v--,clr--;
		E a;
		a.to=v,a.len=leng,a.clr=clr;
		E b;
		b.to=u,b.len=leng,b.clr=clr;
		g[u].push_back(a),g[v].push_back(b);
	}
	dfs(0,0);
	for(int ind=0;ind<17;++ind){
		for(int u=0;u<n;++u){
			anc[ind+1][u]=anc[ind][anc[ind][u]];
		}
	}
	for(int i=0;i<Q;++i){
		int clr,leng,u,v;
		cin>>clr>>leng>>u>>v;
		clr--;
		u--;
		v--;
		int lca=LCA(u,v);
		q[u].emplace_back(i,'d',0,1);
		q[u].emplace_back(i,'s',clr,-1);
		q[u].emplace_back(i,'c',clr,leng);
		q[v].emplace_back(i,'d',0,1);
		q[v].emplace_back(i,'s',clr,-1);
		q[v].emplace_back(i,'c',clr,leng);
		q[lca].emplace_back(i,'d',0,-2);
		q[lca].emplace_back(i,'s',clr,2);
		q[lca].emplace_back(i,'c',clr,-2*leng);
	}
	DFS(0,0,0);
	for(int i=0;i<Q;++i){
		cout<<ans[i]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 46040
#include<string>
#include<iostream>

using ll = long long;
using namespace std;

int main()
{
    string s;
    ll k;
    cin >> s >> k;

    bool flag = true;
    int n = s.size();

    for(int i = 1; i < n; i++)
    {
        if(s[i] != s[i-1]) flag = false;
    }

    if(flag)
    {
        // same characters
        cout << n * k / 2 << endl;
    }
    else
    {
        ll cnt = 0;
        for(int i = 1; i < n; i++)
        {
            if(s[i] == s[i-1])
            {
                cnt++;
                i++;
            }
        }

        if(s[0] != s[n-1])
        {
            // no same char connection
            cout << k * cnt << endl;
        }
        else
        {
            ll pos = 0;
            while(true)
            {
                if(s[pos] == s[pos+1])
                {
                    pos++;
                }
                else break;
            }
            ll x = pos + 1;
            pos = n-1;
            while(true)
            {
                if(s[pos] == s[pos-1])
                {
                    pos--;
                }
                else break;
            }
            ll y = n-1 - pos + 1;
            if((x + y) % 2 == 1)
            {
                cout << k * cnt << endl;
            }
            else
            {
                cout << (k-1) * (cnt+1) + cnt << endl;
            }
        }
    }
}

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

int n, ans;

int main() {
  cin >> n;
  vector<int> b(n-1);
  rep (i, n-1) {
    cin >> b[i];
  }
  ans = 0;
  ans += b[0];
  ans += b[n-2];
  rep (i, n-2) {
    ans += min(b[i], b[i+1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(){
  long long n,k;
  cin >> n >> k;
  long long a =0;
  long long ans =0;
  for(int i=1;i<=n;i++){
      if(i%k==0){
          a++;
      }
  }
  long long b =0;
  for(int i=1;i<=n;i++){
      if(i%k==k/2){
          b++;
      }
  }
  if(k%2==0){
      ans +=a*a*a;
      ans +=b*b*b;
  }else{
      ans +=a*a*a;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,m=parseMap(split(readline()))
    island=[[] for i in 1:n]
    ans="IMPOSSIBLE"
    for i in 1:m
        a,b=parseMap(split(readline()))
        push!(island[a],b)
        push!(island[b],a)
    end
    for i in island[1]
        if n in island[i]
            ans="POSSIBLE"
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 169564
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;
const ll MOD = 1e9 + 7; 
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a[5];
  int i;
  for(i=0;i<5;i++){
  	cin>>a[i];
  }
  int k;
  cin>>k;
  for(i=0;i<5-1;i++){
  	for(int j=i+1;j<5;j++){
  		if(a[j]-a[i]>k){
  			cout<<":("<<endl;
  			return 0;
		  }
	  }
  }
  
  if(i==4){
  	cout<<"Yay!"<<endl;
  }
  
  return 0;
}

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

int main() {
	// your code goes here
	int n;cin >> n;
	vector<int> v(n,0);
	for(int i=0;i<n;i++) cin >> v[i];
	vector<int> ans(n,0);
	ans[1]=abs(v[1]-v[0]);
	for(int i=2;i<n;i++){
	    ans[i]=min(ans[i-2]+abs(v[i]-v[i-2]),ans[i-1]+abs(v[i]-v[i-1]));
	}
	cout << ans[n-1];
	return 0;
}


Measured memory_bytes: 1024
program c

integer :: n,six(100000),nine(100000),six_nine,i,j
read(*,*) n

do i = 1,n
	six(i) = 0
	do j = 0,6
		six(i) = six(i) + mod(i / (6 ** j),6)
	enddo
enddo

do i = 1,n
	nine(i) = 0
	do j = 0,5
		nine(i) = nine(i) + mod(i / (9 ** j),9)
	enddo
enddo

six_nine = min(six(n),nine(n))

do i= 1,n-1
	six_nine = min(six_nine,six(i)+nine(n-i))
enddo

write(*,*) six_nine

end program

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int x, ans = 8;
	cin >> x;
	if (x >= 600)ans--;
	if (x >= 800)ans--;
	if (x >= 1000)ans--;
	if (x >= 1200)ans--;
	if (x >= 1400)ans--;
	if (x >= 1600)ans--;
	if (x >= 1800)ans--;
	cout << ans << endl;

}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	scanf("%d", &n);
	int t = n, div = 0;
	do {
		div += t % 10;
	} while (t /= 10);
	if (!(n % div)) printf("Yes");
	else printf("No");
}

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

int main(){
	int n, r, rMin, vMax;
	cin >> n >> rMin >> r;
	vMax = r-rMin;
	rMin = min(r, rMin);
	while(cin >> r){
		vMax = max(r-rMin, vMax);
		rMin = min(r, rMin);
	}
	cout << vMax << endl;
	return 0;
}


Measured memory_bytes: 3108
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919810893;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

ll dp[55][2525];
ll x[55];


int main(){

    ll N, A;
    cin >> N >> A;
    dp[0][0] = 1;
    rep1(i, N){
        ll x;
        cin >> x;
        // cout << "#" << x << endl;
        rrep1(num, N)rrep(sum, 2525)if(sum - x >= 0){
            dp[num][sum] += dp[num - 1][sum - x];
            // if(dp[num][sum])cout << num << ", " << sum << " : " << dp[num][sum] << endl;
        }
    }
    ll ans = 0;
    rep1(num, N)rep(sum, 2525)if(A * num == sum)ans += dp[num][sum];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define lson l, mid, i<<1
#define rson mid+1, r, i<<1|1
#define PII pair<int, int>
#define Size(x) (int)(x.size())
using namespace std;
typedef long long LL;
//const int MOD = 1e9+7;
const auto INF = 0x3f3f3f3f;
const int N = 1e5+5;
struct node {
    LL x, y; int id;
}A[5], a[5];

bool cmp(const struct node &u, const struct node &v) {
    if(u.y == v.y)
        return u.id < v.id;
    return u.y < v.y;
}

int main() {
    LL n;
    scanf("%lld%lld%lld%lld%lld", &a[1].x, &a[2].x, &a[3].x, &a[4].x, &n);
    a[1].id = 1, a[2].id = 2, a[3].id = 3, a[4].id = 4;
    for(int i=1; i<=4; i++)
        A[i] = a[i];
    A[1].y = A[1].x*8, A[2].y = A[2].x*4;
    A[3].y = A[3].x*2, A[4].y = A[4].x;
    sort(A+1, A+1+4, cmp);
    LL answer = 0;
    if(n) {
        answer += (n/2)*A[1].y;
        n = n%2;
    }
    for(int i=1; i<=4; i++)
        A[i] = a[i];
    A[1].y = A[1].x*4, A[2].y = A[2].x*2;
    A[3].y = A[3].x*1;
    sort(A+1, A+1+3, cmp);
    if(n) {
        answer += n*A[1].y;
        n = 0;
    }
    printf("%lld\n", answer);
}






Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[15][1100];
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> h >> w >> k;
  rep(i, h) rep(j, w) cin >> s[i][j];
  ans = LINF;
  for (int bit = 0; bit < (1 << (h - 1)); bit++) {
    cnt = 0;
    ll cut[h + 10] = {}, cut_cou = 0, now = 0;
    bool che[w + 10] = {};
    int ok = 1, out;
    rep(i, h) {
      if (bit & (1 << i)) {
        cnt++;
        cut[i] = 1;
        cut_cou++;
      }
    }
    ll num[h + 1] = {};
    cut_cou = 0;
    rep(j, w) {
      rep(i, h) {
        if (s[i][j] == '1') num[now]++;
        if (cut[i] == 1) now++;
      }
      // debug(num[0]);
      out = 0;
      rep(i, h) {
        if (num[i] > k) {
          if (che[j]) {
            ok = 0;
            break;
          }
          che[j] = true;
          j--;
          cnt++;
          out = 1;
          // debug(num[i]);
          break;
        }
      }
      if (out) rep(i, h) num[i] = 0;
      now = 0;
      // debug(cnt);
    }
    // cout << "\n";
    if (!ok) continue;
    ans = min(ans, cnt);
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
s = input()
# print(n)
# print(k)
# 文字列sの幸福度をカウントする関数
def count_happy(s):
    count = 0
    for i in range(1,len(s)-1):
        if s[i]==s[i-1]:
            count += 1
    return count

# print(count_happy(s))
ans = count_happy(s) + 2*k
ans_final = min(n-1,ans)
print(ans_final)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    string a,b;
    cin>>a;
    b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();i++)
		switch(a[i])
		{
			case 'b':a[i]='d';break;
			case 'd':a[i]='b';break;
			case 'p':a[i]='q';break;
			case 'q':a[i]='p';break;
		} 
    if(a==b)
		cout<<"Yes"<<endl;
    else
		cout<<"No"<<endl;
}

Measured memory_bytes: 512
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var N, x int
	fmt.Scan(&N, &x)
	a := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N; i++ {
		a[i] = nextInt(sc)
	}
	ans := 0
	for i := 0; i+1 < N; i++ {
		if a[i+1]+a[i] > x {
			ans += a[i+1] + a[i] - x
			a[i+1] -= min(a[i+1], a[i+1]+a[i]-x)
			if a[i+1]+a[i] > x {
				a[i] -= min(a[i], a[i+1]+a[i]-x)
			}
		}
	}
	fmt.Println(ans)
}
func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n,m;
cin>>n>>m;
ll a[m];
for(ll i=0;i<m;i++)
{
    cin>>a[i];
}
ll s=0;
for(ll i=0;i<m;i++)
{
    s=s+a[i];
}
ll h=0;
if(s<=n)
{
   h=n-s;
   cout<<h<<endl;
}
else
{
    cout<<-1<<endl;
}


return 0;
}


Measured memory_bytes: 3728
N, M, X, Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

max_x = max(x)
min_y = min(y)
for i in range(X+1,Y+1):
  if(max_x < i <= min_y):
    print('No War')
    break
else:
  print('War')

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {

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


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,x,m;
	cin>>n>>x>>m;
	set<long long> s;
	vector<long long> v;
	while(1){
		if(s.find(x)!=s.end())break;
		s.insert(x);
		v.push_back(x);
		x=x*x;
		x%=m;
	}
	long long cnt=0;
	if(v.size()>=n){
		for(int i=0;i<n;i++){
			cnt+=v[i];
		}
		cout<<cnt<<endl;
		return 0;
	}
	int j;
	for(int i=0;i<v.size();i++){
		if(v[i]==x){
			j=i;
			break;
		}
		cnt+=v[i];
	}
	long long ans=0;
	if(j==0){
		for(int i=0;i<v.size();i++){
			ans+=v[i];
		}
		ans=ans*(n/(long long)(v.size()));
		int tmp=n%(long long)(v.size()); 
		if(tmp!=0){
			for(int i=0;i<tmp;i++){
				ans+=v[i];
			}
		}
		cout<<ans<<endl;
		return 0;
	}
	for(int i=j;i<v.size();i++){
		ans+=v[i];
	}
//	cout<<1;
	ans=ans*((n-(long long)(j))/(long long)(v.size()-j));
	long long k=(n-(long long)(j))%(long long)(v.size()-j);
//	cout<<1;
	if(k>0){
		for(int i=j;i<j+k;i++){
			ans+=v[i];
		}
	}
	cout<<cnt+ans<<endl;
	return 0;
}

Measured memory_bytes: 6004
#include <cmath>
#include <cstdio>
using namespace std;
long long int f(long long int x, long long int y, long long int p){
	int res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1){
            res = (res * x) % p;
 		}
        y = y >> 1;
        x = (x * x) % p;  
    }
    return res;
}
long long int ncr(int n, int r) {
    long long int a = 1, b = 1, i, result[n];
    for (i = 0; i < n / 2; i++){
        result[i] = a * f(b, 1000000005, 1000000007) % 1000000007;
        a *= n - i;
        a %= 1000000007;
        b *= i + 1;
        b %= 1000000007;
    }
    if (n % 2 == 0){
        result[i] = a * f(b, 1000000005, 1000000007) % 1000000007;
        i++;
    }else{
    	result[i] = a * f(b, 1000000005, 1000000007) % 1000000007;
    	i++;
    	result[i] = a * f(b, 1000000005, 1000000007) % 1000000007;
    	i++;
	}
    for (i; i <= n; i++){
        result[i] = result[n - i];
    }
    return result[r];
}
int main(){
	int n, m;
	scanf("%d %d",&n,&m);
	int k = m;
	long long int ans = 1;
	for (int i = 2; i <= int(sqrt(k)); i++){
		if (m % i == 0){
			int c = 0;
			while (m % i == 0){
				c++;
				m /= i;
			}
			ans *= ncr(c + n - 1, c) % 1000000007;
			ans %= 1000000007;
		}
	}
	if (m != 1){
		ans *= n;
		ans %= 1000000007;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1024
/*  `-._:  .:'   `:::  .:\           |\__/|           /::  .:'   `:::  .:.-'
        \      :          \          |:   |          /         :       /    
         \     ::    .     `-_______/ ::   \_______-'   .      ::   . /      
          |  :   :: ::'  :   :: ::'  :   :: ::'      :: ::'  :   :: :|       
          |     ;::         ;::         ;::         ;::         ;::  |       
          |  .:'   `:::  .:'   `:::  .:'   `:::  .:'   `:::  .:'   `:|       
          /     :           :           :           :           :    \       
         /______::_____     ::    .     ::    .     ::   _____._::____\      
                       `----._:: ::'  :   :: ::'  _.----'                    
                              `--.       ;::  .--'                           
                                  `-. .:'  .-'                               
                                     \    /                        
                                      \  /                                   
                                       \/  */

//ヾ(⌐■_■)ノ♪ ◢◤
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n],dp[n];
    for(int i=0;i<n;i++)
        cin>>a[i];  
    for(int i=0;i<min(n,k);i++)
        dp[i]=abs(a[i]-a[0]);
    for(int i=k;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k;j++)
        {
            if(dp[i]>dp[i-j]+abs(a[i]-a[i-j]))
                dp[i]=dp[i-j]+abs(a[i]-a[i-j]);
        }
    }
    cout<<dp[n-1];
}
                
                

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int D;
    cin>>D;
    vector<long int> c(26);
    vector<vector<long int> > s(D,vector<long int>(26)); 
    for (int i=0;i<26;i++) cin>>c[i];
    for (int i=0;i<D;i++){
        for (int j=0;j<26;j++) cin>>s[i][j];
    }
    vector<int> t(D,-1);
    vector<vector<int> > memo(26);
    vector<int> memo2(26,-1);
    vector<long int> ans;
    long int ans2=0;
    for (int i=0;i<26;i++) memo[i].push_back(-1);
    for (int i=0;i<D;i++){
        cin>>t[i];
        t[i]--;
        memo[t[i]].push_back(i);
        memo2[t[i]]=i;
        ans2+=s[i][t[i]];
        for (int j=0;j<26;j++){
             ans2-=c[j]*(i-memo2[j]);
        }
    }
    for (int i=0;i<26;i++) memo[i].push_back(D);
    ans.push_back(ans2);
    
    int M;
    cin>>M;
    int k=0;
    vector<int> d(M),q(M);
    for (int i=0;i<M;i++){
        cin>>d[i]>>q[i];
        d[i]--;
        q[i]--;
        auto it=lower_bound(memo[t[d[i]]].begin(),memo[t[d[i]]].end(),d[i]);
        auto it1=it-1;
        auto it2=it+1;
        long int x=ans[k]-(d[i]-*it1)*(*it2-d[i])*c[t[d[i]]];
        memo[t[d[i]]].erase(it);
        auto ite=lower_bound(memo[q[i]].begin(),memo[q[i]].end(),d[i]);
        auto ite1=ite-1;
        x+=(*ite-d[i])*(d[i]-*ite1)*c[q[i]];
        memo[q[i]].insert(ite,d[i]);
        x+=s[d[i]][q[i]]-s[d[i]][t[d[i]]];
        k++;
        ans.push_back(x);
        t[d[i]]=q[i];
    }

    for (size_t i=1;i<ans.size();i++) cout<<ans[i]<<endl;

    return 0;
}

Measured memory_bytes: 5044
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	x := iScan()
	if x >= 30 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main()
{
	ll n,p;
	cin>>n;
	if(n%2)
		p=n/2+1;
	else
		p=n/2;
	cout<<p<<"\n";
	return 0;
}

Measured memory_bytes: 764
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
v0 = n//k
ans = v0**3
if k%2==0:
    ans += ((n+k//2)//k) **3
print(ans)

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int W, a, b;
    cin >> W >> a >> b;
    int d1 = b - (a + W);
    int d2 = a - (b + W);
    if (d1 < 0 && d2 < 0)
        cout << 0 << "\n";
    else
        cout << max(d1, d2) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int32 i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int32 i = (b) - 1; i >= (a); --i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;



int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n, c;
	cin >> n >> c;
	vector<int32> a(200100,0);
	uint32 s, t;
	vector<pair<int32, int32>> I[30];
	rep(i, 0, n) {
		cin >> s >> t >> c;
		I[--c].push_back(make_pair(s, t));
	}
	rep(i, 0, 30) {
		sort(I[i].begin(), I[i].end());
		rep(j, 1, I[i].size()) {
			if (I[i][j].first == I[i][j - 1].second) {
				I[i][j].first = I[i][j - 1].first;
				I[i][j - 1].first = -1;
			}
		}
		rep(j, 0, I[i].size()) {
			if (I[i][j].first != -1) {
				++a[I[i][j].first << 1];
				--a[I[i][j].second << 1|1];
			}
		}
	}
	
	int32 ans = a[0];
	rep(i, 1, a.size()) {
		a[i] += a[i - 1];
		ans = max(ans, a[i]);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;
 
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
 
//#define int ll
//#define int long long

//配列版
signed main()
{
  array<array<int,110>, 110> t{0};
  int w,h,n; cin >> w >> h >> n;
  
  for(int i=0; i < n; ++i){
    int x,y,a; cin >> x >> y >> a;
    
    if(a==1){
      for(int j=0; j < x; ++j){
        for(int k=0; k < h; ++k)
          t[j][k]=1;
      }
    }
      
    if(a==2){
      for(int j=x; j < w; ++j){
        for(int k=0; k < h; ++k)
          t[j][k]=1;
      }
    }
      
    if(a==3){
      for(int j=0; j < w; ++j){
        for(int k=0;k < y; ++k)
          t[j][k]=1;
      }
    }
          
    if(a==4){
      for(int j=0; j < w; ++j){
        for(int k=y; k < h; ++k)
          t[j][k]=1;
      }
    }
  }
 
  int cnt=0;
  for(int i=0; i < w; ++i){
    for(int j=0; j < h; ++j){
      if(t[i][j]==0)
        ++cnt;
    }
  }
  
  cout << cnt;
  
  return 0;
}

Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

char ans[10];
int getans(LL t)
{
	printf("? %lld\n",t);fflush(stdout);
	scanf("%s",ans);
	if(ans[0]=='Y')return 1;
	else return 0;
}
LL cur=0;
int getnxt(int cur)
{
	int l=(cur==0?0:-1),r=9,mid;
	while(l<r-1)
	{
		mid=(l+r)>>1;
		if(getans(1000000000ll*(mid+10ll*cur)+999999999))r=mid;
		else l=mid;
	}
	return r;
}
int main()
{
	for(int i=1;i<=9;i++)cur=cur*10+getnxt(cur);
	while(cur%10==0)cur/=10;
	if(cur==1)
	{
		while(true)
		{
			if(getans(cur+1))break;
			cur*=10;
		}
		printf("! %lld\n",cur);
	}
	else
	{
		LL tmp=1;while(tmp<cur)tmp*=10;
		while(true)
		{
			if(getans(tmp)==0)break;
			tmp=tmp*10;
			cur=cur*10;
		}
		printf("! %lld\n",cur);
		fflush(stdout);
	}
	return 0;
}

Measured memory_bytes: 684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	public static void main(String[] args) throws IOException {

		// ax + by = c
		// dx + ey = f

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		BigDecimal a, b, c, d, e, f, x, y;

		while ((line = br.readLine()) != null) {
			a = new BigDecimal(line.split(" ")[0]);
			b = new BigDecimal(line.split(" ")[1]);
			c = new BigDecimal(line.split(" ")[2]);
			d = new BigDecimal(line.split(" ")[3]);
			e = new BigDecimal(line.split(" ")[4]);
			f = new BigDecimal(line.split(" ")[5]);

			x = (c.multiply(e).subtract(f.multiply(b))).divide((a.multiply(e)
					.subtract(d.multiply(b))));
			y = (c.multiply(d).subtract(f.multiply(a))).divide((d.multiply(b)
					.subtract(e.multiply(a))));

			x.setScale(3, BigDecimal.ROUND_HALF_UP);
			y.setScale(3, BigDecimal.ROUND_HALF_UP);

			System.out.println(String.format("%.3f %.3f", x.doubleValue(),
					y.doubleValue()));
		}
	}
}

Measured memory_bytes: 18012
while True:
    try:
        t1, t2 = map(float, input().split())
    except:
        break
    t1, t2 = int(t1*100), int(t2*100)
    if t1 < 3550 and t2 < 7100:
        print("AAA")
    elif t1 < 3750 and t2 < 7700:
        print("AA")
    elif t1 < 4000 and t2 < 8300:
        print("A")
    elif t1 < 4300 and t2 < 8900:
        print("B")
    elif t1 < 5000 and t2 < 10500:
        print("C")
    elif t1 < 5500 and t2 < 11600:
        print("D")
    elif t1 < 7000 and t2 < 14800:
        print("E")
    else:
        print("NA")
        


Measured memory_bytes: 5580
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,r;
  cin >>n >>r;
  if(n>=10){
    cout<<r<<endl;
  }
  else{
    cout<<r+(10-n)*100<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[105];
bool k;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) 
		if(a[i]%2) continue;
		else if((a[i]%3)&&(a[i]%5)) k=1;
	if(k) cout<<"DENIED";
	else cout<<"APPROVED";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int x[2], y[2];
  rep (i, 2) {
    cin >> x[i] >> y[i];
  }
  int x3 = x[1] - (y[1] - y[0]);
  int y3 = y[1] + (x[1] - x[0]);
  int x4 = x[0] - (y[1] - y[0]);
  int y4 = y[0] + (x[1] - x[0]);
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	string s; cin >> s;
	string search[4] = { "dream", "dreamer", "erase", "eraser" };

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

	for (int i = 0; i < 4; i++)
	{
		reverse(search[i].begin(), search[i].end());
	}

	int cnt = 0;
	bool flag = true;

	while (cnt < s.size())
	{
		for (int i = 0; i < 4; i++)
		{
			if (s.substr(cnt, search[i].size()) == search[i])
			{
				cnt += search[i].size();
				flag = true;
				break;
			}
			else
			{
				flag = false;
			}
		}
		if (!flag) break;
	}

	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    int W, H, N;
    vector<int> x(N);
    vector<int> y(N);
    vector<int> a(N);

    cin >> W >> H >> N;
    REP(i,N){
        cin >> x[i] >> y[i] >> a[i];
    }

    LL w_l = 0;
    LL w_r = W;
    LL h_d = 0;
    LL h_u = H;

    REP(i,N){
        if(a[i]==1){
            if(w_l < x[i]){
                w_l = x[i];
            }
        }else if(a[i]==2){
            if(w_r > x[i]){
                w_r = x[i];
            }
        }else if(a[i]==3){
            if(h_d < y[i]){
                h_d = y[i];
            }
        }else{
            if(h_u > y[i]){
                h_u = y[i];
            }
        }
    }

    LL w = w_r - w_l;
    LL h = h_u - h_d;

    if(w < 0 || h < 0){
        cout << 0 << endl;
    }else{
        cout << w*h << endl;
    }
    return 0;
    

}

Measured memory_bytes: 3976
n, m = map(int, input().split())
x = list(map(int, input().split()))

# print(n, m, x)

# #%%
# n, m =2, 5
# x = [10, 12, 1, 2, 14]


#%%
x.sort()

#%%




#%%

diff_list = []
for i in range(m-1):
    diff = x[i+1] - x[i]
    diff_list.append(diff)


#%%
diff_list.sort()


#%%
if n-1>0:
    print(sum(diff_list[:-(n-1)]))
else:
    print(sum(diff_list))    

#%%


#%%


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

typedef long long ll;

int main(){
    ll a, b;
    cin >> a >> b;
    ll x = __gcd(a, b);
    
    stack<ll> gcds1;
    queue<ll> gcds2;
    for(ll i = sqrt(x); i >= 1; i--){
        if(x % i == 0) {
            gcds1.push(i);
            gcds2.push(x / i);
        }
    }

    vector<ll> ans;
    while(!gcds1.empty()){
        bool fl = true;
        for(auto it : ans){
            if(gcds1.top() % it == 0 && it > 1) {
                fl = false;
                break;
            }
        }
        if(fl) ans.push_back(gcds1.top());
        gcds1.pop();
    }
    while(!gcds2.empty()){
        bool fl = true;
        for(auto it : ans){
            if(gcds2.front() % it == 0 && it > 1) {
                fl = false;
                break;
            }
        }
        if(fl && gcds2.front() > 1) ans.push_back(gcds2.front());
        gcds2.pop();
    }

    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func isHaikable(a, b, c int) {

}
func main() {
	var a, b, c int
	ret := "NO"
	fmt.Scan(&a, &b, &c)
	if a == 7 {
		if b == 5 && c == 5 {
			ret = "YES"
		}
	} else if b == 7 {
		if a == 5 && c == 5 {
			ret = "YES"
		}
	} else if c == 7 {
		if b == 5 && a == 5 {
			ret = "YES"
		}
	}
	fmt.Println(ret)
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
typedef long long ll;
signed main(){
  ll n,sum=0;
  cin >> n;
  ll a[n],b[n],c[n-1];
  for(int i=0;i<n;i++){
    cin >> a[i];
    a[i]--;
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  for(int i=0;i<n-1;i++){
    cin >> c[i];
  }
  for(int i=0;i<n;i++){
    sum+=b[a[i]];
    if(i!=0){
      if(a[i]==a[i-1]+1){
        sum+=c[a[i-1]];
      }
    }
  }
  cout <<sum<<endl;
}


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

int main() {
    double r;
    double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550;
    cin >> r;
    cout << 2 * pi * r;
    return 0;
}


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

int main()
{
    int n, m;
    cin>>n>>m;
    int a[n], sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    sort(a, a+n);
    int cnt=0;
    for(int i=n-1;i>=0;i--)
    {
        if(sum<=(a[i]*4*m))
            cnt++;
    }
    if(cnt>=m) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int a,b,MAX,ice[90][90],x[]={-1,0,0,1},y[]={0,-1,1,0};void waru(int c,int d,int e){ice[c][d]=false;MAX=max(MAX,e);for(int i=0;i<4;i++){int dx=c+x[i],dy=d+y[i];if(dx>=0 &&dx<a&&dy>=0&&dy<b&&ice[dx][dy])waru(dx,dy,e+1);}ice[c][d] = true;}int main(){while(cin>>b>>a,a|b) {MAX = 0;for(int c=0;c<a;c++) {for(int d=0;d<b;d++){cin>>ice[c][d];}}for(int c =0;c<a;c++){for(int d=0;d<b;d++) {if(ice[c][d])waru(c,d,1);}}cout<<MAX<<endl;}}

Measured memory_bytes: 3040
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,count=0,k;
  cin >> n;
  int d;
  while(n--){
  	cin >>d;
  	k =1;
  	for(int i=2;i*i<=d;i++){
  		if(d%i==0){
  			k=0;
  			break;
  		}
  	}
  	count +=k;
  }

  cout << count << endl;
  return 0;

}


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

int main(){
  
  int N,K;
  cin >> N >> K;
  
  vector<ll> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec[i];
  }
  
  for(int i = K; i < N; i++){
    
    if(vec[i] > vec[i - K]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 4840
// O(2^N * N^2)

#include <bits/stdc++.h>

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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<bool>> g(N, vector<bool>(N, false));
    REP(_, M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a][b] = true;
        g[b][a] = true;
    }

    vector<vector<int>> dp(1 << (N - 1), vector<int>(N, 0));
    dp[0][0] = 1;
    FOR(bit, 1, 1 << (N - 1)) FOR(u, 1, N) {
        //cout << "dp[" << bitset<7>(bit) << "][" << u << "] start" << endl;
        if (bit & 1 << (u - 1)) {
            REP(v, N) {
                if (v != u && (v == 0 || (bit & 1 << (v - 1))) && g[v][u]) {
                    int bit_prev = bit ^ (1 << (u - 1));
                    //cout << "+= dp[" << bitset<7>(bit_prev) << "][" << v << "] = " << dp[bit_prev][v] << endl;
                    dp[bit][u] += dp[bit_prev][v];
                }
            }
        }
        //cout << "dp[" << bitset<7>(bit) << "][" << u << "] = " << dp[bit][u] << endl;
    }
    int result = 0;
    FOR(u, 1, N) {
        result += dp[(1 << (N - 1)) - 1][u];
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256