akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
ll n,w;
vector<vector<ll> >value(4);
ll ww;
ll ans=0;
int main(){
  cin>>n>>w;
  for(int i=0;i<n;i++){
    ll a,b;
    cin>>a>>b;
    if(i==0)ww=a;
    value[a-ww].pb(b);
  }
  ll val[4][101]={};
  sort(value[0].begin(),value[0].end(),greater<ll>());
  sort(value[1].begin(),value[1].end(),greater<ll>());
  sort(value[2].begin(),value[2].end(),greater<ll>());
  sort(value[3].begin(),value[3].end(),greater<ll>());
  for(int i=1;i<=value[0].size();i++)
    val[0][i]+=val[0][i-1]+value[0][i-1];
  for(int i=1;i<=value[1].size();i++)
    val[1][i]+=val[1][i-1]+value[1][i-1];
  for(int i=1;i<=value[2].size();i++)
    val[2][i]+=val[2][i-1]+value[2][i-1];
  for(int i=1;i<=value[3].size();i++)
    val[3][i]+=val[3][i-1]+value[3][i-1];
  for(int i=0;i<=value[0].size();i++){
    for(int j=0;j<=value[1].size();j++){
      for(int k=0;k<=value[2].size();k++){
	for(int l=0;l<=value[3].size();l++){
	  if((ll)(i*ww)+(j*(ww+1))+(k*(ww+2))+(l*(ww+3))<=w){
	    ans=max(ans,val[0][i]+val[1][j]+val[2][k]+val[3][l]);
	  }
	}
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
K,N = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    m=a[i+1]-a[i]
    ans = max(ans,m)
h = K - a[N-1]+a[0]
ans = max(ans,h)
ans = K-ans
print(ans)

  


Measured memory_bytes: 25840
#include <algorithm>
#include <iostream>
#include<string>
#include<vector>
#include <numeric>
#include <queue>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> s(n);
	for (int i = 0; i < n; i++)cin >> s[i];
	sort(s.begin(), s.end());
	long ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			for (int k = j + 1; k < n; k++)
			{
				if (s[i] < s[j] + s[k])
				{
					if (s[j] < s[i] + s[k])
					{
						if (s[k] < s[j] + s[i])
						{
							ans++;
						}
						else break;
					}
					else break;
				}
				else break;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

vector<int> A;

int N, M, Q;
vector<int> a, b, c, d;
int ans;

void dfs(int depth, int v) {
  if (depth == N) {
    int sum = 0;
    for (int i = 0; i < Q; i++) {
      if (A[b[i]] - A[a[i]] == c[i]) {
        sum += d[i];
      }
    }
    ans = max(ans, sum);
    return;
  }
  for (int i = v; i <= M; i++) {
    A[depth] = i;
    dfs(depth + 1, i);
  }
  return;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M >> Q;
  a.resize(Q);
  b.resize(Q);
  c.resize(Q);
  d.resize(Q);
  for (int i = 0; i < Q; i++) {
    int ai, bi, ci, di;
    cin >> ai >> bi >> ci >> di;
    ai--;
    bi--;
    a[i] = ai;
    b[i] = bi;
    c[i] = ci;
    d[i] = di;
  }
  A.resize(N, 0);
  dfs(0, 1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <iomanip>

int main()
{
    int N, K;
    std::cin >> N >> K;
    
    double lNProb = 1.0 / N;
    double lProbSum = 0.0;
    auto calcProb = [K](int i) -> double {
        double prob = 1;
        int buf = i;
        while (buf < K) {
            prob *= 0.5;
            buf *= 2;
        }
        return prob;
    };
    
    for (int i = 1; i < N + 1; ++i) {
        lProbSum += lNProb * calcProb(i);
    }
    
    std::stringstream ss;
    ss << std::setprecision(12);
    ss << lProbSum;
    std::cout << ss.rdbuf();
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x,T a,T b){return a<=x&&x<=b;}
template<class T> void amin(T &a,T v){if(a>v) a=v;}
template<class T> void amax(T &a,T v){if(a<v) a=v;}
int ROUND(double x) { return (int)(x+0.5); }
bool ISINT(double x) { return fabs(ROUND(x)-x)<=EPS; }
bool ISEQUAL(double x,double y) { return fabs(x-y)<=EPS*max(1.0,max(fabs(x),fabs(y))); }
double SQSUM(double x,double y) { return x*x+y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	int N;
	string s;
	cin >> N >> s;

	vector <string> start = 
	{
		"SS",
		"SW",
		"WS",
		"WW",
	};

	for (const string& st : start)
	{
		string now = st;

		for (int i = 1; i <= N+1; i++)
		{
			if (s[i%N] == 'o')
			{
				if (now[i - 1] == 'S' && now[i] == 'S') now += "S";
				if (now[i - 1] == 'S' && now[i] == 'W') now += "W";
				if (now[i - 1] == 'W' && now[i] == 'S') now += "W";
				if (now[i - 1] == 'W' && now[i] == 'W') now += "S";
			}
			else
			{
				if (now[i - 1] == 'S' && now[i] == 'S') now += "W";
				if (now[i - 1] == 'S' && now[i] == 'W') now += "S";
				if (now[i - 1] == 'W' && now[i] == 'S') now += "S";
				if (now[i - 1] == 'W' && now[i] == 'W') now += "W";
			}
		}

		if (now[0] == now[N] && now[1] == now[N+1])
		{
			now = now.substr(0, N);
			cout << now << endl;
			return 0;
		}
	}

	cout << -1 << endl;



	return 0;
}


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

int n;
vector<long long> a;
string s;

bool solve();

int main() {
  int times;
  cin >> times;
  while (times--) {
    cin >> n;
    a.resize(n);
    for (auto& p : a) cin >> p;
    cin >> s;
    vector<long long> basis;
    int res = 0;
    for (int i = n - 1; i >= 0; --i) {
      for (auto b : basis) a[i] = min(a[i], a[i] ^ b);
      if (a[i]) {
        if (s[i] == '0')
          basis.push_back(a[i]);
        else
          res = 1;
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;

constexpr int M = 1046527;
constexpr int L = 14;

char H[M][L] = {{'\0'}};

int char2num(char ch) {
    if (ch == 'A') { return 0; }
    else if (ch == 'C') { return 1; }
    else if (ch == 'G') { return 2; }
    else if (ch == 'T') { return 3; }
    else return 0;
}

int getKey(const string& str) {
    int key = 0;
    for (int i = 0; i < str.length(); i++) {
        key += char2num(str[i]) << 2 * i;
    }
    return key;
}

int h1(const int& key) {
    return key % M;
}

int h2(const int& key) {
    return 1 + key % (M-1);
}

int getHash(const int& key, const int& i) {
    return (h1(key) + i * h2(key)) % M;
}

bool find(const string& str) {
    int key = getKey(str);
    for (int i = 0;; i++) {
        int h = getHash(key, i);
        if (str == H[h]) { return true; }
        else if (H[h][0] == '\0') { return false; }
    }
    return false;
}

bool insert(const string& str) {
    int key = getKey(str);
    for (int i = 0;; i++) {
        int h = getHash(key, i);
        if (str == H[h]) { return false; }
        else if (H[h][0] == '\0') {
            strcpy(H[h], str.c_str());
            return true;
        }
    }
    return true;
}

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

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string cmd, str;
        cin >> cmd >> str;
        if (cmd == "insert") {
            insert(str);
        } else {
            string reply = find(str) ? "yes" : "no";
            cout << reply << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 17544
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) ;
#define MOD 1000000007
#define int long long 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define ff first
#define ss second
#define INF (1LL<<61)

using namespace std;

int n ;
int h[200010];
int b[200010];
int dp[200010];

int32_t main(){   

fastio
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt","w", stdout);
// #endif

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

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


dp[1] =b[1];
int ans = dp[1];
map<int, int> mp;
mp.insert({h[1] , dp[1]});

for(int i =2 ; i<=n ; i++){

	dp[i] = b[i];
	auto it = mp.lower_bound(h[i]);

	if(it!=mp.begin()){
		it--;
		dp[i]+=it->ss;
	}

	mp.insert({h[i] , dp[i]});
	auto ub = mp.upper_bound(h[i]);

	while(ub != mp.end()  && ub->ss<=dp[i]){
		auto temp = ub;
		temp++;
		mp.erase(ub);
		ub = temp;
	}

	ans = max(ans , dp[i]);

}


cout<<ans;

return 0;
}


Measured memory_bytes: 20728
a=int(input())
d=0
e=0
for i in range(40):
  b=i+2
  while b<=a:
    b=b*(i+2)
    e=e+1
  c=b/(i+2)
  if e>1:
    if d<=c:
      d=c
      e=0
  else:
    e=0
if d==0:
  print(1)
else:
  print(int(d))

Measured memory_bytes: 9136
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		ArrayList<String> list = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			list.add(sc.next());
		}
		Collections.sort(list);
		StringBuilder sb = new StringBuilder();
		for(String s : list) {
			sb.append(s);
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#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(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int  ary[n-1];
    rep(i,n-1) cin >> ary[i];
    int ans[n];
    rep(i,n) ans[i]=0;

    rep(i,n-1)
    {
        ary[i]--;
        ans[ary[i]]++;
    }
    rep(i,n)
    {
        cout << ans[i] << endl;
    }
    
    
}




Measured memory_bytes: 5208
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int a,b;
	cin>>a>>b;
	int ans=0;
	for(int i=1;i<=1250;i++)
	{
		int ta=i*0.08;
		int tb=i*0.1;
		if(ta==a&&tb==b)
		{
			ans=i;
			break;
		}
	}
	if(ans==0) cout<<-1<<endl;
	else
	cout<<ans<<endl;

}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if((a*100+b*10+c)%4==0)
     cout<<"YES";
    else 
     cout<<"NO";
    return 0;
}
     
   




Measured memory_bytes: 3616
N, M = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(M)]
maxx = 100000
minn = 0

for l, r in lr:
    minn = max(l, minn)
    maxx = min(r, maxx)

if maxx - minn >= 0:
    print(maxx - minn + 1)
else:
    print(0)


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

int main()
{
    int d;
    cin>>d;
    vector<int> a(d);
    for(int i=0;i<d;i++)
    {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int c=0;
    for(int i=0;i<d-1;i++)
    {
        c+=a[i];
    }
    c+=(a[d-1]/2);
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3188
N = int(input())
S = []
L = []
for i in range(N) :
    s = input()
    S.append(s[0])
m = S.count("M")
a = S.count("A")
r = S.count("R")
c = S.count("C")
h = S.count("H")
L.append(m)
L.append(a)
L.append(r)
L.append(c)
L.append(h)
L = sorted(L,reverse=True)
ans = 0
if len(list(set(S))) < 3 :
    print(0)
elif len(list(set(S))) == 3 :
    print(L[0]*L[1]*L[2])
elif len(list(set(S))) == 4 :
    print(L[0]*L[1]*L[2]+L[0]*L[1]*L[3]+L[0]*L[2]*L[3]
          +L[1]*L[2]*L[3])
else :
    print(L[0]*L[1]*L[2]+L[0]*L[1]*L[3]+L[0]*L[1]*L[4]+L[0]*L[2]*L[3]
          +L[0]*L[2]*L[4]+L[0]*L[3]*L[4]
          +L[1]*L[2]*L[3]+L[1]*L[2]*L[4]+L[1]*L[3]*L[4]
          +L[2]*L[3]*L[4])


Measured memory_bytes: 4036
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	// sc.Split(bufio.ScanWords)
	// S := read()
	var S string
	fmt.Scan(&S)
	prev := "R"
	length := 1
	leftLength := 0
	for i := 1; i < len(S); i++ {
		cur := string(S[i])
		if prev == "L" && cur == "R" {
			gather(length, leftLength)
			fmt.Print(" ")
			length = 0
			leftLength = 0
		}
		if prev == "R" && cur == "L" {
			leftLength = length
		}
		length++
		if i == len(S)-1 {
			gather(length, leftLength)
			fmt.Println("")
		}
		prev = cur
	}
}

func gather(len int, leftLen int) {
	if len <= 1 {
		panic("here")
	}
	res := []int{}
	left := 0
	right := 0
	for i := 1; i <= len; i++ {
		res = append(res, 0)
		if i <= leftLen {
			if i%2 == leftLen%2 {
				left++
			} else {
				right++
			}
		} else {
			if (i-leftLen)%2 == 1 {
				right++
			} else {
				left++
			}
		}
	}
	res[leftLen-1] = left
	res[leftLen] = right
	for i := 0; i < len; i++ {
		fmt.Printf("%d", res[i])
		if i != len-1 {
			fmt.Print(" ")
		}
	}
}


Measured memory_bytes: 7680
#include <iostream>
#include <string>
#include <set>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;
std::set<std::string> S;

int main()
{
    std::cin >> n;
    rep( i, n )
    {
        std::string cmd, str;

        std::cin >> cmd >> str;

        if( cmd == "insert" )
            S.insert( str );
        else
            puts( S.count(str) ? "yes" : "no" );
    }

    return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

  for (ll i = -200; i < 200; i++) {
    bool flag = false;
    for (ll j = -200; j < 200; j++) {
      ll a = i * i * i * i * i;
      ll b = j * j * j * j * j;

      if (a - b == x) {
        cout << i << " " << j << endl;
        flag = true;
        break; 
      }
    }
    if (flag) break;
  }

  return 0;
}

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

long long f(long long n, long long x){
  if(n==-1) return 0;
  else return n/x+1;
}

int main(){
  long long a,b,x;cin>>a>>b>>x; 
  cout<<f(b,x)-f(a-1,x);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    int dp[n + 5][m + 5];
    for(int i = 0; i <= m; i++){
        dp[n][i] = 0;
    }
    for(int i = 0; i <= n; i++){
        dp[i][m] = 0;
    }
    for(int i = n - 1; i >= 0; i--){
        for(int j = m - 1; j >= 0; j--){
            if(s[i] == t[j]){
                dp[i][j] = 1 + dp[i + 1][j + 1];
            }
            else{
                dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
    }
    string ans;
    int i = 0, j = 0;
    while(i < n && j < m){
        if(s[i] == t[j]){
            ans.push_back(s[i]);
            i++, j++;
        }
        else if(dp[i + 1][j] > dp[i][j + 1]){
            i++;
        }
        else{
            j++;
        }
    }
    cout << ans;
    return 0;
}

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

int main() {
int a,b;
cin >> a >> b;
if(a>b){
    for(int i=0;i<a;i++){
        cout << b;
    }
}
else{
    for(int i=0;i<b;i++){
        cout << a;    
}
}
}


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

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

int main()
{
	int N;
	char s[101], t[101];
	scanf("%d", &N);
	scanf("%s", s);
	scanf("%s", t);
	
	int i, j, ls, lt, l, ans;
	char sub_s[101] = {}, sub_t[101] = {};
	for (ls = 0; s[ls] != 0; ls++);
	for (lt = 0; t[lt] != 0; lt++);
	l = (ls < lt)? ls: lt;
	ans = ls + lt;
	for (i = 1; i <= l; i++) {
		for (j = 0; j < i; j++) {
			sub_s[j] = s[ls - i + j];
			sub_t[j] = t[j];
		}
		if (lex_smaller(sub_s, sub_t) == 0) ans = ls + lt - i;
	}
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

typedef long long LL;
const int INF = 100000000;

class Graph{
    private:
        vector<vector<int>> data;
    public: 
    Graph(int n, int initDist=0){
        init(n, initDist);
    }
    void init(int n, int initDist){
        data = vector<vector<int>>(n, vector<int>(n, initDist));
        for(int i=0;i<n;i++)data[i][i] = 0;
    }
    void setCost(int node1, int node2, int cost){
        int index1 = min(node1, node2);
        int index2 = max(node1, node2);
        data[index1][index2] = cost;
    }
    int getCost(int node1, int node2){
        int index1 = min(node1, node2);
        int index2 = max(node1, node2);
        return data[index1][index2];
    }
    void warshall_floyd() {
        for (int i = 0; i < data.size(); i++){
            for (int j = 0; j < data.size(); j++){
                for (int k = 0; k < data.size(); k++){
                    int dist = min(getCost(j,k), getCost(j,i) + getCost(i,k));
                    setCost(j, k, dist);
                }
            }
        }
    }

    friend std::ostream &operator<<(std::ostream &out, const Graph &tgt){
        for (int i = 0; i < tgt.data.size(); i++) {
            for (int j = 0; j < tgt.data.size(); j++) {
                if (i != j && tgt.data[i][j] != INF){
                    out << i << "から" << j << "へのコスト: " << tgt.data[i][j] << endl;
                }
            }
        }
        return out;
    }
};

using namespace std;
int main()
{
#ifdef LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int N, M, R;
    cin >> N >> M >> R;

    vector<int> r;
    r.resize(R);
    for(int i=0;i<R;i++){
        cin >>r[i];
    }

    Graph graph = Graph(N, INF);

    for(int i=0;i<M;i++){
        int a, b, c;
        cin >> a >> b >> c;
        graph.setCost(a-1, b-1, c);
    }

    graph.warshall_floyd();

    int min = INF;
    sort(r.begin(), r.end());
    do{
        int costSum = 0;
        for(int i=0;i<r.size()-1;i++){
            costSum += graph.getCost(r[i]-1, r[i+1]-1);
        }
        if(min > costSum){
            min = costSum;
        }
        
    }
    while(std::next_permutation(r.begin(),r.end()));

    cout << min << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end())
#define DOUBLECHANGE(count) cout << setprecision(count)
#define REV(vec) reverse(vec.begin(),vec.end())
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      int N, L;
      cin >> N >> L;
      if(L <= 0 && L + N - 1 >= 0){
          cout << (N * (N+1) / 2) + N * (L-1) << endl;
      }
      else{
          if(L > 0){
              cout << ((N * (N+1) / 2) + N * (L-1)) - L << endl;
          }
          else{
              cout << (N * (N+1) / 2) + N * (L-1) - (L+N-1) << endl;
          }
      }
}


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

int main(){
    vector<int> a(3), b(3);
    vector<int> city(4, 0);
    for(int i = 0; i < 3; i++){
        cin >> a[i] >> b[i];
        city[a[i] - 1]++;
        city[b[i] - 1]++;
    }

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

    if(city[2] >= 2 &&  city[3] >= 2 && city[1] >= 1 && city[0] >= 1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var a=sc.La;
		var b=sc.La;
		var n=sc.L;
		if(a[0]<=b[0]){
			Console.WriteLine("{0}",a[0]+a[1]*n>=b[0]+b[1]*n?"YES":"NO");
		}
		else{
			Console.WriteLine("{0}",a[0]-a[1]*n<=b[0]-b[1]*n?"YES":"NO");
		}
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27564
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef double D;
typedef long long ll;
const ll mod=1e9+7;
const ll inf=(1ll<<62);
const int SQ=400;
const int MX=2e5+9;
int n,m,P[MX],vis[MX],vis1[MX];
vector<int>v[MX],tmp,tmp1;
void dfs(int x,int p){
    if(v[x].empty())return;
    if(vis[x])return;
    vis[x]=1;
    tmp.push_back(x);
    tmp1.push_back(P[x]);
    for(auto pp:v[x]){
        if(pp==p)continue;
        dfs(pp,x);
    }
}
int main(){
    cin>>n>>m;
    int x,y;
    for(int i=1;i<=n;i++)cin>>P[i];
    for(int i=0;i<m;i++){
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(v[i].empty()){
            if(i==P[i])ans++;
            continue;
        }
        if(vis[i])continue;
        dfs(i,-1);
        for(auto pp:tmp){
            vis1[pp]=1;
//            cout<<pp<<" ";
        }
//        puts("");
        for(auto pp:tmp1){
            if(vis1[pp])ans++;
//            cout<<pp<<" ";
        }
        for(auto pp:tmp){
            vis1[pp]=0;
        }
        tmp.clear();
        tmp1.clear();
    }
    cout<<ans<<endl;
}


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

#define ll long long 
#define d  double 
#define endl "\n"

const ll int MOD=1e9+7;

void solve()
{
	int x,y;
	cin >> x >> y;
	if(2*x<=y and 4*x>=y)
	{
		y = y - (y/2)*2;
		if(y%2==1)
			cout << "No\n";
		else
			cout <<"Yes\n";
	}
	else
		cout << "No\n";
}

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

	solve();
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,l,a[N],d[N],ans;
priority_queue<P> q;

int main(){
  cin>>n>>l;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    q.push(P(a[i],i));
  }
  while(!q.empty()){
    P t=q.top(); q.pop();
    ll len=t.first,idx=t.second;
    d[idx]=max(d[idx-1],d[idx+1])+l-len;
    ans=max(ans,d[idx]);
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	int a, b;
	int count = 0;
	while(n--){
		cin >> a >> b;
		long long int ans = pow(a,2) + pow(b,2);
		if(ans <= pow(k, 2))count++;
		//cout << "current ans : " << ans << endl;	
	}
	cout << count;
}


Measured memory_bytes: 3600
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

module Util =
    let strRev (s: string): string =
        s
        |> Seq.rev
        |> Seq.map string
        |> String.concat ""

    let inline roundup (x: ^a) (y: ^a): ^a =
        let one = LanguagePrimitives.GenericOne
        (x + y - one) / y

type ModInt = MVal of int64

[<RequireQualifiedAccess>]
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] // 型名とモジュール名の重複を許す
module ModInt =
    let modulo = (int64 1e9) + 7L

    let inline init (x: ^a) : ModInt =
        let x = (int64 x) % modulo
        match x with
        | _ when x < 0L -> MVal (x + modulo)
        | _ when x >= modulo -> MVal (x - modulo)
        | _ -> MVal x

    let value (MVal x) = x

    let value2 (x: ModInt) (y: ModInt) = (value x, value y)

    let toString (MVal v) : string = sprintf "%d" v

    /// 拡張ユークリッドの互除法
    /// a (mod m) における逆元 a^-1
    let inline inverse (MVal a) : ModInt =
        let mutable (a, b, u, v) = (a, modulo, 1L, 0L)
        while b > 0L do
            let t = a / b
            a <- a - (t * b)
            let tmp = a
            a <- b
            b <- tmp
            u <- u - (t * v)
            let tmp = u
            u <- v
            v <- tmp
        init u

type ModInt with
    static member inline (+) (lhs: ModInt, rhs: ModInt) : ModInt =
        let l, r = ModInt.value2 lhs rhs
        ModInt.init (l + r)

    static member inline (-) (lhs: ModInt, rhs: ModInt) : ModInt =
        let l, r = ModInt.value2 lhs rhs
        ModInt.init (l - r)

    static member inline (*) (lhs: ModInt, rhs: ModInt) : ModInt =
        let l, r = ModInt.value2 lhs rhs
        ModInt.init (l * r)

    /// a / b = a * b^-1 (mod m)
    static member inline (/) (lhs: ModInt, rhs: ModInt) : ModInt =
        let r = ModInt.inverse rhs
        lhs * r

    /// a^n (mod m) 繰り返しニ乗法
    /// O(log n)
    static member inline Pow (a: ModInt, n: int64) : ModInt =
        let mutable (res, a, n) = (ModInt.init 1, a, n)
        while n > 0L do
            if (n &&& 1L) = 1L then res <- res * a
            a <- a * a
            n <- n >>> 1
        res

[<EntryPoint>]
let main _ =
    let n = read int

    let mutable ans = ModInt.init 1
    for i in 1..n do ans <- ans * ModInt.init i

    printfn "%s" (ModInt.toString ans)
    0 // return an integer exit code


Measured memory_bytes: 16212
#include <stdio.h>

int dp[50];

int shinobu(int i)
{
  if (dp[i] != 0) return dp[i];
  if (i <= 1) return 1;
  return dp[i] = shinobu(i - 1) + shinobu(i - 2);
}

int main(void)
{
  int n;
  scanf("%d", &n);
  printf("%d\n", shinobu(n));

  return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <cstdio>
#include <climits>

using namespace std;

const int N = 200000;

int main() {
  int n, r[N];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &r[i]);

  int mi = r[0], ans = -INT_MIN;
  for (int i = 1; i < n; i++) {
    ans = max(ans, r[i] - mi);
    mi = min(mi, r[i]);
  }
  printf("%d\n", ans);
}

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

int main()
{
    /*A
    int a,b;
    cin>>a>>b;
    if(a-2*b>0)
    cout<<a-2*b<<endl;
    else
    {
        cout<<0<<endl;
    }
    */

   /*B
   int n;
   cin>>n;
   int sum=0;
   vector <int> a(n);
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }

   for(int i=0;i<n;i++)
   {
       for(int j=i+1;j<n;j++)
       {
           sum += a[i]*a[j];
       }
   }

    cout<<sum<<endl;
   */

    /*C
    int n;
    int count=1;
    char c,x;
    cin>>n;

    string str;

    for(int i=0;i<n;i++)
    {   
        cin>>c;
        str.push_back(c);
    }

    for(int i=0;i<n-1;i++)
    {
        x = str[i];
        if(x!=str[i+1])
        {
            count++;
            x = str[i+1];
        }
    }
    cout<<count<<endl;
    */

   int n;
   cin>>n;
   int count=0;
   vector <int> a(n);

   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   sort(a.begin(),a.end());

   for(int i=2;i<n;i++)
   {
       for(int j=i-1;j>0;j--)
       {
           for(int k=j;k>0;k--)
           {
               if(a[i]<a[j]+a[k-1])
               {
                   count++;
               }
               else break;
           }
       }
   }
   cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
L = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    L[a].append(b)
    L[b].append(a)
for i in range(N):
    print(len(L[i]))


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
	string S;
	cin>>S;
	if(S.at(0)!='k'){
		if(S.at(S.size()-1)=='e'&&S.at(S.size()-2)=='c'&&S.at(S.size()-3)=='n'&&S.at(S.size()-4)=='e'&&S.at(S.size()-5)=='y'&&S.at(S.size()-6)=='e'&&S.at(S.size()-7)=='k')cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	else{
		if(S.at(1)!='e'){
			if(S.at(S.size()-1)=='e'&&S.at(S.size()-2)=='c'&&S.at(S.size()-3)=='n'&&S.at(S.size()-4)=='e'&&S.at(S.size()-5)=='y'&&S.at(S.size()-6)=='e')cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
			return 0;
		}
		if(S.at(2)!='y'){
			if(S.at(S.size()-1)=='e'&&S.at(S.size()-2)=='c'&&S.at(S.size()-3)=='n'&&S.at(S.size()-4)=='e'&&S.at(S.size()-5)=='y')cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
			return 0;
		}
		if(S.at(3)!='e'){
			if(S.at(S.size()-1)=='e'&&S.at(S.size()-2)=='c'&&S.at(S.size()-3)=='n'&&S.at(S.size()-4)=='e')cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
			return 0;
		}
		if(S.at(4)!='n'){
			if(S.at(S.size()-1)=='e'&&S.at(S.size()-2)=='c'&&S.at(S.size()-3)=='n')cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
			return 0;
		}
		if(S.at(5)!='c'){
			if(S.at(S.size()-1)=='e'&&S.at(S.size()-2)=='c')cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
			return 0;
		}
		if(S.at(1)!='e'){
			if(S.at(S.size()-1)=='e')cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
			return 0;
		}
		cout<<"YES"<<endl;
	}
}

Measured memory_bytes: 3576
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
t = input()

if len(s) < len(t):
    ans = "UNRESTORABLE"
else:
    reg = -1
    for i in range(len(s)-len(t),-1,-1):
        for j in range(len(t)):
            if s[i+j] != '?' and s[i+j] != t[j]:
                break
        else:
            reg = i
            break
    if reg == -1:
        ans = "UNRESTORABLE"
    elif reg == len(s)-len(t):
        s = s[:i]+t
        ans = s.replace('?','a')
    else:
        s = s[:i]+t+s[i+len(t):]
        ans = s.replace('?','a')
print(ans)

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

#define int long long

using namespace std;
#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
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;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

string s;
bool a[33];
 
signed main(){
	cin>>s;
	bool can=true;
	rep(i,0,s.size()){
	    a[s[i]-'a']=true;
	}
	rep(i,0,26){
	    if(!a[i]){
	        s+='a'+i;
	        can=false;
	        break;
	    }
	}
	int cnt=-1;
	bool can1=false;
	if(!can){
	    cout<<s<<endl;
	    return 0;
	}
	else{
	    rrep(i,0,s.size()){
	        rrep(j,i,s.size()){
	            if(s[i]<s[j]){
	                swap(s[i],s[j]);
	                cnt=i;
	                can1=true;
	            }
	            if(can1)break;
	        }
	        if(can1)break;
	    }
	}
	if(cnt==-1)cout<<"-1"<<endl;
	else rep(i,0,cnt+1){
	    cout<<s[i];
	}
	cout<<endl;
	//cout<<s<<endl;
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  string s; cin >> s;
  cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
  return;
}

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


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=true;
    ll ans=0,sum=0;
    int i=0;
    string s;
    cin >>s;    

    if(s[0]!= 'A')flag=false;

    bool C=false;
    for (i = 1; flag && i < s.length(); i++){
    
        if(2 <= i && i < s.length()-1){
            if(C && s[i]=='C'){
                flag=false;
            }else if(s[i]=='C'){
                C=true;
            }else if('A'<= s[i] && s[i] <= 'Z'){
                flag=false;
            }

        }else{
            if('A'<= s[i] && s[i] <= 'Z'){
                flag=false;
            }
        }
    }

    if(!C)flag=false;

    if(flag)cout << "AC";
    else cout << "WA";
    
    return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

x, y, a, b, c = gets.split.map(&:to_i)
p = gets.split.map(&:to_i).sort.reverse.take(x)
q = gets.split.map(&:to_i).sort.reverse.take(y)
r = gets.split.map(&:to_i)

puts (p + q + r).sort.reverse.take(x + y).reduce(:+)


Measured memory_bytes: 30804
#include <stdio.h>
#include <limits.h>

int main() {
  int number_n, time_limit, min_cost = INT_MAX, i, flag = 0;
  scanf("%d %d", &number_n, &time_limit);
  int time[number_n];
  int cost[number_n];
  for(i = 0; i < number_n; i++) {
    scanf("%d %d", &cost[i], &time[i]);
    if(time[i] <= time_limit && min_cost > cost[i]) {
      flag = 1;
      min_cost = cost[i];
    }
  }
  if(flag == 0) {
    printf("TLE\n");
  } else {
    printf("%d\n", min_cost);
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
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; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int cost[200001];
vector<vector<int> > v(200001);
void dfs(int now) {
    if (cost[now] == 2) return;
    for (int nxt : v[now]) {
        if (cost[nxt] <= cost[now] + 1) continue;
        cost[nxt] = cost[now] + 1;
        dfs(nxt);
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    
    
    fill_n(cost, 200001, inf);
    
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        
        a--; b--;
        
        v[a].eb(b);
        v[b].eb(a);
    }
    
    cost[0] = 0;
    dfs(0);
    
    if (cost[n - 1] <= 2) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 12784
N,M,X=map(int,input().split())
List = list(map(int, input().split()))
pattern1 = 0
pattern2 = 0
setCost = set(List)
for i in range(N):
  if i in setCost:
    pattern1 += 1
  if i == X:
    break
for j in range(N,0,-1):
  if j in setCost:
    pattern2 += 1
  if j == X:
    break
if pattern1 < pattern2:
  print(pattern1)
else:
  print(pattern2)

Measured memory_bytes: 9192
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let s = sc.chars();
    let k: usize = sc.read();
    let n = s.len();
    let ans = solve(
        0,
        s.len(),
        k,
        &s,
        &mut vec![vec![vec![-1; k + 1]; n + 1]; n],
    );
    println!("{}", ans);
}

fn solve(l: usize, r: usize, k: usize, s: &Vec<char>, dp: &mut Vec<Vec<Vec<i64>>>) -> i64 {
    if dp[l][r][k] != -1 {
        return dp[l][r][k];
    }
    if r == l + 1 {
        return 1;
    }
    if r == l {
        return 0;
    }

    let mut ans = 0;
    ans = cmp::max(ans, solve(l, r - 1, k, s, dp));
    ans = cmp::max(ans, solve(l + 1, r, k, s, dp));

    if s[l] == s[r - 1] {
        ans = cmp::max(ans, solve(l + 1, r - 1, k, s, dp) + 2);
    } else if k > 0 {
        ans = cmp::max(ans, solve(l + 1, r - 1, k - 1, s, dp) + 2);
    }

    dp[l][r][k] = ans;
    ans
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 237820
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n,m,c,x,ans=0;
  cin>>n>>m>>c;
  int b[m];
  rep(i,0,m) cin>>b[i];
  rep(i,0,n){
    ll sum=c;
    rep(j,0,m){
      cin>>x;
      sum+= b[j]*x;
    }
    if(sum>0) ans++;
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3616
import fractions
A, B, C, D = [int(i) for i in input().split()]
result = B+1 - A
def lcm(a, b):
    return (a * b) // fractions.gcd(a, b)
def wareru(min_num, max_num, waru):
    return (max_num)//waru - (min_num-1)//waru
result -= wareru(A, B, C) + wareru(A, B, D) - wareru(A, B, lcm(C,D))
print(result)

Measured memory_bytes: 5588
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		String[] S = toStringArray(nextString());
		long day=5000000000000000L;
		long K=nextLong();
		long ans = 1;
		for(int i=0;i<K;i++){
			long n = Long.parseLong(S[i]);
			if(n!=1){
				ans=n;
				break;
			}
		}
		System.out.println(ans);

	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ull unsigned long long
#define mp make_pair
#define F first
#define S second
#define mod 1000000007

int a[100005];
int dp[100005];

int main()
{
    int n,k;
    cin >> n >> k; 
    for(int i=0;i<n;i++)
        cin >> a[i];
    
    for(int i=0;i<n;i++)
        dp[i] = INT_MAX;

    dp[0] = 0;

    for(int i=1;i<n;i++)
        for(int j=1;j<k+1 && i-j>-1;j++)
            dp[i] = min(dp[i-j]+abs(a[i]-a[i-j]), dp[i]);
    
    cout << dp[n-1] << endl;




}

Measured memory_bytes: 1024
n,m=gets.split.map &:to_i;$p=(0..n).map{Array.new(11,0)};$g=(0..n).map{[]};m.times{a,b=gets.split.map &:to_i;$g[a].push(b);$g[b].push(a)};def f(u,d,l)if d>=0&&$p[u][d]<1;$p[u][d]=l;$g[u].map{|v|f v,d-1,l}end end;q=gets.to_i;d=$<.map &:split;1.upto(q){|i|0.upto(d[-i][1].to_i){|a|f d[-i][0].to_i,a,d[-i][2].to_i}};1.upto(n){|i|p$p[i][0]}

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

typedef long long int int64;

int64 dinic_dfs(int v,int64 *g,int n,int t,int *level,int *iter,int64 e){
  if(v==t) return e;
  for(int u=iter[v];u<n;u++,iter[v]++){
    if(level[v]+1!=level[u] || g[v*n+u]==0) continue;
    int64 f=dinic_dfs(u,g,n,t,level,iter,g[v*n+u]<e?g[v*n+u]:e);
    if(f>0){
      g[v*n+u]-=f;
      g[u*n+v]+=f;
      return f;
    }
  }
  return 0;
}

int64 dinic(const int64 *ing,const int n,const int s,const int t){
  int64 *g=(int64 *)calloc(n*n,sizeof(int64));
  memcpy(g,ing,n*n*sizeof(int64));
  int *level=(int *)calloc(n,sizeof(int));
  int *array=(int *)calloc(n,sizeof(int));
  int *iter=(int *)calloc(n,sizeof(int));
  int64 flow=0;
  while(1){
    memset(level,0,n*sizeof(int));
    int front=0,last=0;
    level[s]=1;
    array[last++]=s;
    while(front<last && level[t]==0){
      const int v=array[front++];
      for(int u=0;u<n;u++){
	if(g[v*n+u]>0 && level[u]==0){
	  level[u]=level[v]+1;
	  array[last++]=u;
	}
      }
    }
    if(level[t]==0) break;
    memset(iter,0,sizeof(int)*n);
    while(1){
      const int64 inf=9223372036854775807LL;
      int64 f=dinic_dfs(s,g,n,t,level,iter,inf);
      if(f==0) break;
      flow+=f;
    }
  }
  free(level);
  free(array);
  free(g);
  free(iter);
  return flow;
}

int64 calc(int *a,int n){
  int64 *g=(int64 *)calloc((n+2)*(n+2),sizeof(int64));
  int i,j;
  for(i=1;i<=n;i++){
    if(a[i]>=0){
      g[i*(n+2)+(n+1)]=a[i];
    } else {
      g[0*(n+2)+i]=-a[i];
    }
  }
  for(i=1;i<=n;i++){
    for(j=2*i;j<=n;j+=i){
      g[i*(n+2)+j]=1000000000LL*1000;
    }
  }
  int64 ans=dinic(g,n+2,0,n+1);
  free(g);
  return ans;
}

void run(void){
  int n;
  scanf("%d",&n);
  int i;
  int a[101];
  for(i=1;i<=n;i++) scanf("%d",a+i);
  int64 sum=0;
  for(i=1;i<=n;i++) if(a[i]>=0) sum+=a[i];
  int64 ans=sum-calc(a,n);
  printf("%lld\n",ans);
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 356
#include<iostream>

using namespace std;

int main(void)
{
    int a,b,c;

    cin>>a>>b>>c;
    if(a == b)
    {
        cout<<c<<endl;
    } else if(a == c) {
        cout<<b<<endl;
    } else {
        cout<<a<<endl;
    }

    return 0;
}


Measured memory_bytes: 256