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

int main() {
  int N;
  cin >> N;

  vector<long long> A(N);
  long long totA = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    totA += A.at(i);
  }

  vector<long long> B(N);
  long long totB = 0;
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
    totB += B.at(i);
  }

  if (totA < totB) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> C(N);
  long long ans = 0;
  long long cost = 0;
  for (int i = 0; i < N; i++) {
    C.at(i) = A.at(i) - B.at(i);
    if (C.at(i) < 0) {
      ans++;
      cost += C.at(i) * (-1);
    }
  }

  sort(C.begin(), C.end());
  reverse(C.begin(), C.end());

  int i = 0;
  while (cost > 0) {
  cost -= C.at(i);
  i++;
  ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 2176
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
#from collections import defaultdict
def main():
    n = int(input())
    s = tuple(map(int, tuple(input())))
    num_pos = [] # 各数字がｓ中に最後にあらわれる位置。
    for num in range(10):
        if num in s:
            num_pos.append(n - s[::-1].index(num) - 1)
    unique_num = [0] * n # ｓの各桁でその桁以降にある数字の種類。
    for i1 in range(n):
        unique_num[i1] = sum([np >= i1 for np in num_pos])
    unique_num.append(0)
    r = 0
    for keta1 in range(10):
        if keta1 in s:
            keta1_pos = s.index(keta1)
            for keta2 in range(10):
                if keta2 in s[keta1_pos + 1:]:
                    keta2_pos = s[keta1_pos + 1:].index(keta2) + keta1_pos + 1
                    r += unique_num[keta2_pos + 1]
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9720
#include <bits/stdc++.h>
#define Tayeb ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;
using namespace std;
int main()
{
    Tayeb;
    string A,B;
    cin >> A >> B;

      if(A.length()>B.length())
      cout << "GREATER" << "\n";
      else if(A.length()<B.length())
      cout << "LESS" << "\n";
      else if(A==B)
      cout << "EQUAL" << "\n";
      else
      {
          for(int i=0,j=0; i<A.length()&&j<B.length(); i++,j++)
          {
              if(A[i]!=B[i])
              {
                  if(A[i]>B[i])
                  {
                  cout << "GREATER" << "\n";
                  break;
                  }
                  else if(A[i]<B[i])
                  {
                  cout << "LESS" << "\n";
                  break;
                  }
              }
          }
      }
    return 0;

}


Measured memory_bytes: 3620
#include <stdio.h>
 
int main(){
	int H, W;
  	scanf("%d %d", &H, &W);
  	int h, w;
  	scanf("%d %d", &h, &w);
  	int field[H][W];
  	for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        field[i][j] = 0;
      }
    }
  	for(int i = 0; i < h; i++){
      for(int j = 0; j < W; j++){
        field[i][j] = 1;
      }
    }
  	for(int i = 0; i < H; i++){
      for(int j = 0; j < w; j++){
        field[i][j] = 1;
      }
    }
  int count = 0;
  for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(field[i][j] == 0){
          count++;
        }
      }
    }
  	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk

using namespace std;

inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }

const int N = 200000 + 111;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

ll bin_pow(ll a, ll p) {
    ll res = 1;
    while (p) {
        if (p & 1) {
            res = res * a % MOD;
        }
        a = a * a % MOD;
        p >>= 1;
    }
    return res;
}

ll rev(ll x) {
    return bin_pow(x, MOD - 2);
}

ll fact[N], rfact[N];

void init() {
    fact[0] = 1;
    rep(i, 1, N) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    rfact[N - 1] = rev(fact[N - 1]);
    repb(i, N - 2, -1) {
        rfact[i] = rfact[i + 1] * (i + 1) % MOD;
    }
}

ll C(int n, int k) {
    if (k < 0 || k > n) {
        return 0;
    }
    return fact[n] * rfact[k] % MOD * rfact[n - k] % MOD;
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, 0, sz(s)) {
        if (s[i] == 'x') {
            cnt++;
        }
    }
    cout << (cnt <= 7 ? "YES\n" : "NO\n");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int H, W;
    
    while (true) {
      StringBuilder peri = new StringBuilder();
      StringBuilder mid  = new StringBuilder();
      String crlf = System.getProperty("line.separator");
      H = in.nextInt();
      W = in.nextInt();
      
      if (H == 0 && W == 0) break;
      
      for (int w = 0; w < W; w++) {
        peri.append("#");
      }
      for (int w = 0; w < W; w++) {
        if (w == 0 || w == W - 1) mid.append("#");
        else                      mid.append(".");
      }
      for (int h = 0; h < H; h++) {
        if (h == 0 || h == H - 1) System.out.println(peri);
        else                      System.out.println(mid);
      }
      System.out.print(crlf);
    }
  }
}

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

using namespace std;

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

    int n;
    cin >> n;

    int res = n;
    for (int i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            res = res / i * (i -1);
            while (n % i == 0) n /= i;
        }
    }
    if (n != 1) res = res / n * (n - 1);

    cout << res << '\n';

    return 0;
}



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


const int MOD = 1000000007;
const int A = 0, C = 1, G = 2, T = 3;
int main() {
    int N;
    cin >> N;
    int64_t dp[114][4][4][4] = {};
    dp[0][T][T][T] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                for (int l = 0; l < 4; l++) {
                    for (int m = 0; m < 4; m++) {
                        if (j == A && k == G && l == C) continue;
                        if (j == A && k == G && m == C) continue;
                        if (j == A && l == G && m == C) continue;
                        if (k == A && l == G && m == C) continue;
                        if (k == A && l == C && m == G) continue;
                        if (k == G && l == A && m == C) continue;
                        dp[i + 1][k][l][m] += dp[i][j][k][l];
                        dp[i + 1][k][l][m] %= MOD;
                    }
                }
            }
        }
    }
    int64_t num_strings = 0;
    for (int j = 0; j < 4; j++) {
        for (int k = 0; k < 4; k++) {
            for (int l = 0; l < 4; l++) {
                num_strings += dp[N][j][k][l];
                num_strings %= MOD;
            }
        }
    }
    cout << num_strings << "\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<double> ps(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> ps[i];
    }
    vector<vector<double>> dp(n + 1, vector<double>(n + 1));
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= i; ++j) {
            dp[i][j] += dp[i - 1][j] * (1 - ps[i]);
            if (j > 0)
                dp[i][j] += dp[i - 1][j - 1] * ps[i];
        }
    }
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; ++i) {
        ans += dp[n][i];
    }
    printf("%.12f\n", ans);
    return 0;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n;
    ll ans=0;
    string s;
    cin>>n>>s;
    map<string,ll> A[19],B[19];
    rep(i,2){
        rep(bit,1<<n){
            string t;
            int a=0;
            if(!i) rep(j,n) if(bit&(1<<j)) t+=s[j];
            rep(j,n) if(!(bit&(1<<n-j-1))) t+=s[n-j-1+n*i],a++;
            if(i) rep(j,n) if(bit&(1<<j)) t+=s[j+n];
            if(!i) A[a][t]++;
            else B[a][t]++;
        }
    }
    rep(i,n+1)for(auto itr=A[i].begin();itr!=A[i].end();itr++){
        ans+=itr->second*B[n-i][itr->first];
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 90368
#include <bits/stdc++.h>
#define ll                      long long
#define ld                      long double
#define ull                     unsigned long long
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<ll,ll>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define MIN                     -1e9
#define pi                      3.1415926535897932384626433832795
 
using namespace std;
 
void INPUT()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
 
/*
----------------------------------------------------------------
 
   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Read the Question and the sample test cases carefully
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible ..
 
----------------------------------------------------------------*/
 
 
void solve()
{
 
}
 
int main() {
 
  FIO
  INPUT();
  int d,s,t;
  cin>>d>>t>>s;
  if(t*s>=d)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
}

Measured memory_bytes: 3648
import java.lang.Integer.max
import java.util.*

fun main(args : Array<String>) {
    val (n, m, q) = readLine()!!.split(" ").map { it.toInt() }
    val qq = mutableListOf<Item>()

    repeat(q) {
        val (a, b, c, d) = readLine()!!.split(" ").map { it.toInt() }
        qq.add(Item(a-1, b-1, c, d))
    }

    val dfs = Stack<IntArray>()
    for (i in 1..m) {
        val a = IntArray(n){0}
        a[0] = i
        dfs.push(a)
    }

    var hScore = 0

    while (dfs.isNotEmpty()) {
        val a = dfs.pop()
        if (a.last() != 0) {
            hScore = max(hScore, qq.map { if (a[it.idx2] - a[it.idx1] == it.diff) it.score else 0 }.sum())
            continue
        }

        val lastIdx = a.indexOfLast { it != 0 }
        for (i in a[lastIdx]..m) {
            val newA = a.copyOf()
            newA[lastIdx+1] = i
            dfs.push(newA)
        }
    }

    println(hScore)
}

data class Item(val idx1: Int, val idx2: Int, val diff: Int, val score: Int)

Measured memory_bytes: 57968
#include<iostream>
using namespace std;
bool a,b,c;
int main(){
  string s; cin >> s;

  for ( int i = 0; i < 3; i++ ) {
    if ( s[i] == 'a') a = true;
    if ( s[i] == 'b') b = true;
    if ( s[i] == 'c') c = true;    
  }

  if ( a && b && c ) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
#define NIL -1
using ll = long long;
const ll MOD = 1000000007;
#define REP(i,n) for (ll i=0; i < (n); ++i)
#define FOR(i,a,b) for (ll i=(a); i < (b); ++i)
using namespace std;

int get_gcd(int a, int b){while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<int> a(x),b(y),c(z);
  REP(i,x) cin >> a[i];
  REP(i,y) cin >> b[i];
  REP(i,z) cin >> c[i];
  sort(ALL(a), greater<int>());
  sort(ALL(b), greater<int>());
  sort(ALL(c), greater<int>());

  using Tup = tuple<int,int,int,int>;
  auto sum = [&](const Tup& s) {
    return a[get<1>(s)]+b[get<2>(s)]+c[get<3>(s)];
  };
  priority_queue<Tup> pq;
  set<Tup> used;

  pq.push(Tup{a[0]+b[0]+c[0],0,0,0});
  used.insert(pq.top());
  REP(i,k) {
    const Tup curr = pq.top(); pq.pop();
    cout << get<0>(curr) << endl;

    if (get<1>(curr)+1 < x) {
      Tup next(curr);
      get<1>(next)++;
      get<0>(next) = sum(next);
      if (used.find(next) == used.end()) {
        pq.push(next);
        used.insert(next);
      }
    }

    if (get<2>(curr)+1 < y) {
      Tup next(curr);
      get<2>(next)++;
      get<0>(next) = sum(next);
      if (used.find(next) == used.end()) {
        pq.push(next);
        used.insert(next);
      }
    }

    if (get<3>(curr)+1 < z) {
      Tup next(curr);
      get<3>(next)++;
      get<0>(next) = sum(next);
      if (used.find(next) == used.end()) {
        pq.push(next);
        used.insert(next);
      }
    }
  }

  return 0;
}


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

int main() {
    int N, K;
    std::cin >> N >> K;

    int sum = 0, x;
    for (int i = 0; i < N; ++i) {
        std::cin >> x;
        sum += std::min(x * 2, (K - x) * 2);
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 256
def power(x, y, p) : 
    if y==0: return 1%p
    res = 1     # Initialize result 
  
    # Update x if it is more 
    # than or equal to p 
    x = x % p  
      
    if (x == 0) : 
        return 0
  
    while (y > 0) : 
          
        # If y is odd, multiply 
        # x with result 
        if ((y & 1) == 1) : 
            res = (res * x) % p 
  
        # y must be even now 
        y = y >> 1      # y = y/2 
        x = (x * x) % p 
    return res  

F = [0,1,1]
for i in range(3,200001):
	F += [ 1 + F[i%(bin(i).count('1'))]]
	

n=int(input())
s=input()
ones = s.count('1')
a = ones -1
b = ones
c = ones+1
moda = modb = modc = 0
for i in range(n-1,-1,-1):
	pos = n-1-i
	if s[i]=='1':
		if a>0 : moda = (moda + power(2, pos, a) ) %a
		modc = (modc + power(2, pos, c) ) %c

for i in range(n):
	if s[i] == '0': #ajout
		add = power(2, n-1-i, c)
		ans = (modc + add) % c
		# ~ print("i",i, "add",add,"ans",ans)
		print(F[ans]+1)
	else: # retrait
		if a<=0: print(0)
		else:
			sub = power(2, n-1-i, a)
			ans = (moda - sub) % a
			print(F[ans]+1)


Measured memory_bytes: 11052
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >>a[i];
  }
sort(a,a+n);int ans=0;int c=1;
for(int i=0;i<n-1;i++){
  if(a[i]==a[i+1]){
    c++;
    if(i==n-2){
      if(c%2==1) ans++;
    }
  }
  else{
    if(c%2==1) ans++;
    if(i==n-2) ans++;
    c=1;
  }
}
cout << ans<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define ip1(arr, n) for(int i=1; i<=n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define inf 1e9
#define INF 1e16
#define MOD 1000000007


int main(){

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll n,d;
    cin>>n>>d;
    ll ans=0;
    // map<pair<ll, ll>, ll>m;
    for(int i=0; i<n; i++){
        ll x,y;
        cin>>x>>y;
        double a = sqrt((x*x)+(y*y));
        // a = floor(a);
        if(a<=d){
            ans++;
        }
        // m[{x,y}]=1;
    }
    
    cout<<ans<<endl;
    return 0;
}

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

typedef pair<int, int> ii;

int main(){
    int N;
    scanf("%d", &N);

    multiset<ii> SE;
    multiset<ii> ES;
    for(int i = 0; i < N; i ++){
        int x, l;
        scanf("%d%d", &x, &l);
        SE.insert(ii(x-l, x+l));
        ES.insert(ii(x+l, x-l));
    }

    int ans = 0;
    int lastCovered = -2147483647;
    while(!SE.empty()){
        ii temp = *ES.begin();
        int e = temp.first;
        int s = temp.second;

        //printf("s=%d e=%d\n", s, e);

        ES.erase(ES.find(ii(e, s)));
        SE.erase(SE.find(ii(s, e)));
        if(s >= lastCovered){
            ans ++;
            lastCovered = e;
        }
    }

    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 9600
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

int main()
{
	ll a,b;
	cin>>a>>b;
	if(a%2==0||b%2==0) puts("Even");
	else puts("Odd");
}

Measured memory_bytes: 256
// 2015/07/03 Tazoe

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

void DFS(int J, int Y, int a, int b, string s)
{
	if(a==J && b==Y){		// 得点に達したら
		cout << s << endl;
		return;
	}

	if(a>J || b>Y)			// 得点を超えてしまったら
		return;

	if((a<5 && b<5) || (a==5 && b==4) || (a==4 && b==5)){
		DFS(J, Y, a+1, b, s+"A");
		DFS(J, Y, a, b+1, s+"B");
	}
}

int main()
{
	int j, y;
	cin >> j >> y;

	DFS(j, y, 0, 0, "");

	return 0;
}

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

using namespace std;

#define llint long long int
#define REP(i,s,l) for(llint i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {

    //N個のソース i番目は  Ai1～AiMのM個   A11~A1M A21~A2M 
    //同じMこの文字列もある

    int code, seisuko, plusC;
    cin >> code >> seisuko >> plusC;

    int setB[seisuko];
    int sum = 0;
    int inputA = 0;
    int count = 0;

    //B入力
    REP(i,0,seisuko){
        cin >> setB[i] ;
    }

    //M個入れたら判定
    REP(i,0,code){
        sum = 0;
        REP(t,0,seisuko){
            cin >> inputA;
            sum += inputA * setB[t];
        }

        sum += plusC;
        if(sum > 0) count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define f0r(a, b) for (long long a = 0; a < (b); ++a)
#define f1r(a, b, c) for (long long a = (b); a < (c); ++a)
#define f0rd(a, b) for (long long a = (b); a >= 0; --a)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); --a)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define fix(prec) {cout << setprecision(prec) << fixed;}
#define mp make_pair
#define f first
#define s second
#define presum(p, a, n) {p[0] = a[0]; for (int i = 1; i < (n); i++) p[i] = a[i] + p[i-1];}
#define all(v) v.begin(), v.end()
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define readgraph(list, edges) for (int i = 0; i < edges; i++) {int a, b; cin >> a >> b; a--; b--; list[a].pb(b); list[b].pb(a);}
#define ai(a, n) for (int ele = 0; ele < n; ele++) cin >> a[ele];
#define ain(a, lb, rb) for (int ele = lb; ele <= rb; ele++) cin >> a[ele];
#define ao(a, n) {for (int ele = 0; ele < (n); ele++) { if (ele) cout << " "; cout << a[ele]; } cout << '\n';}
#define aout(a, lb, rb) {for (int ele = (lb); ele <= (rb); ele++) { if (ele > (lb)) cout << " "; cout << a[ele]; } cout << '\n';}
typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
 
mt19937 rng(steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
// const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;





ll n, m, k, q, l, r, x, y, z;
ll a[1000005];
ll b[1000005];
ll c[1000005];
string s, t;
ll ans = 0;



void solve(int tc) {
  cin >> s;
  cout << (s[2] == s[3] && s[4] == s[5] ? "Yes\n" : "No\n");
}

int main() {
  send help

  // usaco("file");

  int tc;
  tc = 1;
  // cin >> tc;
  for (int t = 0; t < tc; t++) solve(t);
} 

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

namespace mondai0040
{
	class Program
	{
		static void Main(string[] args)
		{
			var	n	= int.Parse( Console.ReadLine() );
			for( int nn = 0; nn < n; nn++ ) {
				var	line	= Console.ReadLine();
				var	key	= key_fined( line );
				var	new_line	= "";
				foreach( var c in line ) {
					if( (c >= 'a') && (c <= 'z') ) {
						int	i;
						for( i = 0; i < 26; i++ ) {
							if( key[ i ] == c ) {
								break;
							}
						}
						new_line	+= (char)(i + 'a');
					} else {
						new_line	+= c;
					}
				}
				Console.WriteLine( new_line );
			}
		}

		
		static int[] key_fined( string line )
		{
			for( int a = 3; ; a += 2 ) {
				for( int b = 0; b < 26; b++ ) {
					string[]	chk_org	= { "that", "this" };
					string[]	chk		= { "", "" };
					for( int i = 0; i < 2; i++ ) {
						foreach( var c in chk_org[ i ] ) {
							chk[ i ]	+= (char)(((a * (c - 'a') + b) % 26) + 'a');
						}
					}
					bool	find	= false;
					for( int i = 0; i < 2; i++ ) {
						if( line.IndexOf( chk[ i ] ) != -1 ) {
							find	= true;
							break;
						}
					}
					if( find ) {
						//Console.WriteLine( "a={0} b={1}: {2},{3}", a, b, chk[ 0 ], chk[ 1 ] );
						var	org	= "abcdefghijklmnopqrstuvwxyz";			
						var	key	= new int[ 26 ];		
						for( int i = 0; i < 26; i++ ) {
							key[ i ]	= ((a * (org[ i ] - 'a') + b) % 26) + 'a';
						}		
						return( key );
					}
				}
			}
		}
	}
}

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

void kock(int n, double x1,double  y1, double  x2,double y2){
  double sx,sy, tx,ty, ux,uy;
  if (n > 0){

  sx = (2 * x1 + 1 * x2) / 3 ;
  sy = (2 * y1 + 1 * y2) / 3 ;

  tx = (1 * x1 + 2 * x2) / 3 ;
  ty = (1 * y1 + 2 * y2) / 3 ;

  ux = ((tx - sx) * cos(M_PI / 3) - (ty - sy) * sin(M_PI / 3)) + sx;
  uy = ((tx - sx) * sin(M_PI / 3) + (ty - sy) * cos(M_PI / 3)) + sy;
  

  kock(n-1, x1,y1, sx,sy);
  printf("%f %f\n",sx,sy);
  kock(n-1, sx,sy, ux,uy);
  printf("%f %f\n",ux,uy);
  kock(n-1, ux,uy, tx,ty);
  printf("%f %f\n",tx,ty);
  kock(n-1, tx,ty, x2,y2);
  }
}

int main(){

  int n;
  double x1 = 0.0, y1 = 0.0;
  double x2 = 100.0, y2 = 0.0;

  scanf("%d",&n);
  printf("%f %f\n",x1,y1);
  kock(n, x1,y1, x2,y2);
  printf("%f %f\n",x2,y2);
  return 0;
}
  

Measured memory_bytes: 636
from collections import Counter

N = int(input())
D = list(map(int, input().split()))

C = Counter(D)

if D[0] > 0 or C[0] > 1:
  print(0)
  exit(0)
  
mod = int(998244353)
ans = 1
for i in range(2,max(D)+1):
  ans = (ans * (C[i-1] ** C[i]) % mod) % mod
  
print(ans)

Measured memory_bytes: 19936
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;

using namespace std;
int main(){
	int k,x;
	cin >> k >> x;
	for(int i=x-k+1;i<=x+k-1;i++)
        cout<<i<<endl;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;


int gcd(int a, int b, int c){
	int min_val = min(a,min(b,c));
	
	int gcd_val = 1;
	for (int i =1;i<=min_val; i++){
		if (((a%i) == 0) && ((b%i) == 0) && ((c%i) == 0)){
			gcd_val = max(gcd_val, i);
		}
	}
	
	return gcd_val;
}

int main()
{
	int n;
	cin>>n;
	
	long long sum =0;
	
	for(int i = 1; i<=n; i++){
		for(int j = 1; j<=n; j++){
			for(int k = 1;k<=n;k++){
				sum += gcd(i,j,k);
			}
		}
	}
	
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3648
object Main extends App {
	val n = scala.io.StdIn.readInt
	val v = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val c = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	
	println(v.zip(c).map{case (a, b) => a - b}.filter(_ > 0).sum)
}

Measured memory_bytes: 25656
import math

N, M = map(int, input().split())

MOD = 10 ** 9 + 7

# (a^b)%MODを返す関数
# O(logb)
# 例えばb = 62のとき
# 62 -> 31 -> 30 -> 15 -> 14 -> 7 -> 6 -> 3 -> 2 -> 1 -> 0
def modpow(a, b):
    if b == 0:
        return(1)

    # b:evenのとき
    if b % 2 == 0:
        # a^(b/2)をhalfとしてその二乗を計算
        half_b = b // 2
        half = modpow(a, half_b)
        return((half ** 2) % MOD)
    # b:oddのとき
    else:
        # bを偶数にするために1減らす
        return((a * modpow(a, b-1)) % MOD)

# (aCb)%MODを返す関数
# 例えば10C3のとき
# 10C3 = 10*9*8/3*2*1 = mul/div
def modcomb(a, b):
    # aCb = aC(a-b)なので
    # bが大きかったらa-bに書き換えた方が早い
    if b > a - b:
        return(modcomb(a, a-b))

    # aCb = mul/div
    mul = 1
    div = 1
    for i in range(b):
        mul *= a - i
        div *= b - i
        mul %= MOD
        div %= MOD

    # (mul/div)%MODを求めたい
    # divの逆元を用いる
    # p:primeのときmodpとして(ここではMOD:primeなので使える)
    # a^(-1) ≡　a^(p-2)
    # この式は、ある数をaで割った時のあまりが
    # ある数にa^(p-2)をかけた時のあまりに等しいという意味
    res = (mul * modpow(div, MOD - 2)) % MOD
    return(res)

ans = 1

for i in range(2, math.floor(math.sqrt(M))+1):
    # 次のifがTrueになるiは必然的に素数になる
    if M % i == 0:
        cnt = 0
        while M % i == 0:
            cnt += 1
            M //= i
        ans *= modcomb(cnt + (N - 1), cnt)
        ans %= MOD
# 最後に残った場合、その素数を処理する
if M != 1:
    ans *= modcomb(1 + (N - 1), 1)
    ans %= MOD

print(ans)


Measured memory_bytes: 3192
#include <stdio.h>
int main(void){
int a,b;
char op;
while(1){
scanf("%d %c %d",&a,&op,&b);
if ( op == '+' ){
  printf("%d\n",a+b);
} else if ( op == '-' ){
  printf("%d\n",a-b);
} else if ( op == '*' ){
  printf("%d\n",a*b);
} else if ( op == '/' ){
   printf("%d\n",a/b);
} else {
   break;
}
}       
return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int g[701][701],col[701];
int dp[2][701];
int num1,num2,n,x,y,m;
void init(int n){
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++) 
	 if(i!=j) g[i][j]=1;
}
bool dfs(int x,int c){
	if(col[x]==0){
		col[x]=c;
		if(c==1) num1++;
		else num2++;	
	}
	else return col[x]==c;
	for(int i=1;i<=n;i++){
		if(x!=i&&g[x][i]){
			if(!dfs(i,-c)) return 0;
		}
	} 
	return 1;
} 
int main(){
	std::ios::sync_with_stdio(false);
	cin>>n>>m;init(n);
	for(int i=1;i<=m;i++){
		cin>>x>>y;g[x][y]=g[y][x]=0;
	}
	dp[0][0]=1;int cur=0;
	for(int i=1;i<=n;i++){
		if(col[i]==0){
			num1=num2=0;
			if(!dfs(i,1)){cout<<"-1\n";return 0;}
			int suf=cur^1;
			memset(dp[suf],0,sizeof(dp[suf]));
			for(int i=0;i<=n;i++){
				if(dp[cur][i]){
					dp[suf][i+num1]=dp[suf][i+num2]=1;
				}
			}
			cur=suf;
		} 
	}
	for(int i=n/2;i>=1;i--){
		if(dp[cur][i]){
			cout<<i*(i-1)/2+(n-i)*(n-i-1)/2<<endl;
			return 0;
		}
	}
	return 0;
}

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

using i64 = long long int;

struct City{
    int idx, p, y;
    bool operator<(const City &obj)const{
        return y < obj.y;
    }
};

int num[100005]={0};

int main(){
    int n, m;
    cin >> n >> m;
    vector<string> ans;
    vector<City> cities;
    for(int i=0;i<m;++i){
        int p, y;
        cin >> p >> y;
        char s[10];
        sprintf(s, "%06d", p);
        string str(s, 6);
        ans.push_back(str);
        cities.push_back((City){i, p, y});
    }
    sort(cities.begin(), cities.end());

    for(auto city : cities){
        char s[10];
        sprintf(s, "%06d", num[city.p]+1);
        string str(s, 6);
        ans[city.idx] += str;
        num[city.p]++;
    }

    for(auto s : ans){
        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 8488
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int32_t main()
{
	IOS;
	int T=1;
	//cin>>T;
	while(T--)
	{
		long double r;
		cin>>r;

		cout.precision(6);
		cout<<2*PI*r<<endl;
	}

	return 0;
}

Measured memory_bytes: 3808
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        String[] NS = new String[N];
        int[] l = new int[N];
        int ans = 0;

        for(int i=0; i<N; i++){
            NS[i] = String.valueOf(i+1);
            l[i] = NS[i].length();
            if(l[i]%2!=0){
                ans += 1;
            } 
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 28372
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int a, b, c, d;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);

    if ((abs(c-b) <= d) && (abs(b-a) <= c) || (abs(c-a) <= d)){
        printf("Yes\n");
    }
    else
        printf("No\n");
    
    return 0;
}

Measured memory_bytes: 128
M=int(input())
N=list(input().split())
check=[0]*M
for i in range(M):
    check[int(N[i])-1]+=1
num=0
for i in range(M):
    num+=check[i]*(check[i]-1)//2
for i in range(M):
    if check[int(N[i])-1]!=2:
        print(num-(check[int(N[i])-1]-1))
    else:
        print(num-1)


Measured memory_bytes: 20576
# -*- coding: utf-8 -*-
import heapq as hp
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
result = 0
cnt_r = x
cnt_g = y
cnt_n = x+y

apples = []
for i in range(a):
    apple = (-p[i], "R")
    hp.heappush(apples, apple)
for i in range(b):
    apple = (-q[i], "G")
    hp.heappush(apples, apple)
for i in range(c):
    apple = (-r[i], "N")
    hp.heappush(apples, apple)

while cnt_n > 0:
    tmp_a = hp.heappop(apples)
    if tmp_a[1] == "R":
        if cnt_r > 0:
            result += -tmp_a[0]
            cnt_r -= 1
            cnt_n -= 1
    elif tmp_a[1] == "G":
        if cnt_g > 0:
            result += -tmp_a[0]
            cnt_g -= 1
            cnt_n -= 1
    else:
        if cnt_n > 0:
            result += -tmp_a[0]
            cnt_n -= 1

print(result)

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

int main(void){
    vector<int> a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(), a.end());
    int ans=a[1]+a[0];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


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

count = 0
pos = 1
for i, a in enumerate(A):
    if a == pos:
        pos += 1
    else:
        count += 1

if count <= N - 1:
    print(count)
else:
    print(-1)



Measured memory_bytes: 32308
N = int(input())
s = [""] * N
t = [0] * N
for i in range(N):
    a, b = map(str, input().split())
    s[i] = a
    t[i] = int(b)
X = input()

sleep_index = s.index(X)
ans = 0
for i in range(sleep_index+1, N):
    ans += t[i]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main () {
    string s;
    cin >> s;
    string t;
    cin >> t;
    sort(s.begin() , s.end());
    sort(t.begin() , t.end());
    reverse(t.begin() , t.end());
    if(s < t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N;
  cin >> N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<pair<ll,ll>> S;
  ll cnt = -1;
  for (ll i = 2; i * i <= N; i++) {
    if (N % i == 0) {
      cnt++;
      S.push_back(make_pair(i,0));
      while (N % i == 0) {
        N /= i;
        S[cnt].second++;
      }
    }
  }
  if (N != 1) {
    S.push_back(make_pair(N,(ll)(1)));
  }
  ll ans = 0;
  for (int i = 0; i < S.size(); i++) {
    for (int j = 2; j < 100; j++) {
      if (S[i].second < ((j+1) * j) / 2) {
        ans += j - 1;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef pair<int,int> P;
typedef long long ll;

int par[100000];
int r[100000];

void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i;
		r[i] = 0;
	}
}

int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x==y) return;
	if(r[x]<r[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(r[x]==r[y]) r[x]++;
	}
}

bool same(int x, int y){
	return find(x) == find(y);
}

int main(){
	int n,m;
	cin >> n >> m;
	int x[100000], y[100000], z[100000];
	init(n);

	for(int i=0;i<m;i++){
		cin >> x[i] >> y[i] >> z[i];
		unite(x[i]-1,y[i]-1);
	}

	set<int> s;
    for(int i=0;i<n;i++){
        s.insert(find(i));
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 6784
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.next());
        int b = Integer.parseInt(scanner.next());

        String operator;
        if (a > b) {
            operator = " > ";
        } else if (a < b) {
            operator = " < ";
        } else {
            operator = " == ";
        }

        System.out.println("a" + operator + "b");
    }
}

Measured memory_bytes: 26156
def main():
	n = int(input())
	sl=[]
	for i in range(n):
		sl.append(list(input()))
	for s in sl:
		s.sort()
	sl.sort()
	
	
	b=sl[0]
	l=1
	ans=0
	for i in range(1,n):
		if sl[i]==b:
			l+=1
			if i==n-1 and l >1:
				ans+=l*(l-1)/2
		else:
			if l>1:
				ans+=l*(l-1)/2
			b=sl[i]
			l=1
	print (int(ans))

main()


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

int LinearSearch(int x,int S[],int N);

int main(){
  int a[10000];
  int b[500];
  int count=0;
  int a_n=0,b_n=0;
  cin >> a_n;
  for(int i=0;i<a_n;i++){
    cin>>a[i];
  }
  cin >> b_n;
  for(int i=0;i<b_n;i++){
    cin>>b[i];
  }
  for(int i=0;i<b_n;i++){
    if(LinearSearch(b[i],a,a_n)!=-1){
      count++;
    }
  }
  cout << count << endl;
}

int LinearSearch(int x,int S[],int N){
  S[N]=x;
  for(int i=0;;i++){
    if(S[i]==x){
      if(i<N)
        return i;
      else
        return -1;
    }
  }
}



Measured memory_bytes: 3108
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    long double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    long double xx;
    xx = x/b*2.0;
    cout << fixed << setprecision(10);
    if(xx > a) {
        xx = a;
        long double bb = x/a;
        b = 2.0*b-bb*2.0;
    }

    cout << 180.0/M_PI * atan(b/xx) << endl;
}

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

typedef struct Node {
	struct Node *next;
	char name[11];
	int time;
} NODE;

NODE *front = NULL;
NODE *rear = NULL;

void enqueue(char *name, int time)
{
	NODE *tmp = (NODE *)malloc(sizeof(NODE));
	memcpy(tmp->name, name, sizeof(tmp->name));
	tmp->time = time;
	tmp->next = NULL;

	if (front == NULL) {
		front = rear = tmp;
	}
	else {
		rear->next = tmp;
		rear = tmp;
	}
}

int dequeue(NODE *node)
{
	if (front != NULL) {
		memcpy(node, front, sizeof(NODE));
		free(front);
		front = node->next;
		return 1;
	}
	else {
		return 0;
	}
}

int main(int argc, char** argv)
{
	int i, proc_num, q, time;
	char name[11];

	scanf("%d %d", &proc_num, &q);

	for (i = 0; i < proc_num; i++) {
		scanf("%s %d", name, &time);
		enqueue(name, time);
	}

	int total_t = 0;

	while (1) {
		NODE node;
		if (dequeue(&node)) {
			int time_left = node.time - q;

			if (time_left > 0) {
				enqueue(node.name, time_left);
				total_t += q;
			}
			else {
				printf("%s %d\n", node.name, total_t + node.time);
				total_t += node.time;
			}
		}
		else {
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 2160
N = int(input())
A = [0] * N
xy = [[] for _ in range(N)]
for i in range(N):
    A[i] = int(input())
    for j in range(A[i]):
        a,b = list(map(int,input().split()))
        a -= 1
        xy[i].append([a,b])

ans = 0
for i in range(1<<N):
    state = [False] * N
    tmp = i
    for j in range(N):
        state[j] = (tmp%2==1)
        tmp = tmp//2
    
    flag = True
    for j in range(N):
        if state[j]:
            for k in range(A[j]):
                if state[xy[j][k][0]] != xy[j][k][1]:
                    flag = False
                    break
                
            if not flag:
                break
    if flag:
        ans = max(ans,sum(state))
        
print(ans)

Measured memory_bytes: 45932
/**
 * @author torith
 * @date 2019-02-09
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

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

    int N; cin >> N;
    int K; cin >> K;

    if(N % 2 == 1) {
        if(N/2 + 1 >= K) cout << "YES" << "\n";
        else cout << "NO" << "\n";
    }else {
        if(N/2 >= K) cout << "YES" << "\n";
        else cout << "NO" << "\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).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 chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010
#define B 32

ll x[N], dp[B][N];
ll n, l, q;

int main(){
	cin>>n;
	rep(i, n) cin>>x[i];
	cin>>l>>q;
	x[n] = x[n-1]+l+1;
	{
		int lx = 0, rx = 0;
		while(lx < n){
			while(x[rx]-x[lx]<=l) rx++;
			dp[0][lx] = rx-1;
			lx++;
		}
		for(int i = 1; i < B; i++){
			for(int j = 0; j < n; j++){
				dp[i][j] = dp[i-1][dp[i-1][j]];
			}
		}
	}
	rep(_, q){
		int a, b;
		cin>>a>>b; a--; b--;
		if(a>b) swap(a, b);
		int lb = 0, ub = n-1; // (lb, ub]
		while(ub-lb>1){
			int md = (lb+ub+1)/2;
			int s = a;
			for(int j = 0; j < B; j++){
				if(1&(md>>j)) s = dp[j][s];
			}
			(b<=s?ub:lb)=md;
		}
		cout<<ub<<endl;
	}
	return 0;
}


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

#define INF 1000000000

using namespace std;

typedef long long LL;

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

	if ((b - a + 1) < (k * 2))
	{
		for (int i = a; i <= b; i++)
		{
			cout << i << endl;
		}
	}
	else
	{

		for (int i = 0; i < k; i++)
		{
			cout << (a + i) << endl;
		}

		for (int i = b - k + 1; i <= b; i++)
		{
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
S_p=input()
T=input()

k=[]
for i in range(len(S_p)-len(T)+1):
	S_sub = S_p[i:i+len(T)]
	if all(s in (t, "?") for s, t in zip(S_sub, T)):
		k.append(i)


if k:
	S=S_p[:k[-1]]+T+S_p[k[-1]+len(T):]
	print(S.replace("?", "a"))
else:
	print("UNRESTORABLE")

Measured memory_bytes: 9040
n, k, q = map(int, input().split())
a = list(map(int, input().split()))
 
d = [a]
a = sorted(a)
ans = a[q - 1] - a[0]
 
while True:
    newd = list()
    li = list()
    for sub in d:
        for c in sub:
            if c != a[0]:
                li.append(c)
            else:
                newd.append(li)
                li = list()
        newd.append(li)
        li = list()
 
    d = list()
    a = list()
    for li in newd:
        if len(li) < k:
            continue
        else:
            d.append(li)
            li = sorted(li)
            a.extend(li[0:len(li) - k + 1])
 
    a.sort()
 
    if len(a) >= q:
        ans = min(a[q - 1] - a[0], ans)
    else:
        break
print(ans)


Measured memory_bytes: 3316
#include <stdio.h>
int main(void){
	int m,n;
	int a,b;
	while(1){
		n=1000;
		scanf("%d",&m);
		if(m==0)break;
		n-=m;
		b=a=n/500;
		n-=a*500;
		b+=a=n/100;
		n-=a*100;
		b+=a=n/50;
		n-=a*50;
		b+=a=n/10;
		n-=a*10;
		b+=a=n/5;
		n-=a*5;
		b+=n/1;
		printf("%d\n",b);
	}
	return 0;
}


Measured memory_bytes: 2044
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;

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

int main(void){
  int n;
  cin>>n;
  while(n--){
    int grid[5][5];
    REP(y,5)REP(x,5)cin>>grid[y][x];
    int ans = 0;
    REP(y1,5)REP(x1,5){
      REP(sy,5)REP(sx,5){
        if(y1+sy>=5||x1+sx>=5) break;
        bool yes = true;
        REP(dy,sy+1)REP(dx,sx+1){
          if(grid[y1+dy][x1+dx]==0) yes = false;
        }
        if(yes)ans=max(ans,(sy+1)*(sx+1));
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * ABC157
 */
public class Main {

	public static void main(String[] args) throws Exception {
		Main main = new Main();

		try (Scanner scan = new Scanner(System.in)) {
			main.duplexPrinting(scan);
		}
	}

	private void duplexPrinting(Scanner scan) {
		int n = scan.nextInt();

		System.out.println(n / 2 + n % 2);

	}

	@SuppressWarnings("unused")
	private static class Pair<T1, T2> {

		private T1 left;
		private T2 right;

		public Pair(T1 left, T2 right) {
			this.left = left;
			this.right = right;
		}

		public T1 left() {
			return left;
		}

		public T2 right() {
			return right;
		}
	}

	@SuppressWarnings("unused")
	private static class UnionFindTree {

		private List<Integer> parents;

		public static UnionFindTree initialize(int n) {
			return new UnionFindTree(n);
		}

		public UnionFindTree(int n) {
			parents = IntStream.range(0, n).boxed().collect(Collectors.toCollection(() -> new ArrayList<>()));
		}

		public int find(int index) {
			if (index == parents.get(index)) {
				return index;
			}
			// 自分の親の親は自分の親とできるため経路圧縮
			parents.set(index, find(parents.get(index)));
			return parents.get(index);
		}

		public void union(int x, int y) {
			int xParent = find(x);
			int yParent = find(y);
			parents.set(yParent, xParent);
		}

		public long size() {
			return parents.stream().map(i -> find(i)).distinct().count();
		}
	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    //cout << "test" << endl;
    rep(i, n) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3604
n,m = map(int,input().split(" "))
a=[0] * (n+1)
mod = 10 ** 9 + 7
for i in range(m):
    a[int(input())] = 1

dp = [0] * (n+1)
for j in range(n+1):
    if a[j] == 1:
        dp[j] = 0
    elif j == 1 or j == 0:
        dp[j] = 1
    else:
        dp[j] = (dp[j-1] + dp[j-2]) % mod

print(dp[n])


Measured memory_bytes: 7668