akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	deque<char> s;
	string ss;
	cin >> ss;
	for (char c : ss) {
		s.push_back(c);
	}
	int q;
	cin >> q;
	int left = 0, right = 1;
	int rev = 0;
	while (q--) {
		int type;
		cin >> type;
		if (type == 1) {
			left ^= 1;
			right ^= 1;
			rev ^= 1;
		} else {
			int t;
			char c;
			cin >> t >> c;
			if (t == 1) {
				if (left == 0) {
					s.push_front(c);
				} else {
					s.push_back(c);
				}
			} else {
				if (right == 0) {
					s.push_front(c);
				} else {
					s.push_back(c);
				}
			}
		}
	}
	if (rev) {
		reverse(s.begin(), s.end());
	}
	for (char c : s) {
		cout << c;
	} 
	cout << '\n';
 	return 0;
}


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) x.begin() , x.end()
#define ll long long 
#define pb push_back
#define mp make_pair

using namespace std;
const int mx = 10001;
long long dp[mx][100][2] , d;
bool visited[mx][100][2];
string n;
long long MOD = 1e9 + 7;
long long dfs(int pos , int sum , bool less){
    if(pos >= n.size())return !sum;
    if(visited[pos][sum][less])return (dp[pos][sum][less])%MOD;
    visited[pos][sum][less] = 1;
    long long ans = 0;
    for(int i = 0; i < 10; ++i){
        if(less || i <= n[pos] - '0'){
            ans += dfs(pos + 1 , (sum + i)%d , less || i < n[pos] - '0') % MOD;
        }
    }
    return dp[pos][sum][less] = ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    cin>>d;
    cout<<(dfs(0 , 0 , 0) - 1) % MOD<<endl;

}

Measured memory_bytes: 18688
import java.util.Scanner;

public class Main {
	static int[][][] house = new int[4][3][10];
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			int b = sc.nextInt() - 1;
			int f = sc.nextInt() - 1;
			int r = sc.nextInt() - 1;
			house[b][f][r] += sc.nextInt();
		}
		String s = "";
		for(int i = 0; i < 4; i++) {
			if(i != 0) {
				s += "\n####################\n";
			}
			for(int k = 0; k < 3; k++) {
				if(k != 0){
					s += "\n";
				}
				for(int l = 0; l < 10; l++) {
					s += " " + house[i][k][l];
				}
			}
		}
		System.out.println(s);
	}
}



Measured memory_bytes: 29808
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

int trans(int x, int y) {
	if (x > y) swap(x, y);
	return x * 1000 + y;
}

vector<vector<int>> graph(1000010, vector<int>());
vector<bool> vis(1000010), calc(1000010);
vector<int> ans(1000010);

int dfs(int n) {
	if (vis[n]) {
		if (!calc[n]) return -1;
		return ans[n];
	}
	vis[n] = true; ans[n] = 1;
	for (int i : graph[n]) {
		int tmp = dfs(i);
		if (tmp == -1) return -1;
		chmax(ans[n], tmp + 1);
	}
	calc[n] = true;
	return ans[n];
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	rep(i, n) {
		vector<int> a(n - 1);
		rep(j, n - 1) {
			cin >> a[j];
			a[j]--;
		}
		rep(j, n - 2) {
			graph[trans(i, a[j + 1])].pb(trans(i, a[j]));
		}
	}
	int ans = 0;
	rep(i, 1000 * n) {
		int tmp = dfs(i);
		if (tmp == -1) {
			cout << -1 << '\n';
			return 0;
		}
		else {
			chmax(ans, tmp);
		}
	}
	cout << ans << '\n';
}

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

using namespace std;

typedef long long int lli;

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

    int n, l;

    cin >> n >> l;
    int sum = 0, mini = 1e+9;
    for (int i=0; i<n; i++) {
        sum += l + i;
        mini = (abs(mini) < abs(l+i)) ? mini : l+i;
    }

    cout << sum-mini << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = list()
# p = list(range(m))
x = list()
# x = list(range(m))
for i in range(m):
    a, b = map(int, input().split())
    p.append(a)
    x.append(b)

for i in range(m):
    count = 0
    for j in range(n):
        z = p[i] -1
        if (j == z):
            count += x[i]

        else:
            count += t[j]
    print(count)


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

int main() {
    long long n,w;    cin>>n>>w;
    long long dp[100005];
    memset(dp, 1e9+1, sizeof(dp));
    long long mx_till_now=0;
    dp[0]=0;
    for(long long i=0;i<n;i++){
        long long wi,vi;cin>>wi>>vi;
        for(long long j=mx_till_now;j>=0;j--)if( dp[j]!=1e9+1 && (dp[j] + wi==1e9+1 ||(dp[j] + wi)<=w )){
                dp[j+vi] = min ( dp[j+vi] , dp[j] + wi );
                mx_till_now=max(mx_till_now,j+vi);
        }
    }   
    cout<<mx_till_now;
    
    return 0;
}

Measured memory_bytes: 4396
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
bool prime[1000001];
int main(){
	int n;
		prime[1] = true;
		for(int i = 2; i * i <= 1000000; i++){
			if(!prime[i]){
				for(int j = i * i; j <= 1000000; j += i){
					prime[j] = true;
				}
			}
		}
	while(cin >> n){
		int ans = 0;
		for(int i = 1; i <= n; i++){
			if(!prime[i])ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define all(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//
int main(void) {
    int N,Q;
    string s;
    cin >> N >> Q;
    cin >>s;
    vector<int> l(Q),r(Q),t(N);
    rep(i,Q) cin >> l.at(i) >> r.at(i);
    rep(i,N) t.at(i) = 0;
    for(int i=1;i<N;i++){
        if(s[i-1]=='A'&&s[i]=='C') t.at(i) = t.at(i-1) + 1;
        else t.at(i) = t.at(i-1);
    }
    rep(i,Q){
        int ans = t.at(r.at(i)-1) - t.at(l.at(i)-1);
        cout << ans << endl;
    }
    return 0;
}

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

//iをlからrまで+1インクリメントでfor
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
// iを0からnまでfor
#define REP(i,n) FOR(i,0,n)

int main() {
    int n;
    int input;
    int count = 0;
    cin >> n ;
    vector<int> v;
    REP(i,n) {
        cin >> input;
        v.push_back(input);
    }

    REP (i,n-2) {
        if (( v[i] < v[i+1] && v[i+1] < v[i+2] )
            || ( v[i] > v[i+1] && v[i+1] > v[i+2] )){
            count++;
        }
    }

    cout << count << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

const int N = 1<<18;
ll dat[2*N], sum[2*N];
ll add(int l, int r, ll x, int a, int b, int k){
  if(r<=a || b<=l)return dat[k];
  if(l<=a && b<=r){
    sum[k] += x;
    return dat[k] += x;
  }
  int m = (a+b)/2;
  return dat[k] = max(add(l,r,x,a,m,2*k+1),add(l,r,x,m,b,2*k+2))+sum[k];
}
ll query(int l, int r, int a, int b, int k){
  if(r<=a || b<=l)return -1ll<<60;
  if(l<=a && b<=r)return dat[k];
  int m = (a+b)/2;
  return max(query(l,r,a,m,2*k+1), query(l,r,m,b,2*k+2)) + sum[k];
}

int n,m;
ll imo[252521];
pair<pii,int> rs[252521];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m){
    int l,r,a;
    scanf("%d%d%d",&l,&r,&a);
    --l;--r;
    imo[l] += a;
    imo[r+1] -= a;
    rs[i] = make_pair(pii(r,l),a);
  }
  REP(i,n)imo[i+1] += imo[i];
  sort(rs,rs+m);
  REP(i,m){
    int l = rs[i].first.second;
    int r = rs[i].first.first;
    int a = rs[i].second;
    add(l,N,-a,0,N,0);
  }
  ll ans = 0;
  int it = 0;
  REP(i,n){
    ll dp = max(query(0,i,0,N,0)+imo[i], imo[i]);
    add(i,i+1,dp,0,N,0);
    CHMAX(ans, dp);
    if(i==n-1)break;
    while(it<m && rs[it].first.first==i){
      int l = rs[it].first.second;
      int r = rs[it].first.first;
      int a = rs[it].second;
      it++;
      add(l,N,a,0,N,0);
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 12928
n, m, x, y = map(int,input().split())
max_x = max(list(map(int,input().split())))
min_y = min(list(map(int,input().split())))

for z in range(x+1,y+1):
  if max_x < z <= min_y:
    print("No War")
    exit()
else:
  print("War")

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

long t[110];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%ld", &t[i]);
	long ans = 1;
	for(int i = 0; i < n; i++)
		ans *= t[i] / __gcd(ans, t[i]);
	printf("%ld\n", ans);
}


Measured memory_bytes: 256
def rev(a)
    if a=='S'
        return 'W'
    else
        return 'S'
    end
end

def go(s,prefix)
    r = prefix + ("." * (N-2))
    r = r.split('')
    N.times{|i|
        if r[i]=='S'
            same = s[i]
        elsif r[i]=='W'
            same = ! s[i]
        end
        if same
            if r[i-1] == '.'
                r[i-1] = r[(i+1)%N]
            elsif r[(i+1)%N]=='.'
                r[(i+1)%N] = r[i-1]
            elsif r[i-1]!=r[(i+1)%N]
                return false
            end
        else
            if r[i-1] == '.'
                r[i-1] = rev(r[(i+1)%N])
            elsif r[(i+1)%N]=='.'
                r[(i+1)%N] = rev(r[i-1])
            elsif r[i-1]==r[(i+1)%N]
                return false
            end
        end
    }
    return r.join('')
end
        
N=gets.to_i
sc=gets.chomp
s=[]
sc.each_char { |c|
    s << (c=='o')
}

['SS', 'SW', 'WS', 'WW'].each{|prefix|
    r = go(s, prefix)
    if r
        puts r
        exit
    end
}
puts -1





Measured memory_bytes: 28012
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace abc152
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_abc152C();
        }
        public static void solve_abc152C()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int[] p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int max = p[0];
            int min = p[0];
            int cnt = 0;
            for (int i = 0; i < n; i++)
            {
                if (p[i] <= max && p[i] <= min)
                {
                    cnt++;
                }
                max = Math.Max(max, p[i]);
                min = Math.Min(min, p[i]);
            }
            Console.WriteLine(cnt);
        }

        public static void solve_abc152B()
        {
            int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int a = ab[0];
            int b = ab[1];
            string a1s = String.Empty;
            string b1s = string.Empty;
            for (int i = 0; i < b; i++)
            {
                a1s += a.ToString();
            }
            for (int i = 0; i < a; i++)
            {
                b1s += b.ToString();
            }

            if (Convert.ToInt64(a1s) > Convert.ToInt64(b1s))
            {
                Console.WriteLine(a1s);
            }
            else
            {
                Console.WriteLine(b1s);

            }
        }

        public static void solve_abc152A()
        {
            int[] nm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.WriteLine(nm[0] == nm[1] ? "Yes" : "No");            
        }
    }
}


Measured memory_bytes: 33116
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t n;

template<typename T, typename V>
int indexOf(const T& c, const V& v)
{
	using std::begin;
	using std::end;
	return std::find(begin(c), end(c), v) - begin(c);
}
template<typename T, typename V>
int lastIndexOf(const T& c, const V& v)
{
	using std::rbegin;
	using std::rend;
	return (rend(c) - std::find(rbegin(c), rend(c), v)) -1;
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> n;
	std::vector<int> a(n/2);
	std::vector<int> b(n / 2);
	for (size_t i = 0; i < n/2; i++)
	{
		in >> a[i]>>b[i];
	}

	std::sort(a.begin(), a.end());
	std::sort(b.begin(), b.end());
	int counta = 1;
	int countb = 1;
	std::vector<int> lista;
	std::vector<int> listacount;
	std::vector<int> listb;
	std::vector<int> listbcount;
	for (int i = 0; i < n / 2 - 1; i++) {
		if (a[i] != a[i + 1]) {
			lista.push_back(a[i]);
			listacount.push_back(counta);
			counta = 1;
		}
		else {
			counta++;
		}
		if (b[i] != b[i + 1]) {
			listb.push_back(b[i]);
			listbcount.push_back(countb);
			countb = 1;
		}
		else {
			countb++;
		}
	}

	lista.push_back(a[n / 2 - 1]);
	listacount.push_back(counta);

	listb.push_back(b[n / 2 - 1]);
	listbcount.push_back(countb);

	int maxa = 0;
	for (int i = 0; i < listacount.size(); i++) {
		maxa = std::max(listacount[i], maxa);
	}
	int maxb = 0;
	for (int i = 0; i < listbcount.size(); i++) {
		maxb = std::max(listbcount[i], maxb);
	}
	if (
		lista.at(indexOf(listacount, maxa)) != listb.at(indexOf(listbcount, maxb)) ||
		lista.at(lastIndexOf(listacount, maxa)) != listb.at(indexOf(listbcount, maxb)) ||
		lista.at(indexOf(listacount, maxa)) != listb.at(lastIndexOf(listbcount, maxb))
		) {
		std::cout << (n - maxa - maxb) << endl;
	}
	else {
		//List<Integer> seta = new ArrayList<>();
		//Collections.addAll(seta, maxa);
		//listacount.removeAll(seta);
		//List<Integer> setb = new ArrayList<>();
		//Collections.addAll(setb, maxb);
		//listbcount.removeAll(setb);

		listacount.erase(std::remove(listacount.begin(), listacount.end(), maxa), listacount.end());
		listbcount.erase(std::remove(listbcount.begin(), listbcount.end(), maxa), listbcount.end());

		int maxas = 0;
		for (int i = 0; i < listacount.size(); i++) {
			maxas = std::max(listacount.at(i), maxas);
		}
		int maxbs = 0;
		for (int i = 0; i < listbcount.size(); i++) {
			maxbs = std::max(listbcount.at(i), maxbs);
		}
		std::cout << std::min(n - maxas - maxb, n - maxa - maxbs) << endl;
	}


	return 0;
}
#endif


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

int main() {
	int N;
	int H[20];
	int ans = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> H[i];

		for (int j = 0; j <= i; j++) {
			if (j == i) ans++;

			else if (H[i] < H[j]) break;
		}
	}

	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        sc.close();
        boolean flag = true;
        while(true){
            c = c - b;
            if(c<1){
                System.out.println("Yes");
                return;
            }
            a = a - d;
            if(a<1){
                System.out.println("No");
                return;
            }
        }
    }
}

Measured memory_bytes: 35748
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

struct Node
{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node *treeMinimum(Node *x)
{
    while (x->left != NIL)
        x = x->left;
    return x;
}

Node *find(Node *u, int k)
{
    while (u != NIL && k != u->key)
    {
        if (k < u->key)
            u = u->left;
        else
            u = u->right;
    }
    return u;
}

Node *treeSuccessor(Node *x)
{
    if (x->right != NIL)
        return treeMinimum(x->right);
    Node *y = x->parent;
    while (y != NIL && x == y->right)
    {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z)
{
    Node *y;
    Node *x;

    if (z->left == NIL || z->right == NIL)
        y = z;
    else
        y = treeSuccessor(z);

    if (y->left != NIL)
    {
        x = y->left;
    }
    else
    {
        x = y->right;
    }

    if (x != NIL)
    {
        x->parent = y->parent;
    }

    if (y->parent == NIL)
    {
        root = x;
    }
    else
    {
        if (y == y->parent->left)
        {
            y->parent->left = x;
        }
        else
        {
            y->parent->right = x;
        }
    }

    if (y != z)
    {
        z->key = y->key;
    }

    free(y);
}

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL)
    {
        root = z;
    }
    else
    {
        if (z->key < y->key)
        {
            y->left = z;
        }
        else
        {
            y->right = z;
        }
    }
}

void inorder(Node *u)
{
    if (u == NIL)
        return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u)
{
    if (u == NIL)
        return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        cin >> com;
        if (com[0] == 'f')
        {
            scanf("%d", &x);
            Node *t = find(root, x);
            if (t != NIL)
                printf("yes\n");
            else
                printf("no\n");
        }
        else if (com == "insert")
        {
            scanf("%d", &x);
            insert(x);
        }
        else if (com == "print")
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if (com == "delete")
        {
            scanf("%d", &x);
            treeDelete(find(root, x));
        }
    }

    return 0;
}


Measured memory_bytes: 22060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <cmath>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define SQR(a) ((a)*(a))
using namespace std;
typedef long long int ll;
typedef pair<int,int> pr;
typedef pair<pr,ll> ppr;
typedef vector<pr> vpr;
const ll INF=(ll)1<<60;
ll DP[152][152][11];
int main() {
	int n,m,times,tmp;
	while(cin >> n >> m && n){
	ll block[152][11]={};
	ll x[152][11]={};
	REP(i,152)
		REP(j,152)
			REP(k,11)
				DP[i][j][k]=INF;
	REP(i,n){
		cin >> times;
		REP(j,times){
		cin >> x[i][j];
		cin >> block[i][j];
		}
	}
	REP(i,11){
	DP[0][0][i]=0;
	DP[1][1][i]=0;
	}
	FOR(i,1,n)
		REP(j,11)
			if(block[i][j])
			REP(l,m+1)
				REP(k,11){
					if(block[i-1][k])
					DP[i][l][j]=min(DP[i][l][j],DP[i-1][l][k]+abs(x[i][j]-x[i-1][k])*(block[i-1][k]+block[i][j]));
					if(block[i-2][k] && l && i!=1)
					DP[i][l][j]=min(DP[i][l][j],DP[i-2][l-1][k]+abs(x[i][j]-x[i-2][k])*(block[i-2][k]+block[i][j]));
				}
	ll minium=INF;
	REP(i,11)
		REP(j,m+1)
			minium=min(minium,DP[n-1][j][i]);
	if(m)
	REP(i,11)
		REP(j,m)
			minium=min(minium,DP[n-2][j][i]);
	cout << minium << endl;
	// your code goes here
	}
	return 0;
}

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

string lower(string str) {
    char c;
    for (int i = 0; i < str.size(); i++) {
        if (isupper(str[i])) {
            c = tolower(str[i]);
            str[i] = c;
        }
    }
    return str;
}


int main(void) {
    string w, s;
    int cnt = 0;
    cin >> w;
    w = lower(w);
    while (1) {
        cin >> s;
        if (s == "END_OF_TEXT") break;
        s = lower(s);
        if (s == w) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int K, S, ans = 0;
	cin >> K >> S;

	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			if(S-i-j>=0&&S-i-j<=K){
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main() {

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
constexpr int P = 1000000007, N = 5e3;
int dp[N + 1][N + 1];
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n, m;
    std::cin >> n >> m;
    for (int i = 1; i <= m; ++i)
        dp[0][i] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j)
            dp[i][j] = 1ll * (j + 1) * dp[i - 1][j] % P;
        for (int j = 1, k = 1; j <= m; ++j, k = 1ll * k * (P + 1) / 2 % P)
            dp[i - 1][j] = (dp[i - 1][j - 1] + 1ll * dp[i - 1][j] * j % P * k) % P;
        for (int j = 2, k = 1; j <= m; ++j, k = 2 * k % P)
            dp[i][j] = (dp[i][j] + 1ll * k * dp[i - 1][j - 1]) % P;
    }
    std::cout << dp[n][m] << std::endl;
    return 0;
}

Measured memory_bytes: 101340
import sys
input = sys.stdin.readline

def main():
    s = input().rstrip()

    hon = ['2','4','5','7','9']
    pon = ['0','1','6','8']
    bon = ['3']

    if s[-1] in hon:
        print('hon')
    elif s[-1] in pon:
        print('pon')
    else:
        print('bon')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9116
import java.util.*

val sc = Scanner(System.`in`)
val H = sc.nextInt()
val W = sc.nextInt()

fun main(args: Array<String>) {
    var a = Array(H) { sc.next() }

    for (i in 0 until 4) {
        a = a.filter { it.contains('#') }.toTypedArray()
        a = rotated(a)
    }
    println(a.joinToString("\n"))
}


fun rotated(a: Array<String>): Array<String> {
    val result = Array(a[0].length) { "" }

    for (i in 0 until a[0].length) {
        for (j in 0 until a.size) {
            result[i] += a[a.size - 1 - j][i].toString()
        }
    }
    return result
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> tosi(N,0);
  for (int i = 0; i < M; i++) {
    int a,b;
    cin >> a >> b;
    tosi.at(a-1) ++;
    tosi.at(b-1) ++;
  }
  for (int i = 0;i < N; i++) {
    cout << tosi.at(i) << endl;
  }  
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 1000005
#define NIL -1

struct Node{
  int p,l,r;
} ;
struct Node tree[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  printf("node %d: parent = %d, depth = %d, ",u,tree[u].p,D[u]);
  if(tree[u].p==NIL){
    printf("root, ");
  }
  else if(tree[u].l==NIL){
    printf("leaf, ");
  }
  else{
      printf("internal node, ");
}
printf("[");
for(i=0,c=tree[u].l;c!=NIL;i++,c=tree[c].r) {
  if(i>0)printf(", ");
  printf("%d", c);
}
printf("]\n");
}

int rec(int num,int p){
  D[num] = p;
  if(tree[num].r!=NIL){
    rec(tree[num].r,p);
  }
  if(tree[num].l!=NIL){
    rec(tree[num].l,p+1);
  }
}
int main(){
  int i,j,d,c,v,l=0,r;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    tree[i].p = NIL;
    tree[i].l = NIL;
    tree[i].r = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0){
        tree[v].l = c;
      }
      else {
        tree[l].r = c;
      }
      l = c;
      tree[c].p = v;
    }
  }
  for(i=0;i<n;i++){
    if(tree[i].p==NIL){
      r = i;
    }
  }
  rec(r,0);
  for(i=0;i<n;i++)print(i);
  return 0;
}



Measured memory_bytes: 6364
#include<stdio.h>
#include<math.h>
typedef struct{
  double x;
  double y;
}point;
void kock(int,point,point);

int main(){

  int n;
  point p1,p2;

  scanf("%d",&n);
  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;
  printf("%.8f %.8f\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);
  return 0;
}
void kock(int n,point p1,point p2){

  double rad=60.0*M_PI/180.0;
  point s,t,u;
  
  if(n==0) return;
  //p1,p2から s,t,uを計算
  s.x=(2*p1.x+p2.x)/3;
  s.y=(2*p1.y+p2.y)/3;
  t.x=(p1.x+2*p2.x)/3;
  t.y=(p1.y+2*p2.y)/3;
  u.x=(t.x-s.x)*cos(rad)-(t.y-s.y)*sin(rad)+s.x;
  u.y=(t.x-s.x)*sin(rad)+(t.y-s.y)*cos(rad)+s.y;

  
  kock(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  kock(n-1,t,p2);
}



Measured memory_bytes: 2052
#include<iostream>
using namespace std;
int main(void)
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<a+b)
        cout << k;
    else if(k<a+b+c)
        cout << a-(k-a-b);
    else
        cout << a-c;
    return 0;
}


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

#define int long long
#define test int t; cin >> t; while (t--)
#define deb(x) cerr << "[" << #x  << " : "<< x << "]\n";
#define pb push_back
#define pp pop_back
#define mkp make_pair 
#define f first
#define s second
#define all(x) x.begin(),x.end()

#define MOD 1000000007
#define MAX 50000

typedef long double ld;
const int N = 1e5 + 10;
const int maxn = 2e6 + 10;
const long double Pie = acos(-1);

signed main() {

	int n;
	cin >> n;
	
	int arr[n];
	
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	
	int maxx = arr[0], ans = 0;
	
	for (int i = 1; i < n; i++) {
		if (arr[i] <= maxx) {
			ans += maxx - arr[i];	
		}
		else {
			maxx = arr[i];
		}
	}
	
	cout << ans;
	
	return 0;
}

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

int main(void) {
	char b;
	cin >> b;
	if (b == 'A' or b =='T') {
		cout << (b=='A' ? 'T' : 'A') << endl;
	}
	else {
		cout << (b == 'C' ? 'G' : 'C') << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char C[3][3];
	char s[3];

	for (int i = 0; i < 3; i++) {
		scanf("%s", C[i]);
	}

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (i == j)s[i] = C[i][j];
		}
		printf("%c", s[i]);
	}
	printf("\n");

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B,K;cin>>A>>B>>K;
    vector<int>sol;
    int len = 0;
    for (int i=1;i<=100;i++){
        int X = A % i;
        int Y = B % i;
        if(X == 0 and Y == 0) {
            len++;
            sol.push_back(i);
        }
    }
    cout << sol[len-K]<< endl;
    return 0;
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;




int main() {

char c;
cin>>c;
cout<<(char)(c+1)<<endl;

return 0;
}

Measured memory_bytes: 3556
import numpy as np
from copy import deepcopy

N, K = map(int,input().split())
X = list(map(int,input().split()))

X_plus = [x for x in X if x > 0]
X_minus = list(reversed([abs(x) for x in X if x < 0]))

X_plus.append(int(1e10)) # 無限大を加えておく
X_minus.append(int(1e10))

if 0 in X: # ろうそくが0にある時の処理
  K -= 1

if K == 0:
  ans = 0
elif K == 1:
  ans = min(X_plus[0], X_minus[0])
else:
  ans = int(1e10) # 初期値
  if len(X_plus) >= K: # 正方向に一直線で進む場合
    var_straight_plus = X_plus[K-1]
    ans = min(ans, var_straight_plus)
  if len(X_minus) >= K: # 負方向に一直線で進む場合
    var_straight_minus = X_minus[K-1]
    ans = min(ans, var_straight_minus)
  # 一度折り返してから正方向に進む場合
  lst_return_plus = [] 
  for s in range(max(1, K-len(X_plus)), min(len(X_minus), K-1)+1):
    var = 2 * X_minus[s-1] + X_plus[K-s-1]
    lst_return_plus.append(var)
  var_return_plus = min(lst_return_plus)
  ans = min(ans, var_return_plus)
  # 一度折り返してから負方向に進む場合
  lst_return_minus = [] 
  for s in range(max(1, K-len(X_minus)), min(len(X_plus), K-1)+1):
    var = 2 * X_plus[s-1] + X_minus[K-s-1]
    lst_return_minus.append(var)
  var_return_minus = min(lst_return_minus)
  ans = min(ans, var_return_minus)
  

print(ans)
  
  
  

Measured memory_bytes: 23092
//
// Created by Huang,Zhiqiang on 2018/7/28.
//

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int n, m;
vector<pair<int, int>> b;

bool cmp(pair<int, int>& p1, pair<int, int>& p2) {
    if (p1.first < p2.first) return true;
    if (p1.first == p2.first) return p1.second < p2.second;
    return  false;
}

int main() {
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        b.push_back(make_pair(x, y));
    }
    sort(b.begin(), b.end(), cmp);
    pair<int, int> t = b[0];
    int ans = 1;
    for (int i = 1; i < m; i++) {
        if (b[i].first < t.second) {
            t.first = b[i].first;
            t.second = min(b[i].second, t.second);
        } else {
            ans++;
            t = b[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
sum=[1 for i in range(n)]
red=[0 for i in range(n)]
red[0]=1
for i in range(m):
  sum[l[i][0]-1]-=1
  sum[l[i][1]-1]+=1
  if red[l[i][0]-1]==1:
    red[l[i][1]-1]=1
  if sum[l[i][0]-1]==0:
    red[l[i][0]-1]=0
ct=0
for i in range(n):
  if sum[i]!=0 and red[i]==1:
    ct+=1
print(ct)

Measured memory_bytes: 29000
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    n = int(input())
    a = list(map(int, readline().split()))

    def factorization(n):
        factors = []

        while n % 2 == 0:
            factors.append(2)
            n //= 2

        for i in range(3, int(n ** 0.5) + 5, 2):
            while n % i == 0:
                factors.append(i)
                n //= i
        if n != 1:
            factors.append(n)

        return Counter(factors)

    a_fac = [0] * n

    for i, num in enumerate(a):
        a_fac[i] = factorization(num)

    lcm = {1: 1}

    for fac in a_fac:
        for key, value in fac.items():
            lcm[key] = max(lcm.get(key, 0), value)

    ans = 0

    lcmmod = 1

    for key, value in lcm.items():
        lcmmod *= pow(key, value, MOD)
        lcmmod %= MOD

    for ele in a:
        ainv = pow(ele, MOD - 2, MOD)
        ans += ((lcmmod*ainv) % MOD)
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 58332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
int n,ans=0;
string s;
void Main(){
    cin>>n;
    vector<vector<int>> syougen(n,vector<int> (n,-1));
    For(i,0,n){
        int a;cin>>a;
        For(j,0,a){
            int x,y;cin>>x>>y;x--;
            syougen[i][x]=y;
        }
    }/*
    For(i,0,n){
        For(j,0,n){
            cout<<syougen[i][j]<<" ";
        }
        cout<<endl;
    }*/
    For(i,0,1<<n){
        //cout<<endl<<i;
        bool isOK=true;
        For(j,0,n){
            bool flagj=(i>>j)&1;
            //cout<<" "<<flagj;
            For(k,0,n){
                if(i/(1<<k)%2==0) continue;
                if(j==k) continue;
                if(syougen[k][j]==flagj) continue;
                if(syougen[k][j]==-1) continue;
                isOK=false;
                //cout<<"dame "<<syougen[k][j]<<flagj;
            }
        }
        if(isOK){
            int ansi=0;
            For(j,0,n){
                ansi+=(i>>j)&1;
            }
            ans=max(ans,ansi);
        }
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
from collections import defaultdict
def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    Acum = [0] + list(accumulate(A))
    dic = defaultdict(int)
    ans = 0
    for i in range(N + 1):
        ans += dic[Acum[i]]
        dic[Acum[i]] += 1

    print(ans)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 44480
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    int sum = 0;
    
    cin >> x >> y;
    
    if(x == 1){
        sum += 300000;
    } else if(x == 2){
        sum += 200000;
    } else if(x == 3){
        sum += 100000;
    }
    
    if(y == 1){
        sum += 300000;
    } else if(y == 2){
        sum += 200000;
    } else if(y == 3){
        sum += 100000;
    }
    
    if(x == 1 && y == 1){
        sum += 400000;
    }
    
    cout << sum << endl;
    
    return 0;
}


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

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

   s[k-1] = s[k-1] - 'A' + 'a';
   cout << s << endl;

   return 0;
}


Measured memory_bytes: 256
# 区画数
section_count = int(input())
# チェック済みチェック
checked = [False] * section_count
# 区画毎の高さ
section_list = list(map(int, input().split()))
sorted_section_list = sorted(zip(section_list, range(section_count)))

# 海面の高さ(前)
pre_sea_level = 10 ** 9

count = 0
ans = 0
while sorted_section_list:
    # 海面の高さ、ソート前の要素番号を取得
    sea_level, number = sorted_section_list.pop()
    if sea_level != pre_sea_level:
        ans = max(ans, count)
    if sea_level <= 0:
        break

    count += 1
    checked[number] = True
    
    # 隣の区画が海面より上かをチェック。隣合っていれば地続きとしてカウントダウン
    if number > 0 and checked[number - 1]:
        count -= 1
    if number < section_count - 1 and checked[number + 1]:
        count -= 1
    
    pre_sea_level = sea_level

ans = max(ans, count)
print(ans)


Measured memory_bytes: 20980
import sys
ans = False
ans_str = {True:'YES', False:'NO'}
# 7 chars
target = 'keyence'

input_str = input()
input_len = len(input_str)
if target in input_str:
    if input_str.index(target) == 0:
        print('YES')
    elif input_str.index(target) == -7:
        print('YES')
    else:
        print('NO')
    sys.exit()
else:
    for i in range(6):
        if input_str.find(target[:(i+1)]) == 0 and input_str[-(6-i):] == target[(i+1):]:
            print('YES')
            sys.exit()
    print('NO')
    sys.exit()


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

int main(void) {
	int did=0;
	int p,s;
	int price[100][10];
	int price_unknown[100][10];
	int price_unknown_raw[100][10];
	char buffer[20];
	int i,j;
	int updated;
	int error;
	int missing_exist;
	int missing_id;
	int missing_number;
	int sum;
	while(1) {
		scanf("%d",&p);
		if(p==0)break;
		scanf("%d",&s);
		if(did)putchar('\n');
		memset(price,0,sizeof(price));
		memset(price_unknown,0,sizeof(price_unknown));
		memset(price_unknown_raw,0,sizeof(price_unknown_raw));
		for(i=0;i<=p;i++) {
			for(j=0;j<=s;j++) {
				scanf("%s",buffer);
				if(buffer[0]=='?' && buffer[1]==0) {
					price_unknown[i][j]=1;
					price_unknown_raw[i][j]=1;
				} else {
					price[i][j]=atoi(buffer);
				}
			}
		}
		updated=1;
		error=missing_exist=0;
		while(updated && !error) {
			updated=0;
			missing_exist=0;
			for(i=0;i<p;i++) {
				missing_number=missing_id=0;
				sum=0;
				for(j=0;j<s;j++) {
					if(price_unknown[i][j]) {
						missing_number++;
						missing_id=j;
						missing_exist=1;
					} else {
						sum+=price[i][j];
					}
				}
				if(missing_number==1) {
					price[i][missing_id]=price[i][s]-sum;
					price_unknown[i][missing_id]=0;
					updated=1;
				} else if(missing_number==0) {
					if(sum!=price[i][s])error=1;
				}
			}
			for(j=0;j<s;j++) {
				missing_number=missing_id=0;
				sum=0;
				for(i=0;i<p;i++) {
					if(price_unknown[i][j]) {
						missing_number++;
						missing_id=i;
						missing_exist=1;
					} else {
						sum+=price[i][j];
					}
				}
				if(missing_number==1) {
					price[missing_id][j]=price[p][j]-sum;
					price_unknown[missing_id][j]=0;
					updated=1;
				} else if(missing_number==0) {
					if(sum!=price[p][j])error=1;
				}
			}
		}
		if(error || missing_exist) {
			puts("NO");
		} else {
			for(i=0;i<p;i++) {
				for(j=0;j<s;j++) {
					if(price_unknown_raw[i][j])printf("%d\n",price[i][j]);
				}
			}
		}
		did=1;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
    ll a,b,c,d; cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
}

Measured memory_bytes: 256
// C - Streamline
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()

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

	vi X(M); rp(i, M) cin>>X[i];

	sort(all(X));

	vi P(M-1);
	int pre = X[0];
	rp(i, M-1){
		int now = X[i+1];
		P[i] = abs(now-pre);
		pre = now;
	}

	sort(all(P));

	int ans = 0;
	rp(i, M-N) ans += P[i];
	cout<< ans <<endl;
}

Measured memory_bytes: 1024
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string S;
	std::cin >> S;
	
	std::cout << std::string(S.size(), 'x') << "\n";
}


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

typedef long long int ll;

int main(){
    ll a , b , c ,d; cin >> a >> b >> c >> d;
    ll e = (c*d)/(__gcd(c ,d));
    ll cc = b/c - (a-1)/c;
    // cc/=2;
    // if(((a + c - (a%c))/c)%2 == 0){
    //     cc++;
    // }
    ll dd = b/d - (a-1)/d;
    // dd/=2;
    // if(((a+d - (a%d))/d)%2 == 0){
    //     dd++;
    // }
    ll ee = b/e - (a-1)/e;
    // ee/=2;
    // if(((a+e - (a%e))/e)%2 == 0){
    //     ee++;
    // }
    if(e > b){
        ee = 0;
    }
    //cout << cc << " " << dd << " " << ee << '\n';
    ll ans = cc + dd - ee;
    ans = b - (a-1) - ans;
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)
#define shosu(x) fixed<<setprecision(x)
typedef long long ll;

int main()
{	
	ll n,k; cin>>n>>k;
	ll a[5];
	a[0]=9*9%11;
	a[1]=10*9%11;
	a[2]=11*9%11;
	a[3]=12*9%11;
	a[4]=13*9%11;
	ll cnt = 0;
	rep(i,5){
		int b=0;
		while(1){
			if(a[i]==k)
				break;
			a[i]=(a[i]+8)%11;
			b++;
		}
		int tmp=(n-3-b)/11+1;
		if(3+b>n)tmp=0;
		cnt+=tmp;
	}
	
	
	cout<<cnt<<endl;


	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <bitset>
#include <unordered_map>
using namespace std;
int dp[110][110];
char ch[110];
int n,pd[110];
unordered_map<long long,int>M[60];
const int mo=998244353;
long long find(int n,long long K){
	if (n==0) return 1;
	if (M[n][K]) return M[n][K];
	int ans=0;
	ans=((K&1)+1)*find(n-1,K>>1)%mo;
	for (int len=1;len<=n/2;len++){
		long long w=(1ll<<len)-1;
		long long sta=K&w,cur=K>>len;
		int rem=n-len-len;
		int R=len*2;
		while (R<=n){
			long long now=cur&w; cur>>=len;
			sta&=now;
			ans=(ans+1ll*find(len,sta)*find(rem,cur))%mo;
			rem-=len; R+=len;
		}
	}
	M[n][K]=ans; return ans;
}
int main(){
	scanf("%s",ch+1); n=strlen(ch+1);
	for (int i=1;i<=n+1;i++) dp[i][i-1]=1;
	for (int len=1;len<=n;len++)
		for (int l=1;l<=n-len+1;l++){
			int r=l+len-1;
			if (ch[l]=='1') dp[l][r]=2*dp[l+1][r]%mo;
			else dp[l][r]=dp[l+1][r];
			for (int mid=l;mid<=r;mid++){
				int len=mid-l+1;
				int R=mid+len;
				long long sta=0;
				for (int i=l;i<=mid;i++) if (ch[i]=='1') sta+=(1ll<<i-l);
				while (R<=r){
					int L=R-len+1;
					long long now=0;
					for (int i=L;i<=R;i++) if (ch[i]=='1') now+=(1ll<<i-L);
					sta&=now;
					dp[l][r]=(dp[l][r]+1ll*find(len,sta)*dp[R+1][r])%mo;
					R+=len;
				}
			}
		//	cout<<l<<" "<<r<<" "<<dp[l][r]<<endl;
		}
	printf("%d\n",dp[1][n]);
	return 0;
}



Measured memory_bytes: 2176