akhauriyash/Code-Regression huggingface dataset:
s = input()
k = int(input())
n = len(s)
c = 0
x = []
a = 1

for i in range(n):
    if i<n-1 and s[i]==s[i+1]:
        a += 1
    else:
        c += a//2
        x.append(a)
        a = 1

c2 = 0
if s[0]==s[-1]:
    c2 = x[0]//2+x[-1]//2-(x[0]+x[-1])//2

print(len(s)*k//2 if len(set(s))==1 else c*k-c2*(k-1))

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();
        int x = sc.NextInt();
        int y = sc.NextInt();

        long answer = long.MaxValue;
        for (int i = 0; i <= 200000; i += 2)
        {
            int tmpA = i / 2;
            int tmpB = i / 2;
            int countA = Math.Max(0, x - tmpA);
            int countB = Math.Max(0, y - tmpB);
            long price = countA * a + countB * b + i * c;
            answer = Math.Min(answer, price);
        }

        Console.WriteLine(answer);
    }

    private static int GetDivisorCount(int n)
    {
        int count = 0;
        for (int i = 1; i <= n; i++)
        {
            if (n % i == 0)
            {
                count++;
            }
        }
        return count;
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    while (true) {
        int a, b;
        char op;
        cin >> a >> op >> b;

        int ans = 0;
        switch (op) {
        case '+':
            ans = a + b;
            break;
        case '-':
            ans = a - b;
            break;
        case '*':
            ans = a * b;
            break;
        case '/':
            ans = a / b;
            break;
        default:
            return 0;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 

int main(){
    int n;cin >> n;
    cout << 0 << endl;
    string s;
    cin >> s;
    if(s=="Vacant") return 0;
    int l=0,r=n;
    for (int i = 0; i < 19; i++) {
        int m = (l+r)/2;
        cout << m << endl;
        string t;cin >> t;
        if(t=="Vacant") return 0;
        else if(m%2==0){
            if(s==t){
                l=m;
            }
            else{
                r=m;
            }
        }
        else{
            if(s==t){
                r=m;
            }
            else{
                l=m;
            }
        }
    }
    assert(false);
    return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1)/*%mod*/;
  ll p = fastpow(nodess, num / 2);
 // p %= mod;
  p *= p;
 // p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return 
      abs(u.f - v.f)  + abs(u.se - v.se);
}



/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++; 
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/
const int MX = 1e5 + 9;


int main()
{
    IO;
	ll a,b;
	cin>>a>>b;
	cout<<a*b/__gcd(a,b);
	return 0;
}


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

using namespace std;

typedef long long ll;

inline void update(int &x,ll y) {
  x=(x+y)%MOD;
}

ll pow_mod(ll x,int k) {
  ll ans=1;
  while (k) {
  	if (k&1) ans=ans*x%MOD;
  	x=x*x%MOD;
  	k>>=1;
  }
  return ans;
}

ll inv[405];

void pre(int n) {
  inv[1]=1;
  for(int i=2;i<=n;i++) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
}

int f[2][405][405][2],cur;
int a[405],b[405];

ll val[405];

int dp(int n) {
  int s1=0,s2=0;
  f[0][0][0][0]=1;
  for(int i=1;i<=n;i++) {
  	cur^=1;
  	memcpy(f[cur],f[cur^1],sizeof(f[cur]));
  	val[0]=1;
  	for(int j=1;j<=b[i];j++) val[j]=val[j-1]*a[i]%MOD*inv[j]%MOD;
  	for(int j=0;j<=s1;j++)
  	for(int k=0;k<=s2;k++) {
  		if (f[cur^1][j][k][0]) {
  			for(int l=0;l<b[i];l++)
  			  update(f[cur][j+a[i]][k+l][0],(MOD-f[cur^1][j][k][0])*val[l]);
  			update(f[cur][j+a[i]][k+b[i]][1],f[cur^1][j][k][0]*val[b[i]-1]%MOD*a[i]);
		  }
  		if (f[cur^1][j][k][1]) {
  			for(int l=0;l<b[i];l++)
  			  update(f[cur][j+a[i]][k+l][1],(MOD-f[cur^1][j][k][1])*val[l]);
		  }
	  }
	s1+=a[i];s2+=b[i];
  }
  int ans=0;
  for(int i=1;i<=s1;i++) {
  	ll s=inv[i]*s1%MOD;
    for(int j=1;j<=s2;j++) {
      s=s*inv[i]%MOD;
      if (f[cur][i][j][1]) update(ans,f[cur][i][j][1]*s%MOD*j);
      s=s*j%MOD;
    }
  }
  return ans;
}

int main() {
  pre(400);
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
  printf("%d\n",dp(n));
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());
    int alice=0; int bob=0;
    for(int i=n-1;i>=0;i=i-2){
        alice+=a.at(i);
        if(i==0){
            int unko=0;
        }
        else{
            bob+=a.at(i-1);
        }

    }
    int ans;
    ans=alice-bob;
    cout<<ans<<endl;

}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

ll MOD = 2019;
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        res %= MOD;
        a = a * a;
        a %= MOD;
        b >>= 1;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;
	ll P = 2019;
	ll N = S.size();
	vll cumsum (N+1);
	ll base = 1;
	R0F(i, N) {
		cumsum[i] = (cumsum[i+1] + (S[i] - '0') * base) % P;
		base = (base * 10) % P;
	}
 
	map<ll, int> occ;
	ll ans = 0;
	F0R(i, N) {
		if (P == 2) {
			if ((S[i] - '0') % P == 0) {
				ans += i+1;
			}
		} else if (P == 5) {
			if ((S[i] - '0') % P == 0) {
				ans += i+1;
			}
		} else {
			occ[cumsum[i]]++;
			ans += occ[cumsum[i+1]];
		}
	}
	print(ans);
}

Measured memory_bytes: 5132
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

static int msb(large x) {
    assert(x != 0);
    auto pos = 0;
    for (int i = 0; i < 60; ++i) {
        if ((x >> i) & 1) {
            pos = i;
        }
    }
    return pos;
}

static large f(large x) {
    if (x == 0) return 0;
    if (x == 1) return 1;
    if (x == 2) return 3;
    if (x == 3) return 0;
    
    int bitpos = msb(x);
    large bit = 1LL << bitpos;
    if (x == bit) return bit;

    auto n = x - bit + 1;
    auto y = (n % 2 == 0) ? 0LL : bit;
    return y | f(x ^ bit);
}

int main()
{
    large a, b;
    cin >> a >> b;
    if (a == 0)
        cout << f(b) << endl;
    else
        cout << (f(a - 1) ^ f(b)) << endl;
    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/07/09  Problem: SQUARE869120CONTEST_03 B / Link: https://atcoder.jp/contests/s8pc-3/  ----- */


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

	LL H, W, K; cin >> H >> W >> K;
	assert(K > 1);
	vector<string> s(H);
	for (int i = 0; i < H; ++i) {
		cin >> s[i];
		FOR(j, 0, W) {
			s[i][j] -= '0';
		}
	}
	auto fall = [](VS& s) {
		int H = SZ(s), W = SZ(s[0]);
		FOR(j, 0, W) {
			vector<int>a;
			FOR(i, 0, H) {
				if (s[i][j])a.push_back(s[i][j]);
				s[i][j] = 0;
			}
			FOR(i, 0, SZ(a)) {
				s[H - i - 1][j] = a[SZ(a) - 1 - i];
			}
		}
	};
	auto f = [&K, &fall](int aa, int bb, auto s) {
		s[aa][bb] = 0;
		LL ret = 0;
		bool upd = 1;
		LL t = 0;
		int H = SZ(s), W = SZ(s[0]);
		while (upd) {
			fall(s);
			upd = 0;
			LL sub = 0;
			{ // check
				FOR(i, 0, H) {
					int cnt = 0;
					int pre = -1;
					FOR(j, 0, W) {
						if (s[i][j] == pre)cnt++;
						else if (s[i][j] != pre && cnt >= K) {
							upd |= pre;
							while (cnt) {
								int k = j - cnt;
								sub += s[i][k];
								s[i][k] = 0;
								cnt--;
							}
							pre = s[i][j];
							cnt = 1;
						}
						else if (s[i][j] != pre) {
							pre = s[i][j];
							cnt = 1;
						}
					}
					if (pre != -1 && cnt >= K) {
						upd |= pre;
						while (cnt) {
							int k = W - cnt;
							sub += s[i][k];
							s[i][k] = 0;
							cnt--;
						}
					}
				}
			}
			ret += (LL)pow(2LL, t)*sub;
			t++;
		}
		return ret;
	};
	LL ans = 0LL;
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			ans = max(ans, f(i, j, s));
		}
	}


	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define INF 1e18
#define EPS 1e-9
#define MOD 1000000007

// for using in pairs
#define F first
#define S second

// Macros
#define all(x) begin(x), end(x)

// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

// Operator overloads.
template<typename T>
ostream& operator<<(ostream &stream, vector<T> v)
{
	for (const auto &it : v)
		stream << it << " ";
	return stream;
}

#define int long long

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


void solve(int tc)
{
	string s;
	cin >> s;
	int ans = 0;
	int m = 0;
	for (int i = 0; i < 3; i++)
	{
		while (s[i] == 'R')
		{
			ans++;
			i++;
			if (i == 3)
				break;
		}
		m = max(ans, m);
		ans = 0;
	}	
	m = max(ans, m);
	cout << m;
}

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

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

	int t = 1;
	// cin >> t;

	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}


Measured memory_bytes: 3608
x, y = input().split(' ')
x = int(x)
y = int(y)

def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)


# Function to return LCM of two numbers
def lcm(a, b):
    return (a * b) / gcd(a, b)

print(int(lcm(x, y)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define chmax(x,y) x = max(x, y)
#define chmin(x,y) x = min(x, y)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

ll f(ll a) {
    if(a % 2) {
        ll l = (a + 1) / 2;
        if(l % 2) return 1;
        return 0;
    }
    ll r = a / 2;
    if(r % 2) {
        ll c = (ll) 1 ^ a;
        return c;
    }
    return a;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    ll x = f(a-1);
    ll y = f(b);
    ll ans = (ll) x^y;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,a,b,c,d; 
    cin>>n>>a>>b>>c>>d;
    a--,b--,c--,d--;
    string s; cin>>s; 
    bool ok=true;
	for (int i=a+1,has=0;i<c;i++){ 
	    if (s[i]=='.') has=0;
	    else has++;
	    if (has>=2) ok=false; 
	}
	for (int i=b+1,has=0;i<d;i++){ 
	    if (s[i]=='.') has=0;
	    else has++;
	    if (has>=2) ok=false; 
	}
    if (c>d ){ 
    	int hs=0; 
    	for (int i=b-1,has=0,dot=0;i<=d+1;i++){ 
    		if (s[i]=='.') dot++,has=0; 
    		else dot=0,has++;  
    		if (has>=2) break; 
    		hs=max(hs,dot); 
    		if (hs>=3) break;
    	} 
    	if (hs<3) ok=false;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}
signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main(){
    int A, B, C;
    cin >> A >> B >> C;

    if(A>=B && A>=C){
        cout << A*10+B+C << endl;
    }
    else if(B>=A && B>=C){
        cout << B*10+A+C << endl;
    }
    else{
        cout << C*10+A+B << endl;
    }
    return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    ll r_count = 0, g_count = 0, b_count = 0;
    rep(i, n){
        if(s.at(i) == 'R') r_count++;
        else if(s.at(i) == 'G') g_count++;
        else if(s.at(i) == 'B') b_count++;
    }

    ll d = 0;
    for(int i = 0; i < n; ++i) {
        for (int j = 0; j<n; ++j) {
            if(i-j<0 || i+j>n-1) break;
            else if(s.at(i-j) != s.at(i) && s.at(i) != s.at(i+j) && s.at(i-j) != s.at(i+j)){
                d++;
            }
        }
    }
    ll ans = r_count * g_count * b_count - d;
//    if(r_count==0 || g_count==0 || b_count==0) cout << 0 << endl;
    cout << ans <<endl;

    return 0;
}

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

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

    long long r = 0, g = 0, b = 0;
    for (int i = 0; i < N; i++) {
        if (S.at(i) == 'R') {
            r++;
        }
        else if (S.at(i) == 'G') {
            g++;
        }
        else {
            b++;
        }
    }

    long long ans1 = r * g * b, ans2 = 0;
    if (ans1 != 0) {
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                if (j + j - i < N) {
                    if (S.at(i) != S.at(j) && S.at(i) != S.at(j + j - i) && S.at(j) != S.at(j + j - i)) {
                        ans2++;
                    }
                }
            }
        }
    }

    cout << ans1 - ans2 << endl;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        //int n; ci	n>>n; int arr[n]; for(int i = 0; i<n; i++) cin>>arr[i];
		string s; cin>>s;
		if(s[2] == s[3] and s[4] == s[5])
		{
			cout<<"Yes";
		}
		else cout<<"No";

		
		cout<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
import math

s=list(input())
cnt = ""
for i in range(len(s)):
    if s[i]=="A" or s[i]=="T" or s[i]=="G" or s[i]=="C":
        t = ""
        for j in range(len(s)-i):
            if s[i+j]=="A" or s[i+j]=="T" or s[i+j]=="G" or s[i+j]=="C":
                t += s[i+j]
            else:
                break
        if len(t) >= len(cnt):
            cnt = t
print(len(cnt))

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define MAX 999999999

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

typedef long long ll;

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

    int a, b, c;
    cin >> a >> b >> c;

    cout << min(b, c) << " " << max(0, b + c - a) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;
const int MAXK = 100010;

ll gcd(ll a, ll b) { return b ? gcd(b, b % a) : a; }

ll powm(ll x, ll t) {
  if (!t) return 1;
  ll res = powm(x, t/ 2);
  (res *= res) %= mod;
  if (t&1) (res *= x) %= mod;
  return res;
}

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n, k;
  cin >> n >> k;
  
  vector<mint> cnt(MAXK);
  for(int i = 1; i <= k; ++i) {
    cnt[i] = powm(k/i, n);
  }
  for(int i = k; i >= 1; --i) {
    mint sum = 0;
    for(int j = i + i; j <= k; j += i) sum += cnt[j];
    cnt[i] -= sum; 
  }
  mint ans = 0;
  for(int i = 1; i <= k; ++i) {
    ans += cnt[i] * i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4052
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <stack>
#include <vector>
using namespace std;

using LL = long long;
const int MAXN = 1e4 + 5;

int main() {
  //
  int N;
  string str;
  cin >> N >> str;
  int popcnt = 0;
  for (auto ch : str) popcnt += (ch - '0');
  int propval[2] = {0};
  for (int i = 0; i < 2; i++) {
    int mod = popcnt - (2 * i - 1);
    if (mod > 0) {
      int val = 0;
      for (auto ch : str) val = ((val << 1) + ch - '0') % mod;
      propval[i] = val;
    }
  }
  stack<int> Sans;
  for (int i = str.size() - 1, cnt2[2] = {1, 1}; i >= 0; i--) {
    int ans, mod, val;
    if (str[i] == '0') {
      mod = popcnt + 1;
      ans = 1;
      val = (propval[0] + cnt2[0]) % mod;
      while (val) {
        val %= __builtin_popcount(val);
        ans++;
      }
    } else {
      mod = popcnt - 1;
      if (mod >= 1) {
        ans = 1;
        val = (propval[1] - cnt2[1] + mod) % mod;
        while (val) {
          val %= __builtin_popcount(val);
          ans++;
        }
      } else
        ans = 0;
    }
    Sans.push(ans);
    cnt2[0] = (cnt2[0] << 1) % (popcnt + 1);
    if (popcnt > 1) cnt2[1] = (cnt2[1] << 1) % (popcnt - 1);
  }
  while (!Sans.empty()) {
    int ans = Sans.top();
    Sans.pop();
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3988
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
#define N 110
char a[N][15];
map<string,int> p;
int main()
{
    int i,j,k,n,flag;
    scanf("%d",&n);
    scanf("%s",a[0]);
    p[a[0]]=1;
    flag=1;
    for(i=1;i<n;i++)
    {
        scanf("%s",a[i]);
        k=strlen(a[i-1]);
        if(a[i-1][k-1]!=a[i][0])
            flag=0;
        if(p[a[i]])
            flag=0;
        p[a[i]]=1;
    }
    if(flag==0)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


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

#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, k;
    cin >> n >> k;
    int ans;
    if (n <= k - 2) {
        ans = 0;
    } else if (n == k - 1) {
        ans = 1;
    } else if (n == k) {
        ans = 0;
    } else {
        ans = n - k;
    }

    if (n == 0) {
        ans = 0;
    }
    if (k == 1) {
        ans = 0;
    }

    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
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main() {
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        p[i]--;
    }
    vector<int> A(N);
    vector<int> B(N);
    for (int i = 0; i < N; i++) {
        A[i] = 1 + (i * 20001);
    }
    B[p[0]] = 0;
    for (int i = 1; i < N; i++) {
        int temp = p[i] - p[i - 1];
        temp *= -20001;
        temp++;
        B[p[i]] = B[p[i - 1]] + temp;
    }
    int minValue = *min_element(B.begin(), B.end());
    for (int i = 0; i < N; i++) B[i] += abs(minValue) + 1;
    for (int i = 0; i < N; i++) cout << A[i] << (i == N - 1 ? '\n' : ' ');
    for (int i = 0; i < N; i++) cout << B[i] << (i == N - 1 ? '\n' : ' ');
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;

    if (n % 2 == 0)
    {
        cout << n / 2 - 1 << endl;
    }
    else
    {
        cout << n / 2;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void Radix32(int *a,const int sz)
{
  int x,shift=0,elem[0400],temp[sz];
  while(shift<040)
  {
    int bucket[0400]={0};
    rep(i,sz){x=(a[i]>>shift)&0377;bucket[x]++;temp[i]=a[i];}
    elem[0]=0;rep(i,0377)elem[i+1]=elem[i]+bucket[i];
    rep(i,sz){x=(temp[i]>>shift)&0377;a[elem[x]]=temp[i];elem[x]++;}
    shift+=010;
  }
}
int main(void)
{
  int N=IN(),A[N];long sum=0;
  rep(i,N){A[i]=IN();}
  Radix32(A,N);
  rep(i,N-1){sum+=A[N-1-((i+1)>>1)];}
  return printf("%ld\n",sum),0;
}

Measured memory_bytes: 3104
n = int(input())
h_org = list(map(int,input().split()))

h = []
h.append(h_org[0])

for i in range(1,n):
    if h_org[i-1] != h_org[i]:
        h.append(h_org[i])

if n == 1:
    print("Yes")
    exit()
elif n == 2:
    if h[0] <= h[1]:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

for i in range(1,len(h)-1):
    if h[i-1] == h[i]:
        pass

    if h[i] <= h[i+1] and h[i-1] <= h[i]:
        pass
    elif h[i] - h[i+1] == 1 and h[i] - h[i-1] >= 1:
        pass
    elif h[i-1] - h[i] == 1 and h[i+1] >= h[i]:
        pass
    else:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 14228
#include<iostream>
using namespace std;
typedef long long ll;
const int maxn=5e5+10;

int main()
{
	string s,t;
	cin>>s>>t;int ans=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans;
	return 0;	
} 

Measured memory_bytes: 3496
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
int main(){
	ll h,w;
	cin>>h>>w;
	int cnt=0;
	for(ll i=0;i<h;i++){
		string str;
		cin>>str;
		for(int j=0;j<w;j++){
			if(str[j] == '#')cnt++;
		}
	}
	if(cnt == h+w-1)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}

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

int main() {
    int ans = 1;
    string str;
    cin >> str;
    vector<string> weeks = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
    rep(i, 7) {
        if(weeks.at(i) == str) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int K; cin >> K;
    int S; cin >> S;
    int cnt = 0;
    int z = 0;
    REP (i, K+1) {
        FOR (j, i, K+1) {
            z = S-i-j;
            if (j<=z && z<=K) {
                if (i==j && j==z) cnt += 1;
                else if (i==j || j==z) cnt += 3;
                else cnt += 6;
            }
        }
    }
    cout << cnt << '\n';
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b, c, d;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << "\n";
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc083a()
}

fun abc083a() {
    val (a, b, c, d) = readLine()!!.split(" ").map { it.toInt() }

    val diff = a + b - c - d

    val answer = if (diff == 0) "Balanced" else if (diff > 0) "Left" else "Right"

    println(answer)
}


Measured memory_bytes: 37884
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int a, b;
int main() {
	scanf("%d %d", &a, &b);
	if (a == b)
		printf("%d\n", a * 2);
	else
		printf("%d\n", max(a, b) * 2 - 1);
}

Measured memory_bytes: 128
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-28 17:46:12
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=200;
int n,m,mod;
i64 &Add(i64 &a,i64 b){ return a=(a+b)%mod; }
namespace m2
{
	i64 f[N],F[N];
	int main(int n)
	{
		i64 ans=0; memset(f,0,sizeof(f)); f[0]=1;
		fr(i,1,n)
		{
			fr(j,0,m/2){ F[j]=f[j]; f[j]=0; }
			fr(j,0,m/2){ Add(f[0],F[j]); Add(f[j+1],F[j]); }
		}
		fr(i,0,m/2) Add(ans,f[i]);
		return ans;
	}
}
namespace m1
{
	i64 f[N][N],F[N][N];
	int a[N],b[N],n;
	int main(int _n)
	{
		i64 ans=0; memset(f,0,sizeof(f)); f[0][0]=1;
		fd(i,_n,1) if(i&1){ n++; a[n]=1; b[n]=(i+m<=_n); }
		fr(i,1,m) if(!(i&1)) b[++n]=1;
		fr(i,1,n)
		{
//			putchar(10);
//			fr(j,0,m+1) fr(k,0,m) printf("%I64d%c",f[j][k],k==m?'\n':' ');
			fr(j,0,m+1) fr(k,0,m) F[j][k]=0;
			fr(j,0,m+1) fr(k,0,m){ Add(F[std::min(j,m)][k],f[j][k]); f[j][k]=0; }
//			fr(j,0,m+1) fr(k,0,m) printf("%I64d%c",F[j][k],k==m?'\n':' ');
			fr(j,0,m) fr(k,0,m) fr(A,0,a[i]) fr(B,0,b[i])
			{
				if(A&&B) Add(f[j+1][std::max(j,k)+1],F[j][k]);
				if(A&&!B) Add(f[j+1][0],F[j][k]);
				if(!A&&B) Add(f[0][k?k+1:0],F[j][k]);
				if(!A&&!B) Add(f[0][0],F[j][k]);
			}
//			printf("%d  %d %d\n",i,a[i],b[i]);
//			fr(j,0,m+1) fr(k,0,m) printf("%I64d%c",f[j][k],k==m?'\n':' ');
		}
		fr(i,0,m+1) fr(j,0,m) Add(ans,f[i][j]);
		return ans;
	}
}
int main()
{
	n=read(); m=read(); mod=read();
	if(m%2==0) printf("%d\n",int(1ll*m2::main(n/2)*m2::main((n+1)/2)%mod));
	else printf("%d\n",int(m1::main(n)));
	return 0;
}

Measured memory_bytes: 768
import numpy as np
import numba
@numba.jit
def solve(n,s):
    dp=np.zeros((n+1,n+1),dtype=np.int16)
    for i in range(n):
        for j in range(i+1,n):
            if s[i]==s[j]:
                if dp[i][j]<j-i:
                    dp[i+1][j+1]=dp[i][j]+1
    print(np.amax(dp))
n=int(input())
s=np.array([ord(i) for i in input()])
solve(n,s)

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

using namespace std;
typedef long long ll;

int main(){
  ll n,k=0;
  cin >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  for(ll i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      k++;
    }
  }
  if(k){
    cout << "NO" <<endl;
  }else{
    cout << "YES" <<endl;
  }
  return 0;
}

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

int main() {
    int N, K, A[200001];
    cin >> N >> K;
    for (int i = 1; i <= N; ++i) cin >> A[i];

    int counter[200001] = {0};
    for (int i = 1; i <= N; ++i) ++counter[A[i]];
    sort(counter + 1, counter + N + 1, greater<int>());
    int sum = 0;
    for (int i = 1; i <= K; ++i) sum += counter[i];

    cout << N - sum << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<iomanip>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,c;
    string b;
    cin>>a>>b;
    c=0;
    c=(b[0]-'0')*100+(b[2]-'0')*10+b[3]-'0';
    cout<<a*c/100;
/*
 *  long long a;
    string s;
    cin>>a>>s;
    s.erase(1,1);
    long long b=stoll(s);
    cout<<a*b/100;
*/
}

Measured memory_bytes: 3564
#include <iostream>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int max = 0;
  int count = 0;
  for (int i = 0; i < S.size(); i++)
  {
    if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') 
    {
      count++;
      if (max < count) max = count;
    }
    else count = 0; 
  }
  cout << max;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int a,b,c;
	int i;
	scanf("%d",&n);
	if(n==2) {
		scanf("%d%d",&a,&b);
		for(i=1;i+i<=a && i+i<=b;i++) {
			if(a%i==0 && b%i==0)printf("%d\n",i);
		}
		if(a%b==0)printf("%d\n",b);
		else if(b%a==0)printf("%d\n",a);
	} else if(n=3) {
		scanf("%d%d%d",&a,&b,&c);
		for(i=1;i+i<=a && i+i<=b && i+i<=c;i++) {
			if(a%i==0 && b%i==0 && c%i==0)printf("%d\n",i);
		}
		if(b%a==0 && c%a==0)printf("%d\n",a);
		else if(a%b==0 && c%b==0)printf("%d\n",b);
		else if(a%c==0 && b%c==0)printf("%d\n",c);
	} else return 1;
	return 0;
}

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

using namespace std;

using int64 = long long;
const int64 LINF = 1LL << 61;
const int INF = 1 << 30;

int main()
{
  int N, H;
  cin >> N >> H;
  // 多分 a_i が最大の刀だけ振りそう
  vector< int > mp(N);
  int mx = 0;
  for(auto &p : mp) {
    int a;
    cin >> a >> p;
    mx = max(mx, a);
  }
  sort(begin(mp), end(mp));

  int64 sum = 0;
  int64 ret = LINF;
  for(int i = N; i >= 0; i--) {
    if(i != N) sum += mp[i];
    ret = min(ret, (N - i) + (max(0LL, H - sum) + mx - 1) / mx);
  }

  cout << ret << endl;
}

Measured memory_bytes: 640
SD=list(input())
T=list(input())

for i in reversed(range(len(SD)-len(T)+1)):
  #print(SD[i:i+len(T)])
  for j in range(len(T)):    
    if SD[i+j]!="?" and SD[i+j]!=T[j]:
      break
  else:
    for j in range(len(T)):
      if SD[i+j]=="?":
        SD[i+j]=T[j]
    for j in range(len(SD)):
      if SD[j]=="?":
        SD[j]="a"
    print("".join(SD))
    break
else:
  print("UNRESTORABLE")

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (300006)
int main()
{
	ll h; cin>>h; int n; cin>>n;
	ll A[n];
	FOR(i,0,n-1)cin>>A[i];
	if(accumulate(A,A+n,0ll) >= h) cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;


ll gcd(ll a, ll b) {
  if(a&&b){
    if(a>=b) return gcd(b,a%b);
    else return gcd(a,b%a);
  }
  if(a>=b) return a;
  else return b;
}

int main (){
  ll n;
  cin>>n;
  vector<ll>a;
  ll z;
  for(ll i=0;i<n;i++){
    cin>>z;
    a.push_back(z);
  }
  while(a.size()>1){
    ll p,q;
    p=a[a.size()-1];
    q=a[a.size()-2];
    a.pop_back();
    a.pop_back();
    ll r=gcd(q,p);
    if(r>0) a.push_back(r);
  }
  cout<<a[0]<<endl;
}


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

int main(){
    int n; cin >> n;
    vector<string> s(n); rep(i,n){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }
    unordered_map<string,ll> hash;
    ll ans = 0;
    rep(i,n) hash[s[i]]++;
    for(auto i:hash){
        ll tmp = i.second;
        ans += tmp*(tmp-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 17700
from sys import stdin
from itertools import accumulate
input = stdin.readline
N = int(input())
A = [0] + list(map(int, input().split()))
acc = list(accumulate(A))
# print(acc)

lefti = 0
righti = 0
ans = 10**15
for i in range(2, N-1):
    while abs(acc[lefti]-(acc[i]-acc[lefti])) > abs(acc[lefti+1]-(acc[i]-acc[lefti+1])):
        lefti += 1
    while abs(acc[righti]-acc[i]-(acc[-1]-acc[righti])) > abs(acc[righti+1]-acc[i]-(acc[-1]-acc[righti+1])):
        righti += 1
    minbc, maxbc = min(acc[lefti], acc[i]-acc[lefti]
                       ), max(acc[lefti], acc[i]-acc[lefti])
    minde, maxde = min(acc[righti]-acc[i], acc[-1]-acc[righti]
                       ), max(acc[righti]-acc[i], acc[-1]-acc[righti])
    #print(i, minbc, maxbc, minde, maxde)
    ans = min(ans, max(maxbc, maxde)-min(minbc, minde))
print(ans)


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

int h, w;

int main()
{
    while (cin >> h >> w)
    {
        if (h == 0 && w == 0)
            return 0;
        for (int i = 1; i <= h; i++)
        {
            for (int j = 1; j <= w; j++)
            {
                if (i == 1 || i == h || j == 1 || j == w)
                    cout << "#";
                else
                    cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <string>

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


int main(void) {
    int n;
    while (cin >> n) {
        if (n == 0) {
            break;
        }
        int tanka[5] = {5, 7, 5, 7, 7};
        string s;
        vector<int> l;
        for (int i = 0; i < n; i++) {
            cin >> s;
            l.push_back(s.length()); 
        }

        for (int i = 0; i < l.size(); i++) {
            int posi = 0;
            vector<int> work(5, 0);
            for (int j = i; j < l.size(); j++) {
                int length = l[j];
                if (work[posi] + length < tanka[posi]) {
                    work[posi] += length; 
                } else if (work[posi] + length == tanka[posi]) {
                    posi++; 
                    if (posi == 5) {
                        cout << i + 1 << endl;
                        break;
                    }
                } else {
                    break;
                }
            }
            if (posi == 5) {
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3092
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    H, W = map(int, input().split())
    sh, sw = map(int, input().split())
    gh, gw = map(int, input().split())
    sh -= 1
    sw -= 1
    gh -= 1
    gw -= 1
    grid = []
    for _ in range(H):
        grid.append(input().rstrip('\n'))

    que = deque()
    que.append(sh * W + sw)
    seen = [[-1] * W for _ in range(H)]
    seen[sh][sw] = 0
    seen2 = [[0] * W for _ in range(H)]
    d = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    while que:
        hw = que.popleft()
        h, w = divmod(hw, W)
        if seen2[h][w]:
            continue
        seen2[h][w] = 1
        # toho
        for dh, dw in d:
            h_new, w_new = h+dh, w+dw
            if 0 <= h_new < H and 0 <= w_new < W:
                if grid[h_new][w_new] == ".":
                    if seen[h_new][w_new] == -1 or seen[h_new][w_new] > seen[h][w]:
                        que.appendleft(h_new * W + w_new)
                        seen[h_new][w_new] = seen[h][w]
        # warp
        for dh in range(-2, 3):
            for dw in range(-2, 3):
                h_new, w_new = h + dh, w + dw
                if 0 <= h_new < H and 0 <= w_new < W:
                    if grid[h_new][w_new] == ".":
                        if seen[h_new][w_new] == -1:
                            que.append(h_new * W + w_new)
                            seen[h_new][w_new] = seen[h][w] + 1
    print(seen[gh][gw])
    #[print(*seen[h]) for h in range(H)]


if __name__ == '__main__':
    main()


Measured memory_bytes: 97524
N, K = map(int, raw_input().split())
ans = 0
for b in xrange(K + 1, N + 1):
    l, r, c = K, b - 1, (N + 1) / b
    ll = K + c * b
    ans += c * (r - l + 1)
    if ll <= N:
        ans += N - ll + 1
    if l == 0:
        ans -= 1
print ans


Measured memory_bytes: 2568
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
pair<string, int>A[101];
signed main() {
    int N; cin >> N;
    vector<string>S(N);
    vector<int>P(N);
    rep(i, N) {
        cin >> S[i] >> P[i];
        A[i].first = S[i];
        A[i].second = P[i]*-1;
    }
    sort(A,A+N,greater<pair<string,int>>());
    rev(i, N) {
        rep(j, N) {
            if (A[i].second == 0-P[j]) {
                cout<<j+1<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3664