stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:


// dpの練習

// dpでなく、愚直に組んだプログラミング

// ナップサック問題とほぼ同じ



#include <iostream>

#include <algorithm>

#include <cstring>



using namespace std;



int wei; // 持てる最大の重さ

int n; // お宝の数

int v[1001]; // お宝の価値

int w[1001]; // お宝の重さ

 // グローバル配列は0で初期化されている

int dp[1001][1001]; //メモテーブル



int max_value(int i, int j) {

  int value;



  if( dp[i][j] >= 0 ){

    return dp[i][j];

    //すでに１回は調べている

  }

 

  if (i == n) {

    // 品物がもう残っていないときは、価値の和の最大値は0で確定

    //もうお宝がないつまり、価値は0

    value = 0;

  } else if (j < w[i]) {

    //風呂敷が持てる重さを超えてしまう

    // 残りの容量が足りず品物iを入れられないので、入れないパターンだけ処理

    // i+1 以降の品物のみを使ったときの最大値をそのままこの場合の最大値にする

    value = max_value(i + 1, j);

  } else {

    //左がお宝を入れない、右がお宝を入れた場合

    // 品物iを入れるか入れないか選べるので、両方試して価値の和が大きい方を選ぶ

    value = max( max_value(i + 1, j), max_value(i + 1, j - w[i]) + v[i] );

  } 

  return dp[i][j] = value;

  //メモに記憶させる

}



void max_weight( int ans ){



  int w_min;

   

  for (int i = wei -1 ; i >= 0 ; i--){

    if( ans != max_value( 0 , i ) ){

         w_min = i + 1;

         break;

    }

  }

  cout << w_min << endl;  

}





int main(void){



  int cnt = 1;

  while( cin >> wei ){

    memset( dp , -1 , sizeof(dp) );

    //まだ調べてないところを-1で初期化

    if( wei == 0 )break;

    cin >> n;

    char ten;

    for( int i = 0 ; i < n ; i++ ){

      cin >> v[i] >> ten >> w[i];

    }

    cout << "Case " << cnt << ":" << endl;

    int ans = max_value( 0 , wei );

    cout << ans << endl;

    max_weight(ans);

    cnt++;

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.444038890609327x):
#include <iostream>

#include <cstring>

#include <algorithm>

#define MAX 1000

using namespace std;



int main(void){



  int n,W;

  int w[MAX+1];

  int v[MAX+1];

  int dp[MAX+1][MAX+1];

  char ten;

  int cnt = 1;



  while( cin >> W , W ){

    cin >> n;

    for( int i = 0 ; i < n ; i++ ){

      cin >> v[i] >> ten >> w[i];

    }



    for( int i = 0 ; i < MAX ; i++ ){

      for( int j = 0 ; j < MAX ; j++ ){

	dp[i][j] = 0;

      }

    }



    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 << "Case " << cnt++ << ":" << endl;

    for( int i = W ; i >= 0 ; i-- ){

      if( dp[n][i] != dp[n][W] ){

	cout << dp[n][W] << endl << i+1 << endl;

	break;

      }

    }

  }  

  return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <cstring>



using namespace std;



int wei; // 持てる最大の重さ

int n; // お宝の数

int v[1001]; // お宝の価値

int w[1001]; // お宝の重さ

 // グローバル配列は0で初期化されている

int dp[1001][1001]; //メモテーブル



int max_value(int i, int j) {

  int value;



  if( dp[i][j] >= 0 ){

    return dp[i][j];

    //すでに１回は調べている

  }

 

  if (i == n) {

    // 品物がもう残っていないときは、価値の和の最大値は0で確定

    //もうお宝がないつまり、価値は0

    value = 0;

  } else if (j < w[i]) {

    //風呂敷が持てる重さを超えてしまう

    // 残りの容量が足りず品物iを入れられないので、入れないパターンだけ処理

    // i+1 以降の品物のみを使ったときの最大値をそのままこの場合の最大値にする

    value = max_value(i + 1, j);

  } else {

    //左がお宝を入れない、右がお宝を入れた場合

    // 品物iを入れるか入れないか選べるので、両方試して価値の和が大きい方を選ぶ

    value = max( max_value(i + 1, j), max_value(i + 1, j - w[i]) + v[i] );

  } 

  return dp[i][j] = value;

  //メモに記憶させる

}



void max_weight( int ans ){



  int w_min;

   

  for (int i = wei -1 ; i >= 0 ; i--){

    if( ans != max_value( 0 , i ) ){

         w_min = i + 1;

         break;

    }

  }

  cout << w_min << endl;  

}





int main(void){



  int cnt = 1;

  while( cin >> wei ){

    memset( dp , -1 , sizeof(dp) );

    //まだ調べてないところを-1で初期化

    if( wei == 0 )break;

    cin >> n;

    char ten;

    for( int i = 0 ; i < n ; i++ ){

      cin >> v[i] >> ten >> w[i];

    }

    cout << "Case " << cnt << ":" << endl;

    int ans = max_value( 0 , wei );

    cout << ans << endl;

    max_weight(ans);

    cnt++;

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.444038890609327x):
#include <iostream>

#include <cstring>

#include <algorithm>

#define MAX 1000

using namespace std;



int main(void){



  int n,W;

  int w[MAX+1];

  int v[MAX+1];

  int dp[MAX+1][MAX+1];

  char ten;

  int cnt = 1;



  while( cin >> W , W ){

    cin >> n;

    for( int i = 0 ; i < n ; i++ ){

      cin >> v[i] >> ten >> w[i];

    }



    for( int i = 0 ; i < MAX ; i++ ){

      for( int j = 0 ; j < MAX ; j++ ){

	dp[i][j] = 0;

      }

    }



    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 << "Case " << cnt++ << ":" << endl;

    for( int i = W ; i >= 0 ; i-- ){

      if( dp[n][i] != dp[n][W] ){

	cout << dp[n][W] << endl << i+1 << endl;

	break;

      }

    }

  }  

  return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <map>

#include <set>

#include <queue>

#include <algorithm>

#include <cstring>

#include <cmath>

#include <sstream>

#include <vector>

#include <string>

#include <iomanip>

#include <bitset>

#define INF	100000000

#define pb	push_back

#define fi first

#define sec second

#define SS stringstream

using namespace std;

typedef pair<int, int> P;

typedef long long int	ll;



int w, n;

int t = 0;

int dp[1001][1001];

vector<P> vec;



int rec(int i, int j){

	if(dp[i][j] >= 0) return dp[i][j];

	int res;

	if(i == n) res = 0;

	else if(j < vec[i].sec) res = rec(i+1, j);

	else res = max(rec(i+1, j), rec(i+1, j-vec[i].sec)+vec[i].fi);

	return dp[i][j] = res;

}



int main(){

	while(scanf("%d", &w)){

		t++;

		if(w == 0) break;

		memset(dp, -1, sizeof(dp));

		scanf("%d", &n);

		for(int i = 0; i < n; i++){

			int temp1, temp2;

			char trash;

			scanf("%d%c%d", &temp1, &trash, &temp2);

			vec.pb(P(temp1, temp2));

		}

		printf("Case %d:\n", t);

		printf("%d\n", rec(0, w));

		for(int i = 1; i <= w; i++){

			if(rec(0, w-i) != rec(0,w)){

				printf("%d\n", w-i+1);

				break;

			}

		}

		vec.clear();

	}

}

// Faster C++ solution for the same problem (measured speedup: 9.234418629587609x):
#include <bits/stdc++.h>

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

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;

 

const double EPS = 1e-10;

const ll INF = 100000000;

const ll MOD = 1000000007;



struct ITEM {

    int v, w;

    double x;



    bool operator>(const ITEM& right) const {

        return x > right.x;

    }

} item[1000];



int N, W;

int v[1000], w[1000];

int ans;

int ans2;



void dfs (int pos, int val, int sum, bool flag) {

    if (ans < val) {

        ans = val;

        ans2 = sum;

    }

    if (ans == val) {

        ans2 = min(ans2, sum);

    }

    if (pos == N) return;

    if (flag) {

        int _W = W-sum;

        double lim = val;

        for (int i = pos; i < N; i++) {

            if (_W >= item[i].w) {

                lim += item[i].v;

                _W -= item[i].w;

            } else {

                lim += _W * item[i].x;

                break;

            }

        }

        if (lim+EPS < ans) {

            return;

        }

    }

    if (sum+item[pos].w <= W) {

        dfs(pos+1, val+item[pos].v, sum+item[pos].w, false);

    }

    dfs(pos+1, val, sum, true);

}



int main() {

    int testcase = 1;

    while (cin >> W) {

        if (W == 0) break;

        ans = 0;

        cin >> N;

        rep(i,N) {

            char tmp;

            cin >> item[i].v >> tmp >> item[i].w;

            item[i].x = item[i].v / (double)item[i].w;

        }

        sort(item, item+N, greater<ITEM>());

        dfs(0, 0, 0, false);

        cout << "Case " << testcase << ":" << endl;

        cout << ans << endl;

        cout << ans2 << endl;

        testcase++;

    }

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

using namespace std;

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



int main(){

	int weight;

	int n,v,w,c=0;

	int dp[1001][1001];

	while(scanf("%d\n",&weight) && weight){

		c++;

		rep(i,1001)rep(j,1001)dp[i][j]=0;

		

		scanf("%d\n",&n);

		for(int k=1;k<=n;k++){

			scanf("%d,%d\n",&v,&w);

			for(int i=0;i<=w;i++){

				dp[k][i] = dp[k-1][i];

			}

			for(int i=w;i<=weight;i++){

				dp[k][i] = max(dp[k-1][i],dp[k-1][i-w]+v);

			}

		}

		/*for(int k=0;k<=n;k++){

			for(int i=0;i<=weight;i++)

				printf("%4d",dp[k][i]);

			puts("");

		}*/

		printf("Case %d:\n",c);

		printf("%d\n",dp[n][weight]);

		for(int i=0;i<=weight;i++){

			if(dp[n][i]==dp[n][weight]){

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

				break;

			}

		}

	}

}

// Faster C++ solution for the same problem (measured speedup: 9.115927622899859x):
#include <bits/stdc++.h>

using namespace std;



bool cmp(const pair<int,int> &a,const pair<int,int> &b){

	if( a.first != b.first ) return a.first < b.first;

	else return a.second > b.second;

}

int main(){

	int n,W;

	int t = 1;

	while( cin >> W >> n && W ){

		vector< pair<int,int> > cur;

		cur.push_back({0,0});

		for(int i = 0 ; i < n ; i++){

			int w,c;

			scanf("%d,%d",&c,&w);

			for(int j = 0 , t = cur.size() ; j < t ; j++ )

				cur.push_back(pair<int,int>(cur[j].first+w,cur[j].second+c));

			sort(cur.begin(),cur.end(),cmp);

			int maxi = -1;

			vector< pair<int,int> > nex;

			for(int j = 0 ; j < cur.size() ; j++){

				if( maxi >= cur[j].second ) continue;



				if( cur[j].first <= W ) nex.push_back(cur[j]);

				maxi = cur[j].second;

			}cur = nex;

		}

		int ans = 0, ans2 ;

		for(int i = 0 ; i < cur.size() ; i++){

			if( cur[i].first <= W ){

				ans = cur[i].second;

				ans2 = cur[i].first;

			}

		}



		cout << "Case " << t++ << ":" << endl;

		cout << ans << endl;

		cout << ans2 << endl;

	}

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

#define INF (1<<21)

int dp[1001][1001];

pair<int,int> solve(vector<int> value , vector<int> weight , int W , int N){

	for(int i=0;i<1001;i++)

		for(int j=0;j<1001;j++)

			dp[i][j] = 0;

	for(int num=1;num<=N;num++){

		for(int w=0;w <= W;w++){

			dp[num][w] = max( dp[num][w] , dp[num-1][w]);

			if(w >= weight[num])dp[num][w] = max( dp[num][w] , dp[num-1][w-weight[num]] + value[num]);

		}

	}	

	int ans1 = *max_element(dp[N],dp[N]+W+1);

	int ans2 = find(dp[N],dp[N]+W+1,ans1)-dp[N];

	return make_pair(ans1,ans2);

}



int main(){

	int n,w,CaseNum=0;

	while(cin >> w && w){

		cout << "Case " << ++CaseNum << ":" << endl;

		cin >> n;

		vector<int> value(1+n) , weight(1+n);

		for(int i=1;i<=n;i++){

			scanf("%d,%d\n",&value[i],&weight[i]);

		}

		pair<int,int> ans = solve(value,weight,w,n);

		cout << ans.first << endl << ans.second << endl;

	}

}

// Faster C++ solution for the same problem (measured speedup: 9.082683859132645x):
#include <bits/stdc++.h>

using namespace std;



bool cmp(const pair<int,int> &a,const pair<int,int> &b){

	if( a.first != b.first ) return a.first < b.first;

	else return a.second > b.second;

}

int main(){

	int n,W;

	int t = 1;

	while( cin >> W >> n && W ){

		vector< pair<int,int> > cur;

		cur.push_back({0,0});

		for(int i = 0 ; i < n ; i++){

			int w,c;

			scanf("%d,%d",&c,&w);

			for(int j = 0 , t = cur.size() ; j < t ; j++ )

				cur.push_back(pair<int,int>(cur[j].first+w,cur[j].second+c));

			sort(cur.begin(),cur.end(),cmp);

			int maxi = -1;

			vector< pair<int,int> > nex;

			for(int j = 0 ; j < cur.size() ; j++){

				if( maxi >= cur[j].second ) continue;



				if( cur[j].first <= W ) nex.push_back(cur[j]);

				maxi = cur[j].second;

			}cur = nex;

		}

		int ans = 0, ans2 ;

		for(int i = 0 ; i < cur.size() ; i++){

			if( cur[i].first <= W ){

				ans = cur[i].second;

				ans2 = cur[i].first;

			}

		}



		cout << "Case " << t++ << ":" << endl;

		cout << ans << endl;

		cout << ans2 << endl;

	}

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

  for(int c=1,w; cin>>w,w; c++){

    int n,tr[1001][2] = {0};

    cin >>n;

    for(int i=1; i<=n; i++){

      scanf("%d,%d",&tr[i][0],&tr[i][1]);

    }

    int dp[1001][1001] = {0};

    for(int i=1; i<=n; i++){

      for(int j=0; j<=w; j++){

	if(j>=tr[i][1]){dp[j][i] = max(dp[j][i-1],dp[j-tr[i][1]][i-1]+tr[i][0]);}

	else{dp[j][i] = dp[j][i-1];}

      }

    }

    int pr = dp[w][n], val;

    for(int j=0; j<=w; j++){

      if(pr == dp[j][n]){val = j;break;}

    }

    cout <<"Case "<<c<<":"<<endl;

    cout <<pr<<endl<<val<<endl;

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8202165811592856x):
#include<iostream>

#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

  int w,n,tre[1001][2],dp[1001][1001] = {0},x;

  for(int c = 1; cin >>w,w; c++){

    cin >>n;

    for(int i=1; i<=n; i++){

      scanf("%d,%d",&tre[i][0],&tre[i][1]);

    }

    for(int i=1; i<=n; i++){

      for(int j=1; j<=w; j++){

	dp[i][j] = dp[i-1][j];

	if(j>=tre[i][1]){dp[i][j] = max(dp[i][j],dp[i-1][j-tre[i][1]]+tre[i][0]);}

      }

    }

    for(int j=0; j<=w; j++){

      if(dp[n][j] == dp[n][w]){x = j;break;}

    }

    cout <<"Case "<<c<<":"<<endl<<dp[n][w]<<endl<<x<<endl;

  }

  return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

using namespace std;

int main()

{

    double n,d,x,i,s=0,a,b;

    cin>>n>>d;

    for(i=0;i<n;i++)

    {

        cin>>a>>b;

        x=sqrt((a*a)+(b*b));

        if(x<=d)

            s++;

    }

    cout<<s<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 4.752785082641719x):
#include<stdio.h>

#include<math.h>

int main()

{

    long long int a, b, i, p, q, count = 0;

    scanf("%lld%lld", &a, &b);

    for (i=0; i<a; i++){

        scanf("%lld%lld", &p, &q);

        if ((double)(sqrt(pow(p,2)+pow(q,2))) <= b) count ++;

    }

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

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstring>

#include <string.h>

using namespace std;



int main()

{

    string S;

    cin>>S;

    if(S[2]==S[3]&&S[4]==S[5])

        cout<<"Yes"<<endl;

    else

        cout<<"No"<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.33072938928035x):
#include <stdio.h>



int main(){

	char kopi[450];

	scanf("%s",kopi);

	if (kopi[2] == kopi [3] && kopi[4] == kopi [5]){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;

int main()

{

    string s;

    cin>>s;

    if (s[2]==s[3]&&s[4]==s[5])

        cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.33072938928035x):
#include <stdio.h>



int main(){

	char kopi[450];

	scanf("%s",kopi);

	if (kopi[2] == kopi [3] && kopi[4] == kopi [5]){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int main(){

    string s;

    cin >> s;

    if(s[2]==s[3] && s[4]==s[5])cout << "Yes";

    else cout << "No";

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.318091158063885x):
#include <stdio.h>



int main(){

	char kopi[450];

	scanf("%s",kopi);

	if (kopi[2] == kopi [3] && kopi[4] == kopi [5]){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define elif else if

typedef long long ll;

typedef unsigned long long ull;

#define DEBUG(x) cout << (x) << endl

#define TGET(a, b) get<b>(a)



int is_prime(ll n)

{

    double n_sqrt;

    if (n == 2 || n == 3)

    {

        return 1;

    }

    if (n <= 1 || n % 6 != 1 && n % 6 != 5)

    {

        return 0;

    }

    n_sqrt = double(sqrt((double)n));

    for (int i = 5; i <= n_sqrt; i += 6)

    {

        if (n % i == 0 | n % (i + 2) == 0)

        {

            return 0;

        }

    }

    return 1;

}



int main()

{

    string a;

    cin >> a;

    if(a[2]==a[3]&&a[4]==a[5])

    {

        puts("Yes");

    }

    else

    {

        puts("No");

    }

    

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.34678803233448x):
#include <stdio.h>



int main(){

	char kopi[450];

	scanf("%s",kopi);

	if (kopi[2] == kopi [3] && kopi[4] == kopi [5]){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

char s[10];

int main()

{

	scanf("%s",s);

	if (s[2]==s[3]&&s[4]==s[5]) printf("Yes");else

	printf("No");

} 

// Faster C++ solution for the same problem (measured speedup: 5.2714177452545625x):
#include <stdio.h>



int main(){

	char kopi[450];

	scanf("%s",kopi);

	if (kopi[2] == kopi [3] && kopi[4] == kopi [5]){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}
// Slower C++ solution:
#include <stdio.h>

#include <math.h>

#include <iostream>

using namespace std;

int main()

{   int n,t,j=0;

      char c[6];

      for(int i=0;i<6;i++)cin>>c[i];

      

            if(c[2]==c[3]&& c[4]==c[5])cout<<"Yes";

            else cout<<"No";

 

   return 0;



}

// Faster C++ solution for the same problem (measured speedup: 5.315370514037868x):
#include <stdio.h>



int main(){

	char kopi[450];

	scanf("%s",kopi);

	if (kopi[2] == kopi [3] && kopi[4] == kopi [5]){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <string.h>

using namespace std;



int main()

{

	

	char s[10];

	scanf("%s", s);

	

	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";

	else cout << "No";

	

}

// Faster C++ solution for the same problem (measured speedup: 5.280480279888692x):
#include <stdio.h>



int main(){

	char kopi[450];

	scanf("%s",kopi);

	if (kopi[2] == kopi [3] && kopi[4] == kopi [5]){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    char a[6];

    cin>>a;



    if(a[4]==a[5]&&a[2]==a[3]){

        cout<<"Yes"<<endl;

    }

    else{cout<<"No"<<endl;}

}


// Faster C++ solution for the same problem (measured speedup: 5.333240471625532x):
#include <stdio.h>



int main(){

	char kopi[450];

	scanf("%s",kopi);

	if (kopi[2] == kopi [3] && kopi[4] == kopi [5]){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstring>

#include <string.h>

using namespace std;



int main()

{

    string S;

    cin>>S;

    if(S[2]==S[3]&&S[4]==S[5])

        cout<<"Yes"<<endl;

    else

        cout<<"No"<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.330865117184138x):
#include<stdio.h>

	int main(){

		char S[15];

			//coffee

		scanf ("%s",&S);

		

		if (S[2]==S[3] && S[4]==S[5]){

			printf("Yes\n");

		}else{

			printf ("No\n");

		}

		return 0;

	}
// Slower C++ solution:
#include <iostream>

using namespace std;

int main()

{

    string s;

    cin>>s;

    if (s[2]==s[3]&&s[4]==s[5])

        cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.330865117184138x):
#include<stdio.h>

	int main(){

		char S[15];

			//coffee

		scanf ("%s",&S);

		

		if (S[2]==S[3] && S[4]==S[5]){

			printf("Yes\n");

		}else{

			printf ("No\n");

		}

		return 0;

	}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int main(){

    string s;

    cin >> s;

    if(s[2]==s[3] && s[4]==s[5])cout << "Yes";

    else cout << "No";

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.3182265641804465x):
#include<stdio.h>

	int main(){

		char S[15];

			//coffee

		scanf ("%s",&S);

		

		if (S[2]==S[3] && S[4]==S[5]){

			printf("Yes\n");

		}else{

			printf ("No\n");

		}

		return 0;

	}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define elif else if

typedef long long ll;

typedef unsigned long long ull;

#define DEBUG(x) cout << (x) << endl

#define TGET(a, b) get<b>(a)



int is_prime(ll n)

{

    double n_sqrt;

    if (n == 2 || n == 3)

    {

        return 1;

    }

    if (n <= 1 || n % 6 != 1 && n % 6 != 5)

    {

        return 0;

    }

    n_sqrt = double(sqrt((double)n));

    for (int i = 5; i <= n_sqrt; i += 6)

    {

        if (n % i == 0 | n % (i + 2) == 0)

        {

            return 0;

        }

    }

    return 1;

}



int main()

{

    string a;

    cin >> a;

    if(a[2]==a[3]&&a[4]==a[5])

    {

        puts("Yes");

    }

    else

    {

        puts("No");

    }

    

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.346924169114016x):
#include<stdio.h>

	int main(){

		char S[15];

			//coffee

		scanf ("%s",&S);

		

		if (S[2]==S[3] && S[4]==S[5]){

			printf("Yes\n");

		}else{

			printf ("No\n");

		}

		return 0;

	}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

char s[10];

int main()

{

	scanf("%s",s);

	if (s[2]==s[3]&&s[4]==s[5]) printf("Yes");else

	printf("No");

} 

// Faster C++ solution for the same problem (measured speedup: 5.271551963000073x):
#include<stdio.h>

	int main(){

		char S[15];

			//coffee

		scanf ("%s",&S);

		

		if (S[2]==S[3] && S[4]==S[5]){

			printf("Yes\n");

		}else{

			printf ("No\n");

		}

		return 0;

	}
// Slower C++ solution:
#include <stdio.h>

#include <math.h>

#include <iostream>

using namespace std;

int main()

{   int n,t,j=0;

      char c[6];

      for(int i=0;i<6;i++)cin>>c[i];

      

            if(c[2]==c[3]&& c[4]==c[5])cout<<"Yes";

            else cout<<"No";

 

   return 0;



}

// Faster C++ solution for the same problem (measured speedup: 5.315505850882987x):
#include<stdio.h>

	int main(){

		char S[15];

			//coffee

		scanf ("%s",&S);

		

		if (S[2]==S[3] && S[4]==S[5]){

			printf("Yes\n");

		}else{

			printf ("No\n");

		}

		return 0;

	}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <string.h>

using namespace std;



int main()

{

	

	char s[10];

	scanf("%s", s);

	

	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";

	else cout << "No";

	

}

// Faster C++ solution for the same problem (measured speedup: 5.280614728379142x):
#include<stdio.h>

	int main(){

		char S[15];

			//coffee

		scanf ("%s",&S);

		

		if (S[2]==S[3] && S[4]==S[5]){

			printf("Yes\n");

		}else{

			printf ("No\n");

		}

		return 0;

	}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    char a[6];

    cin>>a;



    if(a[4]==a[5]&&a[2]==a[3]){

        cout<<"Yes"<<endl;

    }

    else{cout<<"No"<<endl;}

}


// Faster C++ solution for the same problem (measured speedup: 5.333376263465026x):
#include<stdio.h>

	int main(){

		char S[15];

			//coffee

		scanf ("%s",&S);

		

		if (S[2]==S[3] && S[4]==S[5]){

			printf("Yes\n");

		}else{

			printf ("No\n");

		}

		return 0;

	}
// Slower C++ solution:
#include<iostream>

using namespace std;

main()

{

string S;

cin >> S;

if(S[2] == S[3] && S[4] == S[5])

    {

cout << "Yes" << endl;

    }

else

    {

cout << "No" << endl;

    }

return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.330865117184138x):
#include<stdio.h>

	int main(){

		char S[15];

			//coffee

		scanf ("%s",&S);

		

		if (S[2]==S[3] && S[4]==S[5]){

			printf("Yes\n");

		}else{

			printf ("No\n");

		}

		return 0;

	}
// Slower C++ solution:
#include <iostream>

#include <cstring>

#include <string.h>

using namespace std;



int main()

{

    string S;

    cin>>S;

    if(S[2]==S[3]&&S[4]==S[5])

        cout<<"Yes"<<endl;

    else

        cout<<"No"<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.333045694730859x):
#include<stdio.h>

int main()

{

	char S[10];

	scanf("%s",S);

	if(S[2]==S[3] && S[4]==S[5]){

		printf("Yes");

	}

	else {

		printf("No");

	}

	return 0;

}