akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
using std::max;

int LCS(char* s1, char* s2,char *res)
{
    int i,j,M,N,k=0,upbd;
    M=strlen(s1);
    N=strlen(s2);
    int **dp;
    dp=new int* [M+2];
    for(i=0;i<M+2;i++)
        dp[i]=new int [N+2];
    for(i=0;i<N+2;i++)
        dp[0][i]=0;
    
    for(i=1;i<M+1;i++)
    {
        dp[i][0]=0;
        for(j=1;j<N+1;j++)
        {
            if(s1[i-1]==s2[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    k=dp[M][N];

    i=M;
    j=N;
    upbd=k;
    res[k]='\0';
    while(i>0 && j>0)
    {
        if(dp[i-1][j]==dp[i-1][j-1] && dp[i-1][j-1]==dp[i][j-1] )
        {
            if (dp[i][j]==dp[i-1][j-1]+1)
                res[--upbd]=s1[i-1];
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]==dp[i][j])
                i--;
            else
                j--;
        }
    }
    for(i=0;i<M+2;i++)
        delete [] dp[i];
    delete [] dp;

    return k;
}


#define MAXLENGTH 3003
int main(void)
{
    char s[MAXLENGTH],t[MAXLENGTH],r[MAXLENGTH];
    scanf("%s%s",s,t);
    LCS(s,t,r);
    printf("%s\n",r);
    return 0;
}



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

int main() {
    ll H;
    cin >> H;
    ll count = 1;
    while(H>1) {
        H /= 2;
        count++;
    }
    ll ans = pow(2,count)-1;
    cout << ans << endl;
}

Measured memory_bytes: 4096
#include<stdio.h>
int main()
{
    int n, k;
    double r = 0;
    scanf("%d %d", &n, &k);
    
    for (int i = 1; i <= n; i++)
    {
        double a = (double)i / (double)k;
        double b = 1.;
        int j = 0;
        while (a < b)
        {
            b /= 2.;
            j++;
        }
        r += b / (double)n;
    }
    
    printf("%.16f\n", r);
    return 0;
}

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

int dp[101][10001];

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    for (int i = 0; i < N; i++)
        cin >> v[i] >> w[i];

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j < w[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 6984
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, c;
  cin >> n >> m >> c;
  int b[m];
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int a[n][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 d = 0;
    for (int j = 0; j < m; j++) {
      d += a[i][j] * b[j];
    }
    d += c;
    if (d > 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



ll mul(ll a, ll b) {
    // infl < ab
    if (infl / a<b) return infl;
    return min(infl, a*b);
}


int N, X, A[201010];
ll B[201010];
//---------------------------------------------------------------------------------------------------
ll get(int a, int b) {
    ll res = B[b];
    if (a) res -= B[a - 1];
    return res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> X;
    rep(i, 0, N) cin >> A[i];
    B[0] = A[0];
    rep(i, 0, N) B[i] = B[i - 1] + A[i];

    ll ans = infl;
    rep(k, 1, N + 1) {
        ll sm = 0;
        int R = N - 1;
        ll p = 5;
        while (0 <= R) {
            int L;
            if (R == N - 1) L = R - 2 * k + 1;
            else L = R - k + 1;
            L = max(L, 0);

            sm = min(infl, sm + get(L, R) * p);
            
            R = L - 1;
            p += 2;
        }
        sm = min(infl, sm + 1LL * X * (N + k));
        chmin(ans, sm);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
using namespace std;
int cnt=0,ans=0,n;
bool b[8];
int main(){
	cin>>n;
	memset(b,0,sizeof(b));
	for(int i=0;i<n;++i){
		int a,now;
		cin>>a;
		if(1<=a && a<=399) now=0;
		else if(400<=a && a<=799) now=1;
		else if(800<=a && a<=1199) now=2;
		else if(1200<=a && a<=1599) now=3;
		else if(1600<=a && a<=1999) now=4;
		else if(2000<=a && a<=2399) now=5;
		else if(2400<=a && a<=2799) now=6;
		else if(2800<=a && a<=3199) now=7;
		else {
			cnt++;
			continue;
		}
		if(!b[now]){
			ans++;
			b[now]=true;
		}
	}
	cout<<max(1,ans)<<" "<<ans+cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <sstream>

using namespace std;

int x,y,z;

int main(){
    
    cin >> x >> y >> z;
    
    int L = x - z, set = y + z;
    
    int ans = L / set;

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


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
class DirectedGraph {
    struct edge {
        int from;
        int to;
        int cost;
    };

    int edge_num = 0;

public:
    int V;
    int E;
    vector<edge> edges;

    DirectedGraph(int v, int e) : V(v), edges(e), E(e) {};

    void add_edge(int from, int to, int cost) {
        edges[edge_num++] = {from, to, cost};
    }

    // O(E * V)
    vector<int> bellman_ford(int s, vector<int> &d) {
        for (int j = 0; j < V; j++) {
            bool update = false;
            for (int i = 0; i < E; i++) {
                edge e = edges[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 (!update) break;
        }

        return move(d);
    }

    vector<int> bellman_ford(int s) {
        vector<int> d(V, INF);
        d[s] = 0;
        return bellman_ford(s, d);
    }
};

signed main() {
    int N, M;
    cin >> N >> M;

    DirectedGraph dg = DirectedGraph(N, M);

    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dg.add_edge(a, b, -c);
    }

    vector<int> dis = dg.bellman_ford(0);
    int ans = dis[N-1];

    dis = dg.bellman_ford(0, dis);

    if (ans != dis[N-1]) {
        cout << "inf" << endl;
    } else {
        cout << -ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#define FOR(i, a, b) for (int i = a, i##_len = (b); i < i##_len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS (1e-7)
#define INF (1e9)

using namespace std;

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

  int n;
  cin >> n;
  // vector<int> a(n);
  int sum = 0;
  // REP(i, n) {cin >> a[i];
  REP(i, n) {
    int a;
    cin >> a;
    sum += a - 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
N=int(input())
dst = [[0, 0, 0]]
for i in range(N):
    dst.append(input().split())
    
flag = True

for i in range(1, N+1):
    time_diff = int(dst[i][0])-int(dst[i-1][0])
    dst_diff = abs(int(dst[i][1])-int(dst[i-1][1]))+abs(int(dst[i][2])-int(dst[i-1][2]))
    if (time_diff>=dst_diff and (time_diff+2)%2 == (dst_diff+2)%2):
        flg = True
    else:
        flg = False
        break

if flg == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 32148
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>

using namespace std;
using ll = long long int;

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}

int main(void){
  
  int x;
  cin>>x;

  vector<int> p(10000001);

  prime(p, 10000000);
  // for(int i=0;i<100000;i++){
  //   cout<<p[i]<<" ";
  // }

  int i=x;

  while(1){
    if(p[i]==1){
      cout<<i<<endl;
      return 0;
    }
    i++;
  }
  return 0;
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using ll = long long;
using namespace std;
int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}
int main(){
    int a,b;
    cin>>a>>b;
    if(a==1){
        if(b==2) cout<<"3"<<endl;
        if(b==3) cout<<"2"<<endl;
    }
    if(a==2){
        if(b==3) cout<<"1"<<endl;
        if(b==1) cout<<"3"<<endl;
    }
    if(a==3){
        if(b==1) cout<<"2"<<endl;
        if(b==2) cout<<"1"<<endl;
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
 // int a[N][M];
  vector<int> vect(M,0);
  for(int i=0;i<N;i++){
    int K;
    cin>>K;
    for(int j=0;j<K;++j){
      int A;
      cin>>A;
      --A;
      ++vect[A];




    }
  }
  int ans=0;
  for(int i=0;i<M;i++){
    if(vect[i]==N){
      ans++;
    }
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int x,n,p;
	bool w[302]={0};
	cin>>x>>n;
	for(int i=0;i<n;i++)
    {
        cin>>p;
        w[p]=1;
    }
    for(int i=0;;i++)
    {
        if(x-i>=0&&!w[x-i])
        {
            cout<<x-i<<endl;
            break;
        }
        if(x+i<200&&!w[x+i])
        {
            cout<<x+i<<endl;
            break;
        }
    }
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <array>

using namespace std;

int main()
{
    int n, a, b, c;
    
    cin >> n;
    
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b >> c;
        if (c >= a && c >= b)
        {
            if (c * c == a * a + b * b)
            {
                cout << "YES" << endl;
            }
            else
            {
                cout << "NO" << endl;
            }
        }
        else if (b >= c && b >= a)
        {
            if (b * b == a * a + c * c)
            {
                cout << "YES" << endl;
            }
            else
            {
                cout << "NO" << endl;
            }
        }
        else
        {
            if (a * a == b * b + c * c)
            {
                cout << "YES" << endl;
            }
            else
            {
                cout << "NO" << endl;
            }
        }
    }
    
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc() {
	ll n;
	ll ans = 0;

	cin >> n;

	ans = ceil((double)n / 2.0f);

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

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

	solve_abc();

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define N 105000
int main()
{
    int a[N]={0},n,i,j,z,sum;
    for(i=2;i<=N/2;i++){
	if(a[i]==0){
	    for(j=2;j*i<=N;j++){
		a[i*j]=1;	     
    	    }
	}
    }
    while(1){
    	cin>>n;
	if(n==0)break;
	else {
    	    z=0;
	    sum=0;
	    for(i=2;i<N;i++){
	    	if(n==z)break;
		if(a[i]==0){
		    sum=sum+i;
		    z++;
		}
	    }
	}
	cout<<sum<<endl;
    }
    return 0;	
}

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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(b - a == c - b)cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

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

bool prime_number(int n){
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   double v,t,y;
   int n;
   while(cin>>v){
      t=v/9.8;
      y=4.9*pow(t,2);
      n=(y/5)+1;
      if(y-5*(n-1)>0) n++;
      cout << n <<endl;
   }
}

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

  int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int mn=min({a,b,c});
    a-=mn;b-=mn;c-=mn;
    int ans=0;
    if (a==0){
      if (b%2 == 1  && c%2==1){
        ans++;
        b+=1;c+=1;
        ans+=(max(b,c)-min(b,c))/2;
        ans+=max(b,c)/2;
      }
      else if (b%2 == 0 && c%2 == 0){
        ans+=(max(b,c)-min(b,c))/2;
        ans+=(max(b,c))/2;
      }
      else if (b%2 == 1 && c%2 == 0){
        ans++;
        a++;c++;
        ans+=(max(b,c)-min(b,c))/2;
        ans+=(max(b,c)-1)/2;
      }
      else{
        ans++;
        a++;b++;
        ans+=(max(b,c)-min(b,c))/2;
        ans+=(max(b,c)-1)/2;
      }
    }
    else if (b == 0){
      swap(a,b);
      if (b%2 == 1  && c%2==1){
        ans++;
        b+=1;c+=1;
        ans+=(max(b,c)-min(b,c))/2;
        ans+=max(b,c)/2;
      }
      else if (b%2 == 0 && c%2 == 0){
        ans+=(max(b,c)-min(b,c))/2;
        ans+=(max(b,c))/2;
      }
      else if (b%2 == 1 && c%2 == 0){
        ans++;
        a++;c++;
        ans+=(max(b,c)-min(b,c))/2;
        ans+=(max(b,c)-1)/2;
      }
      else{
        ans++;
        a++;b++;
        ans+=(max(b,c)-min(b,c))/2;
        ans+=(max(b,c)-1)/2;
      }
    }
    else if ( c==0){
      swap(a,c);
      if (b%2 == 1  && c%2==1){
        ans++;
        b+=1;c+=1;
        ans+=(max(b,c)-min(b,c))/2;
        ans+=max(b,c)/2;
      }
      else if (b%2 == 0 && c%2 == 0){
        ans+=(max(b,c)-min(b,c))/2;
        ans+=(max(b,c))/2;
      }
      else if (b%2 == 1 && c%2 == 0){
        ans++;
        a++;c++;
        ans+=(max(b,c)-min(b,c))/2;
        ans+=(max(b,c)-1)/2;
      }
      else{
        ans++;
        a++;b++;
        ans+=(max(b,c)-min(b,c))/2;
        ans+=(max(b,c)-1)/2;
      }
    }
    cout << ans << endl;
    return 0;
  }
    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9 + 7;
const ll inf = 1e12;
const double pi = 3.141592;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

template <class T>
bool contain(const string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> factor(n + 1, 1);
    auto div = [&](int n) {
        int tmp = n;
        for (int i = 2; i <= n; ++i)
        {
            while(tmp > 0 && tmp%i == 0)
            {
                ++factor[i];
                tmp /= i;
            }
        }
    };
    rep1(i, n + 1) div(i);
    ll ans = 1;
    rep1(i, n + 1){
         ans *= factor[i];
         ans %= mod;
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;
const int maxn = 1e5 + 7;
int N, K;
int stones[maxn], dp[maxn];

void solve() {
    dp[N-1] = 0;
    for (int i = N - 2; i >= 0; --i) {
        dp[i] = 1e9;
        for (int j = 1; j <= K && i + j < N; ++j) {
            dp[i] = min(dp[i], dp[i+j] + abs(stones[i+j] - stones[i]));
        }
    }
    cout << dp[0] << endl;
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> stones[i];
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll D;
ll M;
ll K;
ll CD;

long long koyaku_max(long long a,long long b){
    long long r;
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
long long kobai_min(long long a,long long b){
    long long tmp;
    tmp =  a / koyaku_max(a,b);
    return tmp * b;
}

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;

    ll C_A,C_B,D_A,D_B;
    ll CD_A,CD_B;

    A--;
    C_A = A/C;
    C_B = B/C;
    D_A = A/D;
    D_B = B/D;

    CD = kobai_min(C,D);
    CD_A = A/CD;
    CD_B = B/CD;

    ll N_C  = C_B  - C_A;
    ll N_D  = D_B  - D_A;
    ll N_CD = CD_B - CD_A;

    cout <<  B-A - (N_C+N_D-N_CD) << endl;

    

    

}

Measured memory_bytes: 3620
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

map<int, int> q;

void f(int a) {
  if (a <= 1)
    return;
  if (a % 2 == 0) {
    q[2]++;
    f(a / 2);
    return;
  }
  for (int i = 3; i <= a; i += 2) {
    if (a % i == 0) {
      q[i]++;
      f(a / i);
      return;
    }
  }
}

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    f(i);
  long long ans = 0;
  long long nums[5] = {2, 4, 14, 24, 74};
  long long b[5] = {0};
  for (auto &it : q) {
    for (int i = 0; i < 5; i++) {
      if (it.second >= nums[i])
        b[i]++;
    }
  }
  ans += b[4];
  ans += b[3] * (b[0] - 1);
  ans += b[2] * (b[1] - 1);
  ans += b[1] * (b[1] - 1) * (b[0] - 2) / 2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)
A.append(0)
ans = [0] * N

dif_1 = [0] * (N+1)
dif_2 = [0] * N

for i in range(N+1):
    dif_1[i] = abs(A[i] - A[i+1])

for i in range(N):
    dif_2[i] = abs(A[i] - A[i+2])

num = sum(dif_1)

for i in range(N):
    ans[i] = num - (dif_1[i] + dif_1[i+1]) + dif_2[i]

for i in ans:
    print(i)

Measured memory_bytes: 20396
#include <cstdio>
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <set>
#include <map>
#include <iostream>
#pragma warning(disable:4996)
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int L = *min_element(a.begin(), a.end());
	int R = *max_element(a.begin(), a.end());
	int ans = 1e9;
	int ret = 0;
	for (int i = L; i <= R; i++) {
		ret = 0;
		for (int j = 0; j < n; j++) {
			ret += (i - a[j]) * (i - a[j]);
		}
		ans = min(ans, ret);
			
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{ 
  int n,sum=0;
  cin>>n;
  int a[n];
  
  for(int i = 0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  
  int avg = a[n-1]/2;
  
  for(int i = 0;i<n-1;i++)
  {
    sum = sum + a[i];
  }
  
  cout<<(sum+avg)<<endl;
}


Measured memory_bytes: 3596
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'o') ans++;
  }
  cout << 700 + 100 * ans << endl;
}


Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> N, K;
  invec<ll> H(N);


  bst::sort(H);
  H.resize(max(0, N - K));
  
  return bst::accumulate(H, 0LL);
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void)
{
  int N, M, total;
  int A[100] = {};
  total = 0;
  
  cin >> N >> M;
  
  for(int i = 0; i < N; i++)
  {
    cin >> A[i];
    total += A[i];
  }
  
  int sum = 0;
  
  double check = (double)(total) / (4.0 * (double)M);
  
  for(int i = 0; i < N; i++)
  {
    if((double)A[i] >= check)
    {
    	sum++;
    }
  }
  
  if(sum >= M)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from functools import reduce
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b)

def gcd_list(numbers):
    return reduce(gcd, numbers)

K = i()

sigma = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            sigma += gcd_list([a, b, c])

print(sigma)

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

int s[1002];

#define gc() getchar_unlocked()
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc();
	while (c >= '0');
	return n;
}

int main()
{
	int n, i, is;
	double m, fs, a;
	
	while (n = in()) {
		is = 0; for (i = 0; i < n; i++) is += s[i] = in();
		m = (double)is/n;
		fs = 0; for (i = 0; i < n; i++) {
			a = s[i]-m;
			fs += a*a;
		}
		printf("%.8lf\n", sqrt(fs/n));
	}
	return 0;
}


Measured memory_bytes: 2148
package main

import (
  "fmt"
)

func main() {
  m := make(map[int]int)
  a := 0
  for i := 0; i < 4; i++ {
    fmt.Scan(&a)
    m[a]++
  }
  v := []int{1, 9, 7, 4}
  for _, e := range v {
    if m[e] == 0 {
      fmt.Println("NO")
      return
    }
  }
  fmt.Println("YES")
}


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

typedef struct{
  char mar;
  int  id,num;
} car;

void swap(car *a,car* b){
  car t=*a;*a=*b,*b=t;
}

int partition(car *A,int p,int r){
  int x=A[r].num,i=p-1,j;
  for(j=p;j<r;j++){
    if(A[j].num<=x){
      i=i+1;
      swap(&A[i],&A[j]);
    }
  }
  swap(&A[i+1],&A[r]);
  return i+1;
}



int isStable(car *a,int n){
  int i;
  for(i=0;i<n-1;i++){
    if(a[i].num==a[i+1].num && a[i].id>a[i+1].id)return 0;
  }
  return 1;
}

void quickSort(car *A,int p,int r){
  if(p<r){
    int q=partition(A,p,r);
    quickSort(A,p,q-1);
    quickSort(A,q+1,r);
  }
}


int main(void){

  car A[100000];
  int i,n;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf(" %c %d",&A[i].mar,&A[i].num);
    A[i].id=i;
  }
  quickSort(A,0,n-1);
  printf("%s\n",isStable(A,n)?"Stable":"Not stable");

  for(i=0;i<n;i++){
    printf("%c %d\n",A[i].mar,A[i].num);
  }
  return 0;
}



Measured memory_bytes: 2916
#include<stdio.h>

long long int SerchP(int N,long long int X,long long int P[],long long int A[]){
    if (N==0) {
        return 1;
    }
    else if(X==1){
        return 0;
    }
    else if(X<A[N-1]+2){
        return SerchP(N-1,X-1,P,A);
    }
    else if(X==A[N-1]+2){
        return P[N-1]+1;
    }
    else if(X<(2*A[N-1])+3){
        return SerchP(N-1,X-(A[N-1]+2),P,A)+P[N-1]+1;
    }
    else {
        return (2*P[N-1])+1;
    }
}

int main(){
    int N;
    long long int X,A[51],P[51];
    scanf("%d %lld",&N,&X);
    A[0]=1;
    P[0]=1;
    for (int i=1; i<=N; i++) {
        A[i]=(A[i-1]*2)+3;
        P[i]=(P[i-1]*2)+1;
    }
    
    printf("%lld\n",SerchP(N,X,P,A));
    return 0;
}

Measured memory_bytes: 128
import math

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))

max_l = max(A) + 1
min_l = 0
cur = (max_l + min_l) // 2


def check(l):
    count = 0
    for a in A:
        count += math.ceil(a / l) - 1

    return count <= K


while True:
    if check(cur):
        max_l = cur + 1
    else:
        min_l = cur

    if cur == (max_l + min_l) // 2:
        break

    cur = (max_l + min_l) // 2

print(cur)


Measured memory_bytes: 104700
#include <iostream>
using namespace std;
using ll = long long;
 
 
int main() {
    ll N;
    cin >> N;
    ll mi = 1e15+1;
    for(int i = 0; i < 5; i++) {
        ll a;
        cin >> a;
        mi = min(mi, a);
    }
 
    ll ans = (N + mi - 1) / mi + 4LL;
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n,c,k; cin>>n>>c>>k;
  vector<ll> t(n);
  rep(i, n) cin>>t[i];
  sort(t.begin(),t.end());

  ll ans = 1;
  ll g = t[0];
  ll f = 0;
  rep(i, n) {
    if (g+k < t[i] || f >= c) {
      g = t[i];
      f = 0;
      ans++;
    }
    f++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4008
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll a,b;cin>>a>>b;cout<<a*b<<endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int h, w;
    int a[52][52];
    cin >> h >> w;
    for (int i = 0; i <= w + 1; ++i) {
        a[0][i] = 1;
        a[h+1][i] = 1;
    }
    for (int i = 0; i <= h + 1; ++i) {
        a[i][0] = 1;
        a[i][w+1] = 1;
    }

    int white = 0;
    for (int j = 1; j <=h ; ++j) {
        for (int i = 1; i <=w ; ++i) {
            char c;
            cin >> c;
            if(c == '.') {
                a[j][i] = 0;
                white++;
            }
            else a[j][i] = 1;
        }
    }

    int dist[52][52];
    for (int k = 0; k <= h + 1; ++k) {
        for (int i = 0; i <= w + 1 ; ++i) {
            dist[k][i] = -1;
        }
        
    }
    dist[1][1] = 0;

    queue<pair<int, int> > q;
    q.push(make_pair(1,1));
    while(!q.empty()) {
        auto now = q.front(); q.pop();
        int x = get<0>(now);
        int y = get<1>(now);
        int dx[4] = {1,0,-1,0};
        int dy[4] = {0,1,0,-1};
        for (int i = 0; i < 4; ++i) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(!a[nx][ny]) {
                q.push(make_pair(nx , ny));
                a[nx][ny] = 1;
                dist[nx][ny] = dist[x][y] + 1;
            }
        }
    }
    int black = w *  h - white;

    if(dist[h][w] == -1) {
        cout << -1 << endl;
        return  0;
    }
    cout << h * w - (dist[h][w] +1) - black << endl;


    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;



int main(){

    int n;
    cin >> n;
    vector<int> b(n-1);
    rep(i, n-1){
        scanf("%d", &b[i]);
    }
    b.insert(b.begin(), INF);
    b.emplace_back(INF);
    int s = 0;
    rep(i, n){
        s += min(b[i], b[i+1]);
    }
    ppp(s);


    return 0;
}


Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_8_A
//p212.cpp

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k){
	Node *y = NIL;
	Node *x = root;
	Node *z;

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

	z->parent = y;
	if ( y == NIL ){
		root = z;
	}else{
		if ( z->key < y->key ) {
			y->left = z;
		}else{
			y->right = z;
		}
	}
}

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

int main(){
	int n, i, x;
	string com;

	scanf("%d", &n);

	for ( i = 0; i < n; i++ ) {
		cin >> com;
		if ( com == "insert" ) {
			scanf("%d", &x);
			insert(x);
		} else if ( com == "print" ){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}




Measured memory_bytes: 26728
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static int N,M;
	static int[][] field;
	static int[] v1={1,0,-1,0};
	static int[] v2={0,1,0,-1};
	static Map<String,Integer> map = new HashMap<String,Integer>();
	static{
		map.put("E", 0);
		map.put("N", 1);
		map.put("W", 2);
		map.put("S", 3);
		
	}
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			N=cin.nextInt();
			if(N==0){
				break;
			}
			field=new int[21][21];
			for(int i = 0;i<N;i++){
				field[cin.nextInt()][cin.nextInt()]=1;
			}
			M=cin.nextInt();
			int x=10,y=10;
			if(field[10][10]==1){
				field[10][10]=0;
				N--;
			}
			for(int i = 0;i<M;i++){
				String s = cin.next();
				int dir = map.get(s);
				int len = cin.nextInt();
				for(int j = 0;j<len;j++){
					x+=v1[dir];
					y+=v2[dir];
					if(field[x][y]==1){
						N--;
						field[x][y]=0;
					}
				}
			}
			if(N==0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}

	}

}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt(), s = sc.nextInt();
		int count = 0;
		for (int i = 0; i <= k; i++) {
			for (int j = 0; j <= k; j++) {
				if(s-(i+j)>=0&&s-(i+j)<=k) count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>
main(){
  double x,h,s,a;
  while(1){
    scanf("%lf%lf",&x,&h);
    if(x==0&&h==0) break;
    a=(x/2)*(x/2)+h*h;
    a=sqrt(a);
    s=x*x+a*x*2;
    printf("%f\n",s);
  }

  return 0; 
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int na, nb, m;
int a[maxn], b[maxn];
int ans = 1e9;
int main() 
{
	cin >> na >> nb >> m;
	for(int i = 1; i <= na; ++i) cin >> a[i];
	for(int i = 1; i <= nb; ++i) cin >> b[i];
	for(int i = 1; i <= m; ++i)
	{
		int u, v, w;
		cin >> u >> v >> w;
		ans = min(ans, a[u] + b[v] - w);
	}
	ans = min(ans, *min_element(a + 1, a + na + 1) + *min_element(b + 1, b + nb + 1));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		String s = sc.next();
		boolean flag = false;
		
		int len = s.length();
		while (len > 0) {
			if (len > 7) {
				if (s.substring(len - 7, len).equals("dreamer")) {
					len -= 7;
				} else if (s.substring(len - 6, len).equals("eraser")) {
					len -= 6;
				} else {
					String ss = s.substring(len - 5, len);
					if (ss.equals("erase") || ss.equals("dream")) {
						len -= 5;
					} else {
						break;
					}
				}
			} else if (len == 7) {
				if (s.substring(0, len).equals("dreamer")) {
					flag = true;
				}
				break;
			} else if (len == 6) {
				if (s.substring(0, len).equals("eraser")) {
					flag = true;
				}
				break;
			} else if (len == 5) {
				String ss = s.substring(0, len);
				if (ss.equals("dream") || ss.equals("erase")) {
					flag = true;
				}
				break;
			} else if (len < 5) {
				break;
			}
		}
		
		out.println(flag ? "YES" : "NO");
		out.flush();
	}
	
}

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 byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n,m,x;cin>>n>>m>>x;
  int a[m+10];
  rep(i,0,m)cin>>a[i];

  int l=upper_bound(a,a+m,x)-a;


  out(min(l,m-l));

  return 0;
}


Measured memory_bytes: 256
/*
ID: ramil-p1
PROG: sprime
LANG: C++11
*/
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e3 + 1, inf = 2e9 + 100;

int n;

int q[maxn][maxn];

int d[maxn];

vector<int> p[maxn];

pair<pair<int, int>, int> ed[maxn];

vector<pair<int, int> > e[maxn];

bool good[maxn];

int answer;

int main(){
    ios::sync_with_stdio(0);
    int m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (i != j)
                q[i][j] = inf;
    for (int i = 0; i < m; i++)
        cin >> ed[i].first.first >> ed[i].first.second >> ed[i].second, ed[i].first.first--, ed[i].first.second--, q[ed[i].first.first][ed[i].first.second] = i, q[ed[i].first.second][ed[i].first.first] = i, e[ed[i].first.first].push_back(make_pair(ed[i].first.second, ed[i].second)), e[ed[i].first.second].push_back(make_pair(ed[i].first.first, ed[i].second));
    for (int st = 0; st < n; st++){
        set<pair<int, int> > s;
        for (int i = 0; i < n; i++)
            p[i].clear(), d[i] = inf;
        d[st] = 0;
        s.insert(make_pair(0, st));
        while (!s.empty()){
            int v = s.begin()->second;
            s.erase(s.begin());
            for (int i = 0; i < e[v].size(); i++){
                int to = e[v][i].first, val = e[v][i].second;
                if (d[to] > d[v] + val)
                    s.erase(make_pair(d[to], to)),
                    p[to].clear(),
                    d[to] = d[v] + val,
                    s.insert(make_pair(d[to], to)),
                    p[to].push_back(v);
                else
                if (d[to] == d[v] + val)
                    p[to].push_back(v);
            }
        }
        for (int i = 0; i < n; i++)
            for (int j = 0; j < p[i].size(); j++)
                good[q[i][p[i][j]]] = 1;
    }
    for (int i = 0; i < m; i++)
        if (!good[i])
            answer++;
    cout << answer;
}


Measured memory_bytes: 896