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

// input
int A, B, C, D;

map<int, char> m;


void input() {
    string s;
    cin >> s;
    A = s[0] - '0';
    B = s[1] - '0';
    C = s[2] - '0';
    D = s[3] - '0';
}


int solve(int i, int j, int k) {
    int ret = A;
    ret += pow(-1, i) * B;
    ret += pow(-1, j) * C;
    ret += pow(-1, k) * D;
    return ret;
}


void print_ans(int i, int j, int k) {
    printf("%d%c%d%c%d%c%d=7\n", A, m[i], B, m[j], C, m[k], D);
}


int main() {
    input();
    m[0] = '+';
    m[1] = '-';
    rep(i, 2) rep(j, 2) rep(k, 2) {
        int x = solve(i, j, k);
        if (x == 7) {
            print_ans(i, j, k);
            return 0;
        }
    }
}


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

int main(){
	int ch[26] = {0}, num, i;
	string str;
	getline(cin, str);
	while(!cin.eof()){
		for(int i = 0; i < str.length(); i++){
			num = str[i]-'0';
			if(str[i] >= 'A' and str[i] <= 'Z'){
				ch[num-17]++;
			}
			else if(str[i] >= 'a' and str[i] <= 'z'){
				ch[num-49]++;
			}
		}
		getline(cin, str);
	}
	
	for(char c = 'a'; c <= 'z'; c++){
		cout << c << " : " << ch[c-'0'-49] << endl;
	}
			
	return 0;
}

Measured memory_bytes: 1176
S = list(input())

if (not(1 <= int(S[0])*10+int(S[1]) <= 12)) and (not(1 <= int(S[2])*10+int(S[3]) <= 12)):
    print('NA')

elif 1 <= int(S[0])*10+int(S[1]) <= 12:
    if not(1 <= int(S[2])*10+int(S[3]) <= 12):
        print('MMYY')
    else:
        print('AMBIGUOUS')
else:
    print('YYMM')

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    if(N ==1 && M == 1){
        cout << 1 << endl;
        return 0;
    }
    if(N == 1){
        cout << M-2 << endl;
        return 0;
    }
    if(M == 1){
        cout << N-2 << endl;
        return 0;
    }
    cout << (M-2)*(N-2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;

signed main(){
  string S; cin >> S;
  int f = stoi(S.substr(0, 2));
  int b = stoi(S.substr(2, 2));
  string ans = "";
  if ((0<f and f<13) and (0<b and b<13)) {
    ans = "AMBIGUOUS";
  } else 
  if (0<f and f<13) {
    ans = "MMYY";
  } else 
  if (0<b and b<13) {
    ans = "YYMM";
  }
  else {
    ans = "NA";
  }
  cout << ans << endl;
}


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

#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define FORD(i, b, e) for (int i = (b); i >= (int)(e); i--)
#define ll long long
#define st f
#define nd s
#define pb PB
#define eb emplace_back
#define mp make_pair				
#define siz(c) SIZ(c)
const int inf = 1e9 + 7;
const LL INF = 1e18L + 7;
 
#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type
{int o = 0; p << "{"; for (auto c : y) {if (o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if (p > y) p = y;}
sim, class s> void maxi(n &p, s y) {if (p < y) p = y;}

#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "

#ifndef LOCAL
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

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

#else
#include</Users/dawid/algo/mac/ordered_set>
#endif

#define int ll
const int mod = 1e9+7;
const int N = 2e5+7;

int n, ile;

int a[N];
int otw[N];

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n;

	for(int i = 1; i <= 2*n; ++i)
	{
		char c;
		cin >> c;
		a[i] = (c=='B');
	}

	for(int i = 1; i <= 2*n+1; ++i)
	{
		int mam = 0;

		if(i>1 && !otw[i-1])
			++mam;

		int chce = 0;

		if(a[i]!=a[i-1])
			++chce;

		if(mam!=chce)
			otw[i] = 1;

		if(otw[i])
			++ile;
	}

	if(otw[2*n+1] || ile!=n)
	{
		cout << 0 << endl;
		exit(0);
	}

	int bilans = 0;
	int ans = 1;

	for(int i = 1; i <= 2*n; ++i)
	{
		if(otw[i])
			++bilans;
		else
		{
			ans = ans*bilans%mod;
			--bilans;
		}
	}

	for(int i = 1; i <= n; ++i)
	{
		ans *= i;
		ans %= mod;
	}

	cout << ans << endl;
}



Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>
#include <sstream>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

template <typename T>
T gcd(T a, T b) {
	while (b != 0) {
		T temp = a;
		a = b;
		b = temp % b;
	}

	return a;
}

// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string

void solve() {
	ll a, b;
	cin >> a >> b;
	cout << a * b << endl;
}	

int main(){
	IOS;
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	
	
	int t = 1;
	// cin >> t;
	while(t--)
		solve();
	
	return 0;
}





























Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main() {
    
    int i,j,n;
    cin>>n;
    vector<int>a(n);
    for(i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end());
    int sum=0,k;
    for(i=0;i<n-2;i++){
        k=i;int count=0;
        while(k<n&&a[i]==a[k]){k++;count++;}
        for(j=k;j<n-1;j++){
            int t=j;
            int count1=0;
            while(t<n&&a[j]==a[t]){t++;count1++;}
            int z = lower_bound(a.begin(),a.end(),a[i]+a[j])-a.begin();
            // cout<<z<<" ";
            // cout<<count<<" "<<count1<<" "<<z-t<<endl;
            sum=sum+(count*count1*(z-t));
            j=t-1;
        }
        i=k-1;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3572
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = Integer.parseInt(sc.next());
		Arrays.sort(a);
		int c = 1;
		for (int i = 1; i < n; i++)
			if (a[i] != a[i - 1])
				c++;
		if (c % 2 == 0)
			System.out.println(c - 1);
		else
			System.out.println(c);
	}
}

Measured memory_bytes: 49028
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	FastIO
	lld n, i;
	cin >> n;
	lld flag = 1;
	lld A[n];
	foi(i,n){
		cin >> A[i];
	}
	for(i = n-1; i > 0; i--){
		if (A[i] < A[i-1]){
			A[i-1]--;
			if (A[i] < A[i-1]){
				flag = 0;
			}
		}
	}
	if (flag == 0)
		cout <<  "No";
	else
		cout << "Yes";
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int dp[1000000][3];
int solve() 
{
	int n;
	cin>>n;
	int a,b,c;
	cin>>a>>b>>c;
	dp[1][1] =a; dp[1][2] = b;dp[1][3] = c;
	for(int i=2;i<=n;i++){
		cin>>a>>b>>c;
		dp[i][1] += a+max(dp[i-1][2],dp[i-1][3]);
		dp[i][2] += b+max(dp[i-1][1],dp[i-1][3]);
		dp[i][3] += c+max(dp[i-1][1],dp[i-1][2]);
	}
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;
	return 0;
}
int main(){
	int test = 1;
	while (test--)solve();return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;
using P = pair<ll, ll>;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

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

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

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y)
            return false;
        if(par[x] > par[y])
            swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) { return -par[root(x)]; }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    UnionFind uf(n);
    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        if(!uf.issame(x, y)) {
            uf.merge(x, y);
        }
    }
    map<int, vector<ll>> mp;
    for(int i = 0; i < n; i++) {
        mp[uf.root(i)].push_back(a[i]);
    }
    int sz = mp.size();
    if(sz == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    for(auto &p : mp) {
        sort(RALL(p.second));
        ans += p.second.back();
        p.second.pop_back();
    }
    vector<ll> tmp;
    for(auto &p : mp) {
        for(const auto &i : p.second) {
            tmp.push_back(i);
        }
    }
    if(tmp.size() < sz - 2) {
        cout << "Impossible" << endl;
        return 0;
    }
    sort(ALL(tmp));
    for(int i = 0; i < sz - 2; i++) {
        ans += tmp[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 12416
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        h: usize,
        w: usize,
        n: usize,
        cells: [(i64, i64); n],
    }

    let mut hash = std::collections::HashSet::new();
    let mut checked = std::collections::HashSet::new();
    for &(x, y) in &cells {
        hash.insert((x, y));
    }

    let mut ans = vec![0; 10];
    ans[0] = (h - 2) * (w - 2);

    for &(x, y) in &cells {
        for i in x - 2..x + 1 {
            for j in y - 2..y + 1 {
                if i < 1 || i + 2 > h as i64 || j < 1 || j + 2 > w as i64 {
                    continue;
                }
                if !checked.insert((i, j)) {
                    continue;
                }

                ans[0] -= 1;
                let mut cnt = 0;
                for k in i..i + 3 {
                    for l in j..j + 3 {
                        if hash.get(&(k, l)).is_some() {
                            cnt += 1;
                        }
                    }
                }
                ans[cnt] += 1;
            }
        }
    }

    for i in 0..10 {
        println!("{}", ans[i]);
    }
}


Measured memory_bytes: 49304
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

#define MOD 1000000007LL

using namespace std;
using pii=pair<int,int>;
using ll=long long;

int n,k;
vector<set<int>> adj;
vector<bool> color;
vector<int> cnt;

ll dfs(int now, int parent)
{
    ll ret=1;
    if(parent!=-1){
        ret=(ret*max(0,k-cnt[parent]))%MOD;
    }
    else ret=(ret*k)%MOD;
    color[now]=true;
    for(int nxt : adj[now]){
        cnt[nxt]+=1;
        if(nxt==parent) continue;
        ret=(ret*dfs(nxt,now))%MOD;
    }
    return ret;
}

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

    cin>>n>>k;
    adj.resize(n);
    color.resize(n);
    cnt.resize(n,1);
    for(int i=0; i<n-1; i++){
        int a,b;
        cin>>a>>b;
        adj[a-1].insert(b-1);
        adj[b-1].insert(a-1);
    }
    cout<<dfs(0,-1);

    return 0;
}


Measured memory_bytes: 19456
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
     
     
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int x = sc.nextInt();
        PriorityQueue<DataA> queueA = new PriorityQueue<DataA>();
        PriorityQueue<DataB> queueB = new PriorityQueue<DataB>();
        for(int i = 0; i < x; i++) {
        	DataA xx = new DataA(sc.next().charAt(0),sc.nextInt());
        	if(xx.a == 'D')
            queueA.add(xx);
        }
        int y = sc.nextInt();
        for(int i = 0; i < y; i++) {
            String in = sc.next();
            DataB xx = new DataB(in.charAt(0),in.charAt(1),sc.nextInt());
            if(xx.b == 'D' && xx.c == 'D')
            queueB.add(xx);
        }
        int score = 0;
        while(!queueA.isEmpty() && !queueB.isEmpty() && d >= 1) {
            if(d != 1) {
            	DataA tmp = queueA.poll();
            	//System.out.println(tmp.p);
            	if((queueA.size() == 0 && queueB.peek().q >= tmp.p) || (!queueA.isEmpty() && queueB.peek().q >= queueA.peek().p + tmp.p)) {
	            	d -= 2; 
	            	//System.out.println(queueB.peek().q + " " + d );
	                score += queueB.poll().q;
	                queueA.add(tmp);
	                continue;
            	}
            	queueA.add(tmp);
            }

                d -= 1;
                //System.out.println(queueA.peek().p + " " + d);
                score += queueA.poll().p;
                continue;
        }
        if(queueA.isEmpty() && !queueB.isEmpty()) {
        	while(!queueB.isEmpty() && d >= 2) {
        		d -= 2;
        		//System.out.println(queueB.peek().q + " " + d);
        		score += queueB.poll().q;
        	}
        }
        else if(!queueA.isEmpty() && queueB.isEmpty()) {
        	while(!queueA.isEmpty() && d >= 1) {
        		d -= 1;
        		//System.out.println(queueA.peek().p + " " + d);
        		score += queueA.poll().p;
        		
        	}
        }
        
        System.out.println(score);

         
    }
    static class DataB implements Comparable<DataB> {
        char b;
        char c;
        int  q;
        @Override
        public int compareTo(DataB o) {
            return o.q - this.q;
        }
        DataB(char b, char c, int q) {
            this.b = b;
            this.c = c;
            this.q = q;
        }
         
    }
    static class DataA implements Comparable<DataA> {
        char a;
        int p;
        @Override
        public int compareTo(DataA o) {
            return o.p - this.p;
        }
        DataA(char a, int b) {
            this.a = a;
            this.p = b;
        }
         
         
    }
     
}

Measured memory_bytes: 26484
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]
for i in range(H):
    for j in range(W):
        tmp = 0
        if s[i][j] == '.':
            if i >= 1 and j >= 1:
                if s[i-1][j-1] == '#': tmp += 1
            if i >= 1:
                if s[i-1][j] == '#': tmp += 1
            if i >= 1 and j < W-1:
                if s[i-1][j+1] == '#': tmp += 1
            if j >= 1:
                if s[i][j-1] == '#': tmp += 1
            if j < W-1:
                if s[i][j+1] == '#': tmp += 1
            if i < H-1 and j >= 1:
                if s[i+1][j-1] == '#': tmp += 1
            if i < H-1:
                if s[i+1][j] == '#': tmp += 1
            if i < H-1 and j < W-1:
                if s[i+1][j+1] == '#': tmp += 1

            s[i][j] = str(tmp)

for i in range(H):
    print(''.join(s[i]))

Measured memory_bytes: 40300
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int64_t n,k;
    cin>>n>>k;
    cout << fixed << setprecision(10);
    vector<double> p(n);
    rep(i,n){
        cin>>p[i];
    }
    vector<double> s(n+1);
    s[0]=0;
    for(int i=0;i<n;i++){
        s[i+1]=s[i]+p[i];
    }
    /*
    rep(i,n+1){
        cout<<s[i]<<" ";
    }
    cout<<endl;
    */
    double max = 0;
    int stplace=0;
    for(int i=0;i+k<=n;i++){
        int sa = s[i+k]-s[i];
        //cout<<sa<<endl;
        if(sa>max){
            max = sa;
            stplace = i;
        }
    }
    //cout<<stplace<<endl;
    double sum=0;
    for(int i=0;i<k;i++){
        sum +=p[i+stplace]+1;
    }
    cout<<sum/2<<endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace  std;
using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<int, int> pairs;
typedef complex<ll> G;
const int N = 1e5+5;

const int INF = 1e9+5;
void solve(){

    int n;
    cin >> n;

    int a[n];
    for(int i=0;i < n;++i) {
        cin >> a[i];
    }
    vector<int>dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j : {i + 1, i + 2}) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
            }
        }
    }
    cout << dp[n-1] << '\n';





}
int main() {
    fast;
    solve();

}


Measured memory_bytes: 1024
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　| 　_　 _ l
　 　　　／` ミ＿xノ
　　 　 /　　　 　 |　見ちゃだめだよ！
　　　 /　 ヽ　　 ﾉ　　
　 　 │　　|　|　|　　
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)__)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  const int dx = tx - sx, dy = ty - sy;

  cout << string(dy, 'U') << string(dx, 'R');
  cout << string(dy, 'D') << string(dx, 'L');
  cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
  cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
// using ll = boost::multiprecision::int128_t;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;


ll solve(ll a, ll b) {
  if (a == b) return 1;
  if (Log2(a) == Log2(b)) {
    a ^= (1ll<<(Log2(a)-1));
    b ^= (1ll<<(Log2(b)-1));
    return solve(a, b);
  }

  int d1 = Log2(b);
  int d2 = Log2(b - (1ll<<(d1-1)));
  b = (1ll<<(d1-1)) + (1ll<<d2) - 1;

  ll a2 = a + (1ll<<(d1-1));
  ll b2 = (1ll<<d1) - 1;

  ll res = b - a + 1;
  if (b < a2) res += b2 - a2 + 1;
  else res += b2 - b;
  return res;
}


int main() {
  ll a, b; cin >> a >> b;
  cout << solve(a, b) << "\n";
  return 0;
}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t A, B, C, X, Y;
    std::cin >> A >> B >> C >> X >> Y;


    std::vector<int64_t> costs;
    // AB使わない
    {
        // Aの料金
        auto ca = A * X;
        // Bの料金
        auto cb = B * Y;

        costs.push_back(ca + cb);
    }

    // 全部ABで
    {
        auto maXY = std::max(X, Y);
        costs.push_back(maXY * 2 * C);
    }
    // 少ない方をABで
    {
        if (X > Y) {
            auto cost = Y * 2 * C;
            cost += (X - Y) * A;
            costs.push_back(cost);
        }
        else {
            auto cost = X * 2 * C;
            cost += (Y - X) * B;
            costs.push_back(cost);
        }
    }

    std::cout << *std::min_element(costs.begin(), costs.end())  << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

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

// デバッグを消し忘れるな！！！


int main() {
    ll n; cin >> n;
    Vl a(n);
    ll mx = 0;
    rep(i, 0, n){ cin >> a[i]; chmax(mx, a[i]);};
    sort(ALL(a));
    set<ll> s;
    rep(i, 0, n) s.insert(a[i]);
    Vl table(mx+1, false);
    rep(i, 0, n-1) if(a[i] == a[i+1]) table[a[i]] = true;
    for(auto it : s){
        for(int i = 2*it; i <= mx; i += it) table[i] = true;
    }
    ll ans = 0;
    rep(i, 0, n) if(!table[a[i]]) ans++;
    co(ans);

    return 0;
}


Measured memory_bytes: 21872
#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
int A[N+1];
int GCD(int a,int b){
	return b==0?a:GCD(b,a%b);
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	int n,tmp,gcd=0;
	cin>>n; 
	for(int i=0;i<n;++i){
		cin>>tmp;
		++A[tmp];
		gcd=GCD(tmp,gcd);
	}
	
	//pairwise
	for(int i=2;i<=N;++i){
		int flag=0;
		for(int j=i;j<=N;j+=i){
			if(j<=N && A[j]>=1) flag+=A[j];
			if(flag>=2) goto setwise;
		}
	}
	cout<<"pairwise coprime"<<endl;
	return 0;
	
	setwise:
	if(gcd==1) cout<<"setwise coprime"<<endl;
	else cout<<"not coprime"<<endl;
	return 0;
}


Measured memory_bytes: 7544
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    
    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        var n = Read();
        var s = Console.ReadLine();
        long count = 0;
        for(int i = 0; i < n - 2; i++)
        {
            if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
                count++;
           
        }
        Console.WriteLine(count);

        Console.Out.Flush();
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<int,int> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

//input
ll n;
vector<ll>a;
ll s;

ll solve(bool rem){
    s = 0;
    ll res = 0;
    for(int i=1;i<=n;i++){
        s += a[i];
        if(i%2==rem){
            if(s<=0){
                res += 1-s;
                s = 1;
            }
        }
        else{
            if(s>=0){
                res += s+1;
                s = -1;
            }
        }
    }
    return res;
}

int main(){
    cin >> n;
    a.resize(n+1,0);
    rep(i,n)cin>>a[i+1];
    cout << min(solve(1),solve(0)) << endl;

    return 0;
}



Measured memory_bytes: 3956
from collections import Counter


N, P = map(int, input().split())
S = list(input())

cnt = 0
if P in [2, 5]:
    for i, s in enumerate(S):
        if int(s) % P == 0:
            cnt += (i + 1)
else:
    num = 0
    mods = Counter()
    for i, s in enumerate(reversed(S)):
        num += int(s) * pow(10, i, P)
        num %= P
        mods[num] += 1
    mods[0] += 1
    for i, s in enumerate(S):
        mods[num] -= 1
        cnt += mods[num]
        num -= int(s) * pow(10, N - 1 - i, P)
        num %= P

print(cnt)


Measured memory_bytes: 61936
#!/usr/bin/env python3

import sys

def debug(*a):
    print(*a, file=sys.stderr)

s = input().strip()
v = [int(s[i]) for i in range(4)]
for x in range(8):
    a = v[0]
    for i in range(3):
        if (x >> i) & 1:
            a += v[i+1]
        else:
            a -= v[i+1]
    debug(f'x = {x}, a = {a}')
    if a == 7:
        s = ''
        for i in range(3):
            s += str(v[i])
            if (x >> i) & 1:
                s += '+'
            else:
                s += '-'
        s += str(v[3]) + '=7'
        print(s)
        sys.exit(0)
        


Measured memory_bytes: 9176
#define f(I)p[I]+h[I]*(h[I]-2*h[i])
n;
long C,h[2<<17],p[2<<17];
P[2<<17];
s,t=-1,i;
c(x,y,z){
	return (h[y]-h[x])*(p[y]+h[y]*h[y]-p[z]-h[z]*h[z])>=
	(h[z]-h[y])*(p[x]+h[x]*h[x]-p[y]-h[y]*h[y]);
}
main(){
	for(scanf("%*d%ld",&C);~scanf("%ld",h+i);){
		for(;s<t&&f(P[s])>=f(P[s+1]);s++);
		p[i]=i?h[i]*h[i]+C+f(P[s]):0;
		for(;s<t&&c(P[t-1],P[t],i);t--);
		P[++t]=i++;
	}
	printf("%ld",p[i-1]);
}

Measured memory_bytes: 4608
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    ll ans = 0;
    stack<char> st;
    for (char c : S) {
        if (st.empty() || st.top() == c) {
            st.push(c);
        } else {
            st.pop();
            ans += 2;
        }
    }

    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

signed main()
{
    int A, B, K;
    cin >> A >> B >> K;
    set<int> ans;
    for(int i = A; i < A + K; ++i) {
        if(i <= B) { ans.insert(i); }
    }
    for(int i = B - K + 1; i <= B; ++i) {
        if(i >= A) { ans.insert(i); }
    }
    for(auto& a : ans) {
        printf("%lld\n", a);
    }
    return 0;
}


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

int sento;
int data[1000];

void push(int);
int pop();

int main(){
  int change1;
  int change2;
  char set[100];
  sento = 0;

  while(scanf("%s",set) != EOF){
    if(set[0] == '+'){
      change1 = pop();
      change2 = pop();
      push(change1 + change2);
    }
    else if(set[0] == '-'){
      change2 = pop();
      change1 = pop();
      push(change1 - change2);
    }
    else if(set[0] == '*'){
      change1 = pop();
      change2 = pop();
      push(change1 * change2);
    }
    else{
      push(atoi(set));
    }
  }
  printf("%d\n",pop());
  return 0;
}


void push(int x){
  data[++sento] = x;
}

int pop(){
  sento--;
  return data[sento + 1];
}



Measured memory_bytes: 2088
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
ans = [0 for i in range(n)]

tmp=0
for i in range(1,math.ceil(math.sqrt(n))):
    for j in range(1,math.ceil(math.sqrt(n))):
        for k in range(1,math.ceil(math.sqrt(n))):
            tmp = i**2+j**2+k**2+i*j+j*k+k*i
            if tmp <=n:
                ans[tmp-1]+=1

for i in range(0,n):
    print(ans[i])

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5;
const int MAX_E = 1e5 + 5;

int N, d[MAX_N] = {0}, k = 0;
int a, b;
int rec[MAX_E];

struct Edge {
    int to, next;
}edges[MAX_E];
int head[MAX_N], cnt = 0;

void add(int u, int v) {
    edges[++cnt].to = v;
    edges[cnt].next = head[u];
    head[u] = cnt;
}

void dfs(int u, int ban) {
    int color = 0;
    for (int j = head[u]; j != -1; j = edges[j].next) {
        if (++color == ban) color++;
        rec[j] = color;
        dfs(edges[j].to, color);
    }
}

int main() {
    scanf("%d", &N);
    memset(head, -1, sizeof(head));
    for (int i = 1; i < N; i++) {
        scanf("%d %d", &a, &b);
        add(a, b);
        d[a]++; d[b]++;
    }
    for (int i = 1; i <= N; i++) k = max(k, d[i]);
    printf("%d\n", k);
    dfs(1, 0);
    for (int i = 1; i < N; i++) {
        printf("%d\n", rec[i]);
    }
    return 0;
}


Measured memory_bytes: 3456
import scala.io.StdIn

object Main extends App {

  val Array(n, m) = StdIn.readLine().split(' ').map(_.toInt)
    
  val a = Array.fill(n,m)(0)
  
  (0 until n).foreach{ i =>
    a(i) = StdIn.readLine().split(' ').map(_.toInt)
  }

  val b = Array.fill(m)(0)
  (0 until m).foreach{ i =>
    b(i) = StdIn.readLine().toInt
  }

  val result = (0 until n).map { k =>
    (0 until m).foldLeft(0) { (acc, p) =>
       acc + a(k)(p)*b(p)
    }
  }
  
  result.foreach(println)
  
}


Measured memory_bytes: 47396
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;

signed main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  char now=s[0];
  bool o=false;
  REP(i,n){
    if(s[i]!=now){
      if(o){
        s[i]=now;
      }
      else{
        o=true;
        k--;
        s[i]=now;
      }
    }
    else{
      if(o){
        o=false;
        if(k==0){
          break;
        }
      }
    }
  }
  int ans=0;
  REP(i,n){
    if(i==0&&s[i]=='L'){
      continue;
    }
    else if(i==n-1&&s[i]=='R'){
      continue;
    }
    if(s[i]=='L'&&s[i-1]=='L'){
      ans++;
    }
    if(s[i]=='R'&&s[i+1]=='R'){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(2e5)+10;
const ll INF=1e18;
int n,m,K,ans,x;
ll a[maxn],b[maxn];
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m); read(K);
	for (int i=1;i<=n;i++) read(a[i]),a[i]+=a[i-1];
	for (int i=1;i<=m;i++) read(b[i]),b[i]+=b[i-1];
	b[m+1]=INF;
	for (int i=0;i<=n;i++) {
		x=upper_bound(b+1,b+m+2,K-a[i])-b-1;
		if (a[i]+b[x]<=K) ans=max(ans,x+i);
	}
	printf("%d\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 6760
# -*- coding: utf-8 -*-
n = int(input())
s = {}
for _ in range(n):
    c = input()
    if c not in s:
        s[c] = 0
    s[c] += 1

m = int(input())
t = {}
for _ in range(m):
    c = input()
    if c not in t:
        t[c] = 0
    t[c] += 1

res = 0
for k in s.keys():
    r = s[k]
    if k in t:
        r -= t[k]
    res = max(res, r)

for k in t.keys():
    r = 0
    if k in s:
        r += s[k]
    r -= t[k]
    res = max(res, r)

print(res)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
int main(){
    ll n;
    cin>>n;
    if(n%2==0){
        cout<<n<<" "<<n<<" "<<n/2<<endl;
        return 0;
    }
    for(ll i=1; i<=3500; i++){
        for(ll j=1; j<=3500; j++){
            ll bunsi=n*i*j;
            ll bunbo=(4LL*i*j) - (n*i) - (n*j);
            if(bunbo==0) continue;
            if(bunsi%bunbo==0 && bunsi/bunbo>0){
                cout<<i<<" "<<j<<" "<<bunsi/bunbo;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
//ll a[N],sum[N];
int a,b,c,d;

bool check1(){
    if(abs(a-c)<=d) return true;
    return false;
}

bool check2(){
    if(abs(a-b)<=d&&abs(b-c)<=d)    return true;
    return false;
}

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

    cin >>a>>b>>c>>d;
    if(check1()||check2())  cout <<"Yes"<<"\n";
    else    cout <<"No"<<"\n";

    return 0;
}


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

int main(){
  int n,k;
  cin >>n;
  cin>>k;
  for(int i=0;i<k;i++){
    int x,y;
    cin>>x>>y;
    if(x>n/2) x=(n+1)-x;
    if(y>n/2) y=(n+1)-y;
    int t = (x>y)?(y):(x);
    if(t%3==1) cout<<1;
    else if(t%3==2) cout<<2;
    else cout<<3;
    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	var start, end int
	first := true
	for i, c := range s {
		if first && c == 'A' {
			first = false
			start = i
		}
		if c == 'Z' {
			end = i
		}
	}
	ans := s[start : end+1]
	fmt.Println(len(ans))
}


Measured memory_bytes: 1920
# -*- coding: utf-8 -*-

S = input()

words = ['dream', 'dreamer', 'erase', 'eraser']

while len(S)>0:
    hit = False
    for w in words:
        s = S[-len(w):]
        if w == s:
            S = S[0:-len(w)]
            hit = True
            break
    
    if not hit:
        break

if len(S)==0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


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

  return 0;
}







Measured memory_bytes: 256
#include<iostream>
#define T(x) x<=12&&x>= 6


int main(){
    long long a , b;
    std::cin >> a >> b;
    if(T(a)){
        std::cout << b/2;
    }else{
        if(a >= 13)std::cout << b;
        else std::cout << 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
for(int x,y,i=0;  ; i++){
cin >> x >> y;
if(x==0 && y==0)break;
if(x>y) cout << y << " " << x <<endl;
else cout << x << " " << y <<endl;
}
return 0;
}


Measured memory_bytes: 3000
# -*- coding: utf-8 -*-
import numpy as np

C0=list(map(int,input().split()))
C1=list(map(int,input().split()))
C2=list(map(int,input().split()))
k=0
C=np.zeros(4)
for a1 in range(101):
    for b1 in range(101):
        if C0[0]==a1+b1:
            a1_solid=a1
            b1_solid=b1
            b2=C0[1]-a1_solid
            b3=C0[2]-a1_solid
            a2=C1[0]-b1_solid
            a3=C2[0]-b1_solid
            if C1[1]==a2+b2 and C1[2]==a2+b3 and C2[1]==a3+b2 and C2[2]==a3+b3 and k==0:
                print("Yes")
                k+=1
        if a1==99 and b1==99  and k==0:
                print("No")
                k+=1



Measured memory_bytes: 13536
using System;

namespace ABC116B
{


    using System;
    using System.Collections.Generic;
    using System.Linq;
    class MainClass
    {
        static int[] s;
  

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);

            var alst = new List<int>();
            int a = 0;
            for(int i = 1; i <= 1000000; i++)
            {
                if (i == 1)
                {
                    a = s[0];

                }
                else
                {

                    if (alst[i - 2] % 2 == 0)
                    {
                        a = alst[i - 2] / 2;

                    }
                    else
                    {
                        a = alst[i - 2] * 3 + 1;
                    }
                }

                if (alst.IndexOf(a)>=0)
                {
                    Console.WriteLine(i);
                    return;
                }
                alst.Add(a);


            }
            return;
        }
    }
}


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

using namespace std;

int main()
{
    int K;
    string S;

    cin >> K >> S;

    int size = S.length();

    string ANS = S;

    if (size > K)
    {

        ANS = S.substr(0, K) + "...";
    }

    cout << ANS << endl;
}

Measured memory_bytes: 3628
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

int main()
{
    optimizeIO();

    int na,nb,k;
    cin>>na>>nb>>k;

    vector<LL>va(na);
    vector<LL>vb(nb);

    for(int i=0;i<na;i++) cin>>va[i];
    for(int i=0;i<nb;i++) cin>>vb[i];

    for(int i=1;i<na;i++) va[i] += va[i-1];
    for(int i=1;i<nb;i++) vb[i] += vb[i-1];

    int mx = 0;

    for(int i=0;i<na;i++)
    {
        LL val = va[i];
        LL rem = k-val;

        int id = upper_bound(ALL(vb),rem)-vb.begin();
//        DBG(id);

        if(val<=k)
        {
            int pos = i+1 + id;
//            DBG(pos);
            mx = max(mx,pos);
        }
    }

    for(int i=0;i<nb;i++)
    {
        LL val = vb[i];
        LL rem = k-val;

        int id = upper_bound(ALL(va),rem)-va.begin();
//        DBG(id);

        if(val<=k)
        {
            int pos = i+1 + id;
//            DBG(pos);
            mx = max(mx,pos);
        }
    }

    cout<<mx<<endl;

    return 0;
}

/**
3 4 10
60 90 120
80 150 80 150

3 4 230
60 90 120
80 150 80 150

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




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

using ll = long long;

int H, W;
int N;
set<pair<int, int>> painted;

set<pair<int, int>> cnds[10];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> H >> W >> N;
	for (int i = 0; i < N; i++) {
		int x, y; cin >> x >> y;
		painted.emplace(x, y);
	}

	for (auto p : painted) {
		for (int x = p.first - 1; x <= p.first + 1; x++) {
			for (int y = p.second - 1; y <= p.second + 1; y++) {
				if (x - 1 < 1 || x + 1 > H || y - 1 < 1 || y + 1 > W) {
					continue;
				}
				int has = 0;
				for (int a = x - 1; a <= x + 1; a++) {
					for (int b = y - 1; b <= y + 1; b++) {
						has += painted.count({a, b});
					}
				}
				assert(has > 0);
				cnds[has].emplace(x, y);
			}
		}
	}

	ll ans0 = ll(H-2) * (W-2);
	for (int c = 1; c < 10; c++) {
		ans0 -= int(cnds[c].size());
	}
	cout << ans0 << '\n';
	for (int c = 1; c < 10; c++) {
		cout << cnds[c].size() << '\n';
	}

	return 0;
}


Measured memory_bytes: 47104