akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>
#include <queue>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64; // 9e18
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

//const double PI = 3.141592653589793238463;
//const int MAXN = 1000500;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
const i64 INF = 1e18;
//i64 mod = 1e9 + 7;


i64 T, n, m, k;
//vector <vector<i64>> a;
//vector <i64> a;
//vector <i64> b;
//vector <i64> dp;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(16);


    i64 a, b, c;
    cin >> a >> b >> c;
    cin >> k;

    while (k && a >= b) {
        b *= 2;
        k -= 1;
    }

    while (k && b >= c) {
        c *= 2;
        k -= 1;
    }

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


    return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  int x = K;
  for(int i=0; i<100000; i++){
    if(N/K == 0){
      cout << i+1 << endl;
      break;
    }
    K *= x;
  }
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

func ScanInt() int {
	scanner.Scan()
	txt := scanner.Text()
	n, _ := strconv.Atoi(txt)
	return n
}

type CityInfo struct{ I, P, Y, N int }

func main() {
	ScanInt()
	m := ScanInt()

	cityInfoList := make([]CityInfo, m)
	cityInfoMap := map[int][]CityInfo{}

	for i := 0; i < m; i++ {
		p := ScanInt()
		y := ScanInt()
		cityInfoList[i] = CityInfo{I: i, P: p, Y: y}
		cityInfoMap[p] = append(cityInfoMap[p], CityInfo{I: i, P: p, Y: y})
	}
	for _, cis := range cityInfoMap {
		sort.Slice(cis, func(i, j int) bool {
			return cis[i].Y < cis[j].Y
		})
		for i, ci := range cis {
			cityInfoList[ci.I].N = i + 1
		}
	}

	for i := 0; i < m; i++ {
		ci := cityInfoList[i]
		fmt.Printf("%06d%06d\n", ci.P, ci.N)
	}
}


Measured memory_bytes: 23296
from bisect import bisect_left

ALPHABET = "abcdefghijklmnopqrstuvwxyz"


def main(s, t):
    positions = {char: [] for char in ALPHABET}
    for i, char in enumerate(s):
        positions[char].append(i)

    current = 0
    answer = 0
    for char in t:
        pos_num = len(positions[char])
        if pos_num < 1:
            return -1
        idx = bisect_left(positions[char], current)
        if idx < pos_num:
            current = positions[char][idx] + 1
        else:
            answer += len(s)
            idx = bisect_left(positions[char], 0)
            current = positions[char][idx] + 1

    answer += current
    return answer


s = input()
t = input()
print(main(s, t))

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

using namespace std;

const int N = 2e5 + 5;

int n, k, a[N], used[N], cnt = 0;
long long f[N], bit[N];
vector <pair <long long, int> > comp;

void update (int x, int val) {
    for (int i = x; i < N; i += i & -i) bit[i] += val;
}

long long get (int x) {
    long long ans = 0;
    for (int i = x; i > 0; i -= i & -i) ans += bit[i];
    return ans;
}

signed main(){
    scanf("%d %d", &n, &k);
    long long ans = 0;

    f[0] = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] + a[i];
    for (int i = 1; i <= n; i++) comp.push_back(make_pair(f[i] - 1LL * k * i, i));
    comp.push_back(make_pair(0, 0));

    sort(comp.begin(), comp.end());
    used[comp[0].second] = ++cnt;
    for (int i = 1; i < comp.size(); i++) {
        if (comp[i].first > comp[i - 1].first) used[comp[i].second] = ++cnt;
        else used[comp[i].second] = cnt;
    }

    for (int i = 1; i <= n; i++) {
        update(used[i - 1], 1);
        ans += get(used[i]);
    }

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


Measured memory_bytes: 9456
try:
  a,b,c,d=[int(x) for x in input().split()]
  while(a>0 and c>0):
    c=c-b
    if(c<=0):
      break
    a=a-d
    
  if(a<=0):
    print("No")
    
  else:
    print("Yes")
    
except:
  pass
  


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
  int n, k, s;
  cin >> n >> k >> s;
  if(s==1000000000){
    rep(i, n){
      if(i<k) cout << 1000000000 << " ";
      else cout << 1 << " ";
    }
  }
  else{
    rep(i, n){
      if(i<k) cout << s << " ";
      else cout << s+1 << " ";
    }
  }
  cout << endl;
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_145
{
    class E
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nt = ReadInts();
            int n = nt[0];
            int t = nt[1];
            int[][] abs = new int[n][];
            for(int i = 0; i < n; i++)
            {
                abs[i] = ReadInts();
            }
            Array.Sort(abs, (a, b) => a[0] - b[0]);
            int[,] dp = new int[n, t + 1];
            dp[0, Min(t, abs[0][0])] = abs[0][1];
            for(int i = 1; i < n; i++)
            {
                for (int j = 0; j <= t; j++) dp[i, j] = dp[i - 1, j];
                for(int j = 0; j < t; j++)
                {
                    int next = Min(t, j + abs[i][0]);
                    dp[i, next] = Max(dp[i, next], dp[i - 1, j] + abs[i][1]);
                }
            }
            int res = 0;
            for (int i = 0; i <= t; i++) res = Max(res, dp[n - 1, i]);
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 48224
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int x = i;
        if (x % 3 == 0){
            cout << " " << i;
        }
        else{
            while (x){
                if (x % 10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<sstream>
#include<queue>
#include<set>
#include<cmath>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
int mp[300+5][300+56];
int n,m;
int idx[305];
int cnt[305];
int mp2[300+5][300+5];
int pos[305][305];
int check(int x){
    memset(cnt,0,sizeof(cnt));
    for(int i = 0;i<n;i++){
        cnt[mp2[i][idx[i]]]++;
    }
    int mx = -1;
    int res ;
    for(int i = 1;i<=m;i++){
        if(mx<cnt[i]){
        mx = max(mx,cnt[i]);
        res = i;
        }
    }
    if(mx>x)
        return -res;
    return res;
}
void print()
{
    for(int i = 0 ;i<n;i++){
        for(int j = 0;j<m;j++){
            printf("%d%c",mp2[i][j],j==m-1?'\n':' ');
        }
    }
}
int ok(int x){
    for(int i = 0;i<n;i++){
        for(int j = 0;j<m;j++){
            mp2[i][j] = mp[i][j];
        }
    }
    memset(idx,0,sizeof(idx));
    for(int i = 0;i<m;i++)
    {
        int res = check(x);
        //print();
        if(res>0)
            return 1;
        for(int j = 0;j<n;j++){
            mp2[j][pos[j][-res]] = 0;
        }
        for(int j  = 0;j<n;j++){
            while(mp2[j][idx[j]]==0&&idx[j]<m){
                idx[j]++;
            }
            if(idx[j]>=m)
                return 0;
        }
    }
    return 0;
}
int main()
{
    while(~scanf("%d%d",&n,&m))
    {
        for(int i = 0;i<n;i++){
            for(int j = 0;j<m;j++){
                scanf("%d",&mp[i][j]);
                pos[i][mp[i][j]] = j;
            }
        }
        int l = 0;
        int r = n+1;
        while(r-l>1){
            int mid = (l+r)>>1;
            if(ok(mid)){
                r = mid;
            }
            else
                l =mid;
        }
        cout<<r<<endl;
    }
}


Measured memory_bytes: 1408
H,W=map(int,input().split())
ans=[]
flag=False
for i in range(H):
    a=list(map(int,input().split()))
    if i%2==0:
        if flag==True:
            a[0]+=1
        for j in range(W):
            if j!=W-1:
                if a[j]%2==1:
                    a[j+1]+=1
                    ans.append([i+1,j+1,i+1,j+2])
            elif i!=H-1:
                if a[j]%2==1:
                    flag=True
                    ans.append([i+1,j+1,i+2,j+1])
                else:
                    flag=False
                    
    else:
        if flag==True:
            a[W-1]+=1
        for j in range(W):
            if j!=W-1:
                if a[W-1-j]%2==1:
                    a[W-1-j-1]+=1
                    ans.append([i+1,W-j,i+1,W-j-1])
            elif i!=H-1:
                if a[0]%2==1:
                    flag=True
                    ans.append([i+1,1,i+2,1])
                else:
                    flag=False

print(len(ans))
for i in range(len(ans)):
    print(*ans[i])

Measured memory_bytes: 28036
#include<iostream>
#include<string>
using namespace std;
string s;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C'){
			for(int j=i+1;j<s.size();j++){
				if(s[j]=='F'){
					cout<<"Yes";
					return 0;
				}
			}
			cout<<"No";
			return 0;
		}
	}
	cout<<"No";
} 

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
prev = -1
for i in A:
    ans += B[i-1]
    if prev == i-1:
        ans += C[i-2]
    prev = i
print(ans)

Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
using ll = long long;

int main(void){
    while(1){
        int h, w;
        cin >> h >> w;
        if(h == 0) break;
        int f;
        string s = "#.";
        for(int i = 0; i < h; i++){
            f = i % 2;
            for(int j = 0; j < w; j++) cout << s[(j + f) % 2];
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3172
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  char c;
  cin >> c;
  cout << char(c+1) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
char A[51][51],B[51][51];
int main()
{
    int N,M,f;
    scanf("%d%d",&N,&M);
    for(int i=0;i<N;i++)
        scanf("%s",A[i]);
    for(int i=0;i<M;i++)
        scanf("%s",B[i]);
    f=0;
    for(int i=0;i<=N-M;i++)
    {
        for(int j=0;j<=N-M;j++)
        {
            f=0;
            for(int k=0;k<M;k++)
            {
                for(int l=0;l<M;l++)
                    if(B[k][l]!=A[i+k][j+l])
                    {
                        f=1;
                        break;
                    }
                if(f==1)
                    break;
            }
            if(f==0)
            {
                printf("Yes\n");
                break;
            }
        }
        if(f==0)
            break;
    }
    if(f==1)
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
S = input()
T = input()
d = {}
for s,t in zip(S,T):
    if s in d:
        if d[s] != t:
            print('No')
            exit()
    else:
        d[s] = t

if len(d) != len(set(d.values())):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MIN -1000000
const int MOD=1e9+7;
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
const int max_N=1e5+10;
vector<int> fives;
vector <pii> G[max_N],rg[max_N];
bool isprime[55600];
ll ans=0;
string s;
ll dp[100005][4];
int main()
{
  memset(dp,0,sizeof(dp));
  cin >> s;
  for(int i=int(s.size());i>=0;i--)
    {
      for(int j=3;j>=0;j--)
	{
	  if(i==int(s.size()))
	    {
	      if(j==3) dp[i][j]=1;
	      else dp[i][j]=0;
	    }
	  else
	    {
	      if(j==3)
		{
		  if(s[i]=='?') dp[i][j]=(3*dp[i+1][j])%MOD;
		  else dp[i][j]=(dp[i+1][j])%MOD;
		}
	      else
		{
		  if(s[i]=='?') dp[i][j]=(3*dp[i+1][j]+dp[i+1][j+1])%MOD;
		  else
		    {
		      dp[i][j]=(dp[i+1][j])%MOD;
		      if(j==2 && (s[i]=='?' || s[i]=='C')) dp[i][j]=(dp[i][j]+dp[i+1][j+1])%MOD;
		      if(j==1 && (s[i]=='?' || s[i]=='B')) dp[i][j]=(dp[i][j]+dp[i+1][j+1])%MOD;
		      if(j==0 && (s[i]=='?' || s[i]=='A')) dp[i][j]=(dp[i][j]+dp[i+1][j+1])%MOD;
		    }
		  
		}
	    }
	}
    }
  cout << dp[0][0] << endl;
  return 0;
}


Measured memory_bytes: 8320
n=int(input())
#a,b=map(int,input().split())
dl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
ans=1
dl.sort()
if n%2==0:
    mid=n//2
    ans=dl[mid]-dl[mid-1]
print(ans)    


Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int counter=0;
    string s;
    std::cin >> s;
    for(;;){
        string ss;
        std::cin >> ss;
        if(ss=="END_OF_TEXT")break;
        rep(i,ss.size()){
            if(ss[i]-'A'<=25&&ss[i]-'A'>=0)ss[i]+=32;
        }
        
        if(ss==s)counter++;
    }
    std::cout << counter << std::endl;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
const int N=1010;
int n,m,ind,cnt,top;
int vis[N],que[N],stk[N],bl[N],dfn[N],low[N],u[N*200],v[N*200];
bool ok[N*200],ins[N];
vector<int> ve[N],id[N];
inline void tarjan(int x){
	stk[++top]=x; ins[x]=1; dfn[x]=low[x]=++ind;
	for(auto to:ve[x])
		if(!dfn[to]) tarjan(to),low[x]=min(low[x],low[to]);
		else if(ins[to]) low[x]=min(low[x],dfn[to]);
	if(low[x]==dfn[x]){
		int y; ++cnt;
		do y=stk[top--],ins[y]=0,bl[y]=cnt;
		while(y!=x);
	}
}
inline void solve(int rt){
	int head=1,tail=0; vis[rt]=++ind;
	for(int i=0;i<ve[rt].size();++i){
		ok[id[rt][i]]|=vis[ve[rt][i]]==ind;
		if(vis[ve[rt][i]]!=ind) vis[ve[rt][i]]=ind,que[++tail]=ve[rt][i];
		while(head<=tail){
			int x=que[head++];
			for(auto to:ve[x]) if(vis[to]!=ind) vis[to]=ind,que[++tail]=to;
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,a,b;i<=m;++i) scanf("%d%d",&a,&b),ve[a].push_back(b),id[a].push_back(i),u[i]=a,v[i]=b;
	for(int i=1;i<=n;++i) if(!dfn[i]) tarjan(i);
	for(int i=1;i<=n;++i) solve(i),reverse(ve[i].begin(),ve[i].end()),reverse(id[i].begin(),id[i].end()),solve(i);
	for(int i=1;i<=m;++i){
		if(bl[u[i]]==bl[v[i]]) puts(ok[i]?"same":"diff");
		else puts(ok[i]?"diff":"same");
	}
	return 0;
}

Measured memory_bytes: 8616
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);
#define asc(A) sort(A.begin(),A.end())
#define dsc(A) sort(A.begin(),A.end(),greater<ll>())
#define input(A,N) for(ll i=0;i<N;i++) cin>>A[i];
int main()
{
    fasino
    #ifndef ONLINE_JUDGE
  //  freopen("input.txt", "r", stdin); 
    #endif
    // ll n,k;
    // cin>>n>>k;
    // set<int> tk;
    // for(int i=0;i<k;i++){
    //     int dk,tm;
    //     cin>>dk;
    //     for(int j=0;j<dk;j++){
    //         cin>>tm;
    //         if(tm<=k)
    //         tk.insert(tm);
    //     }
    // }
    // cout<<(k-tk.size());
    ll n;
    cin>>n;
    for(int i=1000;i>=-1000;i--){
        for(int j=-1000;j<=1000;j++){
            if(pow(i,5)-pow(j,5)==n)
            {
                cout<<i<<" "<<j;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4112
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    int ans;

    if (n <= 3) {
        ans = 0;
    } else {
        ans = n / 3;
    }

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

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let mut it = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap());
    let (n, m) = (it.next().unwrap(), it.next().unwrap());
    println!("{}", (n - 1) * (m - 1));
}


Measured memory_bytes: 4352
/*
    Author  : Malisetti Samrat 
    Date    : 2020-05-10 17:30:14 
 */

//Optimisation Flags
#pragma GCC optimize ("O3")
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC optimize("Ofast")

#include   <bits/stdc++.h>
//#include   <ext/pb_ds/assoc_container.hpp>
//#include   <ext/pb_ds/tree_policy.hpp>
#include   <algorithm>
#include   <queue>
#include   <list>
#include   <map>
#include   <math.h>
#include   <numeric>
using      namespace        std;
#define    endl             '\n'
#define    FAST             ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define    ipfile           ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define    pb(x)            push_back(x)
#define    int              long long int
#define    itn              unsigned long long int
#define    db               long double
#define    vll              vector<int>
#define    all(v)           v.begin(),v.end()
#define    rall(v)          v.rbegin(),v.rend()
#define    GCD(m,n)         __gcd(m,n)
#define    LCM(m,n)         m*(n/GCD(m,n))
#define    REVVEC(v)        reverse(v.begin(),v.end())
#define    REVARR(a)        reverse(a,a+n)
#define    maxc(v)          max_element(all(v))
#define    minc(v)          min_element(all(v))
#define    inputarr(a,n)    for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define    outputarr(a,n)   for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define    rep(i,m, n)      for(int i = m; i < (n); ++i)
#define    sp               setprecison(10)
#define    sz(a)            (int)a.size()
#define    erase(vec,val)   vec.erase(std::remove(vec.begin(), vec.end(), val), vec.end()); //deleting specific value element in vector
#define    PI               (db)3.141592653589793238462643383279502884197169399375105820974944
#define    inf              (int)1000000000
#define    mod              (int)1000000007
#define    mem(a,b)          memset(a,b,sizeof(a));
#define    w(x)              int T;cin>>T;while(T -- > 0)
#define    ff                first
#define    ss                second
#define    pqueue            priority_queue< int >
#define    pdqueue           priority_queue< int,vll ,greater< int > >

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

clock_t time_p = clock();

void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}

void solveTC(){

    string  str,str1;
    cin>>str>>str1;

    if(str+str1.back()==str1)
    cout<<"Yes\n";
    else cout<<"No\n";      

}

int32_t main()
{

    FAST

   // w(x){

        solveTC();

   // }

    time();

    return 0;

}

Measured memory_bytes: 3840
#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()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int n, x;
    cin >> n >> x;
    
    int a = MOD;
    int ans = n;
    rep(i, n){
        int m;
        cin >> m;
        a = min(a, m);
        x -= m;
    }

    cout << ans + x / a << endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    string s;
    cin >> s;
    lli ans = 0;
    if (s == "RRR") {
            ans = 3;
        }
        else if (s == "SRR" || s == "RRS")
        {

            ans = 2;
        }
        else if(s=="SSS")
        {
            ans = 0;
        }
        else
        {

            ans = 1;
        }
        out(ans);
}

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

using namespace std;


void solve(long long A, long long B, long long K)
{
    vector<int> v;
    for (int i = 1; i <= min(A, B); ++i) {
        if ((A % i) == 0 && (B % i) == 0) v.push_back(i);
    }
    reverse(v.begin(), v.end());
    cout << v[K-1] << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long A;
    cin >> A;
    long long B;
    cin >> B;
    long long K;
    cin >> K;
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  string S, S1, S2, S3, S4, S5;
  cin >> S;
  int len;
  len = S.length();
  
  S1 = S.substr(0, (len-1)/2);
  S2 = S.substr((len+1)/2, (len-1)/2);
  S3 = S1;
  S4 = S2;
  S5 = S;
  reverse(S3.begin(), S3.end());
  reverse(S4.begin(), S4.end());
  reverse(S5.begin(), S5.end());
  
  if((S1 == S3) && (S2 == S4) && (S==S5)){
	cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
# A - Kyu in AtCoder

late_table = [
    [400, 8],
    [600, 7],
    [800, 6],
    [1000, 5],
    [1200, 4],
    [1400, 3],
    [1600, 2],
    [1800, 1]
]


def kyu(late):
    for i in late_table:
        if late < i[0]:
            return i[1] + 1
    return 1


if __name__ == "__main__":
    late = int(input())
    print(kyu(late))


Measured memory_bytes: 9060
import java.util.*;

public class Main {                   
    
  public static void main(String[] args) {                     
      
      Scanner sc = new Scanner(System.in);
      
      long Q = sc.nextLong();
      long H = sc.nextLong();
      long S = sc.nextLong();
      long D = sc.nextLong();      
      
      long N = sc.nextLong();
      
      long one = Math.min(S,Math.min(Q*4,H*2));
      
      long two = Math.min(D,one*2);
      
      if(N%2 == 1){          
        System.out.println(N/2*two + one);
        return;
      }else{
        System.out.println(N/2*two);
        return;
      }
  
      
  }   
   
}
        

Measured memory_bytes: 23764
#include <stdio.h>
#include <math.h>
int isprim(int);

#define true 1
#define false 0

int main(){
  int i;
  int sizu;
  scanf("%d",&sizu);
  int A[sizu];
  int count = 0;

  for(i = 0; i < sizu; i++){
    scanf("%d",&A[i]);
    if(isprim(A[i]) == true){
      count++;
    }
  }

  printf("%d\n",count);
  
  return 0;
}

int isprim(int x){
  int i;
  
  if(x == 2) return true;

  if(x < 2 || x % 2 == 0 ) return false;

  i = 3;
  while(i <= sqrt(x)){
    if(x % i == 0) return false;
    i = i + 2;
  }
  return true;
}



Measured memory_bytes: 2124
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
typedef long long ll;
using namespace std;
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; }
ll MOD = 1000000007;
ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}

int main()
{
    int X;
    cin >> X;
    ll count = 0;
    int ans = 0;
    for(int i = 1; i <= X; i++)
    {
        count += i;
        if(count >= X)
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

S = str(input())
T = str(input())

if S == T[:len(S)] and len(S) + 1 == len(T):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 10888
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <queue>

using namespace std;

int n, x;
deque <int> q;

int main() {
//	freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> x;
		if (n & 1)
			if (i & 1)
				q.push_back(x);
			else
				q.push_front(x);
		else
			if (i & 1)
				q.push_front(x);
			else
				q.push_back(x);
	}
	for (int i = 0; i < n; ++i)
		cout << q.front() << " ", q.pop_front();
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	const ll sum = accumulate(a.begin(), a.end(), 0ll);
	const ll cycle = static_cast<ll>(n) * (n + 1) / 2;
	if(sum % cycle != 0){
		cout << "NO" << endl;
		return 0;
	}
	const ll m = sum / cycle;
	vector<ll> b(n);
	for(int i = 0; i < n; ++i){
		b[i] = a[(i + 1) % n] - a[i];
	}
	for(int i = 0; i < n; ++i){ b[i] -= m; }
	bool answer = true;
	for(int i = 0; i < n; ++i){
		if(b[i] > 0 || b[i] % n != 0){ answer = false; }
	}
	cout << (answer ? "YES" : "NO") << endl;
	return 0;
}



Measured memory_bytes: 1792
using System;

namespace atcorderpractice
{
    class Mainclass
    {

        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            if(a==b&&a!=c||b==c&&b!=a||a==c&&a!=b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>
int main()
{
	int a,n,cnt=0,f1,f2,f3,f4;
	f1=f2=f3=f4=1;
	char s[1005],ch;
	scanf("%d",&a);
	while(scanf("%c",&ch)!=EOF)
    {
        if(f1&&ch=='P') {cnt++;f1=0;}
        if(f2&&ch=='W') {cnt++;f2=0;}
        if(f3&&ch=='G') {cnt++;f3=0;}
        if(f4&&ch=='Y') {cnt++;f4=0;}
    }
    if(cnt==3) printf("Three\n");
    if(cnt==4) printf("Four\n");
 }


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

#define Pi acos(-1.)
#define pb push_back
#define all(x) (x).begin(), x.end()
#define mp make_pair
#define fi first
#define se second
#define pii pair<int, int>
#define FILE "474"
#define standart 1

using namespace std;

typedef long long ll;

const int INF = 1e9 + 322;
const ll LINF = 2e18 + 474;
const int MAXN  = 2e5 + 228;
const int MOD = 1e9 + 7;
const double eps = 1e-14;


void solve() {
    string s; cin >> s;
    cout << "2018";
    for(int i = 4; i < 10; i++) {
        cout << s[i];
    }
    cout << endl;
}



int main() {
    if(!standart) {
        freopen(FILE".in", "r", stdin);
        freopen(FILE".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int T = 1;
    while(T--)
        solve();

    return 0;
}


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

using namespace std;

typedef long long ll;
const int maxN = 1e5 + 10;
int n;
int a[maxN];
vector < int > g[maxN];
bool used[maxN];
void go(int v) {
    used[v] = true;
    for (int to : g[v]) {
        if (!used[to]) go(to);
    }
}
int b[maxN];
bool have[maxN];
int main() {
   // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    int xr = 0;
    vector < int > ff, gg;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        xr ^= a[i];
        ff.emplace_back(a[i]);
    }
    ff.emplace_back(xr);
    a[n] = xr;
    sort(ff.begin(), ff.end());
    int nxr = 0;
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        nxr ^= b[i];
        gg.emplace_back(b[i]);
    }
    gg.emplace_back(nxr);
    sort(gg.begin(), gg.end());
    if (ff != gg) {
        cout << -1;
        return 0;
    }
    ff.erase(unique(ff.begin(), ff.end()), ff.end());
    b[n] = nxr;
    int uniq = 0;
    /*for (int i = 0; i <= n; i++) cout << a[i] << " ";
    cout << endl;
    for (int i = 0; i <= n; i++) cout << b[i] << " ";
    cout << endl;*/
    for (int i = 0; i <= n; i++) {
        if (a[i] == b[i] && i != n) {
            uniq++;
        }
        else {
            int from = lower_bound(ff.begin(), ff.end(), a[i]) - ff.begin();
            int to = lower_bound(ff.begin(), ff.end(), b[i]) - ff.begin();
            have[from] = true;
            have[to] = true;
            g[from].emplace_back(to);
            g[to].emplace_back(from);
        }
    }
    int cnt = 0;
    for (int i = 0; i < ff.size(); i++) {
        if (!used[i] && have[i]) {
            cnt++;
            go(i);
        }
    }
    cout << (n + 1 - uniq) + cnt - 2 << " ";
    return 0;
}


Measured memory_bytes: 10616
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a

def main():
    rr = []

    while True:
        n,m = LI()
        if n == 0:
            break

        a = sorted([LI()[::-1] for _ in range(m)])
        for i in range(2,n+1):
            a.append([inf, 1, i])

        r = inf
        for i in range(m):
            uf = UnionFind(n+1)
            mt = 0
            uc = 0
            for t,x,y in a[i:]:
                if uf.union(x,y):
                    mt = t
                    uc += 1
                    if uc == n-1:
                        break
            if mt == inf:
                break
            tr = mt - a[i][0]
            if r > tr:
                r = tr

        if r == inf:
            r = -1
        rr.append(r)


    return '\n'.join(map(str, rr))



print(main())



Measured memory_bytes: 9912
from itertools import *

ABCD = input()

n = len(ABCD) - 1 # opの入力数

plumi_list = list(product(["+", "-"], repeat=n))

for bit in range(1 << n):
    formula = ABCD[0]
    for num, op in zip(ABCD[1:], plumi_list[bit]):
        formula += op + num
        ans = eval(formula)

    if ans == 7:
        print(formula + "=7")
        break



Measured memory_bytes: 3060
def partition(array, p, r)
  x = array[r][1]
  i = p - 1
  (p..r-1).each do |index|
    if (array[index][1] <= x) then
      i += 1
      array[i], array[index] = array[index], array[i]
    end
  end
  array[i+1], array[r] = array[r], array[i+1]
  return i+1
end

def quick_sort(array, from, to)
  if from < to then
    q = partition(array, from, to)
    quick_sort(array, from, q-1)
    quick_sort(array, q+1, to)
  end
end

def merge(array, from, mid, to)
  array1 = array[from..mid]
  array2 = array[mid+1..to]
  array1 << ["", (10**9 + 1)]
  array2 << ["", (10**9 + 1)]
  i1 = 0
  i2 = 0
  new_array = []

  (to-from+1).times do
    if (array1[i1][1] <= array2[i2][1]) then
      new_array << array1[i1]
      i1 += 1
    else
      new_array << array2[i2]
      i2 += 1
    end
  end

  array[from, (to-from+1)] = new_array
end

def merge_sort(array, from, to)
  mid = (from + to) / 2
  if (to - from) > 1 then
    merge_sort(array, from, mid)
    merge_sort(array, mid+1, to)
  end
  merge(array, from, mid, to)
end

n = gets.chomp.to_i
array_orig = []
(n).times do 
  input = (gets.chomp.split)
  input[1] = input[1].to_i
  array_orig << input
end

array_quick = array_orig.dup
quick_sort(array_quick, 0, array_quick.size-1)
# p array_quick

array_merge = array_orig.dup
merge_sort(array_merge, 0, array_merge.size-1)
# p array_merge

is_stable = true
(0).upto(array_orig.size-1) do |index|
  if (array_quick[index] != array_merge[index]) then
    is_stable = false
  end
end
puts (is_stable ? "Stable" : "Not stable")

array_quick.each do |item|
  puts item.join(' ')
end

Measured memory_bytes: 29912
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;

    for (int i = N; i <= 999; i ++){
        if( i % 10 == (i /10) % 10 && i % 10 == i / 100 ){
            cout << i << endl;
            break;
        }
    }
    
}

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

#define ll long long
#define endl "\n";
#define mod 1000000007
#define pii pair<int,int>
#define vii vector<pii>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define mk(arr,n,type) type *arr=new type[n];

void fastio() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int main() {
	fastio();
	ll n, x;
	cin >> n;

	ll m = 1;
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (m == 0) {
			continue;
		}

		if (x == 0) {
			m = 0;
			continue;
		}

		if (m == -1) {
			continue;
		}

		ll t = m * x;

		if (t > 1000000000000000000 || t / x != m || t < m) {
			m = -1;
		} else {
			m = t;
		}
	}

	cout << m;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 1e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int p[N], dp[N];
pii t[N*4];

void upd(int pos, int val, int v = 0, int tl = 0, int tr = N){
    if (tl + 1 == tr){
        t[v] = {val, -pos};
        return;
    }
    int tm = tl + tr >> 1;
    if (pos < tm){
        upd(pos, val, v+v+1, tl, tm);
    }
    else{
        upd(pos, val, v+v+2, tm, tr);
    }
    t[v] = min(t[v+v+1], t[v+v+2]);
}

pii get(int l, int r, int v = 0, int tl = 0, int tr = N){
    if (tl >= r || l >= tr) return {inf, inf};
    //cout << l << " " << r-1 << " " << tl << " " << tr-1 << endl;;
    if (l <= tl && tr <= r) return t[v];
    int tm = tl + tr >> 1;
    return min(get(l, r, v+v+1, tl, tm),
               get(l, r, v+v+2, tm, tr));
}

string s;

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    fill(t, t+4*N, mp(inf, inf));
    int n, m;
    cin >> n >> m;
    cin >> s;
    reverse(all(s));
    upd(0, 0);
    //cout << "ok" << endl;
    for (int i = 1; i <= n; i++){
        if (s[i] == '1') continue;
        pii x = get(max(0, i - m), i);
        dp[i] = x.x + 1;
        if (dp[i] > inf){
            cout << -1;
            return 0;
        }
        p[i] = -x.y;
        upd(i, dp[i]);
    }
    vector<int> ans;
    for (int i = n; i; i = p[i]){
        ans.pb(i - p[i]);
    }

    for (int x : ans){
        cout << x<< " ";
    }
    return 0;
}


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





int main(){
	int n,k;
	string s;
	cin>>n>>k>>s;

	if(s[k-1]=='A')s[k-1]='a';
	if(s[k-1]=='B')s[k-1]='b';
	if(s[k-1]=='C')s[k-1]='c';
	cout<<s;
	}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	string S;
	cin >> S;
	int N = S.size();
	vector<int> A(N + 1);
	int cont = 0;
	for (int i = 0; i < N; ++i) {
		if (S[i] == '<') ++cont;
		else cont = 0;
		A[i + 1] = max(A[i + 1], cont);
	}
	for (int i = N - 1; i >= 0; --i) {
		if (S[i] == '>') ++cont;
		else cont = 0;
		A[i] = max(A[i], cont);
	}
	long long ans = 0;
	for (int i = 0; i <= N; ++i) {
		ans += A[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2820
N, K = gets.split.map!(&:to_i)
R, S, P = gets.split.map!(&:to_i)
T = gets.chomp.codepoints
GU = 114 # r
CHOKI = 115 # s
PA = 112 # p

def katite(t)
  if t == GU
    PA
  elsif t == CHOKI
    GU
  else
    CHOKI
  end
end

ans = 0
result = []
T.each_with_index do |t, i|
  k = katite(t)
  if i < K || k != result[i - K]
    result[i] = k
    ans += if k == GU
      R
    elsif k == CHOKI
      S
    else
      P
    end
  else
    cadets = [GU, CHOKI, PA]
    cadets -= [katite(T[i + K])] if i + K < N
    cadets -= [result[i - K]] if i >= K
    result[i] = cadets[0]
  end
end

puts ans

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

int main() {
    string a;
    cin>>a;
    if (a=="Sunny") {
        cout << "Cloudy" << endl;
    } else if (a=="Rainy") {
        cout << "Sunny" << endl;
    } else {
        cout << "Rainy" << endl;
    }
    
}

Measured memory_bytes: 256
#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 fi first
#define se second
#define sz(_a) sizeof(_a)
#define all(_a) _a.begin(),_a.end()
#define forn(_i,_j,_k) for(int _i=_j;_i<_k;_i++)
#define pi 3.14159265
#define vi vector<int>
#define vii vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
string s;
int k,sum=0;
ll ans=0;
int main(void){
	cin>>s>>k;
	bool t=1;
	forn(i,1,s.size())if(s[i]!=s[i-1]){t=0;break;}
	if(t){
		cout<<(ll)s.size()*k/2;
		return 0;
	}
	int cnt=1;
	forn(i,1,s.size()){
		if(s[i]!=s[i-1]){sum+=cnt/2;cnt=0;}
		cnt++;
	}
	sum+=cnt/2;
	int _cnt=1;
	forn(i,1,s.size()){
		if(s[i]!=s[i-1])break;
		_cnt++;
	}
	if(s[s.size()-1]==s[0])
		if(cnt%2==1&&_cnt%2==1){
			sum++;
			ans--;
		}
	ans+=(ll)sum*k;
//	cout<<cnt<<' '<<sum<<' '<<ans<<' '<<endl;
//	if(cnt%2==0&&isEqual)ans--;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    sort(ALL(A));
    ll ans = 0;
    for (int i = 0; i < N/2; i++) ans -= 2 * A[i];
    for (int i = N/2; i < N; i++) ans += 2 * A[i];
    if (N % 2 == 0) {
        ans += A[N/2-1] - A[N/2];
    } else {
        ans = max(ans - A[N/2+1] - A[N/2], ans - 4 * A[N/2] + A[N/2] + A[N/2-1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
N,x=map(int,input().split())
alist=list(map(int,input().split()))

answer=0
if alist[0]>x:
  answer+=alist[0]-x
  alist[0]=x
  
for i in range(1,N):
  if alist[i-1]+alist[i]>x:
    answer+=alist[i-1]+alist[i]-x
    alist[i]=x-alist[i-1]
    
#print(alist)
print(answer)

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    for (int i = 0; i < H; i++) cin >> grid[i];
    vector<vector<int>> dp(H+1, vector<int>(W+1, 999));
    
    if (grid[0][0] == '#') dp[1][1] = 1;
    else dp[1][1] = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (i >= 2) {
                if (grid[i-1][j-1] != grid[i-2][j-1]) dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
                else dp[i][j] = min(dp[i][j], dp[i-1][j]);
            }
            if (j >= 2){
                if (grid[i-1][j-1] != grid[i-1][j-2]) dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
                else dp[i][j] = min(dp[i][j], dp[i][j-1]);
            }
        }
    }
    if (grid[H-1][W-1] == '#') dp[H][W]++;
    cout << dp[H][W]/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define re(v) {for(auto &_re : v) cin >> _re;}
#define rre(v){for(auto &_re : v) for(auto &_rre : _re) cin >> _rre;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define prr(v) {for(auto _prr : v) cout << _prr.ff << " " << _prr.ss << endl;}
#define eb emplace_back
using namespace std;
const ll M = 1e9 + 7;
const ll mod = 998244353;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define int long long
int n, modulo;
template<class T, int L=0, int R=2000000000>//[0,2e9]
class SegmentTree{
private:
  struct node{
    node *l = nullptr;
    node *r = nullptr;
    T val = 1;
    node(){}
  };
  node *root = new node();
  void update(int p,T val,node *cur,int l,int r){
    if(l==r){
        cur->val = val;
    }
    else{
      int m = (l+r)/2;
      if(p<=m){
        if(!cur->l){
          cur->l = new node();
        }
        update(p,val,cur->l,l,m);
        cur->val = cur->l->val;
        if(cur->r) cur->val *= cur->r->val;
      }
      else{
        if(!cur->r){
          cur->r = new node();
        }
        update(p,val,cur->r,m+1,r);
        cur->val = cur->r->val;
        if(cur->l) cur->val *= cur->l->val;
      }
    }
    cur->val %= modulo;
  }
  T query(int a,int b, node *cur,int l,int r){
    if(!cur or r < a or l > b) return 1;
    if(l>=a && r<=b){
      return cur->val;
    }
    int m = (l+r)/2;
    return query(a,b,cur->l,l,m) * query(a,b,cur->r,m+1,r) % modulo;
  }
public:   
  void update(int p,int val){
  	update(p, val, this->root, L, R);
  }
  T query(int l,int r){
  	return query(l, r, this->root, L, R);
  }
};
vector<int> adj[200200];
vector<ll> ways(200200), dp(200200);
SegmentTree<ll, 0, 200200> tree[200200];
void dfs(int u,int p){
	ways[u] = 1;
	for(int i=0;i<adj[u].size();i++){
		int v = adj[u][i];
		if(v!=p){
			dfs(v, u);
			tree[u].update(i, ways[v] + 1);
			ways[u] *= (ways[v] + 1);
			ways[u] %= modulo;
		}
	}
}
void go(int u,int p){
	//dp[u] = (dp[p] / (ways[u]+1) + 1) * ways[u];
	for(int i=0;i<adj[u].size();i++){
		int v = adj[u][i];
		if(v!=p){
			//dp[v] = dp[u] / (ways[u] + 1) + 1
			dp[v] = (tree[u].query(0, i-1) * tree[u].query(i+1, adj[u].size()) + 1) % modulo;
			tree[v].update(adj[v].size(), dp[v]);
			dp[v] = dp[v] * ways[v] % modulo;
			go(v, u);
		}
	}
}
void solve(){
	cin >> n >> modulo;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin >> a >> b;
		adj[a].pb(b); adj[b].pb(a);
	}
	dfs(1,1);
	dp[1] = ways[1];
	go(1,1);
	for(int i=1;i<=n;i++){
		cout << dp[i] << endl;
	}
}
int32_t main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }  
}

Measured memory_bytes: 95484