akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 10;
const int mod = 1e9 + 7;
int c[maxN], w[maxN];
int minw[maxN];
int f[maxN], r[maxN], rf[maxN];
int cnt[maxN];
int n, x, y;

int main() {
	f[0] = rf[0] = r[1] = 1;
	for (int i = 1; i < maxN; ++i) {
		if (i > 1) r[i] = (mod - (mod/i)*1ll*r[mod%i]%mod)%mod;
		f[i] = f[i-1]*1ll*i%mod;
		rf[i] = rf[i-1]*1ll*r[i]%mod;
	}
	cin >> n >> x >> y;
	for (int i = 1; i <= n; ++i) minw[i] = 2e9;
	for (int i = 1; i <= n; ++i) {
		cin >> c[i] >> w[i];
		minw[c[i]] = min(minw[c[i]], w[i]);
	}
	for (int i = 1; i <= n; ++i) {
		if (minw[c[i]] + w[i] <= x) w[i] = minw[c[i]];
	}
	int color = min_element(minw+1, minw+n+1) - minw;
	int best = minw[color];
	int second = 2e9;
	for (int i = 1; i <= n; ++i) {
		if (i == color) continue;
		second = min(second, minw[i]);
	}
	int k = 0;
	int comm = 1;
	auto add = [&](int c) {
		k += 1;
		cnt[c] += 1;
	};
	for (int i = 1; i <= n; ++i) {
		if (color != c[i]) {
			if (best + w[i] <= y) add(c[i]);
		} else {
			if (best == w[i]) {			
				if (comm) {
					add(c[i]);
					comm = 0;
				} else {
					if (best + w[i] <= x or second + w[i] <= y) add(c[i]);
				}
			} else {
				if (second + w[i] <= y) add(c[i]);
			}
		}
	}
	int ans = f[k];
	for (int i = 1; i <= n; ++i) ans = ans*1ll*rf[cnt[i]]%mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll a,b;
	scanf("%lld%lld", &a,&b);
	ll ans = __gcd(a,b);
	printf("%lld\n", (a*b)/ans);
	return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;
bool vis[100000];
queue<int>q;
bool check(int a)
{
	if(a>=1&&a<=100000&&!vis[a])
	return 1;
	return 0;
}
bool bfs(int n)
{
	q.push(0);
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		if(x==n)
		return 1;
		if(check(x+100))
		{
			q.push(x+100);
			vis[x+100]=1;
		}
		if(check(x+101))
		{
			q.push(x+101);
			vis[x+101]=1;
		}
		if(check(x+102))
		{
			q.push(x+102);
			vis[x+102]=1;
		}
		if(check(x+103))
		{
			q.push(x+103);
			vis[x+103]=1;
		}
		if(check(x+104))
		{
			q.push(x+104);
			vis[x+104]=1;
		}
		if(check(x+105))
		{
			q.push(x+105);
			vis[x+105]=1;
		}
	}
	return 0;
}
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		while(!q.empty())
		q.pop();
		memset(vis,0,sizeof(vis));
		printf("%d\n",bfs(n));
	}
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	vector<int> l(n);
	for (int i = 0; i<n; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int ans = 0;
	for (int i = 0; i<k; i++) {
		ans += l[n - 1 - i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

inline int toInt(std::string s) {int v; std::istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {std::ostringstream sout;sout<<x;return sout.str();}

int main(int argc, char const *argv[])
{
	int a,L;
	int max,min;
	string s;
	vector<int>::iterator it;
	int j;

	while(1){
		cin>>a>>L;
		if(a+L==0) break;

		vector<int> v;
		v.push_back(a);

		while(1){

			s=toString<int>(a);

			while(s.size()<L) s+="0";
			
			sort(s.begin(), s.end());
			min=toInt(s);
			//sort(s.begin(), s.end(),greater<int>());
			reverse(s.begin(), s.end());
			max=toInt(s);
			
			a=max-min;
			it=find(v.begin(), v.end(),a);
			if(it!=v.end()) break;

			v.push_back(a);

		}
		j=distance(v.begin(),it);
		cout<<j<<" "<<a<<" "<<v.size()-j<<endl;


	}

	return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll dp[101][4][4][4];

int main(){
	int n;
	cin >> n;
	dp[0][3][3][3] = 1;
	for(int len=0; len<n; len++){
		for(int c1=0; c1<4; c1++){
			for(int c2=0; c2<4; c2++){
				for(int c3=0; c3<4; c3++){
					for(int c4=0; c4<4; c4++){
						if(c2 == 0 && c3 == 1 && c4 == 2) continue;
						if(c2 == 1 && c3 == 0 && c4 == 2) continue;
						if(c2 == 0 && c3 == 2 && c4 == 1) continue;
						if(c1 == 0 && c3 == 1 && c4 == 2) continue;
						if(c1 == 0 && c2 == 1 && c4 == 2) continue;
						dp[len+1][c2][c3][c4] += dp[len][c1][c2][c3];
						dp[len+1][c2][c3][c4] %= mod;
					}
				}
			}
		}
	}
	ll ans = 0;
	for(int i=0; i<4; i++){
		for(int j=0; j<4; j++){
			for(int k=0; k<4; k++){
				ans += dp[n][i][j][k];
			}
		}
	}
	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*input
4 7 3
3 2
4 3
2 1
4 4

21 77 68
16 73
16 99
19 66
2 87
2 16
7 17
10 36
10 68
2 38
10 74
13 55
21 21
3 7
12 41
13 88
18 6
2 12
13 87
1 9
2 27
13 15
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 200005
#define bit(x,y) ((x>>y)&1LL)
#define na(x) (#x) << ":" << x
const int mod = 1e9 + 7;
ostream& operator << (ostream &os, vector<int>&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << sp;
	return os;
}
ostream& operator << (ostream &os, pair<int, int> x) {
	cout << x.fi << sp << x.se << sp;
	return os;
}
ostream& operator << (ostream &os, vector<pair<int, int> >&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << endl;
	return os;
}

struct dsu {
	int par[N];
	dsu() {
		for (int i = 1; i <= N - 5; i++) par[i] = i;
	}
	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}
	void uni(int x, int y) {
		x = find(x); y = find(y);
		if (x != y) par[x] = y;
	}
} d;

#define pow binPow
long long binPow(long long a, long long q) {
	long long ret = 1;
	for (int i = 0; (1LL << i) <= q; i++) {
		if (q & (1LL << i)) ret = (ret * a) % mod;
		a = (a * a) % mod;
	}
	return ret;
}

#define exp exp__
int n, X, Y;
pair<int, int> a[N];
vector<vector<pair<int, int> > > haveCol(N);
vector<vector<int> > mem(N);
int exp[N];

void prep() {
	exp[1] = 1;
	for (int i = 2; i <= N - 5; i++) exp[i] = exp[i - 1] * i % mod;
}

pair<int, int> mn = mp(2e9, 0);
pair<int, int> mn2 = mp(2e9, 0);
void makeEdge() {
	for (int i = 1; i <= n; i++) {
		sort(haveCol[i].begin(), haveCol[i].end());
		for (int j = 1; j < haveCol[i].size(); j++) {
			if (haveCol[i][j].fi + haveCol[i][0].fi <= X) {
				d.uni(haveCol[i][0].se, haveCol[i][j].se);
			}
			else break;
		}
	}
	for (int i = 1; i <= n; i++) {
		int c = a[i].se + a[mn.se].se;
		if (a[i].fi == a[mn.se].fi && c <= X) d.uni(i, mn.se);
		else if (a[i].fi != a[mn.se].fi && c <= Y) d.uni(i, mn.se);
	}
	for (int i = 1; i <= n; i++) {
		int c = a[i].se + a[mn2.se].se;
		if (a[i].fi == a[mn2.se].fi && c <= X) d.uni(i, mn2.se);
		else if (a[i].fi != a[mn2.se].fi && c <= Y) d.uni(i, mn2.se);
	}
}

void solve() {
	for (int i = 1; i <= n; i++) {
		int u = d.find(i);
		mem[u].push_back(a[i].fi);
	}
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		sort(mem[i].begin(), mem[i].end());
		if (mem[i].size() >= 2) {
			ans = ans * exp[mem[i].size()] % mod;
			int cnt = 1;
			for (int j = 1; j < mem[i].size(); j++) {
				if (mem[i][j] != mem[i][j - 1]) {
					ans = ans * binPow(exp[cnt], mod - 2) % mod;
					cnt = 1;
				}
				else cnt++;
			}
			ans = ans * binPow(exp[cnt], mod - 2) % mod;
		}
	}
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef UncleGrandpa
	freopen("1test.inp", "r", stdin);
#endif
	cin >> n >> X >> Y;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].fi >> a[i].se;
		mn = min(mn, mp(a[i].se, i));
		haveCol[a[i].fi].push_back(mp(a[i].se, i));
	}
	for (int i = 1; i <= n; i++) {
		if (a[i].fi == a[mn.se].fi) continue;
		mn2 = min(mn2, mp(a[i].se, i));
	}
	prep();
	makeEdge();
	solve();
}

Measured memory_bytes: 27136
s = list(input())
ans = True
odds = ["R","U","D"]
evens = ["L","U","D"]
for i in s[::2]:
    if not i in odds:
        ans = False

for j in s[1::2]:
    if not j in evens:
        ans = False

if ans:
    print("Yes")
else:
    print("No")



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

int main()
{
  string s;
  while (cin >> s) {
    int joi = 0, ioi = 0;
    for (int i = 2; i < s.size(); ++i) {
      if (s[i-2] == 'J' && s[i-1] == 'O' && s[i] == 'I')
	++joi;
      if (s[i-2] == 'I' && s[i-1] == 'O' && s[i] == 'I')
	++ioi;
    }

    cout << joi << endl << ioi << endl;
  }
  return 0;
}

Measured memory_bytes: 0
a,b=map(int,input().split())

A=[]
B=[]

for x in range(1,20001):
  if (x*8)//100==a:
    A.append(x)
  if (x*10)//100==b:
    B.append(x)
    
c=set(A)&set(B)

if len(c)==0:
  print(-1)
else:
  print(min(c))

Measured memory_bytes: 9064
n,m = map(int,input().split())
li = []
for mi in range(m):
  tmp = list(map(int,input().split()))[1:]
  lli = [0]*n
  for ni in range(n):
    if (ni+1) in tmp:
      lli[ni] = 1
  li += [lli]
p = list(map(int,input().split()))
yyy = [0]*n
score = 0
while True:
  must1 = 1
  for mi in range(m):
    onoff = 0
    for ni in range(n):
      onoff += li[mi][ni]*yyy[ni]
    should1 = bool(onoff%2 == p[mi])
    must1 *= should1
  if must1 == 1:
    score += 1
  yyy[0] += 1
  for ni in range(n-1):
    if yyy[ni] == 2:
      yyy[ni] = 0
      yyy[ni+1] += 1
  if yyy[n-1] == 2:
    break
print(score)

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

int main() {
  int n;
  bool f1 = false, f9 = false, f7 = false, f4 = false;
  while (cin >> n) {
    if (n == 1) f1 = true;
    if (n == 9) f9 = true;
    if (n == 7) f7 = true;
    if (n == 4) f4 = true;
  }
  if (f1 && f9 && f7 && f4)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

xs = [0] * (max(a) + 1)

for v in a:
    if xs[v] == 0:
        for j in range(v, len(xs), v):
            xs[j] += 1
    else:
        xs[v] += 1
print(len(list(filter(lambda v: xs[v] == 1, a))))


Measured memory_bytes: 116736
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
A = read_ints()
A_ = set(A)
if len(A) == len(A_):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 25680
#include<stdio.h>
int main(void){
    int n;
    int l;
    int k;
    char s[50];
    scanf("%d",&n);
    scanf("%d",&l);
    k=l-1;
    scanf("%s",s);
    if(s[k]=='A')
    s[k]='a';
    if(s[k]=='B')
    s[k]='b';
    if(s[k]=='C')
    s[k]='c';
    printf("%s",s);
    return 0;
}

Measured memory_bytes: 128
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

vector<vector<int>> g(200100);

void dfs(int now, int p, int cnt, vector<int> &v)
{
	for (int next : g[now])
	{
		if (next == p)continue;
		dfs(next, now, cnt + 1, v);
	}
	v[now] = cnt;
}

int main()
{
	int n; cin >> n;
	rep(i, n - 1)
	{
		int a, b; cin >> a >> b;
		--a, --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> fromOne(200100), fromN(200100);
	dfs(0, -1, 0, fromOne);
	dfs(n - 1, -1, 0, fromN);
	int cnt = 0;
	rep(i, n)
	{
		if (fromOne[i] <= fromN[i])++cnt;
	}
	if (n - cnt >= cnt)cout << "Snuke" << endl;
	else cout << "Fennec" << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll A,B,C;
    cin >> A >> B >> C;
    if(A % 2 == 1 && B % 2 == 1 && C % 2 == 1){
        ll ans = min(A*B,A*C);
        ans = min(ans,B*C);
        cout << ans << endl;
    } else {
        cout << "0" << endl;
    }
}

Measured memory_bytes: 3520
// https://atcoder.jp/contests/abc046/tasks/arc062_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int c, int d) { return c / gcd(c, d) * d; }

int rup(int a, int b) { return (a + (b - 1)) / b; }
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a = 1, b = 1;
    cin >> n;
    REP(i, n) {
        int x, y;
        cin >> x >> y;
        int cx = rup(a, x);
        int cy = rup(b, y);
        int mul = max(cx, cy);
        // while (x * mul < a || y * mul < b) {
        //     mul++;
        // }
        a = x * mul;
        b = y * mul;
    }
    cout << a + b << endl;

    return 0;
}


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

#define int long long
int d(int a, int b) {
	if (a < b) {
		swap(a, b);
	}
	while (b > 0) {
		a = a%b;
		swap(a, b);
	}
	return a;
}
signed main() {
	int N, K;
	cin >> N >> K;
	int x = 0;
	int r;
	int maxr = -1;
	for (int i = 0; i < N; i++) {
		cin >> r;
		if (i == 0) {
			x = r;
		}
		else {
			x = d(x, r);
		}
		//cerr << x << endl;
		maxr = max(maxr, r);
	}
	
	if (K > maxr) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		if (K%x == 0) {
			cout << "POSSIBLE" << endl;
		}
		else {
			cout << "IMPOSSIBLE" << endl;
		}
	}

	return 0;
}

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

int main() {
	int A, B, count = 0;
  
	cin >> A >> B;
	
	for(int num = A; num <= B; num++) {
    	int n = 1000;
        vector<vector<int>> Num(2, vector<int>(5));
        
        Num.at(0).at(0) = num / 10000;
        Num.at(1).at(0) = num % 10000;
    
		for(int k = 1; k < 5; k++) { 
			Num.at(0).at(k) = Num.at(1).at(k - 1) / n;
			Num.at(1).at(k) = Num.at(1).at(k - 1) % n;
			n /= 10;
		}
      
		if(Num.at(0).at(0) == Num.at(0).at(4) && Num.at(0).at(1) == Num.at(0).at(3)) {		
            count++;
        }
    }
  
    cout << count << endl; 	
      
}


Measured memory_bytes: 256
function makelunlun(t)
    ret = []
    for x in t
        d = x % 10
        if d != 0
            push!(ret, 10x+d-1)
        end
        push!(ret, 10x+d)
        if d != 9
            push!(ret, 10x+d+1)
        end
    end
    ret
end

function solve(k)
    t = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    lunlun = copy(t)
    while length(lunlun) < k
        t = makelunlun(t)
        append!(lunlun, t)
    end
    sort!(lunlun)
    lunlun[k]
end

k = parse(Int, readline())
println(solve(k))

Measured memory_bytes: 184616
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  if (a+b > c+d)
    printf("Left\n");
  else if (a+b < c+d)
    printf("Right\n");
  else
    printf("Balanced\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> cnt(n+1, 1);
  REP(i, 2, n+1) {
    for(int j=i; j<=n; j+=i) {
      cnt[j]++;
    }
  }
  ll ans = 0;
  REP(i, 1, n+1) {
    int rem = n-i;
    ans += cnt[rem];
  }
  cout << ans-1 << endk;
  return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    
    string S;
    cin >> S;
    
    i64 len=S.length();
    i64 ans=0;
    set<char> st={'A','C','G','T'};
    rep(i,0,len){
        rep(j,0,len){
            string sub=S.substr(i,j-i+1);
            bool ok=true;
            for(auto c:sub){
                if(st.find(c)==st.end()){
                    ok=false;
                    break;
                }
            }
            if(ok){
                chmax(ans,(i64)sub.length());
            }
        }
    }
    
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, C, D = map(int, readline().split())

    if A * B > C * D:
        print(A * B)
    else:
        print(C * D)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9044
N = int(input())

ans = 0

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)

prime_list = prime_factorize(N)

# 通ったやつ
if prime_list:
    for prime_num in prime_list:
        if N % prime_num == 0:
            for j in range(1, 100):
                if N < prime_num**j:
                    break
                if N % prime_num**j == 0:
                    N //= prime_num**j
                    ans += 1

# 通ってないやつ
# if prime_list:
#     for prime_num in prime_list:
#         if N % prime_num == 0:
#             i = 1
#             while N % prime_num**i == 0:
#                 N //= prime_num**i
#                 ans += 1
#                 i += 1


print(ans)


Measured memory_bytes: 9168
#include<iostream>
using namespace std;
int main()
{
    int h, n;
    cin >> h >> n;
    int a, s = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a;
        s = s + a;
        if(s >= h)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h> 
using namespace std; 
#define deb(x) cout <<"\n"<< (#x) << " = " << (x) << "\n"
const long long  INF = 1e18;
const long long mod=1e9+7 ;
void inputoutput()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); 
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	    
}

void solve()
{
	int n,k;
	cin>>n>>k;
	vector<int> ar(n);
	for(int i=0 ; i<n ; ++i)
		cin>>ar[i];

	int dp[n];
	// dp[i][j] => if I start from this pos till ith positon the minimum i need 
	// to spend if i can stay only k minutes in a bus
			
	dp[n-1]=0;

	for(int i=n-2 ; i>=0 ; --i)
	{
		dp[i]=INT_MAX ;
		for(int m=0 , j=i+1 ; m<k && j<n ; ++m , ++j)
		{
			dp[i]=min(dp[j]+abs(ar[i]-ar[j]) , dp[i] ) ;	
		}
	}

	cout<<dp[0];
	cout<<"\n";


}
int32_t main()
{ 
	inputoutput() ;
	solve();


	return 0;
}


Measured memory_bytes: 4000
#include<iostream>
#include<vector>
using namespace std;
bool binarySearch(int key,vector<int>v,int n) {
	int left = 0, right = n;
	while (left < right) {
		int mid = (left + right) / 2;
		if (v[mid] == key)return true;
		else if (key < v[mid])right = mid;
		else if (v[mid] < key)left = mid + 1;
	}
	return false;
}
int main() {
	int n;
	cin >> n;
	vector<int>v;
	int x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		v.push_back(x);
	}
	int q,cnt=0;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> x;
		if (binarySearch(x, v, n))cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

###
# main
if(__name__ == '__main__'):
    # input
    n, m = map(int, input().split(" "))
    a_arr = list(map(int, input().split(" ")))
 
    sum = 0
    for a in a_arr:
        sum += a
    threshold = sum / (4*m)
 
    a_arr.sort()
 
    if a_arr[n-m] < threshold:
        print("No")
    else:
        print("Yes")

# else:
    # do nothing


Measured memory_bytes: 3060
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = input().rstrip()
    def digsum(n):
        res = 0
        while n:
            res += n%10
            n //= 10
        return res
    if len(n)==1:
        print(n)
    else:
        if n.count('9')==len(n):
            print(9*len(n))
        elif n.count('9')==len(n)-1 and n[0]!='9':
            print(digsum(int(n)))
        else:
            print(9*(len(n)-1)+int(n[0])-1)

if __name__ == '__main__':
    main()

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

typedef long long ll;

int main() {        
	int n;
	cin >> n;
	map<int,int> m;
	for (int i = 0; i < n; ++i) {
		int c;
		cin >> c;
		m[c]++;
	}
	int ans = 0;
	for (auto it = m.begin(); it != m.end(); ++it) {
		if (it->second > it->first) {
			ans += it->second - it->first;
		}
		if (it->second < it->first) {
			ans += it->second;
		}
	}
	cout << ans;
}






Measured memory_bytes: 7932
MOD = 10 ** 9 + 7

def mod_combination(n, k):
    def extended_gcd(a, b):
        if b == 0:
            return (a, 1, 0)
        d, x, y = extended_gcd(b, a % b)
        return (d, y, x - (a // b) * y)
    p, q = 1, 1
    for i in range(n - k + 1, n + 1):
        p = (p * i) % MOD
    for i in range(2, k + 1):
        q = (q * i) % MOD
    return p * (extended_gcd(q, MOD)[1] % MOD) % MOD

def mod_pow(a, b):
    return pow(a, b, MOD)

def mod_inv(a):
    return pow(a, MOD - 2, MOD)


N, M, K = map(int, input().split())

X = mod_pow(M, 2) * (mod_pow(N, 3) - N) % MOD
Y = mod_pow(N, 2) * (mod_pow(M, 3) - M) % MOD

comb = mod_combination(N * M - 2, K - 2)

ans = (X + Y) * mod_inv(6) % MOD * comb % MOD

print(ans)


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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  int d[n];
  rep(i, n) cin >> d[i];

  int ans = 0;
  rep(i, n) {
    rep(j, i) { ans += d[i] * d[j]; }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

int main(){
  int x1,x2,y1,y2;
  int r,l;
  cin>>x1>>y1>>x2>>y2;
  r=y2-y1;
  l=x2-x1;
  int x3,x4,y3,y4;
  x3=x2-r;
  y3=y2+l;

  x4=x1-r;
  y4=y1+l;
  
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
  return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)


int arr[100005];
int main(){
	int n, k, ans = 1e9;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	for (int i = 0; i + k <= n; i++){
		int j = i + k - 1, x = arr[i], y = arr[j];
		if (x < 0 && y > 0)ans = std::min(ans, std::min(-x, y) - x + y);
		else if (x >= 0) ans = std::min(ans, y);
		else ans = std::min(ans, -x);
	}
	cout << ans << endl;
}

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



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

    int taro = 0;
    int hanako = 0;

    for(int i = 0; i < n; i++){
        string t, h;
        cin >> t >> h;

        if(t > h){
            taro += 3;
        }
        else if(t < h){
            hanako += 3;
        }
        else{
            taro++;
            hanako++;
        }
    }
    cout << taro << " " << hanako << endl;
}


Measured memory_bytes: 3204
import java.util.Scanner;

// Java8
public class Main
{
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) throws Exception
	{
		new Main().run();
	}
	
	final long MOD = 1000000007;
	
	void run()
	{
		int n = sc.nextInt();
		int m = sc.nextInt();
		if(Math.abs(n - m)>1)
		{
			System.out.println(0);
			return;
		}
		long fn = factMod(n);
		long fm = factMod(m);
		long res = (fn * fm) % MOD;
		if(n==m) res = (res * 2) % MOD;
		System.out.println(res);
	}
	
	long factMod(int n)
	{
		long res = 1;
		for(int i=1; i<=n; i++)
		{
			res *= i;
			res %= MOD;
		}
		return (int)res;
	}
}


Measured memory_bytes: 23124
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	char ch;

	cin >> ch;

	cout << (char)(ch + 1) << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<ArrayDeque<Integer>> lists = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    lists.add(new ArrayDeque<>());
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < m; i++) {
		    int type = sc.nextInt();
		    if (type == 0) {
		        lists.get(sc.nextInt()).push(sc.nextInt());
		    } else if (type == 1) {
		        int idx = sc.nextInt();
		        if (lists.get(idx).size() > 0) {
		            sb.append(lists.get(idx).peek()).append("\n");
		        }
		    } else {
		        int idx = sc.nextInt();
		        if (lists.get(idx).size() > 0) {
		            lists.get(idx).pop();
		        }
		    }
		}
		System.out.print(sb);
	}
}



Measured memory_bytes: 168476
n,k = map(int,raw_input().split())
jis = [map(int, raw_input().split()) for _ in range(k)]
jis.sort()

dp = [0 for _ in xrange(n)]
dp[0] = 1
pre = [0 for _ in xrange(n)]
pre[0] = 1
mod = 998244353
for i in range(1,n):
	flag = True
	for u,v in jis:
		uu,vv = i - v, i - u
		
		if vv >= 0:
			dp[i] += pre[vv] - (pre[uu - 1] if uu - 1 >= 0 else 0)
			dp[i] %= mod
	pre[i] += dp[i] + pre[i-1]
	pre[i] %= mod

print dp[n-1]

Measured memory_bytes: 76032
program sample
	implicit none
    integer(8) :: x,y,count
    
    read(*,*) x,y
    
    if (x==1) then
    	count =count+300000
    else if (x==2) then
    	count = count+200000
    else if (x==3) then
    	count = count + 100000
    end if
    if (y==1) then
    	count =count+300000
    else if (y==2) then
    	count = count+200000
    else if (y==3) then
    	count = count + 100000
    end if
    if (x==1 .and. y==1) then
    	count = count + 400000
    end if

	write(*,*) count

	stop
end program sample

Measured memory_bytes: 2788
// https://atcoder.jp/contests/abc133/tasks/abc133_d

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// ll lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n), b(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    b[0] = 0;
    for (int j = 1; j < n; j++) {
        b[j] = a[j - 1] * 2 - b[j - 1];
    }

    ll t1 = (a[n - 1] * 2);
    ll t2 = (b[0] + b[n - 1]);
    b[0] = (t1 - t2) / 2;
    for (int j = 1; j < n; j++) {
        b[j] = a[j - 1] * 2 - b[j - 1];
    }
    for (int i = 0; i < n; i++) {
        cout << b[i];
        if (i < n - 1) {
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
#define lli long long int
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define ve vector<lli>
#define vep vector<pair<lli,lli> >
#define fr(i,n) for(lli i=0;i<(n);i++)
#define F first
#define S second
long long int gcd(long long int a,long long int b)
{
	if(a==0)return b;
	return gcd(b%a,a);
}
int bin(long int a[],long int low,long int high,long d,long day[])
{
	//cout<<low<<" "<<high<<" "<<d<<"\n";
	if(low>high)return -1;
	long mid=(low+high)/2;
	if(a[mid]>(a[low]+d)&&(a[mid-1]<=(a[low]+d)||day[mid-1])&&day[mid]==0)
		return mid;
	else if(a[mid]>(a[low]+d)&&day[mid]==0)
		return bin(a,low,mid-1,d,day);
	else
		return bin(a,mid+1,high,d-a[mid+1]+a[low],day);
}
long long power(long long a,long long b)
{
	//cout<<a<<" "<<b<<"\n";
	if(b==0)return 1;
	if(b%2==0)return (power((a*a),b/2));
	return ((a)*(power((a*a),b/2)));
}
/*int subtree(vector<int>v,int sub[],i,j)
{
	if(sub[i]>0)return sub[i];
	for(auto x:v[i])
	{
		if(x!=j)sub[i]+=subtree(v,sub,x,i);
	}
	return sub[i];
}*/
int edge[100010]={0};
bool cmp(int a,int b)
{
	return edge[a]>edge[b];
}	
bool sortbysecdesc(const pair<int,int> &a, 
                   const pair<int,int> &b) 
{ 
       return a.first>b.first; 
} 
int main()
{	
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
	int t=1;
	//cin>>t;
	for(int X=1;X<=t;X++)
	{
		//cout<<"Case #"<<X<<": ";
		int n,W,j;
		cin>>n>>W;
		int v[n],w[n],i,sum=0;
		fr(i,n)cin>>w[i]>>v[i];
		fr(i,n)sum+=v[i];
		//cout<<sum<<"\n";
		lli dp[sum+1]={0};
		fr(i,sum)dp[i+1]=1e18;
		//dp[0]=0;
		fr(i,n)
		{
			for(j=sum;j>=v[i];j--)
			{
				dp[j]=min(dp[j],w[i]+dp[j-v[i]]);
			}
			//dp[v[i]]+=w[i];
			//fr(i,sum+1)cout<<dp[i]<<" ";
			//cout<<"\n";
		}
		for(i=sum;i>=0;i--)
		{
			if(dp[i]<=W)break;
		}
		cout<<i<<"\n";
	}
	return 0;
}

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

int main() {
  int N ;
  string S ;
  cin >> N >> S ;
  if( N % 2 == 0 ){
    int ans ;
    cin >> ans ;
    ans = 0 ;
    for (int i = 0; i <= N / 2 - 1 ; ++i ){
      if ( S [i] == S [i + N / 2] ){
        ans += 2 ;
      }
      else{}
    }
    if( ans == N){
      cout << "Yes" << endl ;
    }
    else{
      cout << "No" << endl ;
    }
  }
  else{
    cout << "No" << endl ;
  }  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007;
#define INF 10*60;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N;cin>>N;
  int t=0;
  while(t*(t+1)/2<N){
    t++;
  }
  print(t)

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char str[1201] ;
    scanf("%[^\n]" , str) ;
    int p = 0 ;
    
    while(str[p] != '\0'){
        p++;
    }
    
    for(int i = 0 ; i < p ; i++){
        if(str[i] >= 'a' && str[i] <= 'z'){
            str[i] = str[i] - 32;
        }
        else if(str[i] >= 'A' && str[i] <= 'Z'){
            str[i] = str[i] + 32;
        }
    }
    printf("%s" , str);
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int int64_t
#define watch(x) cout << (#x) << " is " << (x) << endl

const int32_t MAX=1e9+7;
typedef vector<int> vi;
typedef vector<int64_t> vll;

int32_t main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;

    //Problem code start

    int n,maxh{0};
    cin >> n;
    vi v(n);
    cin >>v[0];
    for(int i=1;i<n;i++){
        cin >> v[i];
        if(v[i]<v[i-1]){
            maxh+=v[i-1]-v[i];
            v[i]=v[i-1];
        }
    }
    cout << maxh;
    return 0;
}

Measured memory_bytes: 4756
s = input()
st = ""
ma = "keyence"
l = []

if s[0:7] == ma or s[-7:] == ma:
    print("YES")
else:
    for i in range(len(ma)):
        if s[0:i] + s[-7+i:] == ma:
            print("YES")
            exit()
    else:
        print("NO")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n, m;
  cin >> n >> m;
  priority_queue<ll> a;
  ll b;
  rep(i,n) {
    cin >> b;
    a.push(b);
  }
  rep(i,m) {
    ll tmp = a.top()/2;
    a.pop();
    a.push(tmp);
  }
  ll ans = 0;
  while (!a.empty()) {
    ans += a.top();
    a.pop();
  }
  cout << ans << '\n';
}

Measured memory_bytes: 4276
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <iterator>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	int k;
	cin >> s >> k;
	const int n = s.size();
	set<string> pq;
	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j <= n && j <= i + k; ++j){
			pq.insert(s.substr(i, j - i));
			if(pq.size() > k){ pq.erase(prev(pq.end())); }
		}
	}
	cout << *pq.rbegin() << endl;
	return 0;
}



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


int main() {
  int A,B,M;
  cin >> A >> B >> M;
  
  vector<int>ref(A);
  vector<int>den(B);
  int minA=100000;
  int minB=100000;
  for(int i=0;i<A;i++){
    cin >> ref.at(i);
    minA = min(minA,ref.at(i));
  }
               
  for(int i=0;i<B;i++){
    cin >> den.at(i);
    minB = min(minB,den.at(i));
  }
  int ans = minA + minB;

  for(int i=0;i<M;i++){
    int x,y,z;
    cin >> x >> y >> z;
    x--;y--;
    int price = ref.at(x) + den.at(y) - z;
    ans = min(ans,price);
  }
  cout << ans << endl;            
   
}
        

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N, S; cin >> N >> S;
  int a[N], sum[N + 1];
  sum[0] = 0;
  rep(i, N) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }

  if(sum[N] < S) {
    cout << 0 << endl;
  }
  else {
    int ans = N;
    for(int i=0; sum[i] + S <= sum[N]; i++) {
      minimize(ans, lower_bound(sum + i, sum + N, sum[i] + S) - sum - i);
    }
    cout << ans << endl;
  }
  
  return 0;
}

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

typedef long long ll;
int mod = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int n = (int)s.size();
	for (int i = n - 1; i >= 0; --i) {
		if ((i + 1) % 2 == 0) {
			bool d = 1;
			string p = "";
			for (int j = 0; j < i / 2; ++j) {
				if (s[j] != s[(i / 2) + j]) {
					d = 0;
					break;
				}
				p += s[j];
			}
			if (d) {
				//cout << p << " ";
				cout << (int)p.size() * 2 ;
				return 0;
			}
		}
	}
	cout << 0;
}



















Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <string>
#include <cmath>

using ll = long long;
using namespace std;
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


int main() {

    int n;
    cin >> n;
    
    int a[n];
    for (int i = 1; i <= n; i++) a[i - 1] = i;

    int a1[n];
    int a2[n];
	
  	for(int i=0;i<n;i++) cin >> a1[i];
    for(int i=0;i<n;i++) cin >> a2[i];

    int a1n,a2n;
    int c = 0;
    do {
        bool t1 = true;
        bool t2 = true;
        for (int i = 0; i < n; i++) {
            if (a[i] != a1[i]) t1 = false;
            if (a[i] != a2[i]) t2 = false;
          	//cout << a[i] << " " << a1[i] << " " << a2[i] << endl;
        }
		
        if (t1) a1n = c;
        if (t2) a2n = c;
        c++;
    } while (next_permutation(a, a + n));

    cout << abs(a1n - a2n) << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
long long a[100005],k,n;
long long maxn;
int check(long long p)
{
    int i=0;
    for(int j=0;j<k;j++)
    {
        long long s=0;
        while(s+a[i]<=p)
        {
            s+=a[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}
int solve()
{
    long long left=0,right=maxn,mid;
    while(right-left>1)
    {
        mid=left+(right-left)/2;
        int v=check(mid);
        if(v>=n) right=mid;
        else left=mid;
    }
    return right;
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        maxn+=a[i];
    }
    int ans=solve();
    cout<<solve()<<endl;
    return 0;
}


Measured memory_bytes: 3880
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int r,c;
		r=scan.nextInt();
		c=scan.nextInt();
		int sheet[][]=new int[r+1][c+1];
		for(int i=0;i<r+1;i++) {
			for(int j=0;j<c;j++) {
					if(j==0)sheet[i][c]=0;
					if(i<r)sheet[i][j]=scan.nextInt();
					if(i==0)sheet[r][j]=sheet[i][j];
					else if(i<r)sheet[r][j]+=sheet[i][j];
					System.out.print(sheet[i][j]+" ");
					sheet[i][c]+=sheet[i][j];
			}
			System.out.println(sheet[i][c]);
		}
		scan.close();
	}

}


Measured memory_bytes: 39984
//8 Puzzle
#include<stdio.h>

#define N 100

int main(){
	int M[N][N];
	int n,u,k,v;
	int i,j;


	//input
	scanf("%d",&n);

	//init
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			M[i][j]=0;
		}
	}

	for(i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		u--;
		for(j=0;j<k;j++){
			scanf("%d",&v);
			v--;
			M[u][v]=1;
		}
	}


	//output
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(j){
				printf(" ");
			}
			printf("%d",M[i][j]);
		}
		printf("\n");
	}


	return 0;
}



Measured memory_bytes: 2052
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

int main() {

	string t = read_item();
	int len = t.size();

	for(auto i : range(len)) {
		if(t[i] == '?') {
			t[i] = 'D';
		}
	}

	printf("%s\n", t.c_str());

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 3752