akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m, l;
  scanf("%d %d %d", &n, &m, &l);
  vector<vector<int>> a(n, vector<int>(m, 0)), b(m, vector<int>(l, 0));
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) cin >> a[i][j];
  }
  for(int i = 0; i < m; i++) {
    for(int j = 0; j < l; j++) cin >> b[i][j];
  }
  
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < l; j++) {
      int64_t cij = 0;
      for(int k = 0; k < m; k++) cij += a[i][k] * b[k][j];
      if(j == 0) cout << cij;
      else cout << ' ' << cij;
    }
    cout << "\n";
  }
}


Measured memory_bytes: 3312
#include<stdio.h>
int main()
{
    int a,b,c,temp,n;
    scanf("%d",&n);
    for(n;n>0;n--)
    {
        scanf("%d%d%d",&a,&b,&c);
        if(a>b)
        {
            temp = a;
            a = b;
            b = temp;
        }
        if(a>c)
        {
            temp = a;
            a = c;
            c = temp;
        }
        if(b>c)
        {
            temp = b;
            b = c;
            c = temp;
        }

        if(a*a+b*b==c*c)
            printf("YES\n");
        else
            printf("NO\n");

    }
    return 0;
}

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

int main() 
{
    double d,t,s;
    cin >> d >> t >> s;
    if (d/s <= t)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll N,A,B;
ll h[100001];

bool C(ll x){
	ll l = x;

	rep(i,N){
		ll a = h[i];
		if(a <= B*x){
			continue;
		}

		ll b = a - B*x;
		ll c = b % (A-B) == 0 ? b / (A-B) : b / (A-B) + 1;

		l -= c;
		if(l < 0) return false;
	}
	return true;
}

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

	cin >> N >> A >> B;

	rep(i,N){
		cin >> h[i];
	}

	ll lb = 0;
    ll ub = 1e10;
    while(ub - lb > 1){
        ll mid = (lb + ub) / 2;
        // cout << lb << "," << mid << "," << ub << "," << C(mid) << endl;
        if(C(mid)) ub = mid;
        else lb = mid;
    }
	
	cout << ub << endl;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}

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

public class Main{
	int INF = 1 << 28;
	double EPS = 1e-9;
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt(), m =sc.nextInt(), k = sc.nextInt();
			if((n|m|k) == 0) break;
			long[][] pas = new long[2][n*m+1];
			pas[0][0] = 1;
			int x = 1;
			for(int i=0;i<n;i++) {
				fill(pas[x], 0);
				for(int j=0;j<=n*m;j++) if(pas[1-x][j] > 0) {
					for(int h=1;h<=m;h++) pas[x][j+h] += pas[1-x][j];
				}
				x = 1-x;
			}
//			debug(pas[1-x]);
			long sum = 0;
			for(int i=0;i<=m*n;i++) sum += pas[1-x][i];
			
//			debug(sum);
			double ex = 0.0;
			for(int i=0;i<=n*m;i++) ex += 1.0 * max(i-k, 1) * pas[1-x][i] / sum;
			
			System.out.println(ex);
		}
	}
	
	void debug(Object... os) {
		System.err.println(deepToString(os));
	}
	
	public static void main(String[] args ) {
		new Main().run();
	}
	}

	

Measured memory_bytes: 23584
/*input
20000
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX 30000
#define INF 0x3f3f3f3f


int N = 6 , n;
int32_t main(){
	IOS;
	cin >> n;
	vector<int> sol;
	int sum = 0;
	REP(i , 1 , MAX + 1){
		if(sol.size() == n - 1) break;
		else if(__gcd(i , N) != 1) sol.pb(i) , sum += i;
	}
	// cout << sol.back() << endl;
	// return 0;
	REP(i , 1 , MAX + 1){
		if(__gcd(i , N) != 1 && i <= sol.back()) continue;
		if((sum + i) % 2 == 0 && (sum + i) % 3 == 0/* && (sum + i) % 7 == 0*/
			 /*&& (sum + i) % 5 == 0*/ && __gcd(sum , i) != 1){
			sol.pb(i);
			break;
		}
	}
	// while(sol.size() < n);
	for(auto to : sol) cout << to << " "; cout << endl;
    return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  long int sum=0;
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  int x=4*m;
  float t=(float)(1/(float)(x));
  t=t*(float)(sum);
  int cnt=0;
  for(int i=0;i<n;i++){
    float y1=(float)(a[i]);
    if(y1>=t){
      cnt++;
    }
  }
  if(cnt>=m)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<ll> a(n);
    ll xr=0;
    REP(i,n){
        cin >> a[i];
        if(i>=2){
            xr=(xr^a[i]);
        }
    }
    ll x12=(a[0]^a[1]);
    if(x12==xr){
        cout << 0 << endl;
        return 0;
    }
    ll res=a[0]+a[1]-xr;
    if(res<0){
        cout << -1 << endl;
        return 0;
    }
    res/=2;
    ll num=xr;
    vector<int> s(60),t(60);
    int cnt=0;
    while(xr){
        s[cnt]=(xr&1?1:0);
        cnt++;xr/=2;
    }
    cnt=0;
    while(res){
        t[cnt]=(res&1?1:0);
        cnt++;res/=2;
    }
    ll ans=0;
    REP(i,60){
        if(s[i]&&t[i]){
            cout << -1 << endl;
            return 0;
        }
        if(t[i]){
            ans+=1LL<<i;
        }
    }
    if(ans>=a[0]){
        cout << -1 << endl;
        return 0;
    }
    REPR(i,60){
        if(s[i]&&!t[i]){
            if(ans+(1LL<<i)<a[0]){
                ans+=(1LL<<i);
            }
        }
    }
    ll p=((ans)^(a[0]+a[1]-ans));
    if(p!=num||ans==0){
        cout << -1 << endl;
        return 0;
    }
    cout << a[0]-ans << endl;
}

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

int main() {
    int x, a, b;
    int ans1, ans2;
    cin >> x >> a >> b;
    ans1 = x - a; if (ans1 < 0) ans1 = ans1 * ( -1); 
    ans2 = x - b; if (ans2 < 0) ans2 = ans2 * ( -1); 

    if (ans1 > ans2) cout << "B" << endl;
    else cout << "A" << endl;
    

    return 0;
}


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


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

  int N,T;
  cin>>N>>T;
  int c[N], t[N];
  int flag[1100] = {};
  
  for(int i = 0; i < N; i++)
  {
    cin>>c[i]>>t[i];
  }
  
  for(int i = 0; i < N; i++)
  {
    if(t[i] <= T) {
      flag[i] = 1;
    }
  }
  int minv = 1100;
  
  for(int i = 0; i < N; i++)
  {
    
    if (flag[i]) {
      minv = min(minv, c[i]);
    }
  }
  
  if (minv != 1100) {
    cout<<minv<<endl;
  } else {
    cout << "TLE" << endl;
  }
  
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <sstream>
#include <queue>

using namespace std;

int main(){

	int a, b;

	while(cin >> a){
		cin >> b;
		cout << a + b << endl;
	}
    return 0; 
}

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

int M, T, P, R;

struct score {
  int ac;
  int time;
  int problem;
};

int main() {
  long h, w;
  while (1) {
    cin >> M >> T >> P >> R;
    if (M == 0) return 0;
    int wrong[50][10] = {0};
    vector<score> scores = vector<score>(T);
    for (int i = 0; i < R; i++) {
      int m, t, p, j;
      cin >> m >> t >> p >> j;
      t--; p--;
      if (j) {
        wrong[t][p]++;
      } else {
        scores[t].ac++;
        scores[t].time += (m + 20 * wrong[t][p]);
      }
    }
    for (int i = 0; i < T; i++) {
      scores[i].problem = i + 1;
    }
    // for (int i = 0; i < T; i++) {
    //   cout << scores[i].problem << ": " <<scores[i].ac << ' ' << scores[i].time << endl;
    // }
    sort(scores.begin(), scores.end(), [](score a, score b){
      return a.ac > b.ac || (a.ac == b.ac && a.time < b.time) || (a.ac == b.ac && a.time == b.time && a.problem > b.problem);
    });
    for (int i = 0; i < T; i++) {
      if (i != 0) {
        if (scores[i].ac == scores[i-1].ac && scores[i].time == scores[i-1].time) {
          cout << '=';
        } else {
          cout << ',';
        }
      }
      cout << scores[i].problem;
    }
    cout << endl;
  }
}



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

const int max_N = (1 << 18) + 21;
const int small_N = (1 << 9) + 21;
const int max_V = (int) 1e5 + 21;

int n, q, V[max_N], W[max_N], f[small_N][max_V];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", V + i, W + i);
  }
  for (int i = 1; i <= n && i <= (1 << 9); ++i) {
    memcpy(f[i], f[i >> 1], sizeof(int) * max_V);
    for (int j = max_V - 1; j >= W[i]; --j) {
      f[i][j] = std::max(f[i][j], f[i >> 1][j - W[i]] + V[i]);
    }
    for (int j = 1; j < max_V; ++j) {
      f[i][j] = std::max(f[i][j], f[i][j - 1]);
    }
  }
  scanf("%d", &q);
  while (q--) {
    int v, L, ans = 0;
    scanf("%d%d", &v, &L);
    std::vector<int> vec;
    while (v > (1 << 9)) {
      vec.push_back(v);
      v >>= 1;
    }
    for (int i = 0; i < (1 << vec.size()); ++i) {
      int sum_v = 0, sum_w = 0;
      for (int j = 0; j < vec.size(); ++j) {
        if ((i >> j) & 1) {
          sum_v += V[vec[j]];
          sum_w += W[vec[j]];
        }
      }
      if (sum_w <= L) {
        ans = std::max(ans, sum_v + f[v][L - sum_w]);
      }
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 205844
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N;
    cin >> N;
    vector<int> A( N ), B( N );
    REP( i, N )
    {
        cin >> A[ i ] >> B[ i ];
    }
    auto MAX = max_element( ALL( A ) );
    cout << A[ distance( begin( A ), MAX ) ] + B[ distance( begin( A ), MAX ) ];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>

struct Target {
    int val{};
    bool hit{};
};

int main()
{
    std::array<Target, 9> bingo;
    for (int i = 0; i < 9; i++) {
        std::cin >> bingo[i].val;
    }

    int n{};
    int val{};
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> val;
        for (int j = 0; j < 9; j++) {
            if (bingo[j].val == val) {
                bingo[j].hit = true;
                break;
            }
        }
    }

    bool result = false;
    for (int i = 0; i < 3; i++) {
        if (bingo[i * 3].hit && bingo[i * 3 + 1].hit && bingo[i * 3 + 2].hit) {
            result = true;
            break;
        }
        if (bingo[i].hit && bingo[i + 3].hit && bingo[i + 6].hit) {
            result = true;
            break;
        }
    }
    if (bingo[0].hit && bingo[4].hit && bingo[8].hit) result = true;
    if (bingo[2].hit && bingo[4].hit && bingo[6].hit) result = true;

    if (result) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <deque>
#include <iostream>
#include <queue>
#include <math.h>
#include <algorithm>
#include <fstream>

using namespace std;
typedef long long ll;


int main(void) {
	int a;
	cin >> a;
	cout << a*a * 3;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using i64 = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const i64 INFL = (1LL << 62);
const i64 MOD = 1000000007;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
i64 mod_pow(i64 a, i64 n, T mod) {
  mod = (i64)mod;
  i64 res = 1, p = a % mod;
  while (n) {
    if (n & 1) res = res * p % mod;
    p = p * p % mod;
    n >>= 1;
  }
  return res;
}
void print() { std::cout << std::endl; }
template <typename T, typename... A>
void print(const T& first, const A&... rest) {
  cout << sizeof...(rest) << endl;
  std::cout << first;
  if (sizeof...(rest)) std::cout << " ";
  print(rest...);
}
template <typename... A>
void print(const A&... rest) {
  print(rest...);
}
template <typename A>
void print(const std::vector<A>& v) {
  std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; });
  std::cout << std::endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  i64 n, m;
  cin >> n >> m;
  i64 ans = 0;
  for (i64 i = 1; i * i <= m; ++i) {
    if (m % i == 0) {
      if ((i * n) <= m) ans = max(ans, i);
      if (((m / i) * n) <= m) ans = max(ans, m / i);
    }
  }
  if (n == 1) {
    cout << m << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> xy_t;
xy_t a, b, c, p;
double x1, x2, x3, xp, y_1, y2, y3, yp;
double s1, s2, s3;
int main()
{
	while(cin >> x1 >> y_1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp)
	{
		a=xy_t(x1, y_1);
		b=xy_t(x2, y2);
		c=xy_t(x3, y3);
		p=xy_t(xp, yp);
		s1=(conj(a-p)*(b-p)).imag();
		s2=(conj(b-p)*(c-p)).imag();
		s3=(conj(c-p)*(a-p)).imag();
		if(((s1>0)&&(s2>0)&&(s3>0))||((s1<0)&&(s2<0)&&(s3<0)))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////



int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    priority_queue<int,vi,greater<int>>red,green;
    vi p(a),q(b),r(c);
    rep(i,a)cin>>p[i];
    rep(i,b)cin>>q[i];
    rep(i,c)cin>>r[i];
    sort(rall(p));
    sort(rall(q));
    sort(rall(r));
    rep(i,x){
        red.push(p[i]);
    }
    rep(i,y){
        green.push(q[i]);
    }
    for(int x:r){
        int tr=red.top(),tg=green.top();
        if(tr<=tg&&tr<x){
            red.pop();
            red.push(x);
        }
        else if(tg<tr&&tg<x){
            green.pop();
            green.push(x);
        }
    }
    ll ans=0;
    rep(i,x){
        ans+=red.top();
        red.pop();
    }
    rep(i,y){
        ans+=green.top();
        green.pop();
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main(){
  int A;
  cin >> A;
  int up[100], dn[100];

  for(int i = 0; i < A; i++){
    cin >> up[i];
  }
  for(int i = 0; i < A; i++){
    cin >> dn[i];
  }
  int sum = 0, sum_max = 0;
  for(int i = 0; i < A; i++){
    sum = 0;
    for(int u = 0; u <= i; u++){
      sum += up[u];
    }
    for(int d = i; d < A; d++){
      sum += dn[d];
    }
    if(sum > sum_max) sum_max = sum;
  }

  cout << sum_max << endl;

  return 0;
}


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

int main(){
  int N,i;
  cin>>N;
  
  for(i=1;i<=N;i++){
    string S;
    cin>>S;
    if(S=="Y"){
      break;
    }
  }
  if(i==N+1){
    cout<<"Three"<<endl;
  }
  else{
    cout<<"Four"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
        ll n;
        cin>>n;
        ll a,b,c;
        a=n/500;
        b=n%500;
        c=b/5;
        ll ans=a*1000 + c*5;
        cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	int N,K,one,a;
	cin >> N >> K;
	int ans = (N-1+K-2)/(K-1);
	cout << ans << endl;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	is >> p.first >> p.second;
	return (is);
}

int main() {
	int N; cin >> N;
	vint V(N); cin >> V;
	sort(begin(V), end(V));	
	bool flag = true;
	for (int i = 0; i < N - 1; i++) {
		flag &= V[i] < V[i + 1];
	}
	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;

	return (0);
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;

ll a,b,c,d;

ll n,mx=1e20,mxx=1e20;

ll aa,bb,cc,dd;

int main()
{
	cin>>a>>b>>c>>d;
	cin>>n;
	aa=a*8,bb=b*4,cc=c*2,dd=d;
	mx=min(mx,aa),mx=min(mx,bb),mx=min(mx,cc),mx=min(mx,dd);
	if(mx==aa)
		cout<<n*4*a;
	else
	if(mx==bb)
		cout<<n*2*b;
	else
	if(mx==cc)
		cout<<n*c;
	else
	if(mx==dd)
	{
		if(n%2==0)
			cout<<n/2*d;
		else
		{
			mxx=min(mxx,aa);
			mxx=min(mxx,bb);
			mxx=min(mxx,cc);
			if(mxx==aa)
				cout<<n/2*d+a*4;
			else
			if(mxx==bb)
				cout<<n/2*d+b*2;
			else
			if(mxx==cc)
				cout<<n/2*d+c;
		}
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int x = sc.nextInt();
		int t = sc.nextInt();
		if (x >= t) out.println(x - t);
		else out.println(0);
		
		out.close();
	}
	
static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}




Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%lld %lld\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
ll n,a,b,k;
bool flag;
int main()
{
    cin>>a>>b>>k;
    ll t=min(a,k);
    a-=t;
    k-=t;
    b-=min(b,k);
    pf2(a,b);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<VI> a(n, VI(n-1));
    REP(i,n) {
        REP(j,n-1) {
            cin >> a[i][j];
            a[i][j]--;
        }
        reverse(ALL(a[i]));
    }

    vector<int> q;
    auto get_next=[&](int i) {
        if ( a[i].size()==0 ) return;
        int j=a[i].back();
        if ( a[j].size()==0 ) return;
        if ( a[j].back()==i ) {
            q.PB(i);
            q.PB(j);
        }
    };
    REP(i,n) get_next(i);
    int day=0;
    while ( q.size() ) {
        day++;
        vector<int> prev=q;
        q.clear();
        sort_uniq(prev);
        for ( auto i:prev ) {
            a[i].pop_back();
        }
        for ( auto i:prev ) {
            get_next(i);
        }
    }
    REP(i,n) {
        if ( a[i].size() ) {
            cout << -1 << '\n';
            return 0;
        }
    }
    cout << day << '\n';
    return 0;
}

Measured memory_bytes: 4224
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int t = Integer.parseInt(sc.next());

		int time = 0;
		while (true) {
			time += t;
			n -= x;
			if (n <= 0) {
				break;
			}
		}

		System.out.println(time);

	}
}


Measured memory_bytes: 35572
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
using namespace std;

int main(){
	int ans=0;
	string str;
    while(cin>>str){
		bool flag=true;
		int len = str.length();
		for(int i=0;i<len/2;i++){
			if(str[i]!=str[len-i-1]){
				flag=false;
				break;
			}
		}
		if(flag) ans++;
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))

const int maxn = 5e5 + 10;
const int inf = 0x7ffffff;

ll cal(ll n) { return n * (n + 1) / 2; }
vector<int> G[maxn];
int c[maxn];

int sz[maxn], sum[maxn];
ll ans[maxn];
void dfs(int u,int fa)
{
    sz[u] = 1;
    int in = sum[c[u]];
    for(int v:G[u])
    {
        if(v == fa)
            continue;
        int front = sum[c[u]];
        dfs(v, u);
        int back = sum[c[u]] - front;
        ans[c[u]] -= cal((ll)sz[v] - (ll)back);
        sz[u] += sz[v];
    }
    
    sum[c[u]] = sz[u] + in;
}
void solve()
{
    int N;
    int a, b;
    cin >> N;
    for (int i = 1; i <= N;i++)
        cin >> c[i];
    for (int i = 1; i < N;i++)
    {
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
        ans[i] = cal((ll)N);
    }
    ans[N] = cal((ll)N);
    dfs(1, 1);
    for (int i = 1; i <= N;i++)
    {
        ans[i] -= cal((ll)(N - sum[i]));
        cout << ans[i] << "\n";
       // cout << c[i]<<" "<<sum[i] << "\n";
    }
}

int main()
{
    //freopen("out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T-- > 0)
        solve();

}

Measured memory_bytes: 44304
import math
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=1
test=A[0]
l=0

while test%2 == 0:
  test=test//2
  c*=2

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
  
for i in np.arange(N-1):
  if A[i+1]%c!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(c*2)==0:
    print(0)
    l=1
    break
  else:
    k=A[i+1]//c
    test=lcm_base(test, k)
if l==0:
  k=test*c//2
  print(M//k//2 + M//k%2)

Measured memory_bytes: 38632
N = int(input())
h = [int(i) for i in input().split()]

cnt = 0

for j in range(N):
  while h[j] > 0:
    for i in range(j, N):
      if h[i] == 0:
        break
      else:
        h[i] -= 1
    cnt += 1

print(cnt)


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

int main(){
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if ( 0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H ) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

typedef long long ll;

const int N = 1e5 + 10;
ll n, a, b, t, p;
ll ans;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> a >> b;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        if (p == 0)
            p = t;
        else {
            int d = t - p;
            ans += min(d * a, b);
            p = t;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  while(true) {
    int n, w, d;
    priority_queue<int, vector<int>, greater<int>> que;
    cin >> n >> w >> d;
    if(n == 0 && w == 0 && d == 0) break;
    vector<P> v;
    v.push_back({d, w});
    rep(i, n) {
      int p, s;
      cin >> p >> s;
      int S, T;
      p--;
      int nd, nw;
      nd = v[p].first;
      nw = v[p].second;
      v.erase(v.begin() + p);
      int mod = 2 * (nd + nw);
      s %= mod;
      // cout << s << endl;
      if(((0 < s) && (s < nw)) || ((nw + nd < s) && (s < 2 * nw + nd))) {
        s %= (nw + nd);
        // cout << s << endl;
        S = s * nd;
        T = nd * nw - S;
        if(S < T) {
          v.push_back({nd, s});
          v.push_back({nd, nw - s});
        } else {
          v.push_back({nd, nw - s});
          v.push_back({nd, s});
        }
        // cout << s << " " << S << " " << T << endl;
      } else {
        s = (s - nw) % (nd + nw);
        // cout << s << endl;
        S = s * nw;
        T = nd * nw - S;
        if(S < T) {
          v.push_back({s, nw});
          v.push_back({nd - s, nw});
        } else {
          v.push_back({nd - s, nw});
          v.push_back({s, nw});
        }
      }
      // cout << s << " " << S << " " << T << endl;
    }
    rep(i, v.size()) {
      int S;
      S = v[i].first * v[i].second;
      que.push(S);
    }
    while(que.size()) {
      int p = que.top();
      que.pop();
      cout << p;
      if(que.size() != 0) cout << " ";
    }
    cout << endl;

  }
  return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;

    if(a < b){
        cout << "a < b" << endl;
    } else if(a > b){
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }

    return 0;
}


Measured memory_bytes: 3112
import java.util.*;
import java.math.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<String> list = new ArrayList<String>();

		int n = scan.nextInt();
		for(int i = 0; i < n; i++){
			BigDecimal x1 = scan.nextBigDecimal();
			BigDecimal y1 = scan.nextBigDecimal();
			BigDecimal x2 = scan.nextBigDecimal();
			BigDecimal y2 = scan.nextBigDecimal();
			BigDecimal x3 = scan.nextBigDecimal();
			BigDecimal y3 = scan.nextBigDecimal();
			BigDecimal x4 = scan.nextBigDecimal();
			BigDecimal y4 = scan.nextBigDecimal();

			BigDecimal ax = x2.subtract(x1);
			BigDecimal ay = y2.subtract(y1);

			BigDecimal bx = x4.subtract(x3);
			BigDecimal by = y4.subtract(y3);

			BigDecimal t = ax.multiply(by);
			BigDecimal tB = ay.multiply(bx);
			
			boolean flag = t.compareTo(tB) == 0;
			list.add(flag? "YES" : "NO");
		}

		for(String s : list){
			System.out.printf("%s\n", s);
		}
	}
}

Measured memory_bytes: 31680
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int C=sc.nextInt();
        
        
        
        System.out.println(C);
        System.out.println(A);
        System.out.println(B);
    }
}


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

int main() {
    char c[2];
    cin >> c;
    if (c[0] == 'a') {
        cout << "vowel" << endl;
    } else if (c[0] == 'e') {
        cout << "vowel" << endl;
    } else if (c[0] == 'i') {
        cout << "vowel" << endl;
    } else if (c[0] == 'o') {
        cout << "vowel" << endl;
    } else if (c[0] == 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        boolean isShown = false;

        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                if (n == i * j) {
                    isShown = true;
                }
            }
        }

        if (isShown) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
int niz[1000000];
int dp[100020];
 
 
 
 
 
int main()
{
   int n,k;
   cin>>n>>k;
   for(int i=0;i<n;i++)
   {
       cin>>niz[i];
   }
   dp[0]=0;
   for(int i=1;i<=n;i++)
   {
       int br=0;
       int minX=INT_MAX;
       for(int j=i-1;j>=0;j--)
       {
           if(br==k)break;
           minX=min(minX,dp[j]+abs(niz[i]-niz[j]));
           br++;
       }
       dp[i]=minX;
   }
   cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
 
using namespace std;
  
int main(){
  int X;
  cin >> X;
  
  int a = X/500;
  X = X-500*a;
  int b = X/5;
  int ans = a*1000+b*5;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll x, y; cin >> x >> y;
    cout << (x%y == 0 ? -1 : x) << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main(){
    int h,n;
    cin >> h >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i,n) {
        cin >> a[i];
        sum += a[i];
    }

    if(sum >= h) dunk("Yes");
    else dunk("No");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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 a,b;
char c;
cin >> a >> c >> b;
if(c == '+') cout << a + b << endl;
else cout << a - b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=2020000000;

string s[110];
int A,B;

void sousa(int A,int B){
	rep(i,50) rep(j,100)s[i] += '#';
	rep(i,50) rep(j,100)s[i+50] +='.';
	int N = (A-2)/50;
	rep(i,N) rep(j,50) s[2*i][2*j-1] ='.';
	rep(j,A-1-N*50) s[2*N+2][2*j-1]='.';
	int M = (B-2)/50;
	rep(i,M) rep(j,50) s[2*i+50][2*j-1]='#';
	rep(j,B-1-M*50) s[2*M+2+50][2*j-1]='#';
	cout<<100<<" "<<100<<endl;
	rep(i,100) cout<<s[i]<<endl;
	
	
}

int main() {
	cin>>A>>B;
	sousa(A,B);
	
	return 0;
}

Measured memory_bytes: 256
S = str(input())
T = str(input())
if T in S:
  print(0)
  exit()
ans, substr = 0, ""
for i in range(len(S) - len(T) + 1):
  substr = S[i: i + len(T)]
  cnt = 0
  for s, t in zip(substr, T):
    if s == t:
      cnt += 1
  ans = max(ans, cnt)
  if ans == len(T) - 1:
    break
print(len(T) - ans)

Measured memory_bytes: 9128
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
*/
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli a,b;
    cin>>a>>b;
    lli val=0;
    vlli v;
    while(a)
    {
        v.pb(a%10);
        a/=10;
    }
    reverse(ALL(v));
    vlli v1;
    while(b)
    {
        v1.pb(b%10);
        b/=10;
    }
    reverse(ALL(v1));
    lli i;
    rep(i,0,v1.sz())
    {
        v.pb(v1[i]);
    }
    lli temp=1;
    repr(i,v.sz()-1,-1)
    {
        val+=(temp*v[i]);
        temp*=10;
    }
    temp=sqrt(val);
    if(temp*temp==val)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}



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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h.at(i);
    const int inf = 1 << 30;
    vector<int> dp(n, inf);
    dp.at(0) = 0;
    for (int i = 1; i < n; ++i) {
        for (int ki = 1; ki <= k; ++ki) {
            if (0 <= i-ki) {
                dp.at(i) = min(dp.at(i), dp.at(i-ki) + abs(h.at(i) - h.at(i-ki)));
            }
        }
    }
    cout << dp.at(n-1) << endl;
    return 0;
}

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

int main(){
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for(int i=0; i<M; i++) cin >> B[i];
  vector<vector<int>> A(N, vector<int>(M));
  for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
      cin >> A[i][j];
    }
  }
  int ans=0;
  for(int i=0; i<N; i++){
    int sum=0;
    for(int j=0; j<M; j++){
      sum+=A[i][j]*B[j];
    }
    sum+=C;
    if(sum>0) ans++;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
clusterN = [1] * n
clusterI = list(range(n))
out = [0] * n
def find(x):
  if clusterI[x] != x:
    minI = find(clusterI[x])
    clusterI[x] = minI
    return minI
  else:
    return x

def unite(x, y):
  CX = find(x)
  CY = find(y)
  if CX != CY:
    if CX > CY:
      CX, CY = CY, CX
      x, y = y, x
    clusterN[CX] += clusterN[CY]
    clusterI[CY] = CX
    

for _ in range(m):
  a, b = map(int, input().split())

  unite(a-1, b-1)
  out[a-1] -= 1
  out[b-1] -= 1

for _ in range(k):

  a, b = map(int, input().split())
  if find(a-1) == find(b-1):
    out[a-1] -= 1
    out[b-1] -= 1
out = [out[i] + clusterN[find(i)] - 1 for i in range(n)]
print(*out)

Measured memory_bytes: 105816
#include<iostream>
#include<float.h>
#include<cfloat>
#include<string>
#include<ctype.h>
#include<algorithm>
#include<errno.h>
#include<cerrno>
#include<assert.h>
#include<cassert> 
#include<map>
#include<memory.h>
#include<cctype>
#include<ctype.h>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<new>
#include<memory>
#include<cmath>
#include<queue>
#include<cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{int n;
 cin>>n;
 if(n<1200){
 cout<<"ABC"<<endl;}
 else{
 cout<<"ARC"<<endl;} 
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   int x;
   string s;
   cin >> x;
   int u;
   u=(x/500)*1000;
   x%=500;
   u+=(x/5)*5;
   cout << u << endl;
   return 0;
}



Measured memory_bytes: 256
import sys

def main():

	S = 0
	N,M = map(int, input().split())
	Lists = list(map(int, input().split()))
	
	count = 0
	
	for List in Lists:
		S += List
	
	
	for List in Lists:
		if List >= S/4/M:
			count += 1
	
	if count >= M:
		print("Yes")
	else:
		print("No")
	
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int s = b - a;
		int t = s * (s + 1) / 2;
		System.out.println(t - b);
	}
}

Measured memory_bytes: 22608
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
//constexpr long long MOD = 1000000007;

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

int main()
{
  int N, M;
  std::cin >> N >> M;
  std::vector<std::pair<int, int>> vec(M);
  for(auto& p: vec)
    std::cin >> p.first >> p.second;
  auto check = [](int x, int s, int c) {
    while(--s)
      x /= 10;
    return x%10 == c;
  };
  int start = N == 1 ? 0 : std::pow(10, N - 1);
  int limit = std::pow(10, N);
  int ans = -1;
  for(int i = start; i < limit; ++i)
  {
    bool flag = true;
    for(auto& p: vec)
    {
      if(!check(i, N - p.first + 1, p.second))
      {
        flag = false;
        break;
      }
    }
    if(flag)
    {
      ans = i;
      break;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



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

int n;
int a[101][101];
int sum[101][101];

int main()
{
	std::cin >> n;
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= n; ++j )
			std::cin >> a[i][j];

	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= n; ++j )
				sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + a[i][j];

	int ans = -( 1 << 30 );
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= n; ++j )
			for( int k = 1; k <= i; ++k )
				for( int l = 1; l <= j; ++l )
					ans = std::max( ans, sum[i][j] - sum[i][l-1] - sum[k-1][j] + sum[k-1][l-1] );

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 1240
H,W = map(int,input().split())
L = [list(input()) for _ in range(H)]
for i in range(H):
    for j in range(W):
        if L[i][j] == '#':
            if i != 0 and L[i-1][j] == '#':
                continue
            if i != H-1 and L[i+1][j] == '#':
                continue
            if j != 0 and L[i][j-1] == '#':
                continue
            if j != W-1 and L[i][j+1] == '#':
                continue
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 9192