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

int main() {
   int N;
   cin >> N;
   vector<vector<vector<int>>>A(4,vector<vector<int>>(3,vector<int>(10)));

   for(int i=0; i<N; i++){
       int b=0, f=0, r=0, v=0;
       cin >> b >> f >> r >> v;
       A.at(b-1).at(f-1).at(r-1)+=v;
   }
   for(int i=0; i<4; i++){
       for(int j=0; j<3; j++){
           for(int k=0; k<10; k++){
               cout << " " << A.at(i).at(j).at(k);
           }
           cout << endl;
       }
       if(i==3) break;
       cout <<"####################" << endl;
   }
    return 0;
}




Measured memory_bytes: 3136
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int n,m,l;
vector<vector<int>> d,d2;


void warshall_floyd(int n){ //nはノード数
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      for(int k = 0; k < n; k++){
        if(d[j][i] == INF || d[i][k] == INF) continue;
        d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
      }
    }
  }
}
void warshall_floyd2(int n){ //nはノード数
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      for(int k = 0; k < n; k++){
        if(d2[j][i] == INF || d2[i][k] == INF) continue;
        d2[j][k] = min(d2[j][k],d2[j][i]+d2[i][k]);
      }
    }
  }
}

int main(){
  cin >> n >> m >> l;
  d.resize(n,vector<int>(n,INF));
  d2.resize(n,vector<int>(n,INF));
  rep(i,n) d[i][i] = 0;
  
  rep(i,m){
    int from,to,cost; cin >> from >> to >> cost;
    if(cost <= l){
      from--;to--;
      d[from][to] = cost;
      d[to][from] = cost; //無向グラフなら
    }
  }
  
  warshall_floyd(n);
  rep(i,n)rep(j,n){
    if(i == j) continue;
    if(d[i][j] == INF) continue;
    if(d[i][j] <= l){
      d2[i][j] = 1;
    }
  }
  warshall_floyd2(n);
  
  int q; cin >> q;
  rep(i,q){
    int s,t; cin >> s >> t;
    s--;t--;
    if(d2[s][t] == INF) cout << -1 << endl;
    else cout << d2[s][t]-1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll X, Y, an = 0;
	cin >> X >> Y;
	while (X <= Y) {
		X *= 2;
		an++;
	}
	cout << an << endl;
}


Measured memory_bytes: 256
N = int( input())
C = [ int( input()) for _ in range(N)]
dp = [1]*(N+1)
colors = [1]*(2*10**5+1)
S = [-1]*(2*10**5+1)
Q = 10**9+7
for i in range(N):
    if i >= 1:
        if C[i] == C[i-1]:
            dp[i+1] = dp[i]
            continue
    if S[C[i]] == -1:
        dp[i+1] = dp[i]
        S[C[i]] = 1
        if i >= 1:
            S[C[i]] = dp[i]
        continue
    dp[i+1] = (dp[i] + S[C[i]])%Q
    S[C[i]] += dp[i]
    S[C[i]] %= Q
print(dp[N])


Measured memory_bytes: 22072
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;
const int MAXN = 100000;
vector<int> to[MAXN];


int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
  }
  int s, t;
  cin >> s >> t;
  s--; t--;

  vector<vector<int>> dist(MAXN, vector<int>(3, INF));
  dist[s][0] = 0;
  queue<P> q;
  q.emplace(s, 0);
  while(!q.empty()) {
    int v = q.front().first;
    int l = q.front().second;
    q.pop();
    for (int u : to[v]) {
      int nc = (l + 1) % 3;
      if (dist[u][nc] != INF) continue;
      dist[u][nc] = dist[v][l] + 1;
      q.emplace(u, nc);
    }
  }
  int ans = dist[t][0];
  if(ans == INF) ans = -1;
  else ans /= 3;

  cout << ans << endl;
}

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

// const long long int MOD = 1000000007;
const int MOD = 1000000007;

long long int F(long long int A, long long int B) {
    long long int C = max(A,B), ans = 0;
    while (C/10 > 0) {
        ans++;
        C /= 10;
    }
    ans++;
    return ans;
}

int main() {
    long long int N,ans = 11;
    cin >> N;
    for (long long int i = 1; i <= sqrt(N); i++) {
        if (N%i != 0) {
            continue;
        }
        ans = min(ans, F(i, N/i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3472
# ans = 全通り - nCa - nCb
#     = 2^n - 1 - nCa - nCb
def comb(n,r,mod=10**9+7):
    a=1
    b=1
    r = min(r,n-r)
    for i in range(r):
        a = a*(n-i)%mod
        b = b*(i+1)%mod
    return a*pow(b,mod-2,mod)%mod

n, a, b = map(int, input().split())

mod = (10**9) + 7

num_all = pow(2, n, mod) - 1
nca = comb(n, a, mod=mod)
ncb = comb(n, b, mod=mod)

ans = num_all - nca - ncb
ans %= mod

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
inline ll divceil(ll a, ll b){return (a+b-1) / b;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

int main(){
    ll n, m;
    cin >> n >> m;
    ll l, r;
    ll lmax = -1, rmin = n+1;
    rep(i, m){
        cin >> l >> r;
        lmax = max(lmax, l);
        rmin = min(rmin, r);
    }
    cout << max(rmin - lmax + 1, 0LL) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl();
    ll lim=sqrt(n);
    while(lim>=1){
        if(n%lim==0)
            break;
        lim--;
    }
    cout<<lim-1+(n/lim)-1<<endl;

    

    return 0;   
}


 
 


Measured memory_bytes: 256
#include <cstdio>
#define ll long long


int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a == 1)
        a = 14;
    if (b == 1)
        b = 14;
    if (a > b) printf("Alice");
    else if (a == b) printf("Draw");
    else printf("Bob");
    return 0;
}


Measured memory_bytes: 128
tmp = list(map(int, input().split()))
x = tmp[0]
y = tmp[1]

ans = 0
if   x == 1:  ans += 300000
elif x == 2:  ans += 200000
elif x == 3:  ans += 100000

if   y == 1:  ans += 300000
elif y == 2:  ans += 200000
elif y == 3:  ans += 100000

if   x == 1 and y == 1:  ans += 400000

print (ans)

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

// @@ !! LIM(f:gcd)
// --> f:gcd
// ---- inserted function gcd from util.cc
// g = eGCD(a, b, s, t)  --->  sa + tb = g
ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

// gcd(0, x) = x, gcd(-x, y) = gcd(x, y)
ll gcd(ll a, ll b) {
  ll dummy1 = 0;
  ll dummy2 = 0;
  return eGCD(abs(a), abs(b), dummy1, dummy2);
}
// ---- end gcd
// @@ !! LIM  -- end mark --

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  auto solve = [&](ll a, ll b, ll c, ll d) -> bool {
    if (a < b) return false;
    if (d < b) return false;
    ll g = gcd(b, d);
    ll l = a - b;
    ll r = a - c;
    if (l < 0) {
      ll t = (-l / g) + 1;
      l += t * g;
      r += t * g;
    }
    if (r <= l + 1) return true;
    if (l < ((r-1) / g) * g) return false;
    return true;
  };

  ll T; cin >> T;
  for (ll _t = 0; _t < T; _t++) {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    cout << (solve(a, b, c, d) ? "Yes" : "No") << "\n";
  }

  return 0;
}



Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    string A,S,C,ans;
    cin >> A >> S >> C;
    cout << A[0] << S[0] << C[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if(c - (a + b) <= 0){
		printf("Yes\n");
	}
	else if(c - (a + b) > 0){
		printf("No\n");
	}
	
	return(0);
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    unsigned long long a,b,x;
    cin>>a>>b>>x;
    unsigned long long ans=(b/x)-(a)/x;
    if (a%x==0)ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)

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

void Main(){
  string S; cin >> S;
  int cnt = 1;
  rep(i, 1, S.size()){
    if(S[i] != S[i - 1]) cnt++;
  }
  cout << cnt - 1 << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 512
n = int(input())
l = []
s = 0
for i in range(n):
  a, b = map(int, input().split())
  s += a
  l.append((a, b))
  
l = sorted(l, key=lambda x: x[1])
for i in range(n):
  if s > l[-1][1]:
    print("No")
    exit()
  else:
    a = l.pop()[0]
    s -= a
print("Yes")

Measured memory_bytes: 74840
N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for _ in range(M)]

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
        return

    if self.parents[x] > self.parents[y]:
        x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
                     
uf = UnionFind(N)
for xyz in XYZ:
  x, y, z = xyz                       
  uf.union(x - 1, y - 1)
print(uf.group_count())
                         

Measured memory_bytes: 32184
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end() 

int main() {
 ll N;
  cin>>N;
  vector<vector<ll>> vec(9,vector<ll>(9));
  for(ll i=1;i<=N;i++) {
    string S=to_string(i);
    if(S.back()=='0') {
continue;
    }
    vec[S[0]-'0'-1][S.back()-'0'-1]++;
  }
  
  ll ans=0;
  for(ll i=0;i<9;i++) {
ans+=vec[i][i]*vec[i][i];
  }
  

  for(ll i=0;i<9;i++) {
for(ll j=0;j<9;j++) {
  if(i==j) {
continue;
  }
  ans+=vec[i][j]*vec[j][i];
}
  }
  
  
  cout<<ans<<endl;
}

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

  


Measured memory_bytes: 3672
import math
N = int(input())
if N == 2:
    print(1)
    exit()
ans = 0
M = int(N**0.5) + 1
for k in range(2, M):
    n = N
    while n:
        if n % k == 0:
            n //= k
        elif n % k == 1:
            ans += n != N
            break
        else:
            break


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


ans2 = 1
for _, i in factorization(N - 1):
    ans2 *= (1 + i)
ans += ans2
print(ans)


Measured memory_bytes: 9476
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define pr(a) printf("%lld\n",a)

int main()
{
    ll n,m,i,j,k,l,t,x,y,z;

    sc(n);

    ll a[n+5];

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

        sc(a[i]);
    }

    sort(a,a+n);

    x=a[n-1];

    ll b[x+5];

    memset(b,0,sizeof(b));



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

        for(j=a[i]; j<=x; j+=a[i])
        {

            b[j]++;

        }
    }

    k=0;

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

        if(b[a[i]]==1)k++;
    }

    cout<<k<<endl;

}


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

typedef long long LL;

const int N=16,mod=1000000007;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n,m,a[N+9];

void into(){
  scanf("%d%d",&n,&m);
  for (int i=1;i<=m;++i)
	scanf("%d",&a[i]);
}

int inv[(1<<N)+9],fac[(1<<N)+9],ifac[(1<<N)+9];

void Get_inv(){
  inv[1]=1;
  fac[0]=fac[1]=1;
  ifac[0]=ifac[1]=1;
  for (int i=2;i<=1<<n;++i){
	inv[i]=mul(mod-mod/i,inv[mod%i]);
	fac[i]=mul(fac[i-1],i);
	ifac[i]=mul(ifac[i-1],inv[i]);
  }
}

int Get_c(int n,int m){return n<m||m<0?0:mul(fac[n],mul(ifac[m],ifac[n-m]));}

int dp[N+9][(1<<N)+9];

void Get_dp(){
  sort(a+1,a+m+1);
  dp[m+1][0]=1;
  for (int i=m;i>=1;--i)
	for (int s=0;s<1<<n;++s){
	  sadd(dp[i][s],dp[i+1][s]);
	  for (int j=0;j<n;++j){
		if (s>>j&1) continue;
		sadd(dp[i][s|1<<j],mul(dp[i+1][s],mul(Get_c((1<<n)-a[i]-s,(1<<j)-1),fac[1<<j])));
	  }
	}
}

int cnt[(1<<N)+9],ans;

void Get_ans(){
  cnt[0]=1;ans=mul(dp[1][0],fac[(1<<n)-1]);
  for (int s=1;s<1<<n;++s){
	cnt[s]=s&1?mod-cnt[s>>1]:cnt[s>>1];
	sadd(ans,mul(cnt[s],mul(dp[1][s],fac[(1<<n)-s-1])));
  }
}

void work(){
  Get_inv();
  Get_dp();
  Get_ans();
}

void outo(){
  printf("%d\n",mul(ans,1<<n));
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 6912
package main

import (
	"fmt"
)

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

func main() {
	var n int
	fmt.Scan(&n)
	v := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&c[i])
	}
	ans := 0
	for i := range v {
		ans += max(v[i]-c[i], 0)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	ll n;
	cin>>n;
	vector<ll> a(n);
	for(ll i=0;i<n;i++)
	cin>>a[i];
	if(a[n-1]!=2){
		cout<<"-1";
		exit(0);
	}
	ll lo=2,hi=3;
	for(ll i=n-2;i>=0;i--){
		ll x=(lo+a[i]-1)/a[i];
		if(x*a[i]>hi){
			cout<<"-1";
			exit(0);
		}
		ll y=hi/a[i];
		if(y*a[i]<lo){
			cout<<"-1";
			exit(0);
		}
		lo=x*a[i];
		hi=y*a[i]+a[i]-1;
	}
	cout<<lo<<" "<<hi;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


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

using namespace std;

int arr[200000];
long long int dp[101][100001];
vector<pair<int, int>> objects;
int main(){

    int N, W, w, v;
    objects.push_back({0, 0});
    cin >> N >> W;
    for(int i = 0; i < N; i++){

        cin >> w >> v;
        objects.push_back({w, v});

    }

    for(int i = 1; i <= W; i++)
        dp[1][i] = i >= objects[1].first ? objects[1].second : 0;

    for(int i = 2; i <= N; i++){
        for(int j = 1; j <= W; j++){
            dp[i][j] = dp[i-1][j];
            if(j - objects[i].first >= 0)
                dp[i][j] = max(dp[i][j], dp[i-1][j-objects[i].first] + objects[i].second);
        }
    }

    cout << dp[N][W] << endl;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
char s[5];
int ans=0,cnt=0;
int main(){
	cin>>s;
	for(int i=0;i<3;i++){
		if(s[i]=='R')cnt++;
		else if(cnt>ans)ans=cnt,cnt=0;
	}
	cout<<max(cnt,ans);
	return 0;
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
//	freopen("in.txt", "r", stdin);
	string s, t;
	cin >> s >> t;
	s = s + s;
	for(int i=0; i<s.length(); i++){
		if(s[i] == t[0]){
			bool ok = false;
			for(int j=i+1, k=1; j<s.length(); j++, k++){
				if(s[j] != t[k]) break;
				if(k == t.length()-1) ok = true;
			}
			if(ok){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
/*************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef long long ijt;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

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

int main() {
	int n;cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = i+1; j <= n; j++) {
			int x = i^j;
			for (int k = 0; k < 60; k++) {
				if ((x >> k) & 1) {
					cout << k + 1 << " "; break;
				}
			}
			
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 512
using System;
class aoj
{
    static void Main()
    {
        while (true)
        {
            string[] u = Console.ReadLine().Split(' ');
            int n = int.Parse(u[0]), m = int.Parse(u[1]);
            if (n == 0 && m == 0) break;
            int[] a = new int[n+1000];
            int[] b = new int[m];
            for (int i = 0; i < n; i++)
                a[i] = int.Parse(Console.ReadLine());
            for (int i = 0; i < m; i++)
                b[i] = int.Parse(Console.ReadLine());
            int c = 0;
            int j;
            for(j = 0; j < m; ++j)
            {
                c += b[j];
                c += a[c];
                if (c >= n-1) break;
            }
            Console.WriteLine(j+1);
        }
    }
}

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

int N,M,K;

int par[100010];

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


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

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

void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y) return;

  par[x]=y;
}

int size(int x){
  return par[root(x)];
}

int main(){
  cin >> N >> M >> K;
  int i,j;
  init(N);
  vector<int> a(M),b(M);
  vector<int> c(K),d(K);
  vector<set<int>> dame(N);
  for(i=0;i<M;++i){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    dame[a[i]].insert(b[i]);
    dame[b[i]].insert(a[i]);
    unite(a[i],b[i]);
  }
  for(i=0;i<K;++i){
    cin >> c[i] >> d[i];
    c[i]--;
    d[i]--;
    if(!same(c[i],d[i])) continue;
    dame[c[i]].insert(d[i]);
    dame[d[i]].insert(c[i]);
  }
  vector<int> root_num(N,0);
  for(i=0;i<N;++i){
    root_num[root(i)]++;
  }
  for(i=0;i<N;++i){
    int ans=root_num[root(i)]-1;
    ans -= dame[i].size();
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 27264
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;

void main()
{
    auto nk = readln.split.to!(long[]);
    long n = nk[0];
    long k = nk[1];
    long[] X = readln.split.to!(long[]);

    long result = long.max;

    foreach (i; 0 .. n - k + 1)
    {
        long a = (X[i + k - 1] - X[i]);
        long b = min(abs(X[i + k - 1]), abs(X[i]));
        result = result.min(a + b);
    }
    result.writeln;
}


Measured memory_bytes: 4372
def main():
    K = int(input())
    if K % 2 == 0 and K % 5 == 0:
        print(-1)
        exit()
    ans = 0
    ten = 1
    mod = [0] * (10**6+5)
    for i in range(10**6):
        tmp = 7 * ten
        tmp %= K
        mod[i] = tmp
        ten *= 10
        ten %= K

    pre = 0   
    for i in range(10**6):
        pre += mod[i]
        if pre % K == 0:
            print(i+1)
            exit()

    print(-1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 71788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    if (c < d) {
        for (int i = a; i < d; i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                cout << "No" << "\n";
                return 0;
            }
        }
        cout << "Yes" << "\n";
        return 0;
    }
    else {
        bool flag = false;
        for (int i = b - 2; i <= d - 2; i++) {
            if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
                flag = true;
            }
        }
        if (!flag ) {
            cout << "No" << "\n";
            return 0;
        }
        for (int i = a; i < c - 1; i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                cout << "No" << "\n";
                return 0;
            }
        }
        cout << "Yes" << "\n";
        return 0;
    }
}

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

using namespace std;

const int N=2e5+5,MOD=1e9+7;

long long fac[N],infac[N];

long long poww(long long x,long long y)
{
	if(y==0) return 1;
	if(y&1) return (x*poww(x,y-1))%MOD;
	return poww((x*x)%MOD,y/2);
}

long long nck(int n,int k)
{
	return (((fac[n]*infac[k])%MOD)*infac[n-k])%MOD;
}

long long get(int a,int b,int c,int d)
{
	int tot=(c-a)+(d-b);
	return nck(tot,c-a);
}

int main()
{
	fac[0]=infac[0]=1;
	for(int i=1;i<N;i++)
	{
		fac[i]=(fac[i-1]*i)%MOD;
		infac[i]=poww(fac[i],MOD-2);
	}
	int n,m,a,b;
	cin >> n >> m >> a >> b;
	long long ans=0;
	for(int i=0;i<n-a;i++)
	{
		ans+=get(0,0,i,b-1)*get(i,b,n-1,m-1);
		ans%=MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6732
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

vector<long long int> E[110000];
vector<long long int> E2[110000];
bool used[110000] = {};
int cnt[110000] = {};
map<P, long long int> m;

void func(int pos){
    used[pos] = true;
    for(long long int to : E[pos]){
        if(used[to]){
            if(m.find(P(pos, to)) == m.end() && m.find(P(to, pos)) == m.end()){
                m[P(pos, to)] = 1;
                cnt[pos] += 1;
                cout << pos << " " << to << endl;
            }
        }else{
            m[P(pos, to)] = 1;
            E2[pos].push_back(to);
            func(to);
        }
    }
}

bool func2(int pos){
    int S = cnt[pos];
    for(long long int to : E2[pos]){
        bool ret = func2(to);
        if(ret){
            cout << pos << " " << to << endl;
            S += 1;
        }else{
            cout << to << " " << pos << endl;
        }
    }
    if(S % 2 == 0){
        return true;
    }else{
        return false;
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        long long int A, B;
        cin >> A >> B;
        E[A].push_back(B);
        E[B].push_back(A);
    }
    if(M % 2 != 0){
        cout << -1 << endl;
        return 0;
    }
    func(1);
    /*
    for(int i = 1; i <= 4; i++){
        cout << cnt[i] << " ";
    }cout << endl;
    */
    func2(1);
    return 0;
}

Measured memory_bytes: 31616
#include <iostream>

using namespace std;

int A[200001];

int main(){
  int i,N,c=0;
  string S;
  cin >> N;
  cin >> S;
  for (i=0;i<N;++i) {
    A[i]=c;
    if (S[i] == '#') {
      c++;
    }
  }
  A[N]=c;
  int min=c;
  c=0;
  for (i=N-1;i>=0;--i) {
    if (S[i] == '.') {
      c++;
    }
    A[i]+=c;
    if (min > A[i]){
      min= A[i];
    }
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 1412
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int x= sc.nextInt();
        int[] a = new int[N];
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);
        int ans = 0;
        boolean flag = false;
        for(int i = 0; i < N; i++){
            //飴が全て配れないかつぴったり配れたときの例外処理
            if(x == a[i]){
                ans++;
                flag = true;
                break;
            }
            //飴が全て配れなかった時ansを-1しないための例外処理
            else if(x < a[i]){
                ans++;
                break;
            }
            else{
                x -= a[i];
                ans++;
            }
        }

        if(flag) System.out.println(ans);
        //全て配れて飴が余った時はans-1
        else System.out.println(ans - 1);

    }
}


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



int main(void){
    int n;
    cin >> n;
    //0だと素数
    vector<ll> is_prime(n+1,0);
    
    is_prime[0] = is_prime[1] = 1;
    for(int i=2;i<n+1;i++){
        // is_prime[i]++;
        if(is_prime[i] == 0){
            is_prime[i] = 1;
            int cnt = 2;
            for(int j=2*i;j<n+1;j+=i){
                // cnt = j / i;
                is_prime[j] += is_prime[i] + is_prime[cnt];
                cnt++;
            }
        }
    }

    ll sum = 0;
    for(int i=2;i<is_prime.size();i++){
        // cout << is_prime[i] << endl;
        sum += i * (is_prime[i] + 1);
    }
    sum ++;
    cout << sum << endl;
    return 0;
}

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

// Function to get the missing number
void solve(){
    long long k;
    string s;
    cin>>k;
    cin>>s;
    string sub = s.substr(0,k);
    cout<<sub;
    if(s.length()>k){
        cout<<"...";
    }
    }


// Driver Code
int main()
{
    solve();
}


Measured memory_bytes: 3600
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>

/* template start */

using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...)                                                    \
  std::cerr << "LINE: " << __LINE__ << "  [" << #__VA_ARGS__ << "]:", \
      debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << std::endl; }

template <typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
  std::cerr << " " << h;
  if (sizeof...(t) > 0) std::cout << " :";
  debug_out(t...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  return a > b && (a = b, true);
}

template <typename Num>
constexpr Num mypow(Num a, u64 b, Num id = 1) {
  if (b == 0) return id;
  Num x = id;
  while (b > 0) {
    if (b & 1) x *= a;
    a *= a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  i64 n, k;
  std::cin >> n >> k;

  std::vector<i64> a(n);
  for (auto&& e : a) std::cin >> e;

  i64 gcd = a[0];
  i64 max = a[0];

  rep(i, 0, n) {
    gcd = std::gcd(gcd, a[i]);
    chmax(max, a[i]);
  }

  if (k % gcd == 0 && k <= max)
    std::cout << "POSSIBLE\n";
  else
    std::cout << "IMPOSSIBLE\n";

  return 0;
}

Measured memory_bytes: 3908
//二分探索
//2018-12-17
//Ebitani Akira

#include <stdio.h>
#include <stdlib.h>

#define N1 100000
#define N2 50000

int Search( int *, int ,int );

int main (){
  int array1[N1];
  int array2[N2];
  int answer = 0;
  int n1, n2;
  int i;
  int re;
    
  scanf( "%d", &n1 );
  if( n1 > 100000 || n1 < 1 ){
    printf("要素数が適当でありません。\n");
    exit(1);
  }
  for( i = 0 ; i < n1 ; i++ ){
    scanf( "%d", &array1[i] );
  }

  scanf( "%d", &n2 );
  if( n2 > 50000 || n2 < 1 ){
    printf("要素数が適当でありません。\n");
    exit(2);
  }
  
  for( i = 0 ; i < n2 ; i++ ){
    scanf( "%d", &array2[i] );
  }
  
  for( i = 0 ; i < n2 ; i++ ){
    re = Search( array1, array2[i], n1 );
    if( re != -1 ){
      answer++;
    }
  }

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

  return 0;
}

int Search( int *Array, int y, int n ){
  int left = 0;
  int right = n;
  int mid;

  while( left < right ){
    mid = ( left + right ) / 2;
    if( Array[mid] == y ){
      return mid;
    }
    else if( y > Array[mid] ){
      left = mid + 1;
    }
    else{
      right = mid;
    }
  }

  return -1;
}

  
    



Measured memory_bytes: 2328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int distA, distB, distC;
	distA = abs(a - b);
	distB = abs(b - c);
	distC = abs(a - c);
	if (distA <= d && distB <= d || distC <= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int n;
  cin >> n;
  int k;
  cin >> k;
  long long int b[n];
  for (int i=0;i<n;i++){
  	cin >> b[i];
  }
  long long int dp[n];
  dp[0]=0;
  dp[1]=abs(b[1]-b[0]);
  for (int i=2;i<n;i++){
    dp[i]=dp[i-1]+abs(b[i]-b[i-1]);
    for (int j=1;j<k;j++){
      if (i-(j+1)>=0){
  		dp[i]=min(dp[i-(j+1)]+abs(b[i]-b[i-(j+1)]),dp[i]);
      }
    }
  }
  cout << dp[n-1] <<endl;
}

Measured memory_bytes: 1792
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]
ans = [0]*N
for r in AB:
    for c in r:
        ans[c-1] += 1
print(*ans, sep='\n')

Measured memory_bytes: 3060
// https://atcoder.jp/contests/abc079/tasks/abc079_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  string n, r;

  cin >> n;

  r = n[1] == n[2] && (n[0] == n[1] || n[2] == n[3]) ? "Yes" : "No";

  cout << r << '\n';

  return 0;
}


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

int main() 
{
    long long int n,j,ans=0,t1;
    cin>>n;
    long long int a[n+1];
    for(long long int i=0;i<=n;i++)
    a[i]=1LL;
    int chk[n]={0};
    for(long long int i=2;i<=n;i++)
    {
        if(chk[i]==0)
        {
            long long int temp;
            j=i;
            while(j<=n)
            {
                chk[j]=1;
                t1=j;
                temp=0;
                while(t1%i==0)
                {
                    temp++;
                    t1/=i;
                }
                a[j]*=(temp+1);
                j+=i;
            }
        }
    }
    for(long long int i=1;i<=n;i++)
    {
        ans+=(i*a[i]);
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 120812
N = int(input())
cntM, cntA, cntR, cntC, cntH = 0, 0, 0, 0, 0
for i in range(N):
    s = input()
    if s[0] == "M":
        cntM += 1
    elif s[0] == "A":
        cntA += 1
    elif s[0] == "R":
        cntR += 1
    elif s[0] == "C":
        cntC += 1
    elif s[0] == "H":
        cntH += 1
Names = [cntM,cntA,cntR,cntC,cntH]
ans = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            if k <= 4:
                ans += Names[i]*Names[j]*Names[k]
print(ans)

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


int main(){
	int x;
    int b=1, p=2;
    int b_;
    int m=0;
    
    cin >> x;
    for(b=1;b<=100;b++){
        b_ = b;
        for(p=1;p<=9;p++){
            b_ *= b;
            if(b_<=x && b_>m){
                m = b_;
            }
        }
    }
	cout << m << endl;

	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;



int main()
{
	int n;
	cin >> n;
	long long int  a[100010];
	for (int i = 1; i < 100010; i++) {
		a[i] = 0;
	}
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		long long int x;
		cin >> x;
		if (x > n) {
			ans++;
		}
		else {
			a[x]++;
		}
	}

	for (int i = 1; i <= n; i++) {
		if (i <= a[i]) {
			ans += a[i] - i;
		}
		else {
			ans += a[i];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() { 
  int n,x,y=0;
  long long sum=0;
  char aaa,memo;
  cin>>n;
  x=n;
  rep(i,n){if(i==0){cin>>memo;

  }
  else{cin>>aaa;
  if(aaa==memo)x--;
  memo=aaa;
  }
  }
  

  
  cout<<x<<endl;
}

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

using namespace std;


int main(void) {
	// 自分の得意な言語で
	// Let's チャレンジ！！

	int n;
	vector<int>v;


	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		v.push_back(x);
	}
	sort(v.begin(), v.end());

	cout << v.at(v.size() / 2) - v.at(v.size() / 2 - 1)  << endl;


	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <algorithm>
using namespace std;

bool eq(int a[], int b[], int n) {
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) return false;
    }
    return true;
}

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

    int P[10], Q[10];
    for (int i = 0; i < N; i++) cin >> P[i];
    for (int i = 0; i < N; i++) cin >> Q[i];

    int R[10];
    for (int i = 0; i < N; i++) R[i] = P[i];
    sort(&R[0], &R[N]);

    int p, q;
    int dic = 0;

    do {
        if (eq(R, P, N)) p = dic;
        if (eq(R, Q, N)) q = dic;
        dic++;
    } while (next_permutation(&R[0], &R[N]));

    cout << abs(p - q) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
}



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

using namespace std;

int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i <= n; ++i) {
    int n_digits = 0;
    int tmp = i;
    while (tmp > 0) {
      n_digits++;
      tmp /= 10;
    }
    if (n_digits % 2 != 0) ans++;
  }

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



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
using namespace std;
typedef long long ll;
ll a,b,c,d;
ll gcd(ll a,ll b){
	if (a%b==0) return b;
	else return gcd(b,a%b);
}
int main(){
	cin>>a>>b>>c>>d;
	ll t1=b/c-(a-1)/c;
	ll t2=b/d-(a-1)/d;
	ll p=c*d/gcd(c,d);
	ll t3=b/p-(a-1)/p;
	cout<<(b-a+1)-(t1+t2-t3);
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int n, prev;
int ma = 0;
int ma2 = 0;
int snt = 0;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    cin >> n;
    int a[n + 1];
    FOR(i, 1, n)
    {
        cin >> a[i];
        if(ma < a[i]) ma = a[i];
    }
    FOR(i, 1, n)
    {
        if (a[i] == ma) snt++;
        if (a[i] < ma) ma2 = max(ma2, a[i]);
    }
    if(snt > 1 || ma2 == 0) ma2 = ma;
    FOR(i, 1, n)
    {

        if(a[i] != ma)
            cout << ma;
        else cout << ma2;
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &e : a)
    cin >> e;

  ll ans = 1e16;

  for (int i = 0; i < 2; ++i)
  {
    ll cnt = 0, sum = 0;
    for (int j = 0; j < n; ++j)
    {
      sum += a[j];
      if (j % 2 == i)
      {
        if (sum <= 0)
        {
          cnt += abs(sum) + 1;
          sum = 1;
        }
      }
      else
      {
        if (sum >= 0)
        {
          cnt += abs(sum) + 1;
          sum = -1;
        }
      }
    }
    ans = min(cnt, ans);
  }

  cout << ans << endl;

  return 0;
}


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

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


Measured memory_bytes: 3088
#include <algorithm>
#include <stdio.h>
#include <vector>
using ll = long long;
struct Int3
{
	int x, y, z;
	Int3() {};
	Int3(int x, int y, int z) :x(x), y(y), z(z) {};
	bool operator<(const Int3& ano) const {
		if (x != ano.x)
			return x < ano.x;
		if (y != ano.y)
			return y < ano.y;
		return z < ano.y;
	}
	bool operator>(const Int3& ano) const {
		if (x != ano.x)
			return x > ano.x;
		if (y != ano.y)
			return y > ano.y;
		return z > ano.y;
	}
};
template<int _size>
class Union_tree
{
public:
	Union_tree() {
		for (int i = 0; i < _size; i++)
			root[i] = i;
		for (int i = 0; i < _size; i++)
			branchs[i] = 1;
	}
	int find(int node) {
		if (root[node] == node)
			return node;
		return root[node] = find(root[node]);
	}
	void merge(int node1, int node2) {
		int root1 = find(node1), root2 = find(node2);
		if (root1 == root2)
			return;
		branchs[root1] = branchs[root2];
		branchs[root2] = 0;
		root[root2] = root1;
	}
	bool same(int node1, int node2) {
		return find(node1) == find(node2);
	}
	int size(int node) {
		return branchs[find(node)];
	}
private:
	int root[_size], branchs[_size];
};

int main() {
	int	n, x[100000], y[100000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d %d", x + i, y + i);
	Int3 S[100000];
	for (int i = 0; i < n; i++)
		S[i].x = x[i], S[i].y = i;
	std::sort(S, S + n);

	std::vector<Int3> EDGES;
	for (int i = 1; i < n; i++)
		EDGES.emplace_back(S[i].x - S[i - 1].x, S[i].y, S[i - 1].y);

	for (int i = 0; i < n; i++)
		S[i].x = y[i], S[i].y = i;
	std::sort(S, S + n);

	for (int i = 1; i < n; i++)
		EDGES.emplace_back(S[i].x - S[i - 1].x, S[i].y, S[i - 1].y);

	std::sort(EDGES.begin(), EDGES.end());
	Union_tree<100000> tree;
	int costs = 0;
	for (Int3& s : EDGES) {
		if (tree.same(s.y, s.z))
			continue;
		costs += s.x;
		tree.merge(s.y, s.z);
	}
	printf("%d\n", costs);
}

Measured memory_bytes: 7668
from collections import deque
import sys
from collections import defaultdict
class UnionFind:
    def __init__(self, n):
        class KeyDict(dict):
            # 辞書にないときの対応
            def __missing__(self,key):
                self[key] = key
                return key
        self.parent = KeyDict()
        self.rank = defaultdict(int)
        self.weight = defaultdict(int)

    # 根を探す
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            # 経路圧縮
            # 自分自身じゃない場合は、上にさかのぼって検索(再帰的に)
            y = self.find(self.parent[x])           
            self.weight[x] += self.weight[self.parent[x]]   #圧縮時にweightを更新(和)
            self.parent[x] = y      #親の置き換え(圧縮)
            return self.parent[x]

    # 結合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # 低い方を高い方につなげる(親のランクによる)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
        
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    ### 重み付き
    def weighted_union(self, x, y, w):
        # print("unite",x,y,w,self.weight)
        px = self.find(x)
        py = self.find(y)
        # 低い方を高い方につなげる(親のランクによる)
        # if px == py: return 0
        if self.rank[px] < self.rank[py]:
            self.parent[px] = py
            self.weight[px] = - w - self.weight[x] + self.weight[y]
        else:
            self.parent[py] = px
            self.weight[py] =  w + self.weight[x] - self.weight[y]
        if self.rank[px] == self.rank[py]:
            self.rank[px] += 1
        return 0

    # 判定
    def judge(self, x, y):
        return self.find(x) == self.find(y)
input = sys.stdin.readline
n, m = map(int, input().split())
langs = [[] for i in range(m)]
for i in range(n):
    inputs = list(map(int, input().split()))
    k = inputs[0]
    ls = inputs[1:]
    for l in ls:
        langs[l-1].append(i)
# print(langs)
uf = UnionFind(n)
for l in langs:
    if len(l) <= 1: continue
    x = l[0]
    for y in l[1:]:
        if not uf.judge(x, y): uf.union(x, y)

ans = set()
for i in range(n):
    ans.add(uf.find(i))
if len(ans) == 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 126468
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
int N;
vector<double> p;
double dp[3100][3100];
int main(){
	cin>>N;
	p.resize(N);
	for (int i=0;i<N;++i)cin>>p[i];
	dp[0][0]=1.0;
	for (int i=0;i<N;++i){
		for (int j=0;j<=i;++j){
			dp[i+1][j+1]+=dp[i][j]*p[i];
			dp[i+1][j]+=dp[i][j]*(1.0-p[i]);
		}
	}

	double res=0.0;
	for (int j=N/2+1;j<=N;++j)res+=dp[N][j];
	cout<<fixed<<setprecision(10)<<res<<endl;

}

Measured memory_bytes: 72320