akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve() 
{
    string s;cin>>s;
    REP(i,3){
        if(s[i]=='7'){
            cout<<"Yes"<<endl;
            return;
        }
    }cout<<"No"<<endl;
}

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

Measured memory_bytes: 3620
n,c = list(map(int, input().split()))
W=[]
P=[]
for _ in range(n):
    w,val = list(map(int, input().split()))
    W.append(w)
    P.append(val)
dp=[]
for i in range(n+1):
    dp.append([0]*(c+1))
for i in range(1,n+1):
    for j in range(1,c+1):
        inc=0
        exc=0
        if j-W[i-1]>=0:
            inc=P[i-1]+dp[i-1][j-W[i-1]]
        exc=dp[i-1][j]
        dp[i][j]=max(inc,exc)
print(dp[n][c])

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    ll n; cin >> n;
    VL b(n,0);
    rep(i,n-1){
        ll a; cin >> a;
        b[a-1]++;
    }
    for(auto x : b){
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include <vector>
#define INF 2000000000

using namespace std;

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

Measured memory_bytes: 1024
H, W = map(int, input().split())
S = [input() for _ in range(H)]

G = [[None for j in range(W)] for i in range(H)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

count = 0

for i in range(H):
    for j in range(W):
        if G[i][j] is not None:
            continue
        if S[i][j] == '#':
            color = 1
        else:
            color = 0
        stack = [(i, j, color)]
        G[i][j] = count
        while stack:
            x, y, c = stack.pop()
            for k in range(4):
                nx, ny = x + dx[k], y + dy[k]
                if not (0 <= nx < H and 0 <= ny < W):
                    continue
                if G[nx][ny] is not None:
                    continue
                if S[nx][ny] == '#':
                    nc = 1
                else:
                    nc = 0
                if nc == c:
                    continue
                G[nx][ny] = count
                stack.append((nx, ny, nc))
        count += 1

C = [[0, 0] for _ in range(count)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            C[G[i][j]][0] += 1
        else:
            C[G[i][j]][1] += 1

res = 0

for b, w in C:
    res += b * w

print(res)

Measured memory_bytes: 27028
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  vector<int> a(n+1);
  for(int i = 1; i <= n; i++) cin >> a[i];

  vector<int> idx(n+1);
  for(int i = 1; i <= n; i++){
    idx[a[i]] = i;
  }

  set<int> st = {0, n+1};
  int ans = 0;
  for(int i = 1; i <= n; i++){
    auto pos = st.lower_bound(idx[i]);
    int right = *pos, left = *(--pos);
    ans += i * (idx[i] - left) * (right - idx[i]);
    st.insert(idx[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12800
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file freopen("out.out","w",stdout);
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REV(a) reverse(a.begin(),a.end())
#define SORT(a) sort(a.begin(),a.end())
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

ll a,b;

int main() {
		fastio
		cin>>a>>b;
		if(a%b==0)cout<<-1<<endl;
		else {
				cout<<a<<endl;
		}



		return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

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;
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input values
    int N, W;
    cin >> N >> W;

    vector<int> w(N), v(N);
    rep (i, N) {
        cin >> w[i] >> v[i];
    }

    // dp table
    vector<vector<ll>> dp(110, vector<ll>(100100, 0));

    // init dp table

    // init condition

    // loop
    rep (i, N) {
        for (int sum_w = 0; sum_w <= W; sum_w++) {
            if (sum_w - w[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w-w[i]]+v[i]);
            }
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

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

Measured memory_bytes: 87296
N, M = map(int, input().split())
n_switch = []
switch = []
for i in range(M):
	s = list(map(int, input().split()))
	n_switch.append(s[0])
	switch.append(s[1:])
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
	x = 1
	b = bin(i)[2:].rjust(N, '0')
	for j in range(M):
		n_light = 0
		for k in range(n_switch[j]):
			if b[switch[j][k] - 1] == '1':
				n_light += 1
		if n_light % 2 != p[j]:
			x *= 0
			break
	if x == 1:
		ans += 1
print(ans)

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

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

	int n;
	cin>>n;
	ll a1 = 1;
	ll b1 = 1;
	ll mul;
	while(n--){
			int a,b;
			cin>>a>>b;
			ll x = a1 / a;
			if(a1 % a != 0)
				x++;
			
			ll y = b1 / b;
			if(b1 % b != 0)
				y++;
			mul = max(x,y);
			a1 = a * mul;
			b1 = b * mul;
	}
	
	cout<<a1+b1<<endl;
	
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if (a.back() == b[0] && b.back() == c[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
const int maxn=20+10;
const int INF=int(1e9)+10;
#define LL long long
char str[maxn][maxn];
int swaped[maxn];
bool used[maxn];
bool ans;
int n,m;
bool check() {
	memset(used,0,sizeof(used));
	for(int i=0; i<m; i++) {
		if(used[i])
			continue;
		for(int j=0; j<m; j++) {
			bool vis=true;
			if(i==j||used[j])
				continue;
			for(int k=0; k<n; k++) {
				if(str[k][i]==str[swaped[k]][j])
					continue;
				vis=false;
				break;
			}
			if(vis){
				used[i]=used[j]=true;
				break;
			}
		}
	}
	int cnt=0;
	int pos=-1;
	for(int i=0; i<m; i++)
		if(!used[i]) {
			cnt++;
			pos=i;
		}
	if(cnt>=2||(cnt&&(m%2==0)))
		return false;
	if(cnt==1) {
		for(int i=0; i<n; i++) {
			if(str[i][pos]!=str[swaped[i]][pos])
				return false;
		}
	}
	return true;
}
void dfs(int u,int falg) {
	if(u==(n+1)>>1) {
		if(check())
			ans=true;
		return ;
	}
	for(int i=u; i<n; i++) {
		if(swaped[i]==-1) {
			for(int j=i+1; j<n; j++) {
				if(swaped[j]==-1) {
					swaped[i]=j;
					swaped[j]=i;
					dfs(u+1,falg);
					swaped[i]=-1;
					swaped[j]=-1;
				}
			}
			if(falg) {
				swaped[i]=i;
				dfs(u+1,false);
				swaped[i]=-1;
			}
		}
	}
}
void init() {
	memset(swaped,-1,sizeof(swaped));
	ans=false;
}
int main() {
	while(~scanf("%d %d",&n,&m)) {
		init();
		for(int i=0; i<n; i++)
			scanf("%s",str[i]);
		if(n&1)
			dfs(0,true);
		else
			dfs(0,false);
		printf("%s\n",ans?"YES":"NO");
	}
}

Measured memory_bytes: 256
import sys
h,w=map(int,input().split())
cmap=[input() for _ in range(h)]

whitesum=0
for each in cmap:
    whitesum += each.count(".")

def nextpoint(y,x):
    global cmap
    tmp=[]
    returnlist=[]
    cmap[y]=cmap[y][:x] + "#" + cmap[y][x+1:]

    if y == 0:
        tmp.append([y+1,x])
    elif y == h-1:
        tmp.append([y-1,x])
    else:
        tmp.extend([[y-1,x],[y+1,x]])

    if x == 0:
        tmp.append([y,x+1])
    elif x == w-1:
        tmp.append([y,x-1])
    else:
        tmp.extend([[y,x+1],[y,x-1]])

    for l in tmp:
        if cmap[l[0]][l[1]] == ".":
            cmap[l[0]]=cmap[l[0]][:l[1]] + "#" + cmap[l[0]][l[1]+1:]
            returnlist.append(l)

    return returnlist

start=[0,0]
seen=[start]
todo=[]
todo.extend(nextpoint(start[0],start[1]))

i=2
finishflag=True

while finishflag:
    nextlist=[]

    for nep in todo:
        if nep == [h-1,w-1]:
            print(whitesum-i)
            sys.exit()
        else:
            nextlist.extend(nextpoint(nep[0],nep[1]))
    todo=[]
    todo.extend(nextlist)

    if todo == []:
        finishflag = False

    i += 1

print("-1")



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

#define D 0.999

using std::cin;
using std::cout;
using std::endl;
using std::vector;

void output(int num_10, int num_50, int num_100, int num_500) {
	if (num_10 != 0) {
		cout << "10 " << num_10 << endl;
	}
	if (num_50 != 0) {
		cout << "50 " << num_50 << endl;
	}
	if (num_100 != 0) {
		cout << "100 " << num_100 << endl;
	}
	if (num_500 != 0) {
		cout << "500 " << num_500 << endl;
	}
}

int main(void) {
	int num = 0;
	while (1) {
		double sum;
		cin >> sum;
		if (sum == 0) {
			break;
		}
		if (num > 0) {
			cout << endl;
		}
		num++;
	
		vector<int> purse(4, 0);
		for (int i = 0; i < 4; i++) {
			int tmp;
			cin >> tmp;
			purse[i] = tmp;
		}

		int num_10 = 0;
		for (int i = sum / 10 + D; i >= 0; i -= 5) {
			if (i <= purse[0]) {
				num_10 = i;
				sum -= num_10 * 10;
				purse[0] -= i;
				break;
			}
		}
		int num_50 = 0;
		for (int i = sum / 50 + D; i >= 0; i -= 2) {
			if (i <= purse[1]) {
				num_50 = i;
				sum -= num_50 * 50;
				purse[1] -= i;
				break;
			}
		}
		int num_100 = 0;
		for (int i = sum / 100 + D; i >= 0; i -= 5) {
			if (i <= purse[2]) {
				num_100 = i;
				sum -= num_100 * 100;
				purse[2] -= i;
				break;
			}
		}
		int num_500 = 0;
		for (int i = sum / 500 + D; i >= 0; i--) {
			if (i <= purse[3]) {
				num_500 = i;
				sum -= num_500 * 500;
				purse[3] -= i;
				break;
			}
		}

		int change_50 = 0;
		while (1) {
			if (purse[0] >= 5) {
				purse[0] -= 5;
				purse[1] += 1;
				change_50++;
			} else {
				break;
			}
		}
		int change_100 = 0;
		while (1) {
			if (purse[1] >= 2) {
				purse[1] -= 2;
				purse[2] += 1;
				change_100++;
			} else {
				break;
			}
		}
		int change_500 = 0;
		while (1) {
			if (purse[2] >= 5) {
				purse[2] -= 5;
				change_500++;
			} else {
				break;
			}
		}

		num_10 += change_50*5;
		if (change_100*2 > change_50) {
			num_50 += change_100*2 - change_50;
		}
		if (change_500*5 > change_100) {
			num_100 += change_500*5 - change_100;
		}

		output(num_10, num_50, num_100, num_500);
	}

	return 0;
}



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

#define ll long long
#define ull unsigned long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, x; cin >> n;
    vector<int> a(n), b(n);
    rep(i,n){
        cin >> a[i];
        if(i%2 == 0 && n%2 == 0){
            b[n/2 + i/2] = a[i];
        }
        else if(i%2 == 1 && n%2==1){
            b[n/2 + i/2 + 1] = a[i];
        }
    }
    for(int i = n-1; i>=0; i--){
        int cnt = n-1 - i;
        if(cnt%2 == 0){
            b[cnt/2] = a[i];  
        }
    }
    for(int i:b){
        cout << i << " ";
    }
    return 0;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long L, R, ans, tmp;
    ans = 30000000;
    cin>>L>>R;
    bool flg=false;
    R = min(R, L+2019);
    for(long long i=L;i<R;i++){
        for(long long j=i+1;j<=R;j++){
            tmp = (i*j)%2019;
            ans = min(ans, tmp);
            if(ans==0){
                flg = true;
                break;
            }
        }
        if(flg)break;
    }cout<<ans<<endl;
}

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

int main() {
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
   cout<<( n>=30 ? "Yes" : "No");
     return 0;
}


Measured memory_bytes: 3684
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll N,A,B;
    cin >> N >> A >> B;
    if((N >= 2 && B >= A) || (N == 1 && A == B))
    cout << B*(N-2) - A*(N-2) + 1 << endl;
    else cout << 0 << endl;
}



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

typedef vector<int> vi;
typedef pair<int,int> pii;
#define For(i,n) for(int i = 0; i < (int) n; ++i)
#define Rep(i,n) for(int i = 1; i <= (int) n; ++i)
#define ll long long
#define lld long double
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define ar array
#define INF 1e18;
#define all(v) (v).begin(),(v).end()
const int N=2e5+1;


void solve(){
    lld d,t,s;
    cin>>d>>t>>s;
    if(d/s<=t){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t;
    t=1;
    while(t--){
        //cout<<"Case #"<<a<<": ";
        solve();
        //a+=1;
    }
}


Measured memory_bytes: 3736
#!/usr/bin/env python3
import sys
from bisect import bisect


def solve(N: int, A: "List[int]"):

    A.reverse()
    res = [A[0]]
    for i in A[1:]:
        pos = bisect(res,i)
        if len(res) <= pos:
            res.append(i)
        else:      
            res[pos] = i

    print(len(res))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8776
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0i32; n];
    for i in 0..n {
        av[i] = read(&mut stdin_lock, &mut buf, b'\n');
    }

    let mut lv = vec![0i32; n];
    for i in 1..n {
        lv[i] = max(lv[i - 1], av[i - 1]);
    }
    let mut rv = vec![0i32; n];
    for i in 1..n {
        let j = n - i - 1;
        rv[j] = max(rv[j + 1], av[j + 1]);
    }

    for i in 0..n {
        println!("{}", max(lv[i], rv[i]));
    }
}


Measured memory_bytes: 7676
s = input()
a = int(s[0:2])
b = int(s[2:4])

if a <= 12 and b <= 12 and a != 0 and b != 0:
    print('AMBIGUOUS')
elif (a > 12 and 0 < b <= 12) or (a == 0 and 0 < b <= 12):
    print('YYMM')
elif (0 < a <= 12 and b > 12) or (0 < a <= 12 and b == 0):
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3064
// AOJ 0301: Baton Relay Game
// 2017.10.31

#include <stdio.h>

typedef struct { int pre, nxt; char f; } T;
T s[200002];
int n, m;
int a[200002];

void calc()
{
	int i, j, aa, cur = 0;
	
	for (i = 0; i < m; i++) {
		aa = a[i];
		if (aa & 1) for (j = 0; j < aa; j++) cur = s[cur].pre;
		else       for (j = 0; j < aa; j++) cur = s[cur].nxt;
		s[cur].f = 0;
		s[s[cur].pre].nxt = s[cur].nxt;
		s[s[cur].nxt].pre = s[cur].pre;
		cur = s[cur].nxt;
	}
}

int main()
{
	int q, i;

	scanf("%d%d%d", &n, &m, &q);
	for (i = 0; i < n; i++) s[i].f = 1, s[i].nxt = i+1, s[i].pre = i-1;
	s[0].pre = n-1, s[n-1].nxt = 0;
	for (i = 0; i < m; i++) scanf("%d", a+i);
	calc();
	while (q-- > 0) {
		scanf("%d", &i);
		printf("%d\n", s[i].f);
	}
	return 0;
}

Measured memory_bytes: 4856
// template version 1.13
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  string s;cin>>s;

  int A = 'A';
  dump(A);
  int m = sz(s);
  string ans = "";
  rep(i, m){
    int v = (s[i]-65+n)%26;
    ans += v+65;
  }
  cout << ans << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
n = int(input())
t = []
ans = [0]*(10**4+5)
def calc(x, y, z):
    return x**2+y**2+z**2 + x*y + y*z + z*x

for x in range(1, 10**2):
    for y in range(1, 10**2):
        for z in range(1, 10**2):
            t.append(calc(x,y,z))

for i in t:
    if i < 10**4+5:
        ans[i] += 1
for i in range(1,n+1):
    print(ans[i])

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second

const int maxn = 1123456;
const int inf = 0x3f3f3f3f;

int n, cntm[maxn], cntc[maxn], q, k;
ll sm[maxn], sc[maxn];
char s[maxn];

int main() {
    scanf("%d%s", &n, s + 1);
    FOR(i, 1, n) {
        cntm[i] = cntm[i - 1] + (s[i] == 'M');
        cntc[i] = cntc[i - 1] + (s[i] == 'C');
        sc[i] = sc[i - 1] + (s[i] == 'C' ? cntm[i] : 0);
        sm[i] = sm[i - 1] + (s[i] == 'M' ? cntc[i] : 0);
    }
    scanf("%d", &q);
    while (q--) {
        scanf("%d", &k);
        k--;
        ll ans = 0, now = 0;
        int pre = -inf;
        FOR(i, 1, n) {
            if (s[i] == 'D') {
                if (i - pre >= k) {
                    now = sc[min(i + k, n)] - sc[i] - ll(cntc[min(i + k, n)] - cntc[i]) * cntm[i];
                } else {
                    now -= sc[i] - sc[pre];
                    now += cntm[pre] * ll(cntc[i] - cntc[pre]);
                    now -= ll(cntc[min(pre + k, n)] - cntc[i]) * (cntm[i] - cntm[pre]);
                    now += sc[min(i + k, n)] - sc[min(pre + k, n)];
                    now -= ll(cntc[min(i + k, n)] - cntc[min(pre + k, n)]) * cntm[i];
                }
                pre = i;
                ans += now;
            }
        }
        printf("%lld\n", ans);
    }
}

Measured memory_bytes: 27136
s = gets.chomp.split("")

bs = s.map.with_index { |c, i| i if c == "B" }.compact
tobe = [*(s.count - bs.count)...s.count]

ans = bs.count.times.inject(0) do |r, i|
  r + tobe[i] - bs[i]
end

puts ans


Measured memory_bytes: 23160
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  ll a,b,c;
  cin>>a>>b>>c;
  if(a%2 == 0 || b%2==0 || c%2==0) {
    cout << 0 << endl;
  } else {
    if(a >= b && a >= c) {
      cout << b * c << endl;
    } else if(b >= a && b >= c) {
      cout << a * c << endl;
    } else {
      cout << a * b << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = input()
if c<d:
    if "##" in s[a:c+1] or "##" in s[b:d+1]:
        print("No")
    else:
        print("Yes")
    exit()
else:
    if "##" in s[a:c+1] :
        print("No")
        exit()
    print("Yes" if "..." in s[b-1:d+2] else "No")


Measured memory_bytes: 9488
h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]


coord = {}
for i in range(h):
    for j in range(w):
        a_ij = a[i][j] - 1
        coord[a_ij] = (i, j)

import math
cost = [[0 for i in range(int(math.ceil(h * w / d)))] for i in range(d)]
for i in range(h * w - d):
    i0 = int(i / d)
    i1 = int(i % d)
    cost[i1][i0] = abs(coord[i + d][0] - coord[i][0]) + abs(coord[i + d][1] - coord[i][1])

cost_sum = [[0 for i in range(int(math.ceil(h * w / d)))] for i in range(d)]
for i in range(d):
    for j in range(int(math.ceil(h * w / d))):
        if j != 0:
            cost_sum[i][j] = cost_sum[i][j-1] + cost[i][j-1]
        else:
            cost_sum[i][j] = 0

for i in range(q):
    l = lr[i][0] - 1
    r = lr[i][1] - 1

    _cost_sum = cost_sum[int(l % d)]
    print(_cost_sum[int(r / d)] - _cost_sum[int(l / d)])


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef unsigned long long llu;

#define author ayushtomar
#define rf freopen("in.txt", "r", stdin)
#define wf freopen("out.txt", "w", stdout)
#define debug(x) cerr<<#x<<" "<<x<<endl;
#define f first
#define mp make_pair
#define pb push_back
string s;
string s1;
stack < char > S;
int main()
{
    int pos=0;
    cin>>s;
    s1.resize(s.size());
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(S.size()==0)
        {
            S.push(s[i]);
            continue;
        }
        if(s[i]=='T')
        {
            if(S.top()=='S')
                S.pop();
            else
                S.push(s[i]);
        }
        else
            S.push(s[i]);
    }
    cout<<S.size();



 return 0;
}


Measured memory_bytes: 772
#include<bits/stdc++.h>
#define ll long long
#define ljc 998244353
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
int n,a[101010],b[101010],A[101010],B[101010];
map<int,int> mp;
int F[101010],cnt[101010];
int find(int x){
    return F[x]==x?x:F[x]=find(F[x]);
}
void merge(int x,int y){
    int xx=find(x),yy=find(y);
    if (xx!=yy) F[xx]=yy;
}
int main(){
    n=read();
    for (int i=1;i<=n;i++) a[i]=read(),a[n+1]^=a[i];
    for (int i=1;i<=n;i++) b[i]=read(),b[n+1]^=b[i];
    for (int i=1;i<=n+1;i++){
        A[i]=a[i];B[i]=b[i];
    }
    sort(A+1,A+n+2),sort(B+1,B+n+2);
    for (int i=1;i<=n+1;i++){
    	if (A[i]!=B[i]){
    		puts("-1");
			return 0;
		}
	}
    int tot=0;
    for (int i=1;i<=n;i++){
        if (a[i]!=b[i]) a[++tot]=a[i],b[tot]=b[i];
    }
    a[tot+1]=a[n+1],b[tot+1]=b[n+1];
    n=tot;
    int m=0;
    for (int i=1;i<=n+1;i++){
        a[i]=mp[a[i]]?mp[a[i]]:mp[a[i]]=++m;
	}
    for (int i=1;i<=n+1;i++) b[i]=mp[b[i]];
    for (int i=1;i<=m;i++) F[i]=i;
    for (int i=1;i<=n+1;i++) merge(b[i],a[i]);
    for (int i=1;i<=m;i++) cnt[find(i)]++;
    int ans=n-1;
    for (int i=1;i<=m;i++){
        if (cnt[i]) ans++;
	}
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 10440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
  if(b==0)return a;
  return gcd(b,a%b);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    --a;
    ll al,ar,am,bl,br,bm;
    ll l=gcd(c,d);
    l=c*d/l;
    al=a/c;
    ar=a/d;
    am=a/l;
    bl=b/c;
    br=b/d;
    bm=b/l;
    cout<<b-a-(bl+br-bm)+(al+ar-am)<<endl;
    return 0;
}


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

#define N 40

static int d[N];
static int n;

nextint(fp)
FILE *fp;
{
  int rval = 0;
  int ch;
  
  do {
    ch = fgetc(fp);
  } while (isspace(ch));
  for (; isalpha(ch); ch = fgetc(fp))
    ++rval;
  ungetc(ch, fp);
  
  return rval;
}

vassert(i, val)
{
  int cval = 0;
  
  for (; i < n && cval < val; ++i)
    cval += d[i];
  if (cval != val)
    return -1;
    
  return i;
}

main()
{
  int i, j;
  
  for (;;) {
    scanf("%d", &n);
    if (n == 0) break ;
    for (i = 0; i < n; ++i)
      d[i] = nextint(stdin);
    
    for (i = 0; i < n; ++i) {
      j = i;
      j = vassert(j, 5);
      if (j < 0) continue ;
      j = vassert(j, 7);
      if (j < 0) continue ;
      j = vassert(j, 5);
      if (j < 0) continue ;
      j = vassert(j, 7);
      if (j < 0) continue ;
      j = vassert(j, 7);
      if (j < 0) continue ;
      printf("%d\n", i + 1);
      break ;
    }
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int N = 2e5 + 10;
int n,k;
vector<int> b(N,0);
int a[N];
void simulate(){
    for(int i = 0; i<n; i++){
        int l = max(0, i - a[i]);
        int r = min(n - 1,i + a[i]);
        b[l]++;
        b[r + 1]--;
    }
    for(int i = 1; i<n; i++){
        b[i] += b[i-1];
    }
    for(int i = 0; i<n; i++){
        a[i] = b[i];
        b[i] = 0;
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    
    cin>>n>>k;
    for(int i = 0; i<n; i++){
        cin>>a[i];
    }
    for(int i = 0; i<k; i++){
        simulate();
        bool f = false;
        for(int j = 0; j<n; j++){
            if(a[j] != n){
                f = true;
            }
        }
        if(!f){
            break;
        }
    }
    for(int i = 0; i<n; i++){
        cout<<a[i]<<" ";
    }
}

Measured memory_bytes: 4780
#include <iostream>
#include <iomanip>
#include <complex>
#include <cmath>
using namespace std;

int main()
{
	const double PI = acos(-1.0);
	int A, B, H, M;
	cin >> A >> B >> H >> M;
	complex<double> a(0.0, A);
	complex<double> b(0.0, B);
	a *= exp(complex<double>(0.0, -(H * 360.0 / 12.0 + M * 360.0 / 60.0 / 12.0) * PI / 180.0));
	b *= exp(complex<double>(0.0, -(M * 360.0 / 60.0) * PI / 180.0));
	cout << setprecision(20) << abs(a - b);
	return 0;
}


Measured memory_bytes: 4136
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int N, C;
	cin >> N >> C;

	vector<int> s(N), t(N), c(N);
	for (int i = 0; i < N; i++) {
		cin >> s[i] >> t[i] >> c[i];
		s[i]--, t[i]--, c[i]--;
	}
	DMP(s,t,c);

	vector<vector<int>> memo(C + 1, vector<int>(100011));
	for (int i = 0; i < N; i++) {
		memo[c[i]][s[i]]++;
		memo[c[i]][t[i] + 1]--;
	}

	for (int c = 0; c < C; c++) {
		for (int i = 0; i < 100010; i++) {
			memo[c][i + 1] += memo[c][i];
		}
	}
	//DMP(memo);

	int ans = 0;
	for (int i = 0; i < 100011; i++) {
		int cnt = 0;
		for (int c = 0; c < C; c++) {
			if (memo[c][i]) cnt++;
		}
		ans = max(ans, cnt);
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 13952
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int main() {
    int a;
    std::string s;
    std::cin >> a >> s;

    if (3200 <= a) {
        std::cout << s << std::endl;
    } else {
        std::cout << "red" << std::endl;
    }

    return 0;
}


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = 0; i < K; i++) {
    if (i % 2 == 0) {
      if (A % 2 == 1) A--;
      B += A / 2, A /= 2;
    } else {
      if (B % 2 == 1) B--;
      A += B / 2, B /= 2;
    }
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=32e4;

int t[N];
int main(){
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++){
		for(int j=1;j<i;j++){
			int d=min(i-j,min(abs(i-x)+abs(j-y),abs(i-y)+abs(j-x))+1);
			t[d]++;
		}
	}
	for(int k=1;k<n;k++)
		cout<<t[k]<<'\n';
	return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int c[1000][1000];
using P = pair<int, int>; 

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int ans = 0;
    int h, w;cin >> h >> w;
    inc(i, 0, h){
        inc(j, 0, w){
            c[i][j] = -1;
        }
    }
    queue<pair<int, int>> q;
    inc(i, 0, h){
        string s;cin >> s;
        inc(j, 0, w){
            if(s[j] == '#'){
                q.push(P(i, j));
                c[i][j] = 0;
            }
        }
    }
    while(!q.empty()){
        auto x = q.front();
        q.pop();
        inc(k, 0, 4){
            int ni = x.fi + di[k];
            int nj = x.se + dj[k];
            if(ni < 0 || ni >= h || nj < 0 || nj > w) continue;
            if(c[ni][nj] != -1) continue;
            c[ni][nj] = c[x.fi][x.se]+1;
            ans = max(ans, c[ni][nj]);
            q.push(P(ni, nj));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12432
x, n = map(int, input().split())
p = list(map(int, input().split()))

ans = x

if x not in p:
    ans = x
else:
    for i in range(1, 52):
        if x - i not in p:
            ans = x - i
            break
        elif x + i not in p:
            ans = x + i
            break
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc076/tasks/abc076_c

int main() {
    string S; cin >> S;
    string T; cin >> T;

    if (S.length() < T.length()) {
        cout << "UNRESTORABLE" << "\n";
        return 0;
    }

    string ans = "~";
    REP(i, S.length() - T.length() + 1) {
        string sub = S.substr(i, S.length());
        bool can = true;
        REP(j, T.length()) {
            if (sub[j] != T[j] && sub[j] != '?') can = false;
        }
        if (can) {
            string P = S;
            REP(j, T.length()) {
                P[i+j] = T[j];
            }
            REP(j, P.length()) {
                if (P[j] == '?') P[j] = 'a';
            }
            ans = min(ans, P);
        }
    }

    if (ans == "~") {
        cout << "UNRESTORABLE" << "\n";
    } else {
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 100000
char C[MAXN+5];
int U,len,win,lose;
int main()
{
    scanf("%s",C);
    len=strlen(C);
    for(int i=0;i<len;i++){
        if(C[i]=='g'){
            if(U>0) win++,U--;
            else U++;
        } else if(U>0) U--;
        else lose++,U++;
    }
    printf("%d",win-lose);
    return 0;
}



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

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

	vector<long long> vec(N+1);

	vec[0] = 2;
	vec[1] = 1;

	for (int i = 2; i < N + 1; i++)
	{
		vec[i] = vec[i - 1] + vec[i - 2];
	}

	cout << vec[N] << endl;
	return 0;
}


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

#define pr 0.000001
typedef long long ll;

ll max(ll a, ll b)
{
    return a>b ? a : b;
}
ll min(ll a, ll b)
{
    return a<b ? a : b;
}
int comparetor (const void * a, const void * b)
{
	return ( *(int*)a - *(int*)b );
}
int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    int dislike[10] = {0};
    while(k--)
    {
    	int temp;
    	scanf("%d", &temp);
    	dislike[temp] = 1;
    }
    while(1)
    {
    	int m = n;
    	int dig[10] = {0};
    	while(m)
    		dig[m%10] = 1, m/=10;
    	int flag = 1;
    	for(int i=0; i<10; i++)
    	{
    		if(dig[i]==1 && dislike[i]==1)
    		{
    			flag = 0;
    			break;
    		}
    	}
    	if(flag == 1)
    	{
    		printf("%d\n", n);
    		break;
    	}
  		n++;
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    if (s[2] == s[3] and s[4] == s[5]) {
        cout << "Yes" << endl;

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

}

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

int main() {

    string s;
    cin >> s;
    long long i = 0;
    long long j = 0;
    long long A = 0; // Aの連続を記憶する変数
    string v;
    int flag = 0;
    long long result = 0;

    for(i = 0; i < s.size(); i++){
        if(s.at(i) == 'C'){
            if(flag == 1){
                v.at(j-1) = 'D';
                flag = 0;
            }else{
                v += s.at(i);
                j++;
            }
        }else if(s.at(i) == 'B'){
            flag = 1;
            v += s.at(i); //代入
            j++;
        }else{
            v += s.at(i); //代入
            j++;
            flag = 0;
        }
    }

    for(i = 0; i < j; i++){
    
        if(v.at(i) == 'A'){
            A++;
        }else  if(v.at(i) == 'B'){
            A = 0;
        }else if(v.at(i) == 'C'){
            A = 0;
        }else if(v.at(i) == 'D'){
            result += A;
        }
    
    }  

    cout << result << endl;
}

Measured memory_bytes: 3900
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  s += "R";
  int n = s.length();
  vector<int> ans(n, 0);
  char p = 'R';
  int l = 0, bl, br, r;
  for(int i = 0; i < n; i++){
    if(p == 'R'){
      if(s[i] == 'L'){
        bl = i-1;
        br = i;
        p = 'L';
      }
    }
    else{
      if(s[i] == 'R'){
        r = i-1;
        ans[bl] += (bl-l+1)/2 + (r-br+1)/2;
        ans[br] += (bl-l+1)/2 + (r-br+1)/2;
        if((bl-l+1)%2 == 1) ans[bl]++;
        if((r-br+1)%2 == 1) ans[br]++;
        l = i;
        p = 'R';
      }
    }
  }
  for(int i = 0; i < n-1; i++){
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	h, n := readInt(), readInt()
	a, b := make([]int, n), make([]int, n)
	for i := range a {
		a[i], b[i] = readInt(), readInt()
	}

	dp := make([]int, h+1)
	for i := range dp {
		dp[i] = math.MaxInt64
	}
	dp[0] = 0

	for i := 1; i <= h; i++ {
		for j := range a {
			if i-a[j] < 0 {
				dp[i] = min(dp[i], b[j])
			} else {
				dp[i] = min(dp[i], dp[i-a[j]]+b[j])
			}
		}
	}

	fmt.Println(dp[h])
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

int main() {
  uint32_t N = 0, T = 0;
  std::cin >> N >> T;
  std::vector<int32_t> ts(T + 1, 0);
  for (size_t i = 0; i < N; i++) {
    uint32_t l = 0, r = 0;
    std::cin >> l >> r;
    ts[l]++, ts[r]--;
  }

  uint32_t max = ts[0];
  for (size_t t = 1; t < T + 1; t++) {
    ts[t] += ts[t - 1];
    if (static_cast<uint32_t>(ts[t]) > max) max = ts[t];
  }

  std::cout << max << std::endl;

  return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ii> P;
typedef unsigned long long int ull;
const int MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;

int main(){
    int n,a;cin>>n>>a;
    int x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    ll dp[n+1][n+1][2501];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=2500;k++){
                dp[i][j][k]=0;
            }
        }
    }
    dp[0][0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=i+1;j++){
            for(int k=0;k<=2500;k++){
                dp[i+1][j][k]+=dp[i][j][k];
                if(k>=x[i]&&j>0) dp[i+1][j][k]+=dp[i][j-1][k-x[i]];
            }
        }
    }
    ll ans=0;
    for(int j=1;j<=n;j++){
        ans+=dp[n][j][j*a];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 54348
n,m=map(int,input().split())
l=[]
for i in range(m):
    a,b=map(int,input().split())
    l.append([a,b])
x=sorted(l)
dic={}
x.append([0,0])
f=1
for i in range(m):
    if x[i][0]==x[i+1][0]:
        dic[str(x[i][0])+'000000'+str(x[i][1])]=f
        f+=1
    else:
        dic[str(x[i][0])+'000000'+str(x[i][1])]=f
        f=1
for i in range(m):
    b=dic[str(l[i][0])+'000000'+str(l[i][1])]
    p=len(list(str(l[i][0])))
    q=len(list(str(b)))
    ans=''
    for j in range(6-p):
        ans+='0'
    ans+=str(l[i][0])
    for j in range(6-q):
        ans+='0'
    ans+=str(b)
    print(ans)


Measured memory_bytes: 38764
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '0' && *s != ',') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int x, a, b;
    cin >> x >> a >> b;

    int p = b - a;

    if (p >= x+1) puts("dangerous");
    else {
        puts(p > 0 ? "safe" : "delicious");
    }

    return 0;
}


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

int main() {
    string result = "NO";
    vector<int> vec(3);
    
    for(int i = 0; i < 3; i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    if(vec.at(0) == 5 && vec.at(1) == 5 && vec.at(2) == 7) {
        result = "YES";
    }
    cout << result << endl;
}


Measured memory_bytes: 256