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

double a,b,c,n,m,h,ans,w,x[500];
string y[500];

int  main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        if(y[i]=="BTC")x[i]=x[i]*380000;
        ans+=x[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dist[801][801];
string f[801];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> bool uin(T &a,T b){return a>b?(a=b,true):false;}
template<class T> bool uax(T &a,T b){return a<b?(a=b,true):false;}
int nceil(int a,int b){
	return (a+b-1)/b;
}
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	int sx=-1,sy=-1;
	for(int i=0;i<n;i++){
		cin>>f[i];
		for(int j=0;j<m;j++){
			if(f[i][j]=='S'){
				sx=i;
				sy=j;
			}
		}
	}
	vector<pair<int,int> > q;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			dist[i][j]=1e9;
		}
	}
	dist[sx][sy]=0;
	q.push_back(make_pair(sx,sy));
	for(int cur=0;cur<q.size();cur++){
		int x=q[cur].first,y=q[cur].second;
		int ncur=dist[x][y];
		for(int d=0;d<4;d++){
			int xx=x+dx[d],yy=y+dy[d];
			if(min(xx,yy)<0||min(n-xx,m-yy)<=0||dist[xx][yy]<1e8||f[xx][yy]=='#')continue;
			dist[xx][yy]=ncur+1;
			q.push_back(make_pair(xx,yy));
		}
	}
	int ans=1e9;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(dist[i][j]>k)continue;
			int res=1e9;
			uin(res,nceil(i,k));
			uin(res,nceil(j,k));
			uin(res,nceil(n-i-1,k));
			uin(res,nceil(m-j-1,k));
			uin(ans,res+1);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 13808
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {

	int N, M;
	vector<pair<int, int>> index;
	scanf("%d %d", &N, &M);
	index.resize(N);
	rep(i, N) {
		int p;
		scanf("%d", &p);
		index[i] = make_pair(p - 1, i);
	}
	//sort(index.begin(), index.end());
	vector<vector<int>> path(N);
	rep(i, M) {
		int x, y;
		scanf("%d %d", &x, &y);
		path[x - 1].push_back(y - 1);
		path[y - 1].push_back(x - 1);
	}
	vector<int> id(N);
	iota(id.begin(), id.end(), 0);

	rep(i, N) {
		if (id[i] == i) {
			queue<int> q;
			q.push(i);
			while (q.size()) {
				int c = q.front();
				q.pop();
				for (auto to : path[c]) {
					if (id[to] != id[c]) {
						id[to] = id[c];
						q.push(to);
					}
				}
			}
		}
	}

	int count = 0;
	rep(i, N) {
		if (id[index[i].first] == id[index[i].second]) count++;
	}

	printf("%d\n", count);

	return 0;
}


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

int main(){
    int N;
    std::cin >> N;
    int a[N];
    for(int i = 0;i < N;i++){
        std::cin >> a[i];
    }
    int count = 0;
    for(int i = 0;i < N;i = i + 2){
        if(a[i]%2 != 0){
            count++;
        }
    }
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>

int main(void){
    int n;
    std::cin >> n;
    std::string s;
    std::cin >> s;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'W') cnt++;
    }
    int ans = 0;
    for(int i = n - cnt; i < n; i++){
        if(s[i] == 'R') ans++;
    }
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3744
N,C = map(int, input().split())
D = [[int(d) for d in input().split()] for _ in range(C)]
clist = [[int(c) for c in input().split()] for _ in range(N)]

L0 = [0]*C
L1 = [0]*C
L2 = [0]*C

for i in range(N):
    for j in range(N):
        if (i+j+2)%3 == 0:
            L0[clist[i][j]-1] += 1
        elif (i+j+2)%3 == 1:
            L1[clist[i][j]-1] += 1
        else:
            L2[clist[i][j]-1] += 1
            
ans = 10**9
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i != j and j != k and k != i:
                c = 0
                for l in range(C):
                    c += L0[l]*D[l][i]
                    c += L1[l]*D[l][j]
                    c += L2[l]*D[l][k]
                ans = min(ans, c)
                
print(ans)

Measured memory_bytes: 45532
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

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

    vector<ll> B(4);
    rep(i, 4) cin >> B[i];
    ll one = min(B[0] * 4, min(B[1] * 2, B[2]));
    ll two = min(min(B[0] * 8, B[1] * 4), min(B[2] * 2, B[3]));
    ll N;
    cin >> N;
    ll ans = 0;
    ans += (N % 2) * one;
    N /= 2;

    ans += N * two;
    output(ans);
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s[100010];
int k;
int main(){
	scanf("%s%d",s,&k);
	int len=strlen(s);
	for (int i=0;i<len;i++){
		if (s[i]!='a'&&'z'-s[i]+1<=k){
			k=k-'z'+s[i]-1;
			s[i]='a';
		}
	}
	s[len-1]=(s[len-1]-'a'+k)%26+'a';
	printf("%s\n",s);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=500005;
#define M 1000000007
#define double long double
#define BINF 1000000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 5000004
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;


int n; 
int t[26][2 * N];
 
void build() {  
  for(int j = 0; j < 26; j++) for (int i = n - 1; i > 0; --i) t[j][i] = t[j][i<<1] + t[j][i<<1|1];
}
 
void modify(int x, int p, int value) { 
  for (t[x][p += n] = value; p > 1; p >>= 1) t[x][p>>1] = t[x][p] + t[x][p^1];
}
 
int query(int x, int l, int r) {
  r++;
  int res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l&1) res += t[x][l++];
    if (r&1) res += t[x][--r];
  }
  return res;
}


#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);

    cin >> n;
    string s;
    cin >> s;
    for(int i = 0; i < n; i++)
        t[s[i] - 'a'][n + i] = 1;
    build();

    int q;
    cin >> q;
    while(q--){
        int x;
        cin >> x;
        if(x == 1){
            int pos; char c;
            cin >> pos >> c;
            pos--;
            modify(s[pos] - 'a', pos, 0);
            modify(c - 'a', pos, 1);
            s[pos] = c;

        }else{
            int l, r;
            cin >> l >> r;
            l--, r--;
            int ans = 0;
            for(int i = 0; i < 26; i++)
                ans += (query(i, l, r) > 0);
            cout << ans << endl;
        }
    }


    

    
   
return 0;  
}
 
 


Measured memory_bytes: 204060
#include <stdio.h>

int main() {
    int i,h;
    
    scanf("%d",&h);
    int A[h];
    
    for(i=1; i<h+1; i++) scanf("%d",&A[i]);
    
    for(i=1; i<h+1; i++) {
        printf("node %d: ",i);
        printf("key = %d, ",A[i]);
        
        if(i/2<=h && i/2>0) printf("parent key = %d, ",A[i/2]);
        if(2*i<=h) printf("left key = %d, ",A[2*i]);
        if(2*i+1<=h) printf("right key = %d, ",A[2*i+1]);
        
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0174
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                string line = RSt();
                if (line == "0") break;

                int aCnt = line.Skip(1).Count(x => x == 'A');
                int bCnt = line.Skip(1).Count(x => x == 'B');
                if (aCnt > bCnt) aCnt++; else bCnt++;
                Console.WriteLine("{0} {1}", aCnt, bCnt);
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int N;
    while (cin >> N, N) {

        vector<pair<int,int>> od(N+2);
        od[0] = {300,300};
        int up = 300;
        int down = 300;
        int lef = 300;
        int rig = 300;
        for (int i=1; i<N; i++) {
            int n,d;
            cin >> n >> d;
            int x = od[n].fi;
            int y = od[n].se;
            switch (d) {
                case 0:{
                    x--;
                    lef = min(x,lef);
                }break;
                case 1:{
                    y--;
                    down = min(y,down);
                }break;
                case 2:{
                    x++;
                    rig = max(rig,x);
                }break;
                case 3:{
                    y++;
                    up = max(up,y);
                }break;
            }

            od[i] = {x,y};

        }
        cout << rig - lef + 1 << " " << up - down + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3032
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<uint> front;
  vector<uint> back;

  bool add_back = true;
  for (auto i = 0; i < N; i++) {
    uint x;
    cin >> x;
    if (i % 2 == 0) back.push_back(x);
    else front.push_back(x);
  }

  if (N % 2 == 0) {
    for (ll i = 0; i < front.size(); i++) cout << front[front.size() - i - 1] << " ";
    for (ll i = 0; i < back.size(); i++) cout << back[i] << " ";
  } else {
    for (ll i = 0; i < back.size(); i++) cout << back[back.size() - i - 1] << " ";
    for (ll i = 0; i < front.size(); i++) cout << front[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3820
s = str(input())

if s == 'SUN':
    print(7)
elif s == 'SAT':
    print(1)
elif s == 'FRI':
    print(2)
elif s == 'THU':
    print(3)
elif s == 'WED':
    print(4)
elif s == 'TUE':
    print(5)
else:
    print(6)   

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n,m;cin >> n >> m;
  vector<int> a(m);
  rep(i,m) cin >> a[i];
  vector<vector<int>> dp(m+1, vector<int>(n+1, -1));
  sort(a.begin(), a.end());
  vector<int> b = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  dp[0][0] = 0;
  rep1(i,m) {
    rep(j,n+1) {
      if(j - b[a[i-1]] >= 0) {
	if(dp[i][j - b[a[i-1]]] != -1) {
	  dp[i][j] = max(dp[i][j - b[a[i-1]]] + 1, dp[i-1][j]);
	}
	else dp[i][j] = dp[i-1][j];
      }
      else dp[i][j] = dp[i-1][j];
    }
  }

  // rep(i,m+1) {
  //   rep(j,n+1) {
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << "\n";
  // }

  int x = m, y = n;
  while(y > 0 ) {
    if(y - b[a[x-1]] >= 0) {
      if( dp[x][y] - 1 == dp[x][y - b[a[x-1]]] ) {
	cout << a[x-1];
	y -= b[a[x-1]];
      }
      else x--;
    }
    else x--;
  }
  cout << "\n";
  return 0;
}


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

int N, a;
set<int> st;

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        if (st.find(a) != st.end())
            st.erase(a);
        else
            st.insert(a);
    }
    cout << st.size() << endl;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    double med_A, med_B;
    ll ans;
    if (N % 2) {
        med_A = A[N/2];
        med_B = B[N/2];
        ans = med_B - med_A + 1;
    } else {
        med_A = (A[N/2-1] + A[N/2]) / 2.0;
        med_B = (B[N/2-1] + B[N/2]) / 2.0;
        ans = 2 * (med_B - med_A) + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4836
//include
//------------------------------------------
#include <bits/stdc++.h>
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> P;
typedef long long ll;
//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;
#define INF (ll)1000000007
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    ll N, M;
    cin >> N >> M;
    ll ans = 0;

    ans += min(N, M/2);

    N -= ans;
    M -= 2*ans;

    ans += M/4;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
using Graph=vector<vector<int>>;
template<class T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main(){
    string s;
    int k;
    cin>>k>>s;
    if(k>=s.size()) cout<<s<<endl;
    else{
        for(int i=0;i<k;++i){
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3612
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

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

using namespace std;
using ll = long long;

static const int MAX = 200000;
static const int WHITE = 0;
static const int RED = 1;
static const int BLUE = 2;

void paint (vector<int> * adj, vector<int> & color, vector<int> & reds, vector<int> & blues) {
  stack<pair<int, int>> S;

  S.push(make_pair(0, RED));

  while (!S.empty()) {
    pair<int, int> p = S.top(); S.pop();
    int u = p.first;
    int col = p.second;

    if (color[u] == WHITE) {
      color[u] = col;

      if (col == RED) reds.push_back(u);
      if (col == BLUE) blues.push_back(u);
    } else {
      continue;
    }

    REP(i, 0, adj[u].size()) {
      int v = adj[u][i];

      // use BLUE and RED alternately
      S.push(make_pair(v, (col == RED) ? BLUE : RED));
    }
  }
}

/**
 * print an array in a row
 */
template <typename T>
void print_array (T arr[], size_t n) {
  for (int i = 0; i < n; i++) printf("%d%c", arr[i], (i == n - 1) ? '\n' : ' ');
}

/**
 * main
 */
int main () {
  vector<int> adj[MAX];
  vector<int> p(MAX);
  vector<int> color(MAX);
  vector<int> reds;
  vector<int> blues;

  int N; cin >> N;

  REP(i, 0, N - 1) {
    int a, b;
    scanf("%d %d", &a, &b);
    adj[a - 1].push_back(b - 1);
    adj[b - 1].push_back(a - 1);
  }

  REP(i, 0, N) color[i] = WHITE;

  paint(adj, color, reds, blues);

  if (reds.size() > N / 3 && blues.size() > N / 3) {
    vector<int> r0;
    vector<int> r1;
    vector<int> r2;

    REP(i, 1, N + 1) {
      if (i % 3 == 0) r0.push_back(i);
      if (i % 3 == 1) r1.push_back(i);
      if (i % 3 == 2) r2.push_back(i);
    }

    auto it_r0 = r0.begin();
    auto it_r1 = r1.begin();
    auto it_r2 = r2.begin();

    REP(i, 0, reds.size())
      p[reds[i]] = (it_r1 == r1.end()) ? *(it_r0++) : *(it_r1++);
    REP(i, 0, blues.size())
      p[blues[i]] = (it_r2 == r2.end()) ? *(it_r0++) : *(it_r2++);
  } else {
    vector<int> r0;
    vector<int> rX;

    REP(i, 1, N + 1) {
      if (i % 3 == 0) r0.push_back(i);
      if (i % 3 != 0) rX.push_back(i);
    }

    auto it_r0 = r0.begin();
    auto it_rX = rX.begin();

    if (reds.size() <= N / 3) {
      REP(i, 0, reds.size())
        p[reds[i]] = *(it_r0++);
      REP(i, 0, blues.size())
        p[blues[i]] = (it_r0 == r0.end())? *(it_rX++) : *(it_r0++);
    } else {
      REP(i, 0, blues.size())
        p[blues[i]] = *(it_r0++);
      REP(i, 0, reds.size())
        p[reds[i]] = (it_r0 == r0.end())? *(it_rX++) : *(it_r0++);
    }
  }

  print_array(p.data(), N);
}


Measured memory_bytes: 17652
package main

import (
	"fmt"
	"math"
)

var height []int

func main() {
	var N int
	fmt.Scan(&N)
	height = make([]int, N+1)
	cost := make([]int, N+1)
	var h int
	for i := 1; i <= N; i++ {
		fmt.Scan(&h)
		height[i] = h
	}
	cost[0] = 0
	cost[1] = 0
	cost[2] = getCost(2, 1)
	for i := 3; i <= N; i++ {
		cost[i] = getMin(cost[i-1]+getCost(i, i-1), cost[i-2]+getCost(i, i-2))
	}
	fmt.Println(cost[N])

}

func getCost(i, j int) int {
	return int(math.Abs(float64(height[i] - height[j])))
}

func getMin(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 5504
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        long M = sc.nextInt();
        long cnt =0;
        if(N == 1){
          if(M == 1)
            cnt = 1;
          else
            cnt = M-2;
        }
        else if(N == 2)
          cnt = 0;
        else if(N > 2){
          if(M == 1)
            cnt = N-2;
          else
            cnt = (N-2)*(M-2);
        }
        System.out.println(cnt);  
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, m;
string str;

int main(){
	cin >> n;
	ll w[n];
	ll sum = 0;
	for(ll i = 0; i < n; i++){cin >> w[i]; sum += w[i];}
	//sort(w, w+n);
	//cout << sum << endl;
    for(ll i = 1; i <= n-1; i++){
		w[i] += w[i-1];	
	}
	ll ans = sum;
	for(ll i = 1; i <= n-1; i++){
		ans = min(abs(sum-2*w[i]), ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
A = [0] * N
B = [0] * N
C = [0] * M
D = [0] * M
ans = [0] * N
for i in range(N):
    A[i],B[i] = map(int,input().split())
for i in range(M):
    C[i],D[i] = map(int,input().split())
for i in range(N):
    li = []
    for j in range(M):
        li.append(abs(A[i] - C[j]) + abs(B[i] - D[j]))
    ans[i] = li.index(min(li)) + 1
for i in range (N):
    print(ans[i])

Measured memory_bytes: 3064
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::{cmp, fmt};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn main() {
    let s: String = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        sc.next()
    };
    let s = s.as_bytes();
    if s.contains(&b'a') && s.contains(&b'b') && s.contains(&b'c') {
        println!("Yes");
    } else {
        println!("No");
    }
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        if buf.last() != Some(&b'\n') {
            panic!("Input must end with '\\n'");
        }
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main() {
 string s;
 cin >> s;
  if (s == "Sunny"){
       cout << "Cloudy";
   }
  if (s == "Cloudy"){
       cout << "Rainy";
   }
  if (s == "Rainy") {
      cout << "Sunny";
   }

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int v[105],d[105],f[105],m[105][105];
int tt,n;
void dfs(int u)
{
    d[u]=++tt;
    v[u]=true;
    for(int i=0;i<n;i++)
        if(m[u][i]&&!v[i])dfs(i);
    f[u]=++tt;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int u,v,k;
        cin>>u>>k;
        for(int j=0;j<k;j++)cin>>v,m[u-1][v-1]=true;
    }
    for(int i=0;i<n;i++)if(!v[i])dfs(i);
    for(int i=0;i<n;i++)cout<<i+1<<' '<<d[i]<<' '<<f[i]<<endl;
    return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

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

#define PI 3.14
typedef long long ll;


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

int main() {
  double r;
  cin >> r;

  cout << 2.0 * r * M_PI << endl;
  return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
	int a, b,ans;
	ans = 0;
	cin >> a >> b;
	
	for (int i = 0; i < 2; i++) {
		if (a >= b) {
			ans += a;
			a -= 1;
		}
		else {
			ans += b;
			b -= 1;
		}
	}

	cout << ans << endl;

	return 0;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint dp[55][55][1305];

int main() {
  int n, score;
  cin >> n >> score;
  dp[0][0][0] = 1;
  rep(i,n) {
    rep(j,i+1)rep(k,score/2+1) {
      {
        int nj = j;
        dp[i+1][nj][k+nj] += dp[i][j][k];
      }
      {
        int nj = j+1;
        dp[i+1][nj][k+nj] += dp[i][j][k];
      }
      {
        int nj = j;
        mint x = j*2;
        dp[i+1][nj][k+nj] += dp[i][j][k]*x;
      }
      if (j >= 1) {
        int nj = j-1;
        mint x = j*j;
        dp[i+1][nj][k+nj] += dp[i][j][k]*x;
      }
    }
  }
  mint ans = dp[n][0][score/2];
  if (score&1) ans = 0;
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 31104
/* 
 * Project: AtCoder Beginners Contest 175 A - Rainy Season
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/29
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
#include <algorithm>
using namespace std;

int8_t s[3];

void solve() {

    uint32_t cnt = 0;
    uint32_t max_cnt = 0;
    for (int i=0;i<3;i++) {
        if (s[i] == 'R') {
            cnt++;
        } else {
            cnt = 0;
        }
        max_cnt = max(max_cnt,cnt);
    }
    printf("%d\n", max_cnt);

}

int main() {

    scanf("%s", s);

    solve();

}

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

int main() {
    string st;
    int s=0,t=0;
    cin>>st;
    for(int i=0;i<st.length();i++){
        if(st[i]=='S'){
            s++;
        } else {
            if(s>0)s--;
            else t++;
        }
    }
    cout<<s+t<<endl;
    return 0;
}


Measured memory_bytes: 640
// sky kaafi neeche aa gaya hai, sab choo rahe hain
// let's raise the bar now :P
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int N = 3e5 + 5;
ll a[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin >> n;
    ll times = n / 500;
    n %= 500;
    cout << (1000LL * times) + 5LL * (n / 5);
return 0;
}


Measured memory_bytes: 256
use strict;
use warnings;
use utf8;
use feature qw(say);
 
my $line = <STDIN>;
my @num = split(/ /, $line);
my $X = $num[0];
my $A = $num[1];
my $B = $num[2];
 
my $date = $B - $A;
 
if ($X < $date) {
  print "dangerous"
} elsif ($date <= 0) {
  print "delicious";
} else {
  print "safe";
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k,ans=0;
  cin>>a>>b>>c>>k;
  while(a>=b){
    ans++;
    b*=2;
  }
  while(b>=c){
    ans++;
    c*=2;
  }
  if(ans>k)cout<<"No";
  else cout<<"Yes";
}


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

int main() {
	long n,m,i,j,k,ans,cur,res,mod=1000000007;
	cin >> n >> k;
	ans=0;
	for(i=k; i<=n+1; i++){
		cur=n*i-i*(i-1)+1;
		ans=(ans+cur)%mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

int main() {
    int n = nxt(), w = nxt();
    vector<ll> weight(100005, INF);
    weight[0] = 0;
    REP(a, n) {
        int wi = nxt(), vi = nxt();
        for (int i = 100004; i >= vi; i--) weight[i] = min(weight[i], weight[i - vi] + wi);
    }
    int ans = 0;
    REP(i, (int)weight.size())
    if (weight[i] <= w) ans = i;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1024
// Author: wlzhouzhuan
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rint register int
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define per(i, l, r) for (rint i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define debug(x) cerr << #x << " = " << x << '\n';
#define pll pair <ll, ll>
#define fir first
#define sec second

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

ll ans = 0;
int n;

int main() {
  scanf("%d", &n);
  for (rint i = 1; i <= n; i++) {
    ans += 1ll * i * (i + 1) / 2;
  }
  for (rint i = 1; i < n; i++) {
    ll u, v;
    scanf("%lld%lld", &u, &v);
    if (u > v) swap(u, v);
    ans -= 1ll * u * (n - v + 1);
  }
  printf("%lld\n", ans);
  return 0;
} 

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

const int MAX_N = 2e5 + 10;
string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	cout << 700 + (s[0] == 'o') * 100 + (s[1] == 'o') * 100 +(s[2] == 'o') * 100 << "\n";
	return 0;
}

Measured memory_bytes: 632
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

p = [0] * n

for i in range(n):
    if a[i] == 1:
        p[0] = 1
        continue
    if p[a[i] - 2] == 0:
        p[a[i] - 1] = 1
    else:
        p[a[i] - 1] = p[a[i] - 2] + 1
print(n - max(p))

Measured memory_bytes: 18888
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <map>
#include <complex>
using namespace std;
typedef complex<double> P;

map< pair<int,int> , int > memo;

P p[200000];

int main(){
	int N;
	double R;
	cin >> N >> R;
	for(int i = 0 ; i < N ; i++){
		cin >> p[i].real() >> p[i].imag();
		p[i].real() += 1000000;
		p[i].imag() += 1000000;
		memo[ make_pair( (int)(p[i].real() / R) , (int)(p[i].imag() / R) ) ] = 1;
	}
	int dx[] = {-1,0,1,-1};
	int dy[] = {-1,-1,-1,0};
	
	map< pair<int,int> , int >::iterator it = memo.begin();
	int ans = 0;
	while( it != memo.end()){
		int X = it->first.first;
		int Y = it->first.second;
		int f = true;
		for(int i = 0 ; i < 4 ; i++){
			if( memo.count( make_pair(X+dx[i],Y+dy[i]) ) ){
				f = false;
			} 
		}
		ans += f;
		++it;
	}
	cout << ans << endl;
}

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

int n;
map<char, int> mp;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	mp['N'] = 0;
	mp['S'] = 1;
	mp['E'] = 2;
	mp['W'] = 3;
	while(1){
		cin >> n;
		if(n == 0) return 0;
		int a[25][25] = {{}};
		for(int i=0; i<n; ++i){
			int x, y;
			cin >> x >> y;
			a[x][y] = 1;
		}
		int m;
		cin >> m;
		int p = 10, q = 10;
		int tmp = 0;
		if(a[p][q] == 1) ++tmp;
		for(int i=0; i<m; ++i){
			char c;
			int d;
			cin >> c >> d;
			for(int j=0; j<d; ++j){
				p += dx[mp.at(c)];
				q += dy[mp.at(c)];
				if(a[p][q] == 1){
					++tmp;
					a[p][q] = 0;
				}
			}
		}
		cout << (tmp == n ? "Yes\n" : "No\n");
	}
}


Measured memory_bytes: 2988
import java.util.Scanner;

class Main{ 
    public static void main(String[] args){ 
        Scanner sc=new Scanner(System.in); 
        int no=1;
        int input=0;
        while(true){
            input=sc.nextInt();
            if(input==0){
                break;
            }
        System.out.println("Case "+no+": "+input);
        no++;
        }
    }
}



Measured memory_bytes: 41724
#include <stdio.h>

#define N 50

int xx[] = { -1, 1, 0, 0, -1, -1, 1, 1 };
int yy[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

int main() {
	static char s[N][N + 1], t[N][N + 1];
	int n, m, h, i, j, i_, j_, cnt;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%s", s[i]);
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			if (s[i][j] == '#')
				t[i][j] = '#';
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			if (s[i][j] == '.') {
				cnt = 0;
				for (h = 0; h < 8; h++) {
					i_ = i + xx[h];
					j_ = j + yy[h];
					if (i_ >= 0 && i_ < n && j_ >= 0 && j_ < m && s[i_][j_] == '#')
						cnt++;
				}
				t[i][j] = cnt + '0';
			}
	for (i = 0; i < n; i++)
		printf("%s\n", t[i]);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vvll sum(n+1,vll(30,0)) ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		for(int j=0;j<30;j++){
			sum.at(i+1).at(j) = sum.at(i).at(j)+(a>>j&1) ;
		}
	}
	ll ans = 0 ;
	ll l=0,r=1 ;
	while(r<=n){
		bool ok = true ;
		for(int j=0;j<30;j++){
			if(sum.at(r).at(j)-sum.at(l).at(j)>1) ok = false ;
		}
		if(ok){
			ans += r-l ;
//			cout << l << " " << r << endl ;
//			cout << ans << endl ;
			r++ ;
		}else{
			l++ ;
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 54912
#include <iostream>
#include <vector>
using namespace std;
const int N=15;
bool st[N];
vector<int> vec;
int cnt=0;
int ans=-1;
int n,m;
void dfs(int u,int sum)
{
    if(u==cnt+1){
        // cout<<sum<<" "<<n<<endl;
        if(ans==-1&&sum>=n){
            ans=sum;
        }
        return ;
    }
    for(auto g:vec){
        if(u==1&&g==0)continue;
        dfs(u+1,sum*10+g);
    }
}
int main()
{
//    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){int x;cin>>x;st[x]=true;}
    for(int i=0;i<10;i++)if(!st[i])vec.push_back(i);
    int tep=n;
    cnt=0;
    while(tep){
        cnt++;
        tep/=10;
    }
    dfs(1,0);
    // cout<<ans<<endl;
    if(ans==-1){
        int minv=vec[0];
        if(minv==0){
            ans=vec[1];
            for(int i=1;i<=cnt;i++)ans=ans*10+minv;
        }else{
            ans=0;
            for(int i=1;i<=cnt+1;i++)ans=ans*10+minv;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/**
*    created: 25.07.2020 21:03:04
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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 int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8]={0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8]={1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int r, g, b; cin >> r >> g >> b;
    int k; cin >> k;
    int cnt = 0;
    while (g <= r) {g *= 2; cnt++;}
    while (b <= g) {b *= 2; cnt++;}
    if (cnt <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int check(char c){
    if( (c >= 'h' && c<='p') || c == 'y' || c == 'u') return 1;

    else return 0;
}

int main(){
    while(1){
        string s; cin>>s;
        if(s == "#") break;

        int count = 0;

        for(int i=1; i<s.size(); i++){
            if(check(s[i-1]) != check(s[i]))count++;
        }

        cout<<count<<endl;

    }

    return 0;
}


Measured memory_bytes: 3212
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 10000000000000000
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
#define SIZE 1000000
int n;
int t;
int nums[114514]={0};
int main(){
	string str,ans;
	cin>>str;
	ans=str;
	cin>>n;
	int m=str.size();
	for(int i=0;i<str.size();i++){
		nums[i]=str[i]-'a';
		nums[i]=(26-nums[i])%26;
	}
	for(int i=0;i<str.size();i++){
		if(n<nums[i]){
			continue;
		}else{
			n-=nums[i];
			ans[i]='a';
		}
	}
	n=(n%26);
	for(int i=0;i<n;i++){
		ans[m-1]++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 896
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
 
static const double EPS = 1e-8;
 
const int tx[] = {0,1,0,-1};
const int ty[] = {-1,0,1,0};
 
char stage[3][3];
double prob[17][3][3];

int main(){
    int n;
    while(~scanf("%d",&n)){
        if(n==0) break;
 
        char s,t,b;
        memset(stage,'.',sizeof(stage));
        cin >> s >> t >> b;
        int sx = (s-'A')%3;
        int sy = (s-'A')/3;
        int gx = (t-'A')%3;
        int gy = (t-'A')/3;
        stage[(b-'A')/3][(b-'A')%3] = 'B';

		fill(prob[0][0],prob[0][0]+3*3*17,0.0);

		prob[0][sy][sx] = 1.0;

		for(int i=0;i<n;i++){
			for(int y=0;y<3;y++){
				for(int x=0;x<3;x++){
					for(int j=0;j<4;j++){
						int dx = x + tx[j];
						int dy = y + ty[j];
						if((dx < 0 || dx >= 3 || dy < 0 || dy >= 3)
							|| stage[dy][dx]=='B') prob[i+1][y][x] += prob[i][y][x]/4.0;
						else prob[i+1][dy][dx] += prob[i][y][x]/4.0;
					}
				}
			}
		}

		printf("%lf\n",prob[n][gy][gx]);
	}
}

Measured memory_bytes: 0
N = int(input())
A_list = list(map(int, input().split()))
A_list= sorted(A_list)[::-1]

Alice = 0
Bob = 0
ans = 0
if N%2 == 0:
  for i in range(0,N,2):
    Alice += A_list[i]
    Bob += A_list[i+1]
  print(Alice - Bob)
else:
  for i in range(0,N-2,2):
    Alice += A_list[i]
    Bob += A_list[i+1]
  print((Alice+A_list[-1]) - Bob)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    //和差積商は英語で　summation difference product quotient 
    int sum,dif,pro;
    sum = a+b;
    dif = a-b;
    pro = a*b;
 /*   cout<<sum<<endl;
    cout<<dif<<endl;
    cout<<pro<<endl;
*/
    int answer = max(max(sum,dif),pro);
    
    cout << answer << endl;

}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	a = b / a;
	if (a >= c) {
		cout << c << endl;
	}
	else {
		cout << a << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;

	int x = a * b;
	if (x % 2 ) {
		cout << "Odd" << endl;
	}
	else {
		cout << "Even" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n = 0, w = 0, s = 0, e = 0; string ss; cin >> ss;
	for (int h = 0; h < ss.size(); h++) {
		if (ss[h] == 'N') { n++; }
		if (ss[h] == 'W') { w++; }
		if (ss[h] == 'S') { s++; }
		if (ss[h] == 'E') { e++; }
	}
	if ((n == 0 && s == 0) || (n != 0 && s != 0)) {
	    if ((w == 0 && e == 0) || (w != 0 && e != 0)) {
			cout << "Yes" << endl; return 0;
		}
	}
	cout << "No" << endl;
	cin >> n;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

int str_int(string str){
	int ans = 0;
	for(int i = 0; i < str.size(); i++){
		if(str[i] == 'm'){
			if(i != 0){
				if(str[i - 1] >= '2' && str[i - 1] <= '9'){
					ans += (str[i - 1] - '0') * 1000;
				}else{
					ans += 1000;
				}
			}else{
				ans += 1000;
			}
		}else if(str[i] == 'c'){
			if(i != 0){
				if(str[i - 1] >= '2' && str[i - 1] <= '9'){
					ans += (str[i - 1] - '0') * 100;
				}else{
					ans += 100;
				}
			}else{
				ans += 100;
			}
		}else if(str[i] == 'x'){
			if(i != 0){
				if(str[i - 1] >= '2' && str[i - 1] <= '9'){
					ans += (str[i - 1] - '0') * 10;
				}else{
					ans += 10;
				}
			}else{
				ans += 10;
			}
		}else if(str[i] == 'i'){
			if(i != 0){
				if(str[i - 1] >= '2' && str[i - 1] <= '9'){
					ans += (str[i - 1] - '0') * 1;
				}else{
					ans += 1;
				}
			}else{
				ans += 1;
			}
		}
	}
	return ans;
}

string int_str(int num){
	string str, dum;
	str = "";
	if(num >= 1000){
		if(num / 1000 > 1){
			dum = "D";
			dum[0] = num / 1000 + '0';
			str = str + dum;
		}
		dum = "m";
		str = str + dum;
	}
	num -= (num / 1000) * 1000;
	if(num >= 100){
		if(num / 100 > 1){
			dum = "D";
			dum[0] = num / 100 + '0';
			str = str + dum;
		}
		dum = "c";
		str = str + dum;
	}
	num -= (num / 100) * 100;
	if(num >= 10){
		if(num / 10 > 1){
			dum = "D";
			dum[0] = num / 10 + '0';
			str = str + dum;
		}
		dum = "x";
		str = str + dum;
	}
	num -= (num / 10) * 10;
	if(num >= 1){
		if(num / 1 > 1){
			dum = "D";
			dum[0] = num / 1 + '0';
			str = str + dum;
		}
		dum = "i";
		str = str + dum;
	}
	num -= (num / 1) * 1;
	return str;
}

int main(){
	
	int n;
	
	string str1, str2, str_a;
	
	int num1, num2, ans;
	
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> str1 >> str2;
		num1 = str_int(str1);
		num2 = str_int(str2);
		ans = num1 + num2;
		str_a = int_str(ans);
		cout << str_a << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>

signed main()
{
  int a, b, c, x;
  scanf("%d %d %d %d", &a, &b, &c, &x);

  int k;
  int ans = 0;
  for ( int i = 0; i <= a; ++i ) {
    for ( int j = 0; j <= b; ++j ) {

      k =  ( x - (( 500 * i ) + ( 100 * j )) ) / 50;
      if ( k <= c && k >= 0 && ( 500 * i ) + ( 100 * j ) + ( 50 * k ) == x ) ans += 1;
    }
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int prime[65536];

int main()
{
    int n;
    int cnt;
    int i, j;

    // initialize sieve
    for (i = 0; i <= 50000; i++){
        prime[i] = 1;
    }

    // make sieve
    prime[0] = prime[1] = 0;
    for (i = 2; i * i <= 50000; i++){
        for (j = i * i; j <= 50000; j += i){
            prime[j] = 0;
        }
    }

    // solve
    while (scanf("%d", &n) * n != 0){
        cnt = 0;
        for (i = 0; i <= n / 2; i++){
            if (prime[i] == 1 && prime[n - i] == 1){
                cnt++;
            }
        }
        printf("%d\n", cnt);
    }

    return (0);
}

Measured memory_bytes: 796