akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var numArray = input.Select(x => long.Parse(x)).ToArray();

            var input2 = Console.ReadLine().Split(' ');
            var numArray2 = input2.Select(x => long.Parse(x)).ToArray();

            double max = 0;
            for (int i = 0; i < numArray2.Count(); i++)
            {
                max += numArray2[i];
            }

            var choose = max / (4 * numArray[1]);
            var choosed = numArray2.Where(x => x >= choose);

            if (choosed.Count() >= numArray[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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


int main() { 
  // find lucas number
  // L0 = 2
  // L1 = 1
  // L2 = 3
  
  int N;
  cin >> N; 

  vector<int64_t> L = {2,1};
  for (int i = 1; i <= N; i++) { 
    L.push_back(L.at(i-1)+L.at(i));
  }
  printf("%lld\n", L.at(N));
}
 


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int n;
	int l[205];
	cin>>n;
	for(int i=1;i<=2*n;i++)
	{
		cin>>l[i];
	}
	sort(l+1,l+2*n+1);
	int ans=0;
	for(int i=1;i<=2*n;i=i+2)
	{
		ans+=l[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

struct nodeI
{
    double x;
    double y;
};

struct nodeII
{
    int u;
    int v;
    double w;
};

nodeI point[10010];
nodeII edge[1000010];
int f[10010];
int n,m;

double cal(int u,int v)
{
    double sum;
    sum=sqrt((point[u].x-point[v].x)*(point[u].x-point[v].x)+(point[u].y-point[v].y)*(point[u].y-point[v].y));
    return sum;
}

int cmp(nodeII n1,nodeII n2)
{
    return n1.w>n2.w;
}

int getf(int p)
{
    if(f[p]==p)
    {
        return p;
    }
    else
    {
        f[p]=getf(f[p]);
        return f[p];
    }
}

int unite(int u,int v)
{
    int fu,fv;
    fu=getf(u);
    fv=getf(v);
    if(fu!=fv)
    {
        f[fv]=fu;
        return 1;
    }
    else
    {
        return 0;
    }
}

int main()
{
    double sum1,sum2;
    int i,cnt;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for(i=1;i<=n;i++)
        {
            scanf("%lf%lf",&point[i].x,&point[i].y);
        }
        sum1=0;
        for(i=1;i<=m;i++)
        {
            scanf("%d%d",&edge[i].u,&edge[i].v);
            edge[i].w=cal(edge[i].u,edge[i].v);
            sum1+=edge[i].w;
        }
        for(i=1;i<=n;i++)
        {
            f[i]=i;
        }
        sort(edge+1,edge+m+1,cmp);
        sum2=0,cnt=0;
        for(i=1;i<=m;i++)
        {
            if(unite(edge[i].u,edge[i].v))
            {
                sum2+=edge[i].w;
                cnt++;
            }
            if(cnt==n-1) break;
        }
        printf("%.3f\n",sum1-sum2);
    }
    return 0;
}


Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Segment_Tree{
	private:
	int n;
	vl date;
	ll Rec(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return 0;
		if(a<=l&&r<=b) return date[k];
		int m=(l+r)/2;
		return (Rec(a,b,k*2+1,l,m)+Rec(a,b,k*2+2,m,r))%mod;
	}
	public:
	Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=vl(2*n-1);
	}
	void Update(int k,int x){
		k+=n-1;
		(date[k]+=x)%=mod;
		while(k>0){
			k=(k-1)/2;
			date[k]=(date[k*2+1]+date[k*2+2])%mod;
		}
	}
	ll Query(int a,int b){
		return Rec(a,b,0,0,n);
	}
	ll Open(int k){
		return date[k+n-1];
	}
};

int n,m;
vi a,b;

int main(){
	cin>>n>>m;
	a=vi(n);
	b=vi(m);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<m;i++) cin>>b[i];
	vp c;
	for(int i=0;i<n;i++){
		int it=lower_bound(b.begin(),b.end(),a[i])-b.begin();
		if(it==0||it==m) continue;
		c.push_back({b[it]-a[i],a[i]-b[it-1]});
	}
	sort(c.begin(),c.end());
	c.erase(unique(c.begin(),c.end()),c.end());
	sort(c.begin(),c.end(),[](P p,P q){
		if(p.first==q.first) return p.second>q.second;
		return p<q;
	});
	vi d;
	int N=c.size(),id=1;
	for(int i=0;i<N;i++) d.push_back(c[i].second);
	sort(d.begin(),d.end());
	d.erase(unique(d.begin(),d.end()),d.end());
	map<int,int> mp;
	for(int i=0;i<d.size();i++) if(mp.find(d[i])==mp.end()){
		mp[d[i]]=id;
		id++;
	}
	for(int i=0;i<N;i++) c[i].second=mp[c[i].second];
	Segment_Tree st(N+1);
	st.Update(0,1);
	ll res=1;
	for(int i=0;i<N;i++){
		ll t=st.Query(0,c[i].second);
		st.Update(c[i].second,t);
		(res+=t)%=mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 10488
import sys
input = sys.stdin.readline
N,M = map(int,input().split())

x = [0] * N
y = [0] * N
z = [0] * N

for i in range(N):
    x[i],y[i],z[i] = map(int,input().split())

m = 0

#print(x,y,z)

for k in range(8):
    kk = k
    k1 = kk % 2
    kk //= 2
    k2 = kk % 2
    kk //= 2
    k3 = kk % 2

    s = [0] * N
    
    for i in range(N):
        s[i] = ((-1)**k1) * x[i] + ((-1)**k2) * y[i] + ((-1)**k3) * z[i]

    s.sort(reverse = True)
    #print(s)
    total = sum(s[:M]) 
    #print(total)
    m = max(total,m)

print(m)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <set>
#include <iostream>
using namespace std;
set<pair<int,long long > >st;
int n;
void output(){
	    auto it=st.begin();
		int i=1;
		while(i<=n){
			if(i<=it->first){
				cout<<it->second<<endl;
				++i;
			}
			else{
				++it;
			}
		}
}
int main(){
	int Q;
	scanf("%d%d",&n,&Q);
	st.insert(make_pair(n,0));
	while(Q--){
		int a;
		long long b;
		cin>>a>>b;
		while(b){
			auto it=st.lower_bound(make_pair(a,-1));
			if(it==st.begin()){
				int pos=it->first;
				long long val=it->second+b/a;
				if(pos==a){
					st.erase(it);
					st.insert(make_pair(a,val));
				}
				else{
					st.insert(make_pair(a,val));
				}
				b%=a;
				if(b){
					st.insert(make_pair(b,val+1));
					b=0;
				}

			}
			else{
				auto it0=it;
				--it0;
				//cout<<it->first<<" "<<it->second<<endl;
				//cout<<it0->first<<" "<<it0->second<<endl;
				int len=a-it0->first;
				long long tot=(it0->second-it->second)*len;
				if(b>=tot){
					b-=tot;
					long long cur=it->second+tot/len;
					if(a==it->first){
						st.erase(it);
						st.insert(make_pair(a,cur));
						st.erase(it0);
					}
					else{
						st.erase(it0);
						st.insert(make_pair(a,cur));
					}
				}
				else{
					long long add=b/len+it->second;
					if(a==it->first){
						st.erase(it);
						st.insert(make_pair(a,add));
					}
					else{
						st.insert(make_pair(a,add));
					}
					b%=len;
					if(b){
						st.insert(make_pair(it0->first+b,add+1));
					}
					b=0;
				}
			}
		}
	}
	output();
	//system("pause");
	return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


int main() {
    int n, h, w; cin >> n >> h >> w;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int a, b; cin >> a >> b;
        if(h <= a && w <= b) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <iostream>
using namespace std;
 
int main()
{
   int d,t,s;
   cin>>d>>t>>s;
   double res=(d*1.0)/s;
   if(res<=t)
   printf("Yes\n");
   else
   printf("No\n");
 
    return 0;
}

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

int main(){
  double d;
  cin>>d;
  int dint=d*1000;
  int dgauss = dint/1000;
  double ans=max(sqrt(2.0)*d,dgauss+1.0);
  cout<<fixed<<setprecision(15)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3276
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
const ll mod = 998244353;
const int N = 1e6+205;
void solve(){
	int n;
	cin>>n; 
	int bx = 0;
	int xa = 0;
	int ba = 0;
	int ans2 = 0;
	int ba2 = 0;
	int bx2 = 0;
	int xa2 = 0;
	for(int i=1;i<=n;i++){
		string s; 
		cin>>s;
		int z = s.size();
		if(s[0]=='B' and s[z-1]=='A')ba2++;
		if(s[0]=='B') bx2++;
		if(s[z-1]=='A')xa2++;
		if(s[0]=='B' and s[z-1]=='A')ba++;
		else if(s[0]=='B') bx++;
		else if(s[z-1]=='A')xa++;
		for(int j=0;j<z-1;j++){
			if(s[j]=='A' and s[j+1]=='B')ans2++;
		}
	}	
	int ans = min(xa,bx);
	int ans3 = min(xa2,bx2);
	if(max(bx2,xa2)==ba2)ans3--;
	xa-=ans;
	bx-=ans;
	/// BA + BA + BA + BA + BA + BA 
	if(ba>0){
		ans+=ba-1;
		ba = 1;
	}
	if((xa>0 or bx>0))ans+=ba;
	
	cout<<max(ans,ans3)+ans2<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
int x,y;
int main()
{
	cin>>x>>y;
	if(y%2==1)cout<<"No";
	else
	{
		if(y%4==0)
		{
			if(y/2>=x&&y/4<=x)cout<<"Yes";
			else cout<<"No";
		}
		else
		{
			if(y/2>=x&&(y-2)/4+1<=x)cout<<"Yes";
			else cout<<"No";
		}
	}
	return 0;
}

Measured memory_bytes: 3632
n,k = map(int,input().split())
lst = list(map(int,input().split()))
E = [0]
for x in lst:
  E.append((1+x)/2+E[-1])
s = 0
for i in range(n+1-k):
  if s < E[i+k] - E[i]:
    s = E[i+k] - E[i]
print(s)    

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

using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
//using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const ll inf = (ll)1e9 * 200;

map<ll, ll> was;
ll A, B, C, D;

ll get(ll x)
{
	//cout << "get " << x << endl;
	if (x == 0) return 0;
	if (x == 1) return D;
	auto &res = was[x];
	if (res != 0) return res;
	res = min((__int128)inf, (__int128)D * x);
	res = min(res, get(x / 2) + A + (x % 2) * D);
	if (x > 3) res = min(res, get(x / 2 + 1) + A + (2 - x % 2) * D);
	res = min(res, get(x / 3) + B + (x % 3) * D);
	res = min(res, get(x / 3 + 1) + B + (3 - x % 3) * D);
	res = min(res, get(x / 5) + C + (x % 5) * D);
	res = min(res, get(x / 5 + 1) + C + (5 - x % 5) * D);
	return res;
}

void solve()
{
	ll n;
	scanf("%lld%lld%lld%lld%lld", &n, &A, &B, &C, &D);
	was.clear();
	ll res = get(n);
	printf("%lld\n", res);
	//cout << was.size() << endl;
}

int main()
{
	int NT;
	scanf("%d", &NT);
	for (int T = 0; T < NT; T++)
	{
		solve();
	}
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    vector<long long> sum(n + 1, 0);
    int mod = 1e9 + 7;
    long long ans = 0;
    for (int i = 0; i < n; ++i){
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
    }
    for (int i = 0; i < n - 1; ++i){
        long long add = 1;
        long long temp = sum[n] - sum[i + 1];
        temp %= mod;
        add *= a[i];
        add *= temp;
        ans += add;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6388
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        boolean isAns = false;
        for (int i = 0; i < 3; i++) {
            if (n % 10 == 7) {
                isAns = true;
                break;
            }
            n = n / 10;
        }

        System.out.println(isAns ? "Yes" : "No");
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32744
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)

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

    vector<ll> d(N);

    rep(i, N) cin >> d[i];

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

    ll ans = 1;
    for (int i = 1; i < N; i++)
    {
        if (d[i - 1] != d[i])
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
int n,a,s[2];
priority_queue<int> d;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a),d.push(a);
	for(int i=1;i<=n;i++)
	{
		a=d.top();
		d.pop();
		s[i&1]+=a;
	}
	printf("%d",s[1]-s[0]);
}

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

int modTable[2001][2001];
long long m = 1000000007;
int t;
int nCrM(int n, int r)
{
    if(n == r || r == 0)
    {
        return 1;
    }
    else if((t = modTable[n][r]) != 0)
    {
        return t;
    }
    t = modTable[n][r] = modTable[n][n-r] = (nCrM(n-1,r)%m + nCrM(n-1,r-1)%m)%m;
    return t;
}

int main()
{
    int n, k;
    cin >> n >> k;
    int i = 1;
    long long mod1=0,mod2=0,mod3=0,mod4=0;
    long long ans;
    while(i <= k)
    {
        if(k==1)
        {
            mod1 = 1;
        }
        else
        {
            mod1 = nCrM(k-1,i-1);
        }
        
        if(n-k-1 > 0)
        {
            if(i-2 >= 0 && n-k-1 >= i-2)
            {
                mod2 = nCrM(n-k-1,i-2);
            }
            if(i-1 >= 0 && n-k-1 >= i-1)
            {
                mod3 = 2*nCrM(n-k-1,i-1);
            }
            if(i >= 0 && n-k-1 >= i)
            {
                mod4 = nCrM(n-k-1,i);
            }
        }
        else if(n-k == 1)
        {
            if(i == 1)
            {
                mod3 = 2;
            }
            else if(i == 2)
            {
                mod2 = 1;
            }
        }
        else if(n-k == 0)
        {
            if(i == 1)
            {
                mod2 = 1;
            }
        }
        
        //cout << mod1 << "|" << mod2 << "|" << mod3 << "|" << mod4 << endl;
        ans = (mod1 * ((mod2+mod3+mod4)%m)) % m;
        cout << ans << endl;
        mod2 = mod3 = mod4 = 0;
        i++;
    }
    //cout << nCrM(1949, 0);
    return 0;
}

Measured memory_bytes: 15104
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	s := strings.Split(sc.Text(), " ")

	A := make([]int, n)
	for i, v := range s {
		A[i], _ = strconv.Atoi(v)
	}

	flg := true
	cnt := 0

	for flg {
		flg = false
		for j := n - 1; j > 0; j-- {
			if A[j] < A[j-1] {
				A[j], A[j-1] = A[j-1], A[j]
				flg = true
				cnt++
			}
		}
	}

	for i, v := range A {
		fmt.Print(strconv.Itoa(v))
		if i < n-1 {
			fmt.Print(" ")
		} else {
			fmt.Println()
		}
	}
	fmt.Println(cnt)
}



Measured memory_bytes: 1144
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    n = int(input())
    #n, k = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    cur = 0
    ans = 0
    for i in range(n):
        x, y = map(int, input().split())
        if x == y:
            cur += 1
        else:
            ans = max(ans, cur)
            cur = 0
    ans = max(ans, cur)
    print("Yes" if ans >= 3 else "No")

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


int main(){

    int N, M;
    string s[100], t[100];
    cin >> N;
    for( int i = 0; i < N; i++ ) cin >> s[i];
    cin >> M;
    for( int i = 0; i < M; i++ ) cin >> t[i];
    

    vector<int> ans(N);

    for( int i = 0; i < N; i++ ){
        for( int j = 0; j < N; j++ ){
            if( s[i] == s[j] ) ans[i]++;
        }
    }

    for( int i = 0; i < N; i++ ){
        for( int j = 0; j < M; j++ ){
            if( s[i] == t[j] ) ans[i]--;
        }
    }

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

    if( ans[N-1] < 0 ) cout << 0 << endl;
    else cout << ans[N-1] << endl;

    return 0;

}

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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

ll dp[101][100001];

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

  int w[n], v[n];
  for(int i = 1; i <= n; i++){
    cin >> w[i] >> v[i];
  }

  for(int i = 1; i <= n; i++){
    for(int j = 0; j <= maxw; j++){
      dp[i][j] = dp[i-1][j];
      if(j-w[i] >= 0){
        dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
      }
    }
  }

  cout << dp[n][maxw] << endl;

  return 0;
}


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int* arr = new int[n+1];
  memset(arr,0,sizeof arr);
  for(int i = 1;i < n; i++) {
    int a;
    scanf("%d", &a);
    arr[a]++;
  }
  for(int i = 1;i <= n; i++)
    printf("%d\n", arr[i]);
  return 0;
}

Measured memory_bytes: 4540
#include <stdio.h>

int main()
{
	long long a = 0;
	int n, l = 0;
	scanf ("%d", &n);
	for (int i = 0; i < n; i++){
		int x; scanf ("%d", &x);
		if (l <= x) l = x;
		else a += l - x;
	}
	printf ("%lld\n", a);
	return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
#include <ctime>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
#define in(i,arr) for(auto &i:arr)cin>>i;
#define all(x) (x).begin(), (x).end()   // sort(all(v)) instead sort(v.begin(),v.end())
int main() {
    fast;
    int t = 1;
    //cin >> t;
    while (t--) {
       int x;
       cin>>x;
       if(x>=30)
           cout<<"Yes";
       else
           cout<<"No";

    }
}



Measured memory_bytes: 3628
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7),n;
	static long cf = 998244353;
    static final int MAX = (int) 1e6;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static long[] Bit;
    public static long[] fac,inv;
    public  static int[] prime; 
    public static long[] dp;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);
 
		int n = sc.nextInt();
		String s = sc.next();
		if(n%2 == 0) {
	        String t = s.substring(0,n/2);
	        
			if(s.equals(t.concat(t))) out.print("Yes");
			else out.print("No");
		}else out.print("No");
		out.close();
	}
	
	
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9
int N;
string S;

int main(){
  cin >> N >> S;
  int ans =0;
  vector<vector<int>> memo(N+2, vector<int>(N+2, 0));
  REP(i, S.size()-1){
    FOR(j, i+ans+1, S.size()-ans){
      int len = memo[i][j] > 0 ? memo[i][j]-1 : 0;
      while((j+len < S.size()) && i+len < j){
        if(S[i+len] == S[j+len]){
          len++;
        }
        else{
          break;
        }
      }
      memo[i+1][j+1] = len;
      ans = max(ans, len);
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    scanf(" %d", &n);

    if(n==1)
    {
        printf("! 1\n");
        fflush(stdout);
        return 0;
    }

    vector<int> dist0(n+1);
    for(int i=2; i<=n; ++i)
    {
        printf("? 1 %d\n", i);
        fflush(stdout);

        scanf(" %d", &dist0[i]);
    }

    int A=-1;
    int max_dist0=0;
    for(int i=2; i<=n; ++i)
    {
        if(max_dist0 < dist0[i])
        {
            max_dist0 = dist0[i];
            A = i;
        }
    }

    assert(A>0);

    vector<int> x(n);
    x[0]=A;
    for(int i=1; i<=n; ++i)if(A!=i)
    {
        printf("? %d %d\n", A,i);
        fflush(stdout);

        int d;
        scanf(" %d", &d);
        x[d]=i;
    }

    // output
    printf("!");
    rep(i,n) printf(" %d", x[i]);
    printf("\n");
    fflush(stdout);
    return 0;
}

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

using namespace std;

void solve1() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		cout << s[i];
		if (i == 3)
			cout << " ";
	}
	cout << endl;
}

int main() {
	solve1();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
int main()
{
	int n;
	cin>>n;
	map<string,int> a;
	for(int i=0;i<n;i++)
	{
		string ss;
		cin>>ss;
		if(a.count(ss)==1)
			a[ss]++;
		else
			a[ss]=1;
	//	a[ss]=0;	
	}
	int m;
	cin>>m;
	int lose=1;
	for(int i=0;i<m;i++)
	{
		string ss;
		cin>>ss;
		if((a.count(ss)==0||a[ss]<1)&&lose)
		{
			cout<<"NO"<<endl;
			lose=0;
		}
		else
		{
			a[ss]--;
		}
	}	
	if(lose)
		cout<<"YES"<<endl;
	//cout<<a[ss];
	return 0;
}

Measured memory_bytes: 27008
import java.util.*;
import java.util.Arrays;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String line1;
        line1 = sc.nextLine();
        String[] k_n_s = line1.split(" ");
        int N = Integer.parseInt(k_n_s[0]);
        int K = Integer.parseInt(k_n_s[1]);
        int[] kn = new int[N];
        for (int i=0;i<N;i++){
            kn[i] = Integer.parseInt(sc.nextLine());
        }
        // System.out.println("\n");
        Arrays.sort(kn);
        // System.out.println("=======");
        // for (int k:kn){
          // System.out.println(k);
        // }
        final int INF = (int)Math.pow(10, 9) + 7;
        // Long min = 1000000000L;
        int diff = INF;
        int min = INF;

        for(int i=0;i<N-K+1;i++){
            diff = kn[K-1+i]-kn[i];
            if (min > diff){
                min = diff;
            }
        }
        // System.out.println("\n");
        // System.out.println("min:");
        System.out.println(min);
    }
}


Measured memory_bytes: 92336
n = int(input())
l = list(map(int,input().split()))

"""
1 insertionSort(A, N) // N個の要素を含む0-オリジンの配列A
2   for i が 1 から N-1 まで
3     v = A[i]
4     j = i - 1
5     while j >= 0 かつ A[j] > v
6       A[j+1] = A[j]
7       j--
8     A[j+1] = v
"""
mm = ''
for i in range(n):
    mm = mm + ' ' + str(l[i])
print(mm.strip())

for i in range(1,n):
    m = ''
    v = l[i]
    j = i-1
    while j >= 0 and l[j]> v:
        l[j + 1] = l[j]
        j = j -1
    l[j+1] = v
    for i in range(n):
        m = m + ' ' + str(l[i])
    print(m.strip())

    


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int k;
    cin >> k;
    queue<ll> q;
    for (ll i = 1; i <= 9; i++) q.push(i);

    int ik = 0;
    while (!q.empty()) {
        ik++;
        ll a = q.front();
        q.pop();

        for (ll i = 0; i <= 9; i++) {
            if ((abs((a % 10) - i) == 1) || (abs((a % 10) - i)) == 0) {
                ll aa = a * 10 + i;
                q.push(aa);
            }
        }

        if (k == ik) {
            cout << a << endl;
            return 0;
        }
    }
}

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

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

const int maxn = 1e5 + 10;

long long p[maxn], ans;
int x[maxn], n, l, r, S;

int main(int argc, char *argv[]) {
#ifdef DEBUG
	freopen(argv[1], "r", stdin);
	freopen(argv[2], "w", stdout);
#endif
	scanf("%d%d", &n, &S);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%"LLFORMAT"d", x + i, p + i);
	}
	l = 1;
	r = n;
	int lst = -1;
	while(x[l] < S && x[r] > S) {
		if(p[l] < p[r]) {
			if(~lst) {
				ans += abs(x[l] - lst);
			}
			lst = x[l];
			p[r] += p[l++];
		}
		else {
			if(~lst) {
				ans += abs(x[r] - lst);
			}
			lst = x[r];
			p[l] += p[r--];
		}
	}
	if(x[l] < S) {
		ans += S - x[l];
		if(~lst) {
			ans += abs(x[l] - lst);
		}
	}
	else {
		ans += x[r] - S;
		if(~lst) {
			ans += abs(x[r] - lst);
		}
	}
	printf("%"LLFORMAT"d\n", ans);
	return 0;
}



Measured memory_bytes: 1536
<?php
ini_set("memory_limit", "-1");

$input = STDIN;

$n = (int)trim(fgets($input));

$keys = array_fill(0, 2000000, 0);
$head = 1;
$tail = 0;

for ($i = 0; $i < $n; $i++) {
    $command = trim(fgets($input));

    if ($command[0] == "i") {
        $keys[$head++] = substr($command, 7);
    } else {
        switch ($command[6]) {
            case "F":
                --$head;
                break;
            case "L":
                ++$tail;
                break;
            default:
                $x = substr($command, 7);
                $keys[$tail] = $x;
                $idx = $head;
                while ($keys[--$idx] != $x) {}
                if ($idx != $tail) {
                    if ($idx - $tail < $head - $idx) {
                        ++$tail;
                        for ($j = $idx; $j > $tail; $j--) {
                            $keys[$j] = $keys[$j-1];
                        }
                    } else {
                        --$head;
                        for ($j = $idx; $j < $head; $j++) {
                            $keys[$j] = $keys[$j+1];
                        }
                    }
                }
        }
    }
}

$reversed_keys = array_slice($keys, $tail + 1, $head - $tail - 1);
print implode(" ", array_reverse($reversed_keys)) . "\n";



Measured memory_bytes: 319720
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    char C1,C2;
    string s;

    cin >> a >> b >> c;


    cout << (a+b)*c/2;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int S,h,m,s;
    cin >> S;
    s = S%60;
    m = ((S - s)/60)%60;
    h = (S - s - m*60)/3600;
    cout << h << ":"<< m << ":"<< s<< endl;
    return 0;
}


Measured memory_bytes: 3108
using System;

namespace ABC158a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            string result = "Yes";
            if(s=="AAA" || s == "BBB")
            {
                result = "No";
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll inv[200005], fac[200005], finv[200005];

void settable(){
    fac[0] = fac[1] = 1;
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for(int i = 2; i <= 200000; i++){
        fac[i] = fac[i-1]*i%mod;
        inv[i] = mod-inv[mod%i]*(mod/i)%mod;
        finv[i] = finv[i-1]*inv[i] % mod;
    }
}



ll choose(ll n, ll k){
    return ((fac[n] * finv[n-k])%mod) * finv[k] % mod;
}


int main(){
    settable();
    ll n, k;
    cin >> n >> k;
    ll lim = max((ll)1, n-k);
    ll ans = 0;
    for(ll i = lim; i <= n; i++){
        ll j = choose(n-1,i-1)*choose(n,i)%mod;
        ans += j;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
package main

import (
	"fmt"
	"strings"
)

const az = "ABCDEFGHIJKLMNOPQRSTUVWXYZA"

func main() {
	var S string
	var N int
    var ind int

	fmt.Scan(&N)
	fmt.Scan(&S)

    SS := strings.Split(S, "")

	for i, c := range SS {
        ind = (strings.Index(az, c) + N )%26
        SS[i] = az[ind:ind+1]
	}
    fmt.Println(strings.Join(SS, ""))
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int h, w;
char table[60][60];
char flag[60][60];
void bfs(int y, int x)
{
	queue<P> que;
	que.push(P(y, x));
	bool ok = false;
	for(int i = 0; i < 4; i++)
	{
		int tmpy = y + dy[i];
		int tmpx = x + dx[i];
		if(table[tmpy][tmpx] == '#')
			ok = true;
	}
	if(ok)
	{
		flag[y][x] = '?';
		table[y][x] = '?';
	}
	while(!que.empty())
	{
		P tmp = que.front();
		que.pop();
		for(int i = 0; i < 4; i++)
		{
			int ny = tmp.first + dy[i];
			int nx = tmp.second + dx[i];
			if(ny < 0 || nx < 0 || ny >= h || nx >= w)
				continue;
			if(flag[ny][nx] != '.' || table[ny][nx] != '#')
				continue;
			flag[ny][nx] = '?';
			table[ny][nx] = '?';
			que.push(P(ny, nx));
		}
	}

}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> h >> w;
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
		{
			cin >> table[i][j];
			flag[i][j] = '.';
		}
	}
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
		{
			if(table[i][j] == '#' && flag[i][j] == '.')
			{
				bfs(i, j);
				/*
				for(int p = 0; p < h; p++)
				{
					for(int q = 0; q < w; q++)
						cout << table[p][q] << " ";
					cout << endl;
				}
				cout << endl;
				*/
			}
		}
	}
	bool ok = true;
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
		{
			if(table[i][j] != flag[i][j])
				ok = false;
		}
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}



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

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;

const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;

int a[N], b[N], c[N], d[N];

main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
  }
  vector < int > ind_a(n + 1), ind_b(n + 1);
  for (int i = 1; i <= n; i++) {
    ind_a[i] = i;
    ind_b[i] = i;
  }
  int res = 0, ans = 0;
  for (int bit = 0; bit < 29; bit++) {
    vector < int > x, y;
    x.pb(0);
    y.pb(0);
    for (int i = 1; i <= n; i++) {
      if ((a[ind_a[i]] >> bit) & 1) {
        x.pb(ind_a[i]);
      }
      if ((b[ind_b[i]] >> bit) & 1 ^ 1) {
        y.pb(ind_b[i]);
      }
    }
    for (int i = 1; i <= n; i++) {
      if ((a[ind_a[i]] >> bit) & 1 ^ 1) {
        x.pb(ind_a[i]);
      }
      if ((b[ind_b[i]] >> bit) & 1) {
        y.pb(ind_b[i]);
      }
    }
    ind_a = x;
    ind_b = y;
//    for (int i = 1; i <= n; i++) {
//      cout << x[i] << ' ';
//    }
//    cout << endl;
//    for (int i = 1; i <= n; i++) {
//      cout << y[i] << ' ';
//    }
//    cout << endl;
//    system("pause");
    for (int i = 1; i <= n; i++) {
      x[i] = (a[ind_a[i]]) & ((1 << (bit + 1)) - 1);
      y[i] = (b[ind_b[i]]) & ((1 << (bit + 1)) - 1);
    }
    int q, w, e;
    q = w = e = 0;
    ans = 0;
    for (int i = 1; i <= n; i++) {
      while (q + 1 <= n && y[q + 1] + x[i] < (1 << bit)) {
        q++;
      }
      while (w + 1 <= n && y[w + 1] + x[i] < (1 << (bit + 1))) {
        w++;
      }
      while (e + 1 <= n && y[e + 1] + x[i] < (1 << bit) + (1 << (bit + 1))) {
        e++;
      }
      ans ^= ((w - q) & 1);
      ans ^= ((n - e) & 1);
    }
    if (ans) {
      res += (1 << bit);
    }
  }
  printf("%d", res);
}


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

using namespace std;

struct Kruskal {
    Kruskal() = default;

    explicit Kruskal(int n) { init(n); }

    struct UnionFind {
        vector<int> p, r;

        UnionFind() = default;

        UnionFind(int size) { init(size); }

        void init(int size) {
            p.resize(size);
            r.resize(size);
            for (int i = 0; i < size; ++i) {
                p[i] = i;
                r[i] = 1;
            }
        }

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

        void unite(int x, int y) {
            x = root(x);
            y = root(y);

            if (x == y) return;

            if (r[x] > r[y]) swap(x, y);
            r[x] += r[y];
            p[y] = x;
        }

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

    struct edges {
        edges() = default;

        edges(int u, int v, long long cost) : u(u), v(v), cost(cost) {}

        bool operator<(const edges &e) const {
            return cost < e.cost;
        }

        int u, v;
        long long cost;
    };

    struct edge {
        edge() {}

        edge(int to, long long cost) : to(to), cost(cost) {}

        int to;
        long long cost;
    };

    vector<edges> E;
    vector<vector<edge>> G;

    void init(int n) {
        G.resize(n + 1);
    }

    void add(int u, int v, long long cost) {
        E.emplace_back(edges(u, v, cost));
    }

    void make_graph(edges e) {
        G[e.u].push_back(edge(e.v, e.cost));
        G[e.v].push_back(edge(e.u, e.cost));
    }

    long long kruskal(int n) {
        long long res = 0;
        UnionFind uf(n + 1);

        sort(E.begin(), E.end());
        for (auto &e : E) {
            if (!uf.same(e.u, e.v)) {
                res += e.cost;
                uf.unite(e.u, e.v);
                make_graph(e);
            }
        }

        return res;
    }

    long long kruskal() {
        return kruskal(G.size());
    }
};


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

    auto g = Kruskal(n);
    for (int i = 0; i < m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;

        g.add(a, b, c);
    }

    cout << g.kruskal() << endl;
}


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

int N;
vector<pair<int, int>> p;
vector<int> pi;
int cnt = 0;

double sum() {
	double r = 0;

	if( pi.size() == N ) {
		cnt += 1;

		for( int i = 1; i < N; ++i ) {
			double x = p[pi[i]].first - p[pi[i-1]].first;
			double y = p[pi[i]].second - p[pi[i-1]].second;
			r += sqrt( x*x + y*y );
		}

		return r;
	}

	for( int i = 0; i < N; ++i ) {
		if( find( pi.begin(), pi.end(), i ) != pi.end() ) {
			continue;
		}

		pi.push_back( i );
		r += sum();
		pi.pop_back();
	}

	return r;
}

int main() {
	ios_base::sync_with_stdio( false );

	cin >> N;
	for( int i = 0; i < N; ++i ) {
		int x, y;
		cin >> x >> y;
		p.push_back( { x, y } );
	}

	cout << fixed << setprecision( 10 );
	cout << sum() / cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;

int main()
{
    string S,T;
    cin >>  S >> T;
    if(T.compare(0,S.length(),S)==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3616
n, m = map(int, input().split())
maxL = 1
minR = n
for i in range(m):
    l, r = map(int ,input().split())
    maxL = max(l, maxL)
    minR = min(r, minR)
if(maxL > minR):
    print(0)
else:
    print(minR - maxL + 1)


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main()  {
	a, b, c, d := nextLine(), nextLine(), nextLine(), nextLine()
	N, _ := strconv.Atoi(a)
  	K, _ := strconv.Atoi(b)
  	X, _ := strconv.Atoi(c)
  	Y, _ := strconv.Atoi(d)
	var total int
	if N > K {
		total = K * X + (N - K) * Y
	} else {
		total = N * X
	}
	fmt.Println(total)
}


Measured memory_bytes: 640
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


int main() {
	int n;
	cin >> n;
	cout << (n + 110) / 111 * 111 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

const ll INF=1e18;

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

  int N;
  ll A,B;
  cin>>N>>A>>B;
  vector<int> P(N);
  rep(i,N) cin>>P[i];

  vector<vector<ll>> dp(N+1,vector<ll> (N+1,INF));
  dp[0][0]=0;
  for(int i=0;i<N;i++){
      for(int j=0;j<=N;j++){
          if(dp[i][j]==INF) continue;
          {
              ll neco=A;
              if(P[i]<j) neco=B;
              chmin(dp[i+1][j],dp[i][j]+neco);
          }

          {
              if(j<P[i]) chmin(dp[i+1][P[i]],dp[i][j]);
          }
      }
  }

  ll ans=INF;
  rep(i,N+1) chmin(ans,dp[N][i]);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 195968
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>

using namespace std;


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


    int MAXN=501;
    int N;cin>>N;

    int C[MAXN];
    int S[MAXN];
    int F[MAXN];

    for(int i=0;i<MAXN;i++){
        C[i]=S[i]=F[i]=0;
    }
    for(int i=0;i<N-1;i++){
        cin>>C[i];
        cin>>S[i];
        cin>>F[i];
    }


    for(int i=0;i<N-1;i++){
        int time=0;
        for(int j=i;j<N-1;j++){
            if(time<=S[j]){
                time=S[j];
            }else{
                while(true){
                    if((time-S[j])%F[j]==0){
                        break;
                    }
                    time++;
                }
            }
            time+=C[j];
        }
        printf("%d\n",time);
    }
    printf("0\n");

    return 0;
}


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

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

#define INF INT_MAX/2 //(1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()


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

  int N,K;
  cin>>N>>K;
  vector<int>h(N);
  for(int i=0;i<N;i++)cin>>h[i];

  vector<int>dp(N,0);
  for(int i=1;i<N;i++){

    int Min = INF;
    for(int j=1;j<=K;j++){
      if(i-j<0)continue;
      Min=min(Min,dp[i-j]+abs(h[i]-h[i-j]));
    }
    dp[i]=Min;

  }

  cout<<dp[N-1]<<endl;
  return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int MAX=3e5+5;
int n;
long long a,b;

long long fac[MAX];
long long inv[MAX];
long long pre[MAX];

#define ll long long
#define ld double
#define vi vector<int>
#define vll vector<ll >
#define endl "\n"
#define print(s) cerr<<#s<<" : ";for(auto i:(s))cerr<<i<<" ";cerr<<"\n";

typedef long long LL; 
typedef long double LD;

int add(int a, int b, int c) {
    int res = a + b;
    return (res >= c ? res - c : res);
}

int mod_neg(int a, int b, int c) {
    int res; if(abs(a-b) < c) res = a - b;
    else res = (a-b) % c;
    return (res < 0 ? res + c : res);
}

int mul(int a, int b, int c) {
    LL res = (LL)a * b;
    return (res >= c ? res % c : res);
}

template <typename T>T power(T e, T n, T m) {
    T x = 1, p = e;
    while(n) {
        if(n & 1) x = mul(x, p, m);
        p = mul(p, p, m);
        n >>= 1;
    }
    return x;
}

template<typename T> T extended_euclid(T a, T b, T &x, T &y) {
    T xx = 0, yy = 1; y = 0; x = 1;
    while(b) {
        T q = a / b, t = b;
        b = a % b; a = t;
        t = xx; xx = x - q * xx;
        x = t; t = yy;
        yy = y - q * yy; y = t;
    }
    return a;
}

template<typename T> T mod_inverse(T a, T n) {
    T x, y, z = 0; 
    T d = extended_euclid(a, n, x, y);
    return (d > 1 ? -1 : mod_neg(x, z, n));
}


long long ncr(long long n,long long r)
{
    if(n<0||r<0||r>n)
    {
        return 0ll;
    }
    return ((((fac[n]*1ll*inv[r])%MOD)*1ll*inv[n-r])%MOD);
}

long long solve(long long a,long long b)
{
    return ((ncr(n,a)*1ll*ncr(n,b))%MOD);
}

void prec()
{
    fac[0]=1;
    inv[0]=1;
    for(int i=1;i<=n;i++)
    {
        fac[i]=(fac[i-1]*i)%MOD;
        inv[i]=mod_inverse(fac[i],1ll*MOD);
    }
    
}



int main()
{   
    scanf("%d %lld %lld",&n,&a,&b);
    prec();
    long long k;
    scanf("%lld",&k);
    long long ans=0;
    for(int i=0;i<=n;i++)
    {
        if((k>=(a*i))&&(((k-(a*i))%b)==0))
        {  
            ans+=solve(i,(k-(a*i))/b);
            ans%=MOD;
        }
    }
    printf("%lld\n",ans);

}

Measured memory_bytes: 5248
#include <stdio.h>
#include <string.h>


int main(){
    
    char word1[100],word2[100];
    int i,n;
    int sum1=0,sum2=0;
    
    scanf("%d",&n);
    for (i=0; i<n; i++) {
        scanf("%s %s",word1,word2);
  
        if (strcmp(word1,word2)>0) {
            sum1 += 3;
        }else if(strcmp(word1,word2)==0){
            sum1++;
            sum2++;
        }else{
            sum2 +=3;
        }
    
    }
    
    printf("%d %d\n",sum1,sum2);
    return 0;
}

Measured memory_bytes: 604