akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(void){
	string s;
	int K;
	cin >> s >> K;
	int n = s.size()-1;

	for(int i=0;i<s.size();i++){
		// a に戻すまでの必要回数
		if(s[i] == 'a')continue;
		int need = 'z' - s[i] + 1;
		if( need <= K ){
			K -= need;
			s[i] = 'a';
		}
	}
	if( K >= 0 ){
		K %= 26;
		for(int i=0;i<K;i++){
			if(s[n] == 'z')s[n] = 'a';
			else s[n] = s[n] + 1;
		}
	}
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  cout << n*k-n-k+1 << endl;
}

Measured memory_bytes: 3576
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define P pair<int, int>
#define Q pair<int, pair<int, int>>
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
const int Mod = 1e9 + 7;
const int mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
			comp_[i] = mod_pow(fact_[i], mod - 2, mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % mod * comp_[y] % mod;
}
//---------------------------------------------------
int n, m;
int solve(int i, int n, int m) {
	return comb((m - i) / 2 + m + n - 1, n - 1, mod) * comb(n, i, mod);
}
signed main() {
	cin >> n >> m;
	int ans = 0;
	for (int i = 0; i <= m && i <= n; i++) {
		if ((m - i) % 2) continue;
		(ans += solve(i, n, m)) %= mod;
	}
	for (int i = 2 * m + 1; i <= 3 * m; i++) {
		(ans -= n * comb(3 * m - i + n - 2, n - 2, mod)) %= mod;
	}
	cout << (ans + mod) % mod << endl;
}

Measured memory_bytes: 31488
#include <iostream>

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

    long long int sum = 0;

    for (long long int a = 1; a <= n; ++a)
    {
        if (a % 3 != 0 && a % 5 != 0)
        {
            sum += a;
        }
    }
    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
#define int long long
using namespace std;
int x;
signed main()
{
	scanf("%lld",&x);
	for (int i=-1000;i<=1000;i++)
	{
		for (int j=-1000;j<=1000;j++)
		{
			int a,b;
			a=i*i*i*i*i;
			b=j*j*j*j*j;
			if (a-b==x)
			{
				printf("%lld %lld\n",i,j);
				return 0;
			}
		}
	}
}

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

template <unsigned Mod> struct ModularInt {
  using M = ModularInt;
  unsigned v;
  ModularInt(long long a = 0) : v((a %= Mod) < 0 ? a + Mod : a) {}
  M operator-() const { return M() -= *this; }
  M& operator*=(M r) { v = (uint64_t)v * r.v % Mod; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= Mod) v -= Mod; return *this; }
  M& operator-=(M r) { if ((v += Mod - r.v) >= Mod) v -= Mod; return *this; }
  friend M operator*(M l, M r) { return l *= r; }
  friend M operator/(M l, M r) { return l /= r; }
  friend M operator+(M l, M r) { return l += r; }
  friend M operator-(M l, M r) { return l -= r; }
  M pow(long long n) const {
    assert(n >= 0);
    M res = 1;
    for (M t = *this; n; t *= t, n >>= 1) if (n & 1) res *= t;
    return res;
  }
  M inv() const { assert(v != 0); return pow(Mod - 2); }
  friend string to_string(M a) { return to_string(a.v); }
};
constexpr unsigned mod = 1e9 + 7;
using Mint = ModularInt<mod>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector< vector<int> > g(n);
  for (int _ = n - 1; _--; ) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  Mint res;
  vector<int> sz(n);
  auto dfs = [&](auto&& self, int v, int p) -> void {
    sz[v] = 1;
    for (int u : g[v]) {
      if (u != p) {
        self(self, u, v);
        sz[v] += sz[u];
      }
    }
    if (g[v].size() >= 2) {
      vector<int> a;
      if (p != -1) {
        a.push_back(n - sz[v]);
      }
      for (int u : g[v]) {
        if (u != p) {
          a.push_back(sz[u]);
        }
      }
      Mint pr = 1 - 1 / Mint(2).pow(n - 1);
      for (int e : a) {
        pr -= (1 - 1 / Mint(2).pow(e)) / Mint(2).pow(n - 1 - e);
      }
      res += pr / 2;
    }
  };
  dfs(dfs, 0, -1);
  cout << res.v << '\n';
}


Measured memory_bytes: 32000
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
map<string,string>ma;
set<int > s;
multiset<string> :: iterator it;

deque <char> q ;
ll ar [55100];
int main()
{
    fast;
     int n,k,x,y;
     n = 3;
int ar[3];
     for(int i=0;i<n;i++)
     {
      cin >> ar[i];
}
int f=0;
sort(ar,ar+n);
if(ar[2]==ar[0]+ar[1])
  f=1;
pr(f);
}




Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vector<T>>;

constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
    if (b <= 0) { return 1; } if (b == 1) { return a % mod; } if (b == 2) { return (a * a) % mod; }
    return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
}
constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
    return (a * mpow(b, mod - 2, mod)) % mod;
}

int op(int a, int b) {
    return max(a, b);
}
int e() {
    return 0;
}

int main() {
    int n, k; cin >> n >> k;
    vec<int> a(n);
    for (auto &e : a) cin >> e;

    int size = 300000 + 1;
    segtree<int, op, e> dp(size);
    for (int i = 0; i < n; ++i) {
        dp.set(a[i], dp.prod(max(0, a[i] - k), min(size, a[i] + k + 1)) + 1);
    }

    cout << dp.all_prod() << endl;
}



Measured memory_bytes: 9632
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S, T;
	int N;
	cin >> N >> S >> T;
	for (int i = 0; i < S.size(); i++) {
		cout << S[i] << T[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
def main():
    n = input()
    tree = MyTree(n)
    for i in range(n):
        id_cn = map(int,raw_input().split())
        id_node = id_cn.pop(0)
        
        tree.add(id_node,None,id_cn)
    
    tree.search_children()
    tree.set_depth_height(tree.nodes[tree.id_root],0)
        
    for node in tree.nodes:
        print "node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}".format(
            node.id_self, node.id_parent, node.sibling, node.degree, node.depth, node.height, node.node_type)


class MyTree():
    def __init__(self,num_nodes):
        self.nodes = [MyNode() for i in range(num_nodes)]
        self.id_root = None

    def add(self,id_node,id_parent,id_children):
        node = self.nodes[id_node]
        node.id_self = id_node
        node.id_parent = id_parent
        node.id_children = id_children
    
    def search_children(self):
        for node in self.nodes:
            if all(item==-1 for item in node.id_children):
                node.node_type = "leaf"
                node.degree = 0
            else:
                node.node_type = "internal node"
                l = node.id_children[0]
                r = node.id_children[1]
                if l == -1:
                    node.degree = 1
                    self.nodes[r].id_parent = node.id_self
                    self.nodes[r].sibling = l
                elif r == -1:
                    node.degree = 1
                    self.nodes[l].id_parent = node.id_self
                    self.nodes[l].sibling = r
                else:
                    node.degree = 2
                    self.nodes[l].id_parent = node.id_self
                    self.nodes[r].id_parent = node.id_self
                    self.nodes[l].sibling = r
                    self.nodes[r].sibling = l

        for node in self.nodes:
            if node.id_parent == None:
                node.id_parent = -1
                node.node_type = "root"
                self.id_root = node.id_self
                break

    def set_depth_height(self,node,depth):
        node.depth = depth
        l_height = []
        if all(item==-1 for item in node.id_children):
            node.height = 0
            return 0
        else:
            for item in node.id_children:
                if not item == -1:
                    l_height.append(self.set_depth_height(self.nodes[item],depth+1))
            height = max(l_height)+1
            node.height = height
            return height
                


class MyNode():
    def __init__(self):
        self.id_self = None
        self.id_parent = None
        self.id_children = None
        self.depth = None
        self.node_type = None
        self.n_children = 0
        self.sibling = -1
        self.degree = 0
        self.height = 0


if __name__ == "__main__":
    main()

Measured memory_bytes: 6516
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define sbits(a) __builtin_popcount(a)
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int A[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int c = 0;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < 3; i++)
        c += s[i] == t[i];
    cout << c;
    return 0;
}


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

N = int(input())

keta = len(str(N))

count = 0

if keta%2 == 1:
    if keta == 1:
        print(N)
    else:
        for i in range(keta):
            if i%2 == 0:
                continue
            else: 
                count += 10**i-10**(i-1)
        count +=N-10**(keta-1)+1
        print(count)
else:
    for i in range(keta):
        if i %2 ==0:
            continue
        else:
            count += 10**i-10**(i-1)
    print(count)

Measured memory_bytes: 3064
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,M,A[200303],B[200203],res=0,sum=0,cou=0;
string S,T;

int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    cout<<2.0*PI*N<<endl;
}    


Measured memory_bytes: 3808
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////
 
#define fs first
#define sc second
#define pb push_back
//#define int long long
#define len(x) (int)(x).size()     
#define all(x) (x).begin(), (x).end()
#define test int _; cin >> _; while(_--)
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
 
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MOD = 1e9+7;
 
inline ll gcd(ll a, ll b){while(b){ a %= b; swap(a, b); } return a; }
inline ll mod(ll a, ll b){return ((a%b)+b)%b;}
inline ll expo(ll b, ll p, ll m = MOD){
  ll ans = 1; 
  while(p > 0){
    if(p&1LL) ans = mod(ans*b, m); 
    b = mod(b*b, m); 
    p >>= 1LL;
  } 
  return ans;
}
 
////////////////////////// Solution starts below. //////////////////////////////

const int N = 1e4+5;

int dp[N][105][2];
int n, d;
string s;

int solve(int i, int md, int edge){
	if(i == n) return md == 0;
	int& ans = dp[i][md][edge];
	if(ans != -1) return ans;
	int sum = 0;
	if(edge){
		for(int k = 0; k <= (s[i]-'0'); k++){
			sum = mod(sum + solve(i+1, mod(md+k, d), (k == (s[i]-'0'))), MOD);
		}
	}else{
		for(int k = 0; k <= 9; k++){
			sum = mod(sum + solve(i+1, mod(md+k, d), 0), MOD);
		}
	}
	return ans = sum;
}

int32_t main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s >> d;
  n = len(s);
  memset(dp, -1, sizeof dp);
  cout << mod(solve(0, 0, 1)-1, MOD) << '\n';
  return 0; 
}

Measured memory_bytes: 12624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		String s = sc.next();
		int ans=0;

		for (int i=0; i<1000; i++){
			String pin = String.format("%03d", i);
			int index1 = s.indexOf(pin.charAt(0));
			if (index1 == -1){
				continue;
			}
			int index2 = s.indexOf(pin.charAt(1), index1 + 1);
			if (index2 == -1){
				continue;
			}
			int index3 = s.indexOf(pin.charAt(2), index2 + 1);
			if (index3 == -1){
				continue;
			}
			ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 26244
n,m,k=map(int,input().split())
mod=998244353
ans=m*pow(m-1,n-1,mod)
ans%=mod

if k==0:
  print(ans)
  exit()

lst=[1]+[1]
for i in range(2,n+10):
  lst.append((lst[-1]*i)%mod)

def combinations(n,r):
  xxx=lst[n]
  xxx*=pow(lst[n-r],mod-2,mod)
  xxx%=mod
  xxx*=pow(lst[r],mod-2,mod)
  xxx%=mod

  return xxx


for i in range(1,k+1):
    ans+=(m*pow(m-1,n-1-i,mod)*combinations(n-1,i))%mod
    ans%=mod


print(ans)


Measured memory_bytes: 90132
/*
 * main.c
 *
 *  Created on: 2020/07/27
 *      Author: 113896
 */
#include <stdio.h>


int main() {

	int a,b;
	char op;
	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		if (op == '?') break;
		if (op == '+') {
			printf("%d\n", a + b);
		} else if (op == '-') {
			printf("%d\n", a - b);
		} else if (op == '*') {
			printf("%d\n", a * b);
		} else if (op == '/') {
			printf("%d\n", a / b);
		} else {
			continue;
		}
	}

	return 0;
}



Measured memory_bytes: 2132
from sys import stdin
import bisect

n = int(stdin.readline().rstrip())
roku = [0]+[6**_ for _ in range(10) if 6**_ <= n]
kyu = [0]+[9**_ for _ in range(10) if 9**_ <= n]

ma = 10**10
for i in range(n+1):
    six = i
    nine = n-i
    count = 0
    while True:
        if six == 0:
            break
        six -= roku[bisect.bisect(roku,six)-1]
        count += 1
    while True:
        if nine <= 0:
            break
        nine -= kyu[bisect.bisect(kyu,nine)-1]
        count += 1
    ma = min(ma,count)
print(ma)

Measured memory_bytes: 3064
using System;

namespace aziz
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] X = Console.ReadLine().Split(' ');
            int X1 = int.Parse(X[0]);
            int X2 = int.Parse(X[1]);
            int X3 = int.Parse(X[2]);
            int X4 = int.Parse(X[3]);
            int X5 = int.Parse(X[4]);
            for (int i = 0; i<X.Length; i++)
            {
                if (X[i] == "0")
                {
                   Console.WriteLine(i + 1);
                }
            }
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  ld R; cin>>R;
  ld PI = 3.1415;
  cout << 2*R*PI <<"\n";
}

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

int n, k;
int imos[1000*4][1000*4];

int main() {

    // input
    cin >> n >> k;
    while(n--){
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'W') x += k;
        x %= 2*k;
        y %= 2*k;

        //for(int i=x%k+1;i<4*k;i+=k){
            //for(int j=y%k+1;j<4*k;j+=k){
                //if((i+j)%(2*k) != (x+1+y+1)%(2*k)) continue;
                //if(i+k < 4*k && j+k < 4*k){
                    //imos[i][j]++;
                    //imos[i+k][j]--;
                    //imos[i][j+k]--;
                    //imos[i+k][j+k]++;
                //}
            //}
        //}
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                int xx = x%k+i*k+1;
                int yy = y%k+j*k+1;
                if((xx+yy)%(2*k) != (x+1+y+1)%(2*k)) continue;
                if(xx+k < 4*k && yy+k < 4*k){
                    imos[xx][yy]++;
                    imos[xx+k][yy]--;
                    imos[xx][yy+k]--;
                    imos[xx+k][yy+k]++;
                }
            }
        }
    }

    // imos
    int ans = 0;
    for(int i=0;i<4*k;i++){
        for(int j=1;j<4*k;j++){
            imos[i][j] += imos[i][j-1];
        }
    }
    for(int i=1;i<4*k;i++){
        for(int j=0;j<4*k;j++){
            imos[i][j] += imos[i-1][j];
            ans = max(ans, imos[i][j]);
        }
    }

    // output
    cout << ans << endl;

    return 0;
}


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

int main(){
  char s1,s2;
  cin >> s1 >> s2;
  if(s1 < s2){
    cout << "<" << endl;
  }
  else if(s1 > s2){
    cout << ">" << endl;
  }
  else{
    cout << "=" << endl;
  }
}

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

using namespace std;

#define make_unique(a) (a.erase(unique(a.begin(),a.end()),a.end()))
#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define readln(x) (getline(cin, x))
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))

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

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

void solve() {
    int n, l;
    cin >> n >> l;
    vector<string> v(n);
    for(int i=0; i<n; i++) {
        cin >> v[i];
    }
    sort(allof(v));
    for(string x : v) cout << x;
    cout << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	int H, W, D;
	cin >> H >> W >> D;
	int A[310][310];
	rep(i,H){
		rep(j,W) cin >> A[i][j];
	}
	int Q;
	cin >> Q;
	vector<int> L(Q), R(Q);
	rep(i,Q) cin >> L[i] >> R[i];
	rep(i,Q) L[i]--, R[i]--;
	vector<P> C(H*W+1);
	rep(i,H){
		rep(j,W) C[A[i][j]-1]=P(i,j);
	}
	vector<vector<int>> sum(D);
	rep(i,D) sum[i].emplace_back(0);
	rep(i,D){
		for(int j=i; j+D<H*W; j+=D){
			int x=abs(C[j+D].first-C[j].first);
			int y=abs(C[j+D].second-C[j].second);
			sum[i].emplace_back(sum[i].back()+x+y);
		}
	}
	rep(i,Q){
		int d=L[i]%D;
		int l=L[i]/D, r=R[i]/D;
		cout << sum[d][r]-sum[d][l] << endl;
	}

	return 0;
}

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

#define min(x,y) ((x)>(y)?(y):(x))

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}
int asc2(const void **a,const void **b){
  return (*(int **)b)[0] - (*(int **)a)[0];
}

int A[100000];
int** BC;
int main(){
  int N,M,i,count;
  long long int sum = 0;
  scanf("%d %d",&N,&M);
  for(i = 0;i < N;i++){
    scanf("%d",&A[i]);
  }
  qsort(A, N, sizeof(int), asc);
  BC = (int**)malloc(sizeof(int*)*M);
  for(i = 0;i < M;i++){
    BC[i] = (int*)malloc(sizeof(int)*2);
    scanf("%d %d",&BC[i][1],&BC[i][0]);
  }qsort(BC,M,sizeof(int*),asc2);count = 0;
  for(i = 0;i < M;i++){
    if(A[min(count + BC[i][1],N-1)] >= BC[i][0]){
      for(;A[count] < BC[i][0]&&count < N;count++){
        sum += (long long int)BC[i][0];
      }break;
    }sum += (long long int)BC[i][0] * (long long int)min(BC[i][1],N-count);count += BC[i][1];
    if(count >= N){break;}
  }
  for(i = count;i < N;i++){
    sum += (long long int)A[i];
  }
  printf("%lld\n",sum);return 0;
}

Measured memory_bytes: 5304
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               ll n,k;
               cin>>n;
               ll a[n];
               ll fre[100005];
               ll sum=0;
               memset(fre,0,sizeof(fre));
               for(ll i=0;i<n;++i)
               {
                    cin>>a[i];
                    fre[a[i]]++;
                    sum+=a[i];
               }
               ll q;
               cin>>q;
               ll x,y;

               for(ll i=1;i<=q;++i)
               {
                    cin>>x>>y;

                    sum -= x*fre[x];
                    sum += fre[x]*y;
                    fre[y] += fre[x];
                    fre[x] = 0;

                    cout<<sum<<"\n";
               }
       }
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int p,q,r,k1,k2,k3,k4,k5,k6;
    cin>>p>>q>>r;
    k1=p+q;
    k2=r+q;
    k3=p+r;
    k4=q+r;
    k5=r+p;
    k6=q+p;
    cout<<min(k1,min(k2,min(k3,min(k4,min(k5,k6)))));
    return 0;
}


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

#define int long long

auto main() -> signed {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > v(n);
    for(int i=0; i<m; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=0; i<n; ++i) cout <<v[i].size() << endl;
    return 0;
}



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

void insertionSort(int x[], int y) {

	int v;
	int j;
	for (int i = 1; i < y; i++) {
		v = x[i];
		j = i - 1;

		while (j >= 0 && x[j] > v)
		{
			x[j + 1] = x[j];
			j--;
		}
		x[j + 1] = v;
		for (int k = 0; k < y; k++) {
			cout << x[k];
			if (k != y -1) {
				cout << " ";
			}
		}
		cout << endl;
	}
}


int main()
{
	int a;
	cin >> a;
	int x[100];

	int i = 0;

	while (true)
	{
		cin >> x[i];
		i++;
		if (cin.eof()) { break; }
	}

	for (int k = 0; k < a; k++) {
		cout << x[k];
		if (k != a-1) {
			cout << " ";
		}
	}
	cout << endl;

	insertionSort(x, a);

	return 0;
}

Measured memory_bytes: 3084
using System;
using System.Linq;

namespace ZTP001
{
    class A
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int A = input[1];
            int B = input[2];

            Console.WriteLine("{0} {1}", Math.Min(A, B), Math.Max(0, A + B - N));
        }
    }
}


Measured memory_bytes: 13396
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define eps 1e-10
using namespace std;

ll r1,c1,r2,c2,fac[maxn],inv[maxn];
const ll mod=1e9+7;

inline ll qpow(ll a,ll b)
{
	ll ans=1,base=a;
	while(b)
	{
		if(b&1) ans=(ans*base)%mod;
		base=(base*base)%mod; b>>=1;
	}
	return ans;
}

inline ll C(ll n,ll m){return ((fac[n]*inv[m])%mod*inv[n-m])%mod;}
inline ll F(ll a,ll b)
{
	ll res=0;
	for(int i=1;i<=b+1;i++) res=(res+C(a+i,i)%mod);
	return res;
}

int main()
{
	cin>>r1>>c1>>r2>>c2; fac[0]=1; inv[0]=1;
	for(int i=1;i<=maxn-4;i++) fac[i]=(i*fac[i-1])%mod;
	for(int i=1;i<=maxn-4;i++) inv[i]=qpow(fac[i],mod-2);
	ll p1=F(r2,c2)-F(r1-1,c2)-F(r2,c1-1)+F(r1-1,c1-1);
	p1=(p1%mod+mod)%mod; cout<<p1<<endl;
	return 0;
}

Measured memory_bytes: 31488
A, B, C = map(int, input().split())

import math
N = (A * B) // math.gcd(A, B)

array_A = [0]*N
array_B = [0]*N

for i in range(A, N+1, A):
    array_A[i-1] = 1

for i in range(C, N+1, B):
    array_B[i-1] = 1

possible = 0
for i in range(N):
    possible += array_A[i]*array_B[i]

print("YES" if possible else "NO")

Measured memory_bytes: 9200
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;
using ll=long long;
using vi=vector<int>;


struct city_t
{
	int x, y;
	vi e;
	int id, passed;
};


bool x_cmp(city_t& a, city_t& b)
{
	return a.x<b.x;
}


bool y_cmp(city_t& a, city_t& b)
{
	return a.y<b.y;
}


int distance(city_t& a, city_t& b)
{
	return min(abs(a.x-b.x), abs(a.y-b.y));
}


struct que_t
{
	int m_id;
	ll m_cost;
	que_t(int id, int cost):m_id(id),m_cost(cost)
	{
	}
	bool operator<(const que_t&rhs) const
	{
		return m_cost>rhs.m_cost;
	}
};


ll solve(vector<city_t>& vcity)
{
	priority_queue<que_t> q;
	int id=0;
	ll cost=0;
	ll ans=0;

	q.push(que_t(id, cost));
	while(!q.empty())
	{
		id=q.top().m_id;
		cost=q.top().m_cost;
		q.pop();

		if(vcity[id].passed) continue;
		vcity[id].passed=1;
		ans+=cost;

		for(auto rid:vcity[id].e)
		{
			if(!vcity[rid].passed)
			{
				q.push(que_t(rid, distance(vcity[id], vcity[rid])));
			}
		}
	}
	return ans;
}


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vector<city_t> vcity(n);

		for(int i=0;i<n;i++)
		{
			scanf("%d%d", &vcity[i].x, &vcity[i].y);
			vcity[i].id=i;
			vcity[i].passed=0;
		}
		{
			auto temp=vcity;
			sort(temp.begin(), temp.end(), x_cmp);
			for(int i=0;i<n;i++)
			{
				if(i+1<n) vcity[temp[i].id].e.push_back(temp[i+1].id);
				if(i-1>=0) vcity[temp[i].id].e.push_back(temp[i-1].id);
			}
			sort(temp.begin(), temp.end(), y_cmp);
			for(int i=0;i<n;i++)
			{
				if(i+1<n) vcity[temp[i].id].e.push_back(temp[i+1].id);
				if(i-1>=0) vcity[temp[i].id].e.push_back(temp[i-1].id);
			}
		}

		printf("%lld\n", solve(vcity));
	}

	return 0;
}


Measured memory_bytes: 11452
#
# abc088 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 0 1
2 1 2
1 0 1"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 2 2
2 1 2
2 2 2"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """0 8 8
0 8 8
0 8 8"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """1 8 6
2 9 7
0 7 7"""
        output = """No"""
        self.assertIO(input, output)


def resolve():
    c = []
    for _ in range(3):
        c.append(list(map(int, input().split())))

    a1 = 0
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1

    if a2+b2 == c[1][1] and a2+b3 == c[1][2] and a3+b2 == c[2][1] and a3+b3 == c[2][2]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16276
from sys import stdin
def input():
    return stdin.readline().strip()

n = int(input())
m, a, r, c, h = 0, 0, 0, 0, 0
for _ in range(n):
    i = input()
    i = i[0]
    if i == 'M':
        m += 1
    elif i == 'A':
        a += 1
    elif i == 'R':
        r += 1
    elif i == 'C':
        c += 1
    elif i == 'H':
        h += 1

ans = 0
from itertools import combinations
for i in combinations([m, a, r, c, h], 3):
    i, j, k = i
    ans += i * j * k
print(ans)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    int N,K;
    cin >> N >> K;
    vector<Pll> pos(N);
    vector<ll> lx(N),ly(N);
    rep (i,N){
        ll x,y;
        cin >> x >> y;
        pos[i]=Pll(x,y);
        lx[i]=x;
        ly[i]=y;
    }
    sort(lx.begin(),lx.end());
    sort(ly.begin(),ly.end());
    ll ans=-1;
    rep(i,N-1){
        for (int j=i+1;j<N;j++){
            rep(k,N-1){
                for (int l=k+1;l<N;l++){
                    int count=0;
                    rep(m,N){
                        ll x=pos[m].first,y=pos[m].second;
                        if (x>=lx[i]&&x<=lx[j]&&y>=ly[k]&&y<=ly[l]){
                            count++;
                        }
                    }
                    if (count>=K){
                        ll area=(lx[j]-lx[i])*(ly[l]-ly[k]);
                        if (ans==-1){
                            ans=area;
                        }
                        else {
                            ans=min(ans,area);
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int N, K, a[100009];
long long ans, sp[100009], s[100009];

long long qry (int st, int dr)
{
    return max (0LL, s[dr] - s[st - 1]);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &K), ans = 0;
for (int i=1; i<=N; i++)
{
    scanf ("%d", &a[i]);
    int x = 0;
    if (a[i] > x) x = a[i];
    sp[i] = sp[i - 1] + x, s[i] = s[i - 1] + a[i];
}
for (int i=1; i<=N - K + 1; i++)
{
    long long curr = sp[i - 1] + sp[N] - sp[i + K - 1] + qry (i, i + K - 1);
    if (curr > ans) ans = curr;
}
printf ("%lld\n", ans);
return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int a, b;
	cin >> a >> b;
	vector<string> s(a);
	rep(i,a) cin >> s[i];
	rep(i,b+2) cout << "#";
	cout << endl;
	rep(i,a){
		cout << "#" << s[i] << "#" << endl;
	}
	rep(i,b+2) cout << "#";
	cout << endl;
	return 0;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f3f;
const int maxn = 1e5+500;
ll T,n,m;
int s[1005][1005];
int ct[1005];
int judge(){
	for(int i=1;i<=n;i++)
		if(ct[i]<n-1){
			return 1;
		}
	//cout<<2222<<endl;
	return 0;		
}

int vis[maxn];
int main(){
	//int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=0;j<n-1;j++){
			scanf("%d",&s[i][j]);
		}
		ct[i] = 0;
	}
	int cnt = 0;
	while(judge()){
		//cout<<11111<<endl;
		int flag=0;
		for(int i=1;i<=n;i++)
			vis[i] = 0;
		for(int i=1;i<=n;i++){
			int now = s[i][ct[i]];
			if(ct[i]>=n-1)
				continue;
			if(vis[now]){
				vis[i] = 1;
				continue;
			}
			if(vis[i])
				continue;
			//cout<<i<<" "<<now<<endl;
			if(i==s[now][ct[now]]&&!vis[i]&&!vis[now]){
			//	cout<<i<<"  "<<now<<endl;
				vis[i] = 1;
				vis[now]=1;
				ct[i]++;
				ct[now]++;
				flag = 1;
			}
		}
		if(!flag){
			printf("-1\n");
			return 0;
		}
		cnt++;
	}
	printf("%d\n",cnt);
	
}



Measured memory_bytes: 4224
n, m, x = map(int,input().split())
a = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
for i in range(x):
    if i in a:
        cnt1 += 1
for j in range(x,n+1):
    if j in a:
        cnt2 += 1
        
print(min(cnt1, cnt2))

Measured memory_bytes: 61812
#include <iostream>
using namespace std;
int main(void){
    int n,a[6]={0};
    cin>>n;
    for(int i=0; i<n; i++){
        double h;
        cin>>h;
        if(h<165)
        a[0] ++;
        if(165<=h&&h<170)
        a[1] ++;
        if(170<=h&&h<175)
        a[2] ++;
        if(175<=h&&h<180)
        a[3] ++;
        if(180<=h&&h<185)
        a[4] ++;
        if(h>=185)
        a[5] ++;
    }
    for(int i=0; i<6; i++){
        cout<<i+1<<":";
        for(int j=0; j<a[i]; j++){
            cout<<"*";
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n;
    ll c;
    cin>>n>>c;
    vc<ll> x(n),v(n);
    for(int i=0;i<n;i++) cin>>x[i]>>v[i];
    ll ans=0;
    {
        vc<ll> pre(n);
        multiset<ll> st,st2;
        st.insert(0);
        st2.insert(0);
        pre[0]=v[0];
        st.insert(pre[0]-2*x[0]);
        st2.insert(pre[0]-x[0]);
        for(int i=1;i<n;i++)
        {
            pre[i]=pre[i-1]+v[i];
            st.insert(pre[i]-2*x[i]);
            st2.insert(pre[i]-x[i]);
            ans=max(ans,pre[i]-x[i]);
        }
        ll cur=0;
        for(int i=n-1;i>=0;i--)
        {
            cur+=v[i];
            st.erase(st.find(pre[i]-2*x[i]));
            st2.erase(st2.find(pre[i]-x[i]));
            ans=max({cur-(c-x[i])+*st.rbegin(),ans,cur-2*(c-x[i])+*st2.rbegin()});
        }
    }
    print(ans);
}

Measured memory_bytes: 11904
import java.util.*;

public class Main {

    static List<List<Integer>> edges = new ArrayList<>();
    static int[] dp = null;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        dp = new int[N];
        Arrays.fill(dp,-1);
        for (int i = 0; i < N; i++) {
            edges.add(new ArrayList<>());
        }
        for (int i = 0; i < M; i++) {
            int x = sc.nextInt()-1;
            int y = sc.nextInt()-1;
            edges.get(x).add(y);
        }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            ans = Math.max(ans , rec(i));
        }

        System.out.println(ans);
    }

    static private int rec(int node){
        if(dp[node]!=-1) return dp[node];
        int ans =0;
        for(int node2 : edges.get(node)){
            ans = Math.max(ans,rec(node2)+1);
        }
        dp[node] = ans;
        return ans;
    }
}


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

int main()
{
  int a[3];
  int b, c;

  cin >> a[0] >> a[1] >> a[2] >> b >> c;

  sort(a, a + 3);

  if (c < b){
    b = c;
  }
  cout << a[0] + b - 50 << endl;

  return 0;
}

Measured memory_bytes: 1176
#include<stdio.h>

#define N 100
#define INFTY (1<<21)

int n,M[N][N];
int d[N];

void bfs(int s,int len){
  int i;
  len++;
  d[s]=len;
  for(i=0;i<n;i++){
    if(M[s][i]==1){
      if(d[i]<=len&&d[i]>=0)continue;
      bfs(i,len);
    }
  }
}

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

  for(i=0;i<n;i++){
    printf("%d %d\n",i+1,d[i]);
  }

  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+20;
ll x[N];
int main()
{
	int n;
	ll A,B;
	while(cin>>n>>A>>B)
	{
		ll ans=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%I64d",&x[i]);
		}
		for(int i=2;i<=n;i++)
		{
			ll w=(x[i]-x[i-1])*A;
			ans+=min(w,B);
		}
		cout<<ans<<endl;
	} 
 
	return 0;
}


Measured memory_bytes: 1024
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

constexpr int bm = 2500;
ll BIT[51][bm];
void add(int A, int gin, ll co) {
	co = 4e12 - co;
	while (gin > 0) {
		BIT[A][gin] = max(BIT[A][gin], co);
		gin -= gin & -gin;
	}
}
ll query(int A, int gin) {
	ll kotae = 0;
	while (gin < bm) {
		kotae = max(BIT[A][gin], kotae);
		gin += gin & -gin;
	}
	return 4e12 - kotae;
}

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


	int N, M, S;
	cin >> N >> M >> S;
	if (S >= 2460) S = 2460;

	vector<ll> E[51];
	rep(i, M) {
		int u, v, a;
		ll b;
		cin >> u >> v >> a >> b;
		b = a << 8 | b << 16;
		E[u].pb(v | b);
		E[v].pb(u | b);
	}
	int C[51], D[51];
	rep1(i, N) {
		cin >> C[i] >> D[i];
	}

	add(1, S + 1, 0);
	priority_queue<ll, vector<ll>, greater<ll> > PQ;
	PQ.push((1 << 12) + S + 1);

	while (PQ.size()) {
		auto p = PQ.top();
		PQ.pop();
		ll ti = p >> 18;
		int i = p >> 12 & 63;
		int gin = p & 4095;



		if (ti > query(i, gin)) continue;

		ll ti2 = ti + D[i];
		int gin2 = gin + C[i];
		if (gin2 > 2460) gin2 = 2460;
		if (ti2 < query(i, gin2)) {
			add(i, gin2, ti2);
			PQ.push(ti2 << 18 | i << 12 | gin2);
		}

		for (auto pp : E[i]) {
			int to = pp & 255;
			ti2 = ti + (pp >> 16);
			gin2 = gin - (pp >> 8 & 255);
			if (gin2 > 0) {
				if (ti2 < query(to, gin2)) {
					add(to, gin2, ti2);
					PQ.push(ti2 << 18 | to << 12 | gin2);
				}
			}
		}

	}

	for (int i = 2; i <= N; i++) {
		co(query(i, 1));
	}



	Would you please return 0;
}

Measured memory_bytes: 4632
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

ll seg[1 << 18];
constexpr ll SIZE = 1 << 17;

void update(int x, int val) {
    int p = SIZE - 1 + x;
    while(p >= 0) {
        chmax(seg[p], val);
        if(p == 0) break;
        p = (p - 1) / 2;
    }
}

int solve(int a, int b, int l=0, int r=SIZE, int k=0) {
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return seg[k];
    int mid = (l+r) / 2;
    int vl = solve(a, b, l, mid, 2*k+1);
    int vr = solve(a, b, mid, r, 2*k+2);
    return max(vl, vr);
}

int N, x;

signed main() {
    cin >> N;
    int sum = 0;
    rep(i,0,N) {
        cin >> x; sum += x;
        int val = solve(0, x) + x;
        update(x, val);
    }
    cout << sum - solve(0, N+1) << endl;
    return 0;
}

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

#define llong long long 
#define xx first
#define yy second
#define ii pair<int, int>
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = - 1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i++ < n; )

#define maxn 2005
int n;
int a[maxn];

bitset<maxn * maxn> b;

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n;
  rep(i, n) cin >> a[i];
  b[0] = 1;
  rep(i, n) {
    b = (b << a[i]) | b;
    b[a[i]] = 1;
  }
  b[0] = 0;
  vector<llong> c;
  rep(i, maxn * maxn) if (b[i]) c.push_back(i);
  cout << c[(len(c) -1 )/ 2];

  return 0;
}


Measured memory_bytes: 20712
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    rep(i,1,10)rep(j,1,10){
      if(i*j==n){cout<<"Yes";
                 return 0;
                }
    }
cout<<"No";
}


Measured memory_bytes: 256