akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;  
int n,m;  
string s[20];  
int swaped[20];  
int used[20];  
int ans = 0;  
bool check()  
{  
    memset(used,0,sizeof used);  
    for(int i=0;i<m;i++){  
        for(int j=0;j<m;j++){  
            if(used[i]||used[j]||i==j) continue;  
            int cur=1;  
            for(int k=0;k<n;k++){  
                if(s[swaped[k]][i]!=s[k][j]){  
                    cur=0;  
                    break;  
                }  
            }  
            if(cur){  
                used[i]=used[j]=1;  
            }  
        }  
    }  
    int cnt=0,to=0;  
    for(int i=0;i<m;i++){  
        if(!used[i]){  
            cnt++;to=i;  
        }  
    }  
    if(cnt>=2||(m%2==0&&cnt)){  
        return false;  
    }  
    if(!cnt) return true;  
    for(int i=0;i<n;i++){  
        if(s[swaped[i]][to]!=s[i][to]){  
            return false;  
        }  
    }  
    return true;  
}  
  
  
void dfs(int now,bool ji)  
{  
    if(now==(n+1)/2){  
        if(check()){  
            ans=1;  
        }  
        return;  
    }  
    for(int i=now;i<n;i++){  
        for(int j=i+1;j<n;j++){  
            if(swaped[i]==-1&&swaped[j]==-1){  
                swaped[i]=j;  
                swaped[j]=i;  
                dfs(now+1,ji);  
                swaped[i]=-1;  
                swaped[j]=-1;  
            }  
        }  
        if(ji&&swaped[i]==-1){  
            swaped[i]=i;  
            dfs(now+1,false);  
            swaped[i]=-1;  
        }  
    }  
  
}  
  
int main()  
{  
    scanf("%d%d",&n,&m);  
    for(int i=0;i<n;i++){  
        cin>>s[i];  
        swaped[i]=-1;  
    }  
    if(n&1){  
        dfs(0,true);  
    }else{  
        dfs(0,false);  
    }  
    if(ans) printf("YES\n");  
    else printf("NO\n");  
}  

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define SLAY ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define LL long long
#define PII pair<int , int>
#define PLL pair<long long , long long>
#define INPUT freopen("input.txt", "r", stdin);

using namespace std;
 
const LL MOD = 1e9+7;

LL c,d,e,f,g,x,y,z,m,n,temp,cnt,ans,sum,t,q;
string str,str1,st2;
vector< int > nums;
const int MAXW = 1e5+1;
LL dp[101][MAXW];
LL w[100];
LL v[100];
LL solve(int i , int rem ){

    if(i== n)return 0;

    LL &ret = dp[i][rem];
    if(ret!=-1)return ret;
    ret=0;
    LL choice1 = solve(i+1 , rem);
    LL choice2=0;
    if( rem - w[i]>=0)
        choice2= v[i]+solve(i+1, rem-w[i]);
    
    ret=max(choice1,choice2);
    return ret;
}
int main()
{
    bool readfromfile=false; if(!readfromfile){SLAY} else{INPUT}

    cin>>n>>m;
    memset(dp , -1 , sizeof(dp));
    for(int i = 0 ; i < n ;i++)cin>>w[i]>>v[i];
    cout<<solve(0,m);
    cout<<endl;

    return 0;
}

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

int main(){
  int n,w;
  cin>>n>>w;
  ll vec[n][2];
  ll dp[n+1][w+1];
  for(int i=0;i<n;i++){
    for(int j=0;j<2;j++){
      cin>>vec[i][j];
    }
  }
  //vec[i][0]=weight,vec[i][1]=value
  //dp[i][j]=0~i,weight:j
  for(int i=0;i<w+1;i++){
    dp[0][i]=0;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<=w;j++){
      dp[i+1][j]=dp[i][j];
      if(j>=vec[i][0]){
        dp[i+1][j]=max(dp[i+1][j],dp[i][j-vec[i][0]]+vec[i][1]);
      }
    }
  }
  cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 79104
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI d;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,m;
  cin>>n>>m;
  d.resize(n+1);
  in x;
  forn(z,2*m){
    cin>>x;
    ++d[x];
  }
  forv(i,d){
    if(d[i]%2){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#define md 1000000007
using namespace std;
long long n,m,f[1003][1003];
char a[1003][1003];
long long trau(long long i,long long j)
{
    if (i>n||j>m)
    {
        return 0;
    }
    if (i==n&&j==m)
    {
        return 1;
    }
    if (a[i][j]=='#') return 0;
    long long &res=f[i][j];
    if (res!=-1) return res;
    res=0;
    res=(res+trau(i+1,j)%md)%md;
    res=(res+trau(i,j+1)%md)%md;
    return res;
}
int main()
{
    //freopen("H_Grid1.inp","r",stdin);
    //freopen("H_Grid1.out","w",stdout);
    cin>>n>>m;
    for (long long i=1;i<=n;++i)
        for (long long j=1;j<=m;++j)
            f[i][j]=-1;
    for (long long i=1;i<=n;++i)
    {
        for (long long j=1;j<=m;++j)
            cin>>a[i][j];
    }
    cout<<trau(1,1);
    return 0;
}

Measured memory_bytes: 12472
from collections import defaultdict as dd

N,M = map(int,input().split())
A2B = dd(list)
B2A = dd(list)
for a in range(M):
    A,B = input().split()
    A2B[A].append(B)
    B2A[B].append(A)
    
# 探索するノードの一覧
nodes_seek = set([str(x) for x in range(1,N+1)])

# 探索したノードの一覧
disc_nodes = set([])

# 各ノードの最短経路を保管する辞書
shortest_path = dd(list)
# 各ノードの暫定の最短ホップ数を保管する辞書
shops = dd(int)
# 各ノードの最短経路における、手前のノードを記憶する辞書
sprev = dd(str)

# ノード1から順に探索
## ノード1に入った⇒ 隣接する部屋のリスト一覧を取得
nxt_nodes = dd(list)
nxt_nodes["1"] = A2B["1"]
nxt_nodes["1"] += B2A["1"]

## ノード1への距離を0として記入
shops["1"] = 0
shortest_path["1"] = []
sprev["1"]=[]
disc_nodes.add("1")

#取得した隣接リストを使う（が、幅優先で考える）


count = 0

while len(disc_nodes) < N:
    # 現在の隣接リストをあたり、次の隣接ノードのリストを作成する
    nnxt_nodes = dd(list)
    for key in nxt_nodes.keys():
        ## 現在の隣接リストから、すでに見つかったノードを省く
        tnxt_nodes = set(nxt_nodes[key]) - disc_nodes
    
        for n in tnxt_nodes:
            # 現在の隣接リストで見つかったノードについて、
            ## 手前のノードとして、現在のKeyを記入
            shops[n] = shops[key]+1
            sprev[n] = str(key)            
            
            ## 探索済みノードとして追記
            disc_nodes.add(n)
            
            ## 次の隣接リストを取得、記載する
            nnxt_nodes[n] += A2B[n]
            nnxt_nodes[n] += B2A[n]
    nxt_nodes = nnxt_nodes

#     count += 1
#     if count >100:
#         break

ans = 'Yes'
       
# print(" ----------------------- ")    

# for i in range(1,N+1):
#     print("i:",i)
#     print("-- shops --")
#     print(shops[str(i)])
    
#     print("-- sprev --")
#     print(sprev[str(i)])
    

# print("disc_nodes")
# print(disc_nodes)

for i in range(1,N+1):
    if i == 1:
        print(ans)
    else:
#         print(i,sprev[str(i)])
        print(sprev[str(i)])


Measured memory_bytes: 220996
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ff first
#define ss second
#define maxn 1000000007
#define PI 3.14159265358979323846
#define MAX 1000007 
using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    //cout<<fixed<<setprecision(20);
    ll n;
    cin>>n;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    ll ans=a[n/2]-a[n/2-1];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#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>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

int main() {

    ll r,D,x;

    cin >> r >> D >> x;

    rep(i,10){
        x = r*x - D;
        cout << x << endl;
    }

}

Measured memory_bytes: 3612
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, x = MAP()
a = LIST()
ans = 0
for i in range(n-1):
    if a[i] + a[i+1] > x:
        ans += a[i] + a[i+1] - x
        a[i+1] = max(0, x - a[i])
print(ans)

Measured memory_bytes: 21592
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    s = input()
    st = set(s)
    mi = 10**18
    for i in st:
        ma = 0
        nr = 0
        for j in s:
            if j == i:
                if ma < nr:
                    ma = nr
                nr = 0
            else:
                nr += 1
        if nr > ma:
            ma = nr
        if mi > ma:
            mi = ma
    print(mi)

    return

if __name__ == '__main__':
    main()


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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N+1);
    rep(i,N) cin >> A[i];
    long long res = 0;
    rep(i,N){
        res += A[i] / 2;
        if(A[i] % 2 && A[i+1]){
            res++;
            A[i+1]--;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	vi c(n);
	rep(i, n) cin >> c[i];
	
	stack<int> st;
	bool check[101] = {};

	rep(i, n) {
		if (c[i] > 0) {
			if (check[c[i]]) {
				cout << i + 1 << endl;
				return 0;
			}
			else {
				st.push(c[i]);
				check[c[i]] = true;
			}
		}
		else {
			if (!st.empty() && st.top() == -c[i]) {
				st.pop();
				check[-c[i]] = false;
			}
			else {
				cout << i + 1 << endl;
				return 0;
			}
		}
	}
	cout << "OK" << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    
    vector<string> A(N);
    vector<string> B(M);
    for(int n=0; n<N; n++) {
        cin >> A[n];
    }
    for(int m=0; m<M; m++) {
        cin >> B[m];
    }
    
    bool flag=false;
    for(int ni=0; ni<N-M+1; ni++) {
        for(int nj=0; nj<N-M+1; nj++) {
            bool tmpf=true;
            for(int mi=0; mi<M; mi++) {
                for(int mj=0; mj<M; mj++) {
                    if(A[ni+mi][nj+mj]!=B[mi][mj]) {
                        tmpf=false;
                        break;
                    }
                }
                if(!tmpf) {
                    break;
                }
            }
            if(tmpf) {
                flag=true;
                break;
            }
        }
        if(flag) {
            break;
        }
    }
    
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int maxn = 1e5 + 9;
int p[maxn], n, k, q;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    cin >> n >> k >> q;
    rep (i,0 , q){
        int a;
        cin >> a;
        p[a]++;
        
    }
    rep(i, 1, n + 1){
        if (k - (q - p[i]) > 0)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 1024
N, A, B = map(int, input().split())
S = input()


b = 0
a = 0
for i in range(N):
    if S[i] == 'a':
        a += 1
        if A + B >= a + b: 
            print('Yes')
        else:
            print('No')
            
    if S[i] == 'b':
        if A + B > a + b and b < B:
            b += 1
            print('Yes')
        else:
            print('No')
            
    if S[i] == 'c':
        print('No')

Measured memory_bytes: 4016
#include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define all(v) v.begin(),v.end()
#define pb push_back
#define INF 1e9
using namespace std;

int abs(int num){
	return (num>=0)?num:-num;
}

int main(){
	int n,in;
	cin>>n;
	vector<int> h;
	rep(i,n){
		cin>>in;
		h.pb(in);
	} 
	int dp[n];
	fill(dp,dp+n,INF);
	dp[0]=0;
	rep(i,n){
		dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
		dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1144
#include <cstdio>
#include <queue>
#include <iostream>
#include <algorithm>
#include<cstring>
using namespace std;
long long dis[310][310];
long long full[310][310];
int main()
{
    int n,m,l;
    cin >> n >> m >> l;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i==j)    dis[i][j] =0;
            else
            {
                dis[i][j] = 0x3f3f3f3f3f3f3f3f;
            }
            
        }
    }
    for(int i=1;i<=m;i++)
    {
        int u,v,w;
        cin >> u >> v >> w;
        dis[u][v] = w;
        dis[v][u] = w;
    }
    for(int k=1;k<=n;k++)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                dis[i][j] = min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i==j)    continue;
            if(dis[i][j]<=l) full[i][j] = 1;
            else
            {
                full[i][j] = 0x3f3f3f3f3f3f3f3f;
            }      
        }
    }
    for(int k=1;k<=n;k++)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                full[i][j] = min(full[i][j],full[i][k]+full[k][j]);
            }
        }
    }
    int q;
    cin >> q;
    for(int i=1;i<=q;i++)
    {
        int x,y;
        cin >> x >> y;
        if(full[x][y]==0x3f3f3f3f3f3f3f3f)  cout << -1 << endl;
        else
        {
            cout << full[x][y] -1 << endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> x(n),y(m);
    rep(i,n) cin >> x[i];
    rep(i,m) cin >> y[i];
    
    ll ysum = 0;
    rep(i,m-1){
        ll d = (y[i+1]-y[i]) % mod;
        ll tmp = (m-i-1) * (i+1) % mod;
        ysum += (d * tmp) % mod;
        ysum %= mod;
    }
    ll xsum = 0;
    rep(i,n-1){
        ll d = (x[i+1] - x[i]) % mod;
        ll tmp = (n-i-1) * (i+1) % mod;
        xsum += (d * tmp) % mod;
        xsum %= mod;
    }

    ll ans = xsum * ysum % mod;
    cout << ans << endl;
}


Measured memory_bytes: 1792
s = input()
n = int(input())

for _ in range(n):
    t = input().split()
    t1 = int(t[1])
    t2 = int(t[2])
    tmp = s[t1:t2+1]
    if t[0] == 'replace':
        s = s[:t1] + t[3] + s[t2+1:]
    elif t[0] == 'reverse':
        s = s[:t1] + tmp[::-1] + s[t2+1:]
    elif t[0] == 'print':
        print(tmp)



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(double (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

const int nCk_MAX = 510000;
ll fac[nCk_MAX], finv[nCk_MAX], inv[nCk_MAX];
bool Preparation = true;
void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < nCk_MAX; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
ll com(int n, int k) {
    if (Preparation) {
        cominit();
        Preparation = false;
    }
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
    init();

    ll h, w, a, b;
    cin >> h >> w >> a >> b;

    ll ans = 0;
    eFOR(i, b + 1, w) {
        int H = h - a - 1, W = i - 1;
        ll tmp = com(H + W, H);
        H = a - 1, W = w - i;
        tmp *= com(H + W, W);
        ans += tmp % mod;
    }
    cout << ans % mod << endl;
}

Measured memory_bytes: 12796
object Main {
    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val n, k = sc.nextInt
        val ans0 = math.pow((n / k), 3).toLong
        if (k % 2 == 1) println(ans0)
        else {
            val m = n / (k / 2) - n / k
            println(ans0 + math.pow(m, 3).toLong)
        }
    }
}


Measured memory_bytes: 27176
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int answer = 0;
  for(int i=1;i<= n;i++){
    int a;
    cin >> a;
    if(a != i) answer++;
  }
  
  if(answer <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

int main(){
    int64_t i,j,k,l;//preparation for
    double r;
    double p;

    p=3.1415926;

    cin>>r;
    r*=2*p;
    cout<<r;

    return 0;
}

Measured memory_bytes: 3776
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int p = in.nextInt();
        String s = in.next();
        int[] digits = new int[n];
        for (int j = 0; j < n; j++) {
            digits[j] = s.charAt(j) - '0';
        }
        if (p == 2 || p == 5) {
            long answer = 0;
            for (int j = 0; j < n; j++) {
                if (digits[j] % p == 0) {
                    answer += j + 1;
                }
            }
            System.out.println(answer);
        } else {
            int[] freq = new int[p];
            freq[0] = 1;
            long answer = 0;
            int curr = 0;
            int pow10 = 1;
            for (int j = n - 1; j >= 0; j--, pow10 *= 10, pow10 %= p) {
                curr += pow10 * digits[j];
                curr %= p;
                answer += freq[curr];
                freq[curr]++;
                //System.out.println("j = " + j + ", curr = " + curr + ", freq = " + freq[curr]);
            }
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 27020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

ll modpow(ll a, ll n, ll m)
{
  ll ret = 1;
  while (n > 0)
  {
    if (n % 2 == 1) ret = ret * a % m;
    a = a * a % m;
    n /= 2;
  }
  return ret;
}

ll modinv(ll a, ll m)
{
  ll b = m, x = 1, y = 0;
  while (b > 0)
  {
    ll q = a / b, r = a - q * b, s = x - q * y;
    a = b, b = r;
    x = y, y = s;
  }
  return mod(x, m);
}

class combination
{
public:
  vector<ll> fac, finv, inv;

  combination(ll M)
  {
    fac = vector<ll>(M, 1);
    finv = vector<ll>(M, 1);
    inv = vector<ll>(M, 1);

    for (ll i = 2; i < M; i++)
    {
      fac.at(i) = fac.at(i - 1) * i % MOD;
      inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
      finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
    }
  }

  ll P(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * finv.at(N - K) % MOD;
  }

  ll C(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * (finv.at(K) * finv.at(N - K) % MOD) % MOD;
  }

  ll H(ll N, ll K)
  {
    return C(N + K - 1, K);
  }
};

int main()
{
  ll B, W;
  cin >> B >> W;

  combination com(B + W);
  const ll half = modinv(2, MOD);

  vector<ll> P(B + W), Q(B + W);
  P.at(0) = 0, Q.at(0) = 0;
  cout << half << endl;

  for (ll i = 1; i < B + W; i++)
  {
    P.at(i) = (P.at(i - 1) + (com.C(i - 1, B - 1) * modpow(half, i, MOD)) % MOD) % MOD;
    Q.at(i) = (Q.at(i - 1) + (com.C(i - 1, W - 1) * modpow(half, i, MOD)) % MOD) % MOD;

    ll ans = Q.at(i);
    ans += half;
    ans %= MOD;
    ans -= P.at(i) * half;
    ans = mod(ans, MOD);
    ans -= Q.at(i) * half;
    ans = mod(ans, MOD);
    cout << ans << endl;
  }
}

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

long long ans;
long long n;
void test(long long current, int use){
	if(current > n) return;
	if(use==0b111)ans++;

	test(current*10 +7, use|0b001);
	test(current*10 +5, use|0b010);
	test(current*10 +3, use|0b100);
}

int main(){
	cin>>n;		ans=0;
	test(0,0);

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
def solve(n):
    def get_count(n):
        if n < 3:
            return [1, 2, 4][n-1]
        cnt = [0] * (n)
        cnt[0] = 1
        cnt[1] = 2
        cnt[2] = 4
        for i in xrange(3, n):
            cnt[i] += cnt[i-1] + cnt[i-2] + cnt[i-3]
        return cnt[n-1]
    cnt =  get_count(n)
    print (((cnt+9)/10) + 364) / 365

if __name__ == "__main__":
    import sys
    while True:
        n = int(raw_input())
        if not n:
            sys.exit()
        solve(n)

Measured memory_bytes: 6464
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
string S[1010];
int d[1010][1010];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void solve() {
	cin >> N >> M;
	rep(i, 0, N) cin >> S[i];
	rep(i, 0, N) {
		rep(j, 0, M) {
			d[i][j] = inf;
		}
	}
	queue<pi> que;
	rep(i, 0, N) {
		rep(j, 0, M) {
			if(S[i][j] == '#') {
				que.push(pi(i, j));
				d[i][j] = 0;
			}
		}
	}
	while(!que.empty()) {
		pi p = que.front(); que.pop();
		rep(i, 0, 4) {
			int nx = p.fst + dx[i], ny = p.sec + dy[i];
			if(0 <= nx && nx < N && 0 <= ny && ny < M && d[nx][ny] == inf) {
				d[nx][ny] = d[p.fst][p.sec] + 1;
				que.push(pi(nx, ny));
			}
		}
	}
	int res = 0;
	rep(i, 0, N) {
		rep(j, 0, M) {
			MAX(res, d[i][j]);
		}
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

string s;

int main() {
  cin >> s;
  if (s.size() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3608
# nは展望台の数　mは道の数
n,m = map(int,input().split())
high = list(map(int,input().split()))

a = []

for x in range(m):
    b = list(map(int,input().split()))
    a.append(b)


loser = []

for y in a:
    high1 = high[y[0]-1]
    high2 = high[y[1]-1]
    if high1 > high2:
        loser.append(y[1])
    elif high1 ==  high2:
        loser.append(y[0])
        loser.append(y[1])
    else:
        loser.append(y[0])

new_loser = list(set(loser))
print(n-len(new_loser))


Measured memory_bytes: 34788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    bool ans = false;
    for (int i = A; i <= B; i++){
        if (i % K == 0) ans = true;
    }
    if (ans) cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3592
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val D = readLine()!!.split(" ").map(String::toInt)

    val map = D.groupBy{ it }.mapValues { it.value.size }.toSortedMap()


    val avgPreIndex = N / 2
    var sum = 0
    var avgPreNumber = 0
    var avgNextNumber = 0
    for ((k, v) in map) {
        sum += v

        if (avgPreNumber != 0) {
            avgNextNumber = k
            break
        }
        if (sum == avgPreIndex) {
            avgPreNumber = k

        }
        if (sum > avgPreIndex) {
            println(0)
            return
        }
    }

    println(avgNextNumber - avgPreNumber)


}

Measured memory_bytes: 60268
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
ull binom_two(ull n){
  if(n%2==0) return n/2*(n-1);
  else return (n-1)/2*n;
}
 
int main(){
  int N;
  cin >>N;
  vector<string> str(N);
  vector<string> temp(N);
  for(int i=0; i<N; i++){
    cin >> str[i];
    temp[i]=str[i];
    sort(temp[i].begin(), temp[i].end());
  }
  sort(temp.begin(),temp.end());
  
  vector<int> freq(N);
  freq[0]++;
  int h=0;
  ull count=0;
  for(int i=1; i<N; i++){
    if(temp[i]==temp[i-1]) freq[h]++;
    else{
      h++;
      freq[h]++;
    }
  }
  for(int i=0; i<=h; i++){
    if(freq[i]<2) continue;
    else count+=binom_two(freq[i]);
  }
  cout << count <<endl;
}

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

struct DSU{
 int N;
 struct Node{ int d; int p; };
 vector<Node> V;
 void init(int n){
  N=n; V.resize(N);
  rep(i,N) V[i]={0,i};
 }
 int root(int a){
  if(a==V[a].p) return a;
  return V[a].p = root(V[a].p);
 }
 void unite(int a,int b){
  a=root(a); b=root(b);
  if(V[a].d<V[b].d){ V[a].p = b; }
  else if(V[a].d>V[b].d){ V[b].p = a; }
  else{ V[a].p = b; ++V[b].d; }
 }
};

int main(){
 int N,Q; scanf("%d%d",&N,&Q);
 DSU G; G.init(N);
 rep(q,Q){
  int c; scanf("%d",&c);
  if(c==0){
   int x,y; scanf("%d%d",&x,&y);
   G.unite(x,y);
  }
  if(c==1){
   int x,y; scanf("%d%d",&x,&y);
   printf((G.root(x)==G.root(y)) ? "1\n" : "0\n");
  }
 }
 return 0;
}

Measured memory_bytes: 4740
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long ll;
const int maxN = 1e5 + 5;
ll s1[maxN], s2[maxN], s3[maxN], s4[maxN], v[maxN], C, x[maxN];
int N;

int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d%lld", &N, &C); x[N + 1] = C;
	for(int i = 1; i <= N; ++i) scanf("%lld%lld", &x[i], &v[i]);
	ll ans = 0;
	for(int i = 1; i <= N; ++i) {
		s1[i] = s1[i - 1] + v[i] - (x[i] - x[i - 1]);
		ans = max(ans, s1[i]);
		s2[i] = s2[i - 1] + v[i] - 2 * (x[i] - x[i - 1]); 
	}
	for(int i = N; i >= 1; --i) {
		s3[i] = s3[i + 1] + v[i] - (x[i + 1] - x[i]);
		ans = max(ans, s3[i]);
		s4[i] = s4[i + 1] + v[i] - 2 * (x[i + 1] - x[i]);
	}
	for(int i = 1; i <= N; ++i) s2[i] = max(s2[i - 1], s2[i]);
	for(int i = N; i >= 1; --i) s4[i] = max(s4[i + 1], s4[i]);
	for(int i = 1; i <= N; ++i) {
		ans = max(ans, s1[i] + s4[i + 1]);
		ans = max(ans, s3[i] + s2[i - 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <cmath>
#include <iostream>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	cout << max(0, a - b * 2) << endl;
}

Measured memory_bytes: 256
def max(a,b); a > b ? a : b; end
  
N,K = gets.split.map(&:to_i)
V = gets.split.map(&:to_i)
L = Array.new(N + 1, 0)
R = Array.new(N + 1, 0)

V.each.with_index(1){|v,i| L[i] = L[i - 1] + v }
V.reverse_each.with_index(1){|v,i| R[i] = R[i - 1] + v }

ans = 0
(0 .. N).each do |l|
  (0 .. N).each do |r|
    break if l + r > K || l + r > N
    b = V.select.with_index{|v,i| v < 0 && (i < l || i >= N - r) }.min(K - (l + r)).inject(0,&:+)
    ans = max(ans, L[l] + R[r] - b)
  end
end
puts ans


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;

int main(void){
    
	scanf("%d", &N);
	
	if(N == 1) printf("Hello World\n");
	else{
	    int a, b; scanf("%d %d", &a, &b);
	    printf("%d\n", a + b);
	}
	
    return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(k,n/k);
    a[0]--;
    for(ll i=0;i<=n%k;i++){
        a[i]++;
    }
    ll ans=0;
    ans+=a[0]*a[0]*a[0];
    if(k%2==0){
        ans+=a[k/2]*a[k/2]*a[k/2];
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1792
def resolve():
    N = int(input())
    C = input()
    l = 0
    r = len(C)-1
    cnt = 0
    while l < r:
        while l < len(C) and C[l] == 'R':
            l += 1
        while r >= 0 and C[r] == 'W':
            r -= 1

        if l >= r:
            break

        if C[l] == 'W' and C[r] == 'R':
            # C[l], C[r] = C[r], C[l]
            cnt += 1
            l += 1
            r -= 1
    
    print(cnt)
    
resolve()

Measured memory_bytes: 67856
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <string.h>
 
#define rep(i,n)    for(ll i=0;i<n;i++)
#define repu(i,k,n) for(ll i=k;i<=n;i++)
#define repd(i,k,n) for(ll i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define INF (ll)ll_MAX
 
typedef long long ll;
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector< ll > vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, ll > > vpp;
 
const ll N = 3*1e5 +5 ;
const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long inf = 1e18;
 
using namespace std;

// ll g[200000], ig[200000];




void solve()
{	

    string s,t;

    cin>>s>>t;

    ll ans = INT_MAX;

    for(ll i=0;i<=s.size()-t.size();i++){
        ll ctr = 0;
        for(ll j=0;j<t.size();j++){
            if(s[i+j]!=t[j]) ctr++;
        }
        ans = min(ans,ctr);
    }

    cout<<ans;


}

int main() {


    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif


    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    ll ctr=0;
    while(t--)
    {   
        ctr++;
        // cout<<"Case #"<<ctr<<": ";
        solve();    
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
}

Measured memory_bytes: 3844
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <bitset>
const int N = 85;
typedef long long ll;
const int mod = 1000000007;
#define fre(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout); 
using namespace std;

int n, m, a[N][N], b[N][N]; 
bitset<25611> f[N][N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int main()
{
	n = read <int> (), m = read <int> ();
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			a[i][j] = read <int> ();
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			b[i][j] = read <int> ();
	f[0][1][12800] = 1, f[1][0][12800] = 1;
	for(int len, i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
		{
			len = (a[i][j] - b[i][j] > 0 ? a[i][j] - b[i][j] : b[i][j] - a[i][j]);
			f[i][j] |= (f[i - 1][j] << len), f[i][j] |= (f[i - 1][j] >> len);
			f[i][j] |= (f[i][j - 1] << len), f[i][j] |= (f[i][j - 1] >> len); 
		}
	for(int i = 0; i <= 12800; i++)
		if(f[n][m][12800 - i] || f[n][m][12800 + i])
		{
			printf("%d\n", i);
			break;
		}
	return 0; 
}


Measured memory_bytes: 22528
#include<bits/stdc++.h>
using namespace std;
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " "<<a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}
#define fr first
#define sc second
 
typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
 
typedef long long int64;
const int INF = 1 << 30;

class UnionFind {
private:
  vector< int > rank, p;
  void link(int x, int y) {
    if(rank[x] > rank[y]) swap( x, y);
    p[x] = y;
    if(rank[x] == rank[y]) rank[y]++;
  }
public:
  UnionFind(int n) : rank(n), p(n) {
    for(int i = 0; i < n; i++) p[i] = i, rank[i] = 0;
  }
  void Union(int x, int y) {
    if(Find(x) != Find(y)) link( Find(x), Find(y));
  }
  int Find(int x) {
    return(x != p[x] ? p[x] = Find(p[x]) : p[x]);
  }
  bool Same(int x, int y) {
    return(Find(x) == Find(y));
  }
};
template< class T >
class SGraph{
protected:
  struct edge {
    int u, v;
    T cost;
    bool operator<(const edge& hoge) const {
      return cost < hoge.cost;
    }
  };
  typedef vector< edge > Edges;
  Edges edges;
public:
  SGraph< T >(){};
  void add_edge( int u, int v, T cost) {
    edges.push_back((edge){ u, v, cost});
  }
};

template< class T >
class MinimumSpanningTree : public UnionFind, public SGraph< T >{
public:
  MinimumSpanningTree(int n):SGraph< T >(), UnionFind(n){};
  T run(){
    sort( SGraph< T >::edges.begin(), SGraph< T >::edges.end());
    T ret = 0;
    ForEach(it, SGraph< T >::edges){
      if(!Same( it -> u, it -> v)){
        Union( it -> u, it -> v);
        ret += it -> cost;
      }
    }
    return ret;
  }
};
int main(){
  int V, E;
  cin >> V >> E;
  MinimumSpanningTree< int > foo(V);
  for(int i = 0; i < E; i++){
    int a, b, c;
    cin >> a >> b >> c;
    foo.add_edge( a, b, c);
  }
  cout << foo.run() << endl;
}

Measured memory_bytes: 2800
/*Author: Qaseem Hasan alias Mikepayne14(Codeforces,SPOJ) 
                           qaseem_hasan_ (HackerEarth,Codechef,HackerRank)
*/


//---------------------------------------------------------
//#pragma GCC optimize "trapv"

#include<bits/stdc++.h>
using namespace std;
//---------------------------------------------------------
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; } //x=min,y=item
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

template<typename ForwardIterator,typename T>
T first_val(ForwardIterator first,ForwardIterator last,T value)
{
    auto it = std::lower_bound(first,last,value);
    return (it!=last)?(it - first) : -1;
}

template<typename ForwardIterator,typename T>
T last_val(ForwardIterator first,ForwardIterator last,T value)
{
    auto it = std::upper_bound(first,last,value);
    return ((it!=last)?(it - first) : -1) - 1;
}
//--------------------------------------------------------
#define acc accumulate
#define eb emplace_back
#define ll long long int
#define lld long long double
#define mii map <int,int>
#define vi vector <int>
#define vll vector <ll>
#define vvi vector <vi>
#define pii pair <int,int>
#define vpii vector <pii>
#define seti set <int>
#define F first
#define S second
#define fil(v,x) fill(all(v),x)
#define filcon(v,x) iota(all(v),x)
#define rep(n) for(int i=0;i<n;++i)
#define repr(n) for(int i=n-1;i>=0;--i)
#define erase(v,e) v.erase(std::remove(v.begin(), v.end(), e), v.end())
#define sqr(x) ((x)*(x))
#define MEM(a, b) memset(a, b, sizeof(a))
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define inrange(i,a,b) ((i>=min(a,b)) && (i<=max(a,b))) 
#define FLSH fflush(stdout)
// #define min_all(a,b,c,d,...) min({a,b,c,d,...})
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define make_unique(v) sort(all(v)); v.erase(unique(all(v)), v.end());
#define INF (int)1e9
#define EPS 1e-8
#define MOD 1e9 + 7
#define tr(x) cout<<#x<<" = { "<<x<<" }\n";
#define khatam '\n'
#define PI acos(-1);

//--------------------------------------------------------

//int ar[40001][40001];

//ll ar[10001];

//--------------------------------------------------------
/*bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.F < j.F;
}*/

void solve()
{
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes" <<khatam;
    else
        cout << "No" << khatam;
}

int main()
{
    FAST_IO;
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
//--------------------------------------------------------
solve();
}



Measured memory_bytes: 256
open System
open System.Collections.Generic

[<AutoOpen>]
module FastIO =
    let reader = new IO.StreamReader(new IO.BufferedStream(Console.OpenStandardInput()))
    let inline read f = reader.ReadLine() |> f
    let inline reada f = reader.ReadLine().Split() |> Array.map f
    let inline readChars() = read string |> Seq.toArray
    let inline readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let inline write (s: string) = writer.Write s
    let inline writeln (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> writeln

    let inline ioDispose() =
        reader.Dispose()
        writer.Dispose()

// -----------------------------------------------------------------------------------------------------

// -----------------------------------------------------------------------------------------------------
let main() =
    let n = read int
    let st = SortedDictionary<string, int>(StringComparer.Ordinal)
    for i in 0 .. n - 1 do
        let s = read string
        if st.ContainsKey(s) then st.[s] <- st.[s] + 1 else st.Add(s, 1)
    let cnt = Seq.maxBy (fun (kv: KeyValuePair<string, int>) -> kv.Value) st
    for kv in st do
        if cnt.Value = kv.Value then puts kv.Key
    ()
// -----------------------------------------------------------------------------------------------------
main()
ioDispose()


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int k;cin>>k;
    int m=0;
    while(b<=a){
        b*=2;
        m++;
    }
    while(c<=b){
        c*=2;
        m++;
    }
    if(m<=k)cout<<"Yes";
    else cout<<"No";

    return 0;
}


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

ll fp(ll x,ll y){
    if(y == 0){
        return 1;
    }
    int p = fp(x,y/2);
    p = p*p;
    if(y%2 == 1){
        p = p*x;
    }
    return p;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll sol = (n > 2 ? 2 : 1);

    ll x = n-1;
    for(ll i = 2; i*i <= x; i++){
        if(x%i){
            continue;
        }
        sol++;
        if(i*i != x){
            sol++;
        }
    }

    x = n;
    for(ll i = 2; i*i <= x; i++){
        if(x%i){
            continue;
        }
        ll d = i,y = x;
        while(y%d == 0){
            y /= d;
        }
        if(y%d == 1){
            sol++;
        }
        if(i*i == x){
            continue;
        }
        d = x/i,y = x;
        while(y%d == 0){
            y /= d;
        }
        if(y%d == 1){
            sol++;
        }
    }
    cout << sol << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

char b;
int main (){
    cin >> b;
    if( b == 'A') cout << 'T' << endl;
    else if( b == 'T') cout << 'A' << endl;
    else if( b == 'C') cout << 'G' << endl;
    else if( b == 'G') cout << 'C' << endl;
    return 0;
}


Measured memory_bytes: 256
import collections
n = int(input())
A = list(map(int,input().split()))
counter = collections.Counter(A)
max_A = max(A)
cnt = 0

for i in range(-1,max_A):
    temp_cnt = counter[i-1] + counter[i] + counter[i+1]
    cnt = max(cnt,temp_cnt)

print(cnt)


Measured memory_bytes: 14564
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	map<int, int> mp;
	int t = 0;
	rep(i,n) {
		if (!mp[v[i]]) mp[v[i]]++;
		else t++;
	}
	cout << n - t - (t % 2) << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 8236
from itertools import combinations

N = int(input())
L = list(map(int, input().split()))
ans = 0
for items in combinations(L, 3):
    if sum(items) - max(items) > max(items):
        a, b, c = items
        if a != b and b != c and a != c:
            ans += 1
print(ans)


Measured memory_bytes: 68668