akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
using P = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  int h = 0,w = 0,d = 0;
  cin >> h >> w >> d;
  vector<P> point(h*w);
  rep(i,0,h){
    rep(j,0,w){
      int a;
      cin >> a;
      a--;
      point[a] = make_pair(i,j);
    }
  }
  vint ans(h*w);
  for(int i = 0;i < h*w;i++){
    if(i + d < h*w){
      ans[i + d] = ans[i] + abs(point[i+d].first - point[i].first) + abs(point[i+d].second - point[i].second);  
    }
  }
  int q = 0;
  cin >> q;
  rep(i,0,q){
    int a,b;
    cin >> a >> b;
    a--;b--;
    cout << ans[b] - ans[a] << endl;
  }
}

Measured memory_bytes: 3200
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
#define int ll
signed main(){
    int MOD=1000000007;
    vector<string>v(2);
    int n; cin>>n;
    rep(i,2)rep(j,n){char hoge; cin>>hoge; v[i].push_back(hoge);}
    int ans=3;
    if(v[0].size()==1)return puts("3")*0;
    int now=0;
    bool past=false;
    while(true){
        if(now>=n)break;
        if(now+1<n&&v[0][now]==v[0][now+1]){
            if(past){ans*=3;ans%=MOD;now+=2;continue;}
            ans*=2;
            ans%=MOD;
            past=true;
            now+=2;
        }else{
            if(past){now++;  past=false;continue;}
            else{
                if(now!=0)ans*=2;
                ans%=MOD;
                past=false;
                now++;

            }
        }
    }
    cout<<ans<<endl;
}

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

int main(){
    long long int N, M;
    cin >> N >> M;

    vector< pair<long long int, long long int> > v(N);

    for(int i = 0; i < N; i++){
        cin >> v[i].first >> v[i].second;
    }

    sort(v.begin(), v.end());

    int sum = 0;
    long long int ans = 0;
    for(int i = 0; i < N; i++){
        sum = M - v[i].second;
        if(sum < 0){
            ans += M * v[i].first;
            break;
        }
        else{
            ans += v[i].first*v[i].second;
            M -= v[i].second;
        }
        //cout << M << endl;
    }

    cout << ans << endl;


}

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

int main(void)
{
	int h, w;
	int i, j;
	
	while (1){
		cin >> h >> w;
		
		if (h == 0 && w == 0){
			break;
		}
		
		for (i = 0; i < h; i++){
			if (i % 2 == 0){
				for (j = 0; j < w; j++){
					if (j % 2 == 0){
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
			}
			else {
				for (j = 0; j < w; j++){
					if (j % 2 == 0){
						cout << ".";
					}
					else {
						cout << "#";
					}
				}
			}
			cout << endl;
		}
		
		cout << "\n";
	}
	
	return (0);
}

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

#define MOD 1000000007
#define fastio std::ios_base::sync_with_stdio(false);
#define ll long long

map <ll, int> m;
int main(){

    fastio;
    
    int n;
    cin >> n;
    ll ans = 0;
    ll x, sum = 0;
    for(int i = 0; i < n; i++){
        cin >> x;
        sum += x;
        m[sum]++;
    }
    
    for(map <ll, int>::iterator it = m.begin(); it != m.end(); it++){
        ll k = it->second;
        if((it->first) == 0)
            ans += (k+1)*k/2;
        else
            ans += k*(k-1)/2;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    int ans=0;
    rep(i,n-1){
        if(a[i]<a[i+1]){
            continue;
        }
        else{
            ans++;
        }
    }
    cout<<ans+1<<endl;
    cout<<n<<endl;
}



Measured memory_bytes: 3868
import queue

while True:
    m = int(input())
    if m == 0:
        break
    n = int(input())
    d = [0]*(n+2)
    for i in range(1,n+1):
        d[i] = int(input())
    visited = [False]*(n+2)
    visited[0] = True
    ok = [False]*(n+2)
    ok[n+1] = True
    rev = [[] for _ in range(n+2)]
    
    que = queue.LifoQueue()
    que.put(0)
    while not que.empty():
        i = que.get()
        for j in range(1,m+1):
            if i+j > n+1:
                break
            k = min(max(i+j+d[i+j], 0), n+1)
            rev[k].append(i)
            if not visited[k]:
                que.put(k)
                visited[k] = True

    que.put(n+1)
    while not que.empty():
        i = que.get()
        for j in rev[i]:
            if not ok[j]:
                ok[j] = True
                que.put(j)

    ans = 'OK'
    if not visited[n+1]:
        ans = 'NG'
    for i in range(n+1):
        if visited[i] and (not ok[i]):
            ans = 'NG'
    print(ans)



Measured memory_bytes: 6884
#include <bits/stdc++.h> 
#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif


using namespace std;
#define M 1000000001
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();++it)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define vc vector<char>
#define sz(a) (int)a.size()
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define ssortB(arr)   stable_sort(arr.begin(),arr.end(),greater<int>());
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define fi first
#define se second
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define mp make_pair
#define endl "\n" 
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define check(ds,x) (int)(ds.find(x)!=ds.end()?1:0)
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    if(n>=30)cout<<"Yes"<<endl;
    else{
        cout<<"No"<<endl;
    }
    }

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#define T true
#define F false

using namespace std;

int main(void) {
	int n, m, x, y, i, ans = 0;
	cin >> n >> m;
	vector<int> d(n + 1, 1), a(n + 1, F);
	a[1] = T;
	for (i = 0; i < m; i++) {
		scanf("%d%d", &x, &y);
		d[x]--;
		d[y]++;
		if (a[x]) {
			a[y] = T;
			if (d[x] == 0)
				a[x] = F;
		}
	}
	for (i = 1; i <= n; i++) {
		if (a[i])
			ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(vector<vector<T>> v) {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << " ";
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(vector<T> v) {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}

int main() {
	int A = 0, B = 0;
	cin >> A >> B;
	if (A + B >= 10) {
		cout << "error" << endl;
	} else {
		cout << A + B << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int n,x=0,y=0,ans=100000,c=0;
  cin>>n>>x;
  c++;
  while(1){
    cin>>ans;
    y+=ans;
    if(y>x) break;
    else{
      c++;
      if(c==n+1) break;
    }
  }
  co(c);
  
  return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n,m = list(map(int, input().split()))
s = input()
t = input()

sdic = {}
for k in range(0, len(s)):
    sdic[k*m] = s[k]
tdic = {}
for k in range(0, len(t)):
    tdic[k*n] = t[k]
ok = 1
for skey in sdic.keys():
    try:
        if tdic[skey] != sdic[skey]:
            ok = -1
    except:
        pass
    
if ok == 1:
    print(int(m * n / gcd(m,n)))
else:
    print('-1')

Measured memory_bytes: 20804
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007 ;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	//ええ..
	int n,K,S,i;cin>>n>>K>>S;
	int Sx=(S==1000000000?999999999:S+1);
	for(i=0;i<K;i++){cout<<S<<" ";}
	for(i=K;i<n;i++){cout<<Sx<<" ";}
}

Measured memory_bytes: 1280
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
typedef int_fast64_t LL;
const LL MOD = 1e9+7;
const int MAXN = 3e5+7;
LL n,A[MAXN];
vector<int> msk[MAXN];
int main(){
    ____();
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> A[i];
    for(int i = 1; i <= n+1; i++) msk[i].resize(60);
    fill(msk[n+1].begin(),msk[n+1].end(),0);
    for(int i = n; i >= 1; i--){
        LL x = A[i];
        for(int k = 0; k < 60; k++){
            msk[i][k] = msk[i+1][k] + x%2;
            x/=2;
        }
    }
    LL res = 0;
    for(int i = 1; i < n; i++){
        LL x = A[i];
        for(int k = 0; k < 60; k++){
            int bit = x%2;
            x/=2;
            if(bit) res = (res + (1ll<<k)%MOD*(n-i-msk[i+1][k])%MOD)%MOD;
            else res = (res + (1ll<<k)%MOD*msk[i+1][k]%MOD)%MOD;
        }
    }
    cout << res << endl;
    return 0;
}

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

#define db(x) if(debug) cout << x << endl

bool debug = true;

using namespace std;

long long N, K;

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

	
	cin >> N >> K;

	cout << min(N, min( N % K, K - N % K)) << endl;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


def MI(): return map(int, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    H, W = MI()
    grid = [input() for _ in range(H)]
    dp = [[0] * W for _ in range(H)]
    dp[0][0] = 1
    for i in range(1, H):
        if grid[i][0] == ".":
            dp[i][0] = dp[i - 1][0]
    for j in range(1, W):
        if grid[0][j] == ".":
            dp[0][j] = dp[0][j - 1]

    for i in range(1, H):
        for j in range(1, W):
            if grid[i][j] == ".":
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
                dp[i][j] %= mod
    print(dp[H-1][W-1] % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 50928
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  if(A==B){
    cout << "Draw" << endl;
  }else{
    if(A!=1&&B!=1){
      if(A>B){
        cout << "Alice" << endl;
      }else{
        cout << "Bob" << endl;
      }
    }else{
      if(A==1){
        cout << "Alice" << endl;
      }else{
        cout << "Bob" << endl;
      }
    }
  } 
}

Measured memory_bytes: 256
from collections import defaultdict
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
cnt=defaultdict(lambda :0)

for i in range(m):
    for j in range(2):
        cnt[ab[i][j]]+=1

for i in cnt.values():
    if i%2!=0:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 32452
mod = 1000000007
n = int(input())
s1 = input()
s2 = input()

ans = 1
for i in range(n):
    if s1[i] == s2[i]:
        if i==0:
            ans *= 3
        else:
            if s1[i-1]==s2[i-1]:
                ans *= 2
            else:
                continue
    else:
        if i==0:
            ans *= 6
        else:
            if s1[i] == s1[i-1]:
                continue
            elif s1[i-1] == s2[i-1]:
                ans *=2
            else:
                ans *= 3
    ans = ans%mod
print(ans)

Measured memory_bytes: 3064
N = int(input())
A = list (map(int, input().split()))
m = len(A)
X = "APPROVED"
for i in range(0, m):
	if (A[i] % 2) == 0:
		if (A[i] % 3) != 0:
			if (A[i] % 5) != 0:
				X = "DENIED"
print(X)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  char S[100];
  cin>>N>>K>>S;
  
  for(int i=0;i<N;i++){
  	cin>>S[i];
  }
   
  S[K-1]+=32;
  cout<<S<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void EqualCut(){
	int N;
	cin >> N;
	i64 A[200010];
	A[0] = 0;
	for (size_t i = 0; i < N; i++)
	{	
		int a;
		cin >> a;
		A[i + 1] = A[i] + a;
	}

	int i1 = 1;
	int i3 = 3;
	i64 ans = 1000000000000;

	for (size_t i = 2; i < (N - 1); i++)
	{
		i64 a1 = (A[i] - A[i1]) ;
		i64 a2 = A[i1]; 
		i64 ans1 = abs(a1 - a2);

		for (int ti = i1 + 1; ti < i; ti++)
		{
			i64 ta1 = (A[i] - A[ti]);
			i64 ta2 = A[ti];
			i64 at = abs(ta1 - ta2);
			if (ans1 > at) {
				i1 = ti;
				ans1 = at;
				a1 = ta1;
				a2 = ta2;
			}
			else {
				break;
			}
		}

		i64 a3 = (A[i3] - A[i]);
		i64 a4 = (A[N] - A[i3]);
		i64 ans2 = abs(a3 - a4);
		for (int ti = i3 + 1; ti < N; ti++)
		{
			i64 ta3 = (A[ti] - A[i]);
			i64 ta4 = (A[N] - A[ti]);

			i64 at = abs(ta3 - ta4);
			if (ans2 > at) {
				i3 = ti;
				ans2 = at;
				a3 = ta3;
				a4 = ta4;
			}
			else {
				break;
			}
		}
		ans = min(ans, abs(max(a1, max(a2, max(a3, a4))) - min(a1, min(a2, min(a3, a4)))));
	}

	cout << ans << "\n";
}
int main() {
	EqualCut();
	return 0;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  while(true) {
    int h, w;
    cin >> w >> h;
    if(!h) break;
    vector<string> s(h);
    REP(i, h) cin >> s[i];

    VVI used(h, VI(w, 0));
    int xl, xr;
    function<void(int,int)> dfs1 = [&](int x, int y) {
      used[y][x] = 1;
      if(y == h-1 || (s[y+1][x] != '.' && s[y+1][x] != s[y][x])) {
        chmin(xl, x); chmax(xr, x);
      }
      REP(i, 4) {
        int nx = x + dx[i], ny = y + dy[i];
        if(IN(0LL, w, nx) && IN(0LL, h, ny) && s[y][x] == s[ny][nx] && !used[ny][nx]) {
          dfs1(nx, ny);
        }
      }
    };

    VVI used2(h, VI(w, 0));
    int cnt = 0;
    double mid = 0;
    function<void(int,int)> dfs2 = [&](int x, int y) {
      // cout << x << " " << y << endl;
      used2[y][x] = 1;
      cnt++;
      mid += (x+0.5);
      REP(i, 4) {
        int nx = x + dx[i], ny = y + dy[i];
        if(i == 2) {
          if(IN(0LL, w, nx) && IN(0LL, h, ny) && s[ny][nx] != '.' && !used2[ny][nx]) {
            dfs2(nx, ny);
          }
        } else {
          if(IN(0LL, w, nx) && IN(0LL, h, ny) && s[ny][nx] == s[y][x] && !used2[ny][nx]) {
            dfs2(nx, ny);
          }
        }
      }
    };

    bool flag = true;
    REP(i, h) REP(j, w) {
      if(used[i][j] || s[i][j] == '.') continue;
      // (i,j)と同じ数字のところを探索してx_l、x_rを求める
      xl = INF, xr = -1;
      dfs1(j, i);
      xr++;
      // (i,j)から上方向に探索して重心Mを求める
      // 同じ数字なら上下左右に進む
      // 違う数字でも上なら進む
      cnt = 0, mid = 0;
      used2.assign(h, VI(w, 0));
      dfs2(j, i);
      mid /= cnt;
      // cout << i << " " << j << " " << xl << " " << xr << " " << mid << " " << cnt << endl;
      if(xl >= mid || mid >= xr) {
        flag = false;
        goto end;
      }
    }

    end:;
    if(flag) cout << "STABLE" << endl;
    else cout << "UNSTABLE" << endl;
  }

  return 0;
}



Measured memory_bytes: 3208
if __FILE__==$0
	
	rl_i=lambda{|str,dl|str.strip.split(dl).map(&:to_i)}
	dl=" "
	n=rl_i[gets,dl]
	if n[0]==1
		n[0]=14
	end
	if n[1]==1
		n[1]=14
	end
	if n[0]>n[1]
		puts "Alice"
	elsif n[0]<n[1]
		puts "Bob"
	elsif n[0]==n[1]
		puts "Draw"
	end
end

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
int main() {
	string str,comand,p;
	int a, b, q, c = 0;
	cin >> str;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> comand >> a >> b;
		if (comand == "print") {
			for (int j = a; j <= b; j++) {
				cout << str[j];
				if (j == b) {
					cout << endl;
				}
			}
		}
		else if (comand == "reverse"){
			reverse(str.begin() + a, str.begin() + b + 1);
		}
		else if (comand == "replace") {
			cin >> p;
			for (int j = a; j <= b; j++) {
				str[j] = p[j-a];
			}
		}
	}
}

Measured memory_bytes: 1212
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维
**加油，奥利给！！！ 
**/
map<int,int>p;
char a[200000];
int main()
{
	ll m,n,i,j,t,k,ans=0;
	cin>>n>>a;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			k=2*j-i;
			if(k<n&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])
			{
				ans++;
			}
		}
	}
	ll q=0,w=0,e=0;
	for(i=0;i<n;i++)
	{
		if(a[i]=='R') q++;
		else if(a[i]=='G') w++;
		else e++;
	}
	cout<<q*w*e-ans;
 } 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

int N, M;
vvi A(305, vi(305));

int dfs(int n, V(bool) D) {
    if(n==0) return 0;
    //int res = INF;
    int t = 0;
    vi cnt(M, 0);
    rep(i, N) {
        rep(j, M) {
            if(D[A[i][j]]) {
                cnt[A[i][j]]++;
                break;
            }
        }
    }
    int mi = 0;
    rep(i, M) {
        if(cnt[i]>cnt[mi]) mi = i;
    }
    int res = cnt[mi];
    D[mi] = false;
    int nx = dfs(n-1, D);
    if(nx) res = min(res, nx);
    return res;
}

signed main() {
    cin >> N >> M;
    rep(i, N) rep(j, M) {
        cin >> A[i][j];
        A[i][j]--;
    }

    V(bool) D(M, true);

    cout << dfs(M, D) << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    long long m[5] = {};
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s[0] == 'M') m[0]++;
        else if (s[0] == 'A') m[1]++;
        else if (s[0] == 'R') m[2]++;
        else if (s[0] == 'C') m[3]++;
        else if (s[0] == 'H') m[4]++;
    }
    for (int i = 0; i < 5; i++) {
        int j = i - 1; int v = m[i];
        while (j >= 0 && m[j] > v) {
            m[j + 1] = m[j];
            j--;
        }
        m[j + 1] = v;
    }
    int cnt=0;
    for (int i = 0; i < 5; i++) {
        if (m[i] != 0) cnt++;
    }
    long long ans=0;
    if (cnt <= 3) ans = m[4] * m[3] * m[2];
    else if (cnt == 4) ans = m[4] * m[3] * m[2] + m[4] * m[3] * m[1] + m[4] * m[2] * m[1] + m[3] * m[2] * m[1];
    else if (cnt == 5) {
        for (int i = 0; i <= 2; i++) {
            for (int j = i + 1; j <= 3; j++) {
                for (int k = j + 1; k <= 4; k++) {
                    ans += m[i] * m[j] * m[k];
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, q = gets.split.map(&:to_i)
s = gets.chomp
lr = q.times.map { gets.split.map(&:to_i) }
arr = Array.new(n, 0)
arr[0] = 0
sum = 0
(1..n-1).each do |i|
  sum += 1 if s[i-1..i] == "AC"
  arr[i] = sum
end
puts lr.map{ |m| arr[m[1]-1] - arr[m[0]-1] }


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
  int64_t n, k;
  cin >> n >> k;

  vector<int64_t> a(n);
  for (auto&& aa : a) {
    cin >> aa;
  }
  sort(a.begin(), a.end());

  auto M = 1000000000000000000L;

  int64_t b = -M;
  int64_t e = M + 1;
  while (b < e) {
    int64_t m = (b + e + 2 * M) / 2 - M;

    int64_t t = 0;
    for (auto aa : a) {
      if (aa < 0) {
        t += a.end() - partition_point(a.begin(), a.end(),
                                       [&](int64_t bb) { return aa * bb > m; });
      } else {
        t += partition_point(a.begin(), a.end(),
                             [&](int64_t bb) { return aa * bb <= m; }) -
             a.begin();
      }
      if (aa * aa <= m) {
        --t;
      }
    }

    t /= 2;

    // cerr << m << ":" << t << endl;

    if (t < k) {
      b = m + 1;
    } else {
      e = m;
    }
  }

  cout << b << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define WR "txt"

void Open() { freopen(WR".in", "r", stdin); freopen(WR".out", "w", stdout); }
void Close() { fclose(stdin); fclose(stdout); }
using namespace std;
int Read()  {
	int val = 0, opt = 1; char ch;
	while (!isdigit(ch = getchar() )) if (ch == '-') opt = -1;
	while (isdigit( ch )) (val *= 10) += ch - '0', ch= getchar();
	return val * opt;
}

void work()  {
	int a, p;
	a = Read(), p = Read();
	cout << (a * 3 + p) / 2;
}

int main(void)  {
	//Open();
	work();
	//Close();
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, a[1000], f[1000], INF = 1'000'000'000'000LL;

LL calc(int s, int e) {
	inc(i, n) { f[i] = 1; }
	LL v = 0;
	incII(i, s, e) {
		if(i == s || i == e || ((i - s) % 2 == 0 && a[i] > 0)) { v += a[i]; f[i] = 0; }
	}
	return v;
}

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	array<LL, 3> ma = { -INF, 0, 0 };
	inc(s, n) {
	inc(e, n) {
		if(s <= e && (e - s + 1) % 2 == 1) { setmax(ma, { calc(s, e), s, e }); }
	}
	}
	LL v = ma[0];
	LL s = ma[1];
	LL e = ma[2];
	calc(s, e);
	
	cout << v << endl;
	int c = s + (n - 1 - e);
	decII(i, s, e) { if(f[i] == 1 && ((i - s) % 2 == 0 || f[i - 1] == 0)) { c++; } }
	cout << c << endl;
	decID(i, e + 1, n) { cout << (i + 1) << "\n"; }
	decII(i, s, e) { if(f[i] == 1 && ((i - s) % 2 == 0 || f[i - 1] == 0)) { cout << (i + 1) << "\n"; } }
	inc(i, s) { cout << 1 << "\n"; }
	
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define umap unordered_map
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


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

  cout << n*(n-1)/2 << endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

typedef pair<int,int> p_ii;

int H, W, K;
vector<string> A;
// vector<vector<bool>> ok;

// void dfs(int sh, int sw, int k) {
//   ok[sh][sw] = true;
//   if (k) {
//     k--;
//     if (sh!=H-1&&A[sh+1][sw]!='#'&&!ok[sh+1][sw]) dfs(sh+1,sw,k);
//     if (sh!=0&&A[sh-1][sw]!='#'&&!ok[sh-1][sw]) dfs(sh-1,sw,k);
//     if (sw!=W-1&&A[sh][sw+1]!='#'&&!ok[sh][sw+1]) dfs(sh,sw+1,k);
//     if (sw!=0&&A[sh][sw-1]!='#'&&!ok[sh][sw-1]) dfs(sh,sw-1,k);
//   }
// }

vector<vector<int>> dis;

void bfs(int sh, int sw) {
  queue<p_ii> q; q.push(make_pair(sh,sw));
  while(!q.empty()) {
    p_ii pos = q.front(); q.pop();
    int h = pos.first, w = pos.second;
    // cout << h << " " << w << endl;
    if (h!=H-1&&A[h+1][w]!='#'&&dis[h+1][w]==-1) { 
      dis[h+1][w] = dis[h][w]+1;
      q.push(make_pair(h+1,w));
    }
    if (h!=0&&A[h-1][w]!='#'&&dis[h-1][w]==-1) {
      dis[h-1][w] = dis[h][w]+1;
      q.push(make_pair(h-1,w));
    }
    if (w!=W-1&&A[h][w+1]!='#'&&dis[h][w+1]==-1) {
      dis[h][w+1] = dis[h][w]+1;
      q.push(make_pair(h,w+1));
    }
    if (w!=0&&A[h][w-1]!='#'&&dis[h][w-1]==-1) {
      dis[h][w-1] = dis[h][w]+1;
      q.push(make_pair(h,w-1));
    }
  }
}

int main() {
  cin >> H >> W >> K;
  A.resize(H); rep(i,H) cin >> A[i];
  dis.resize(H,vector<int>(W,-1));
  int sh, sw; rep(i,H) rep(j,W) if (A[i][j]=='S') { sh=i; sw=j; }
  // dfs(sh,sw,K);
  dis[sh][sw] = 0; bfs(sh,sw);
  // rep(i,H) { rep(j,W) cout << dis[i][j]; cout << endl; }
  // cout << sh << " " << sw << endl;

  int d = INF;
  rep(i,H) rep(j,W) {
    if (dis[i][j]>=0&&dis[i][j]<=K) {
      int dh = min(i,(H-1)-i);
      int dw = min(j,(W-1)-j);
      d = min(d,min(dh,dw));
    }
  }
  int result = (d+K-1)/K + 1;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int x, y, z, k; cin>>x>>y>>z>>k;
    vector<ll> a(x), b(y), c(z);
    for(int i=0; i<x; i++) cin>>a[i];
    for(int i=0; i<y; i++) cin>>b[i];
    for(int i=0; i<z; i++) cin>>c[i];

    sort(a.begin(), a.end(), greater<ll>());
    
    vector<ll> bc;
    for(int i=0; i<y; i++){
        for(int j=0; j<z; j++){
            bc.eb(b[i] + c[j]);
        }
    }

    sort(bc.begin(), bc.end(), greater<ll>());

    vector<ll> ans;
    for(int i=0; i<x; i++){
        for(int j=0; j<min(k, (int)bc.size()); j++){
            ans.eb(a[i] + bc[j]);
        }
    }

    sort(ans.begin(), ans.end(), greater<ll>());

    for(int i=0; i<k; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 43368
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

X, Y, A, B, C = MI()
P = LI()
Q = LI()
R = LI()

P.sort()
Q.sort()
R.sort()

Ans = []
for p in P:
    Ans.append(('P', p))
for q in Q:
    Ans.append(('Q', q))
for r in R:
    Ans.append(('R', r))
Ans.sort(key=lambda tup: tup[1])


Ans_text = []
for i in range(A + B + C - X - Y, A + B + C):
    Ans_text.append(Ans[i][0])

c = collections.Counter(Ans_text)

R_num = c['R']
P_num = c['P']
Q_num = c['Q']

ans = 0
cnt = 0
if c['P'] <= X and c['Q'] <= Y:
    while cnt < (X + Y):
        ans += Ans.pop()[1]
        cnt += 1
elif c['P'] > X:
    while cnt < X:
        ans += P.pop()
        cnt += 1
    while cnt < (X + Y):
        b = Ans.pop()
        if b[0] == 'P':
            continue
        else:
            ans += b[1]
            cnt += 1
else:
    while cnt < Y:
        ans += Q.pop()
        cnt += 1
    while cnt < (X + Y):
        b = Ans.pop()
        if b[0] == 'Q':
            continue
        else:
            ans += b[1]
            cnt += 1
print(ans)

Measured memory_bytes: 121732
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
string s;
long long n,a,b;
vector<long long >x;

int main(){
  cin >> n>>a>> b;
  x.resize(n);
  for(int i=0;i<n;i++)cin>>x.at(i);
  long long ans = 0;
  for(int i=0;i<n-1;i++){
  	ans += min((x.at(i+1)-x.at(i))*a,b);
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int IsPrime(int x);
int main(void){
    int i,n,count;
    
    for(;;){
        scanf("%d",&n);
        if(n==0) break;
        count=0;
        for(i=n+1;i<=2*n;i++){
            if(IsPrime(i)) count++;
        }
        printf("%d\n",count);
    }
    
}

int IsPrime(int x){
    int i;
    for(i=2;i*i<=x;i++){
        if(x%i==0) return 0;
    }
    return 1;
}


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

#define F(i, a, b) for (int i = a; i <= b; i ++)
#define G(i, a, b) for (int i = a; i >= b; i --)
#define out4(x, y, z, w) { if (debug) printf(#x" = "),W(x),printf(" "#y" = "),W(y),printf(" "#z" = "),W(z),printf(" "#w" = "),W(w),putc('\n'); }
#define out3(x, y, z) { if (debug) printf(#x" = "), W(x), printf(" "#y" = "), W(y), printf(" "#z" = "), W(z), putc('\n'); }
#define out2(x, y) { if (debug) printf(#x" = "), W(x), printf(" "#y" = "), W(y), putc('\n'); }
#define out1(x) { if (debug) printf(#x" = "), W(x), putc('\n'); }
#define outline(x) { if (debug) puts("-------------------------------------------"#x"----------------------------------------"); }
#define outarr(a, L, R) { if (debug) { printf(#a"[%d..%d] = ", L, R); F(i, L, R) W(a[i]), putc(' '); putc('\n'); } }
#define Assert(x) { if ((debug) && (!(x))) { puts("Wrong Answer"); exit(0); } }
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define mem(a, b) memset(a, b, sizeof a)
#define mec(a, b) memcpy(a, b, sizeof a)
#define mx(a, b) ((a) = max(a, b))
#define mn(a, b) ((a) = min(a, b))
#define lowbit(x) ((x) & (-(x)))
#define abs(x) ((max(x, - (x))))
#define get getchar()
#define pb push_back
#define putc putchar

template <typename Int>
void R(Int &x) {
	char c = get; x = 0; Int t = 1;
	for (; !isdigit(c); c = get) t = (c == '-' ? - 1 : t);
	for (; isdigit(c); x = (x << 3) + (x << 1) + c - '0', c = get); x *= t;
}
template <typename Int>
void W(Int x) {
	if (x < 0) { putc('-'); x = - x ; }
	if (x > 9) W(x / 10); putc(x % 10 + '0');
}

#define debug (0)

using namespace std;

const int N = 3e5 + 10;
int n, m, L, Ans, t, x[N], stk[N];
struct node { int s, l, r; } v[N];

int main() {
//	freopen("data.in","r",stdin);

	R(n), R(L), Ans = n + 1;
	F(i, 1, n) R(x[i]);
	F(i, 1, n) {
		R(t), Ans += t / (2 * L), t %= 2 * L;
		int l = (t <= 2 * (L - x[i]));
		int r = (t <= 2 * x[i]);
		if (!(l + r)) continue;
		out4(x[i], t, l, r);
		if (!t) { Ans --; continue; }
		if (i == n) Ans -= l == 1;
		v[i] = {1, l, r};
	}

	out1(Ans);

	int top = 0;
	F(i, 1, n - 1)
		if (v[i].s && v[i].l) {
			if (!v[i].r) {
				if (stk[top])
					Ans --, v[stk[top --]].s = 0;
			}
			else
				stk[++ top] = i;
		}

	top = 0;
	G(i, n - 1, 1)
		if (v[i].s && v[i].r) {
			if (!v[i].l) {
				if (stk[top])
					Ans --, top --;
			}
			else
				stk[++ top] = i;
		}
//	out2(Ans, top) ;
	Ans -= top / 2;

	W(1ll * Ans * (2ll * L));
}

Measured memory_bytes: 9476
//ABC086C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int y;
	long long int n;
	cin >> y >> n;
	for(int i=0;i<=y;i++){
		for(int j=0;j<=y-i;j++){
			if(1000*(y-i-j) == n-10000*i-5000*j){
				cout << i << " " << j << " " << y-i-j;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>K;
    vec a(N);
    rep(i,N) cin>>a[i];
    ll sum = 0;
    rep(i,K) sum += a[i];
    ll ans = sum;
    reps(i, K, N){
        sum += a[i] - a[i-K];
        ans = max(ans, sum);
    }
    long double b = ans + K;
    cout<<fixed<<setprecision(10)<<b / 2<<endl;
}

Measured memory_bytes: 1792
S = input()
T = input()
result = False
if all([s >= 'a' and s <= 'z' for s in S]):
  if all([t >= 'a' and t <= 'z' for t in T]):
     if len(S) >= 1 and len(S) <= 10:
        if len(T) == len(S) + 1:
          result = T.startswith(S)
if result:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 8928
#include<iostream>
#include<cstring>

using namespace std;
const int maxn = 200000;
long long a[maxn];
int main()
{
	int N, T;
	
	while (cin >> N >> T)
	{
		long long sum = 0;
		memset(a, 0, sizeof(a));
		for (int i = 0; i < N; i++)
		{
			cin >> a[i];
			if (i == 0)continue;
			if (a[i] - a[i - 1] >= T)
				sum += T;
			else sum += a[i] - a[i - 1];
		}
		sum += T;
		cout << sum << endl;
	}
//	system("pause");
	return 0;
}

Measured memory_bytes: 1792
k,n = gets.split().map(&:to_i)
a = gets.split().map(&:to_i)
n -= 1
max = 0
x = 0
y = 0
i = 0
ans = 0
n.times do
  if i == 0
    max = a[i]
  end
  if a[i+1] - a[i] >= max
    max = a[i+1] - a[i]
    x = a[i+1]
    y = a[i]
  end
  i += 1
end
if k - x + y > max
  if a.last - a[0] > k - x + y
    ans = k - x + y
    puts ans
  else
  	ans = a.last - a[0]
  	puts ans
  end
else
  ans = k - x + y
  puts ans
end

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

struct Union_Find {
	vector<int> par;
	vector<int> rank;
	vector<ll> nnum;

	Union_Find(int n) : par(n), rank(n), nnum(n){
		for(int i=0; i<n; i++){
			par[i] = i;
			rank[i] = 0;
			nnum[i] = 1;
		}
	}

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

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

	void unite(int x, int y){
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		if (rank[rx]<rank[ry]) swap(rx, ry);
		if (rank[rx] == rank[ry]) rank[rx]++;
		par[ry] = rx;
		nnum[rx] += nnum[ry];
	}

	ll nodes(int x){
		return nnum[root(x)];
	}
};

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	Union_Find uf(n+1);
	vector<pi> ab(m);
	rep(i, m) cin >> ab[m-i-1].fi >> ab[m-i-1].se;

	vll ans(m);
	ans[0] = (ll)n*(n-1)/2;

	rep(i, m-1){
		ans[i+1] = ans[i];
		int a = ab[i].fi, b = ab[i].se;
		if (!uf.same(a, b)){
			ans[i+1] -= uf.nodes(a)*uf.nodes(b);
			uf.unite(a, b);
		}
	}

	rep(i, m) cout << ans[m-i-1] << "\n";
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define  pb push_back
#define  xx first
#define  yy second
//#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

typedef long long ll;
typedef vector<string> vi;
typedef pair<int,int> pi;
const int N = 2e5+10;
bool pr[N];
vector<int>prime;
void sieve(){

  for(int i = 4; i<=N; i+=2){
    pr[i] = 1;
  }
  for(int i = 3; i*i<=N; i+=2){

     if(pr[i]==0){
        for(int j=i*i; j<=N; j+=i)
        pr[j] = 1;
     }
  }
  for(int i = 2;i<=N; i++){
    if(pr[i]==0){
        prime.pb(i);
    }
  }
  return ;
}

int phi(int n){

    int res = n;
     for(int  i =0; i<prime.size() && i*i<=n; i++){
            if(n%prime[i]==0){
            while(n%prime[i]==0){
                n/=prime[i];
            }
          res = res-res/prime[i];
        }
     }

     if(n>1){
        res = res - res/n;
     }

     return res;
}



int main()
{
     int n;
     cin >> n;
     cout << (n+1)/2 << endl;

    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    S = str(input())
    T = ''
    while True:
        if len(S) == 0:
            print('YES')
            break
        elif S[len(S)-7:len(S)] == 'dreamer':
            S = S[:len(S)-7]
            continue
        elif S[len(S)-6:len(S)] == 'eraser':
            S = S[:len(S)-6]
            continue
        elif S[len(S)-5:len(S)] == 'dream':
            S = S[:len(S)-5]
            continue
        elif S[len(S)-5:len(S)] == 'erase':
            S = S[:len(S)-5]
            continue
        else:
            print('NO')
            break

Measured memory_bytes: 3188
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define REP(i, a, b) for(int i = a; i < b; i++)

long long int compare(const void* a, const void* b) {
    return *(long long int*)b - *(long long int*)a;
}

long long int factrial(long long int a) {
    long long int fact = 1;
    REP(i, 1, a + 1) {
        fact = fact * i;
    }
    return fact;
}

int main(void) {
    int n;
    long long int m = 0, a = 0, r = 0, c = 0, h = 0, count = 0;
    scanf("%d", &n);
    char s[20];
    REP(i, 0, n) {
        scanf("%s", s);
        if (s[0] == 'M') {
            m++;
        } else if (s[0] == 'A') {
            a++;
        } else if (s[0] == 'R') {
            r++;
        } else if (s[0] == 'C') {
            c++;
        } else if (s[0] == 'H') {
            h++;
        }
    }
    count += m * a * r;
    count += m * a * c;
    count += m * a * h;
    count += m * r * c;
    count += m * r * h;
    count += m * c * h;
    count += a * r * c;
    count += a * r * h;
    count += a * c * h;
    count += r * c * h;
    
    printf("%lld\n", count);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll> L(N);
    rep(i,N) cin>>L[i];

    sort(all(L));
    ll sum = 0;
    rep(i,N-1){
        sum+=L[i];
    }

    if(sum>L[N-1]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


    return 0;
    

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main()
{
    ll n;
    cin >> n;
    ll a[n+1];
    ll b[n];
    REP(i, n + 1)
    {
        cin >> a[i];
    }
    REP(i, n)
    {
        cin >> b[i];
    }
    ll count = 0;
    ll rest = 0;
    REP(i, n){
        rest = 0;
        if (a[i] - b[i] < 0)
        {
            rest = b[i] - a[i];
            if(a[i+1]-rest<0){
                count += a[i] + a[i + 1];
                a[i + 1] = 0;
            }
            else
            {
                count += b[i];
                a[i + 1] -= rest;
            }
        }
        else
        {
            count += b[i];
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 1792