akhauriyash/Code-Regression huggingface dataset:
/************
* 	@Just Another Source code by: ankit.sangwan1999
*	@created on: 22 May 2020
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) //;cout.tie(NULL)
#define ll long long
const int mod = 1e9+7;
#define endl '\n'

const ll inf = 1e18L + 5;


signed main(){

    fastio;

    int N;
    ll W;
    cin>>N>>W;
    ll w[N];
    int v[N];

    int v_max = INT_MIN;
    for(int i=0;i<N;i++){
    	cin>>w[i]>>v[i];
        v_max = max(v_max, v[i]);
    }

    int v_pos = N*v_max; // maximum Value Possible.

    vector<vector<ll>>dp(N+1, vector<ll>(v_pos+1,inf));
    // // In dp[i][j], this time we will Store the Minimum weight for i items such that there value is <= j. 
    // // whereas earliers it was maximum value for i items such that there weight is <=j.

    dp[0][0] = 0;
    for(int i=0;i<=N;i++){
        dp[i][0] = 0;
    }
    for(int i=1;i<=N;i++){
    	for(int j=1;j<=v_pos;j++){
            if(v[i-1] <= j ){ 
                dp[i][j] = min(dp[i-1][j-v[i-1]] + w[i-1], dp[i-1][j]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
    	}
    }

    ll ans = 0;

    // for(int i=0;i<=N;i++){
    //     for(int j=0;j<=v_pos;j++){
    //         if(dp[i][j]==inf){
    //             cout<<"X ";
    //         }
    //         else
    //             cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    for(int val = 0; val<=v_pos; val++){

        if(dp[N][val] <= W){
            ans = max(ans, (ll)val);
        }

    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  vector <ll> v(26, 0);
  rep(i, s.size()) {
    ll num = s.at(i)-'A';
    v.at(num)++;
  }
  ll flag = 0;
  rep(i, 26) {
    if (v.at(i) == 2) flag++;
  }
  if (flag == 2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import deque

def f(x, y):
    if x == 0:
        return y
    if y == 0:
        return -x
    if x == r:
        return -(x + y)
    if y == c:
        return x + y

r, c, n = map(int, input().split())
xy = []
lxy = 0
for i in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    d = []
    if min(x1, y1) == 0 or x1 == r or y1 == c:
        d.append([f(x1, y1), i])
    if min(x2, y2) == 0 or x2 == r or y2 == c:
        d.append([f(x2, y2), i])
    if len(d) == 2:
        xy.append(d[0])
        xy.append(d[1])
        lxy += 2
xy.sort()
q = deque()
lq = -1
for i in range(lxy):
    if not q:
        q.append(xy[i][1])
        lq += 1
    else:
        if q[lq] == xy[i][1]:
            q.pop()
            lq -= 1
        else:
            q.append(xy[i][1])
            lq += 1
print("YES" if not q else "NO")

Measured memory_bytes: 100596
import java.util.*;
 
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int ans = 0;
		for (int i=0;i<=a;i++) {
			for (int j=0;j<=b;j++) {
				int hope_c = (x-i*500-j*100)/50;
				if (0<=hope_c && hope_c <= c) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
 
}

Measured memory_bytes: 35628
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
using P = pair<ll,ll>;

void printNo(){
  cout << "NO" << endl;
  exit(0);
}

//本来はREだけど通ってしまう
int main() {
  string s;cin >> s;
  string pre = "";
  for(ll i=0;i<(ll)s.size();++i){
    if( s.at(i) != 'd' && s.at(i) != 'e' ) printNo();

    if( s.at(i) == 'd' ){
      string tmp = s.substr(i,5);
      if( tmp == "dream" ) i += 4;
      else printNo();
      pre = "dream";
    }
    else if( s.at(i) == 'e' ){
      string tmp = s.substr(i,6);
      if( tmp == "eraser" ){
        i+= 5;
        pre = "eraser";
      }
      else if( tmp.substr(0,5) == "erase" ){
        i+= 4;
        pre = "erase";
      }
      else if( tmp.at(1) == 'r' && pre == "dream" ){
        i++;
        pre = "dreamer";
      }
      else printNo();
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 3848
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int button_a, button_b, answer;
    button_a = Integer.parseInt(sc.next());
    button_b = Integer.parseInt(sc.next());
    if(button_a > button_b) {
      answer = 2 * button_a - 1;
    } else if(button_b > button_a) {
      answer = 2 * button_b -1;
    } else {
      answer = 2 * button_a;
    }
    System.out.println(answer);
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
//#include <unordered_set>
//#include <unordered_map>
#include <stdio.h>

#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INPUT1(n, a) for(int i##n = 0; i##n < n; i##n++) {cin >> a[i##n]; } //n = count, a = vector 
#define OUTPUT1(n, a) cout << "---count---" << endl << n << endl << "---content---" << endl; for(const auto b : a){cout << b << endl; }
#define INPUT2(x, y, field) for(int i##x = 0; i##x < y; i##x++) { for(int j##x = 0; j##x < x; j##x++) { cin >> field[i##x][j##x]; } }
#define OUTPUT2(x, y, field) cout << "---count---" << endl << x << " " << y << endl <<"---content---" << endl; for(int i##x = 0; i##x < y; i##x++) { cout << i##x << "   "; for(int j##x = 0; j##x < x; j##x++) { cout << field[i##x][j##x] << " "; } cout << endl; }

using namespace std;
//using ll = long long;

const int INF = 1001001001;

int main()
{
    int h(0), w(0);
	while(true){
	    cin>>h>>w;
	    if(h==0&&w==0)break;
	    rep(j, h)
	        rep(k, w){
	            if(j==0||j==h-1||k==0||k==w-1)cout<<"#";
	            else cout<<".";
	            if(k==w-1)cout<<endl;
	        }
	    cout<<endl;
	}
}


Measured memory_bytes: 3096
#ifdef DEBUG
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <cassert>
#include <sstream>
#include <fstream>
#include <functional>
#include <set>
#include <bitset>
#include <string>
#include <utility>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#else
#include <bits/stdc++.h>
#endif

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

const int maxn = 233, mod = 1e9 + 7;

int n, m, K, T, TT, dfn[maxn], C[maxn][maxn], low[maxn], ans = 1, tag[maxn], top, stk[maxn];
std::vector<int> g[maxn];

inline int pow_mod(int x, int n) {
	int y = 1;
	while(n) {
		if(n & 1) {
			y = (long long) y * x % mod;
		}
		x = (long long) x * x % mod;
		n >>= 1;
	}
	return y;
}

inline int cyc(int n) {
	int ret = 0;
	for (int i = 1; i <= n; ++i) {
		ret = (pow_mod(K, std::__gcd(i, n)) + ret) % mod;
	}
	return (long long) ret * pow_mod(n, mod - 2) % mod;
}

inline void dfs(int u) {
	low[u] = dfn[u] = ++T;
	stk[top++] = u;
	for (int &v: g[u]) {
		if(!dfn[v]) {
			dfs(v);
			if(low[v] >= dfn[u]) {
				++TT;
				int v_n = 1, e_n = 0, rem = top;
				while(stk[top] != v) {
					++v_n;
					int x = stk[--top];
					for (int y: g[x]) {
						if(tag[y] == TT) {
							++e_n;
						}
					}
					tag[x] = TT;
				}
				for (int y: g[u]) {
					if(tag[y] == TT) {
						++e_n;
					}
				}
				if(e_n == v_n) {
					ans = (long long) ans * cyc(v_n) % mod;
				}
				else if(e_n > v_n) {
					ans = (long long) ans * C[e_n + K - 1][K - 1] % mod;
				}
				else {
					ans = (long long) ans * pow_mod(K, e_n) % mod;
				}
			}
			else {
				low[u] = std::min(low[u], low[v]);
			}
		}
		else {
			low[u] = std::min(low[u], dfn[v]);
		}
	}
	return;
}

int main() {
	for (int i = 0; i < maxn; ++i) {
		C[i][0] = 1;
		for (int j = 1; j <= i; ++j) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
		}
	}
	scanf("%d%d%d", &n, &m, &K);
	while(m--) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for (int u = 1; u <= n; ++u) {
		if(!dfn[u]) {
			top = 0;
			dfs(u);
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
A, B, K = map(int, raw_input().split())
for i in range(K):
    if i % 2 == 0:
        if A % 2 != 0:
            A = A - 1
        B = B + A / 2
        A = A / 2
    else:
        if B % 2 != 0:
            B = B - 1
        A = A + B / 2
        B = B / 2
print(A)
print(B)

Measured memory_bytes: 2568
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int w = scan.nextInt();
		int i,j;
		char a,b,tmp;

		while(h!=0) {
			for(i=0;i<h;i++) {
				a = '#';
				b = '.';
				for(j=0;j<w;j++) {
					
					if(i%2 == 0) {
						System.out.print(a);
					}else {
						System.out.print(b);
					}
					tmp = a;
					a = b;
					b = tmp;
				}
				System.out.println();
			}
			System.out.println();
			h = scan.nextInt();
			w = scan.nextInt();
		}
		scan.close();
	}
}



Measured memory_bytes: 36968
H,W,K = map(int,input().split())
import numpy as np
C = np.zeros((H,W),dtype=np.bool)
for h in range(H):
    S = input()
    for w in range(W):
        if S[w] == '#':
            C[h][w] = 1
from copy import deepcopy as dp
hlen = len(str(bin(2**H-1))[2:])
wlen = len(str(bin(2**W-1))[2:])
ans = 0
for h in range(2**H):
    for w in range(2**W):
        t_arr = dp(C)
        tmp_h = str(bin(h))[2:].zfill(hlen)
        tmp_w = str(bin(w))[2:].zfill(wlen)
        for i,hh in enumerate(tmp_h):
            if hh == '1':
                t_arr[i,:] = 0
        for i,ww in enumerate(tmp_w):
            if ww == '1':
                t_arr[:,i] = 0
        if t_arr.sum() == K:
            ans += 1
print(ans)


Measured memory_bytes: 27312
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 3e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll tree[4 * N], lazy[4 * N];
int idx;
vector<int> adj[N];
pair<int, int> tme[N];

void dfs(int root, int par) {
  tme[root].first = ++idx;
  for (auto it : adj[root]) {
    if (it == par)
      continue;
    dfs(it, root);
  }
  tme[root].second = idx;
}

void propagate(int node, int start, int end) {
  if (!lazy[node])
    return;
  tree[node] += lazy[node] * (end - start + 1);
  if (start != end) {
    lazy[node * 2] += lazy[node];
    lazy[node * 2 + 1] += lazy[node];
  }
  lazy[node] = 0;
}

ll query(int node, int start, int end, int l, int r) {
  propagate(node, start, end);
  if (l > end || r < start)
    return 0;
  if (start >= l && end <= r)
    return tree[node];
  int mid = (start + end) / 2;
  ll p1 = query(node * 2, start, mid, l, r);
  ll p2 = query(node * 2 + 1, mid + 1, end, l, r);
  return p1 + p2;
}

void update(int node, int start, int end, int l, int r, ll val) {
  propagate(node, start, end);
  if (start > r || end < l)
    return;
  if (start >= l && end <= r) {
    lazy[node] = val;
    propagate(node, start, end);
    return;
  }
  int mid = (start + end) / 2;
  update(node * 2, start, mid, l, r, val);
  update(node * 2 + 1, mid + 1, end, l, r, val);
  tree[node] = tree[node * 2] + tree[node * 2 + 1];
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, q, u, v;
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 1);
  int val;
  for (int i = 0; i < q; ++i) {
    cin >> u >> val;
    update(1, 1, idx, tme[u].first, tme[u].second, val);
  }
  for (int i = 1; i <= n; ++i) {
    cout << query(1, 1, idx, tme[i].first, tme[i].first) << ' ';
  }
  return 0;
}


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

using namespace std;

#define int 		long long
#define double 		long double
#define pb 			push_back
#define in 			insert
#define mp 			make_pair
#define f 			first
#define s 			second
#define x 			first
#define y 			second
#define all(el) 	el.begin(), el.end()
#define allr(el) 	el.rbegin(), el.rend()
#define sz(el) 		(int)el.size()

template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1ll;} else {return 0ll;}}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1ll;} else {return 0ll;}}

istream& operator>>(istream &in, vector<int> &a) {
	for (int &now : a) {
		in >> now;
	}
	return in;
}

ostream& operator<<(ostream &out, vector<int> &a) { 
    for (int &now : a) {
    	out << now << ' ';
    }
    out << "\n";
    return out;
}

signed main() {

	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	vector<int> arr = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	k--;
	cout << arr[k];

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; i++)
		cin >> vec.at(i);

	sort(vec.begin(), vec.end());
	cout << vec.at(N - 1) - vec.at(0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,i,A[100000],x,ch,j;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  x=A[n-1];
  i=-1;
  for(j=0;j<n-1;j++){
    if(A[j]<=x){
      i++;
      ch=A[i];
      A[i]=A[j];
      A[j]=ch;
    }
  }
  ch=A[i+1];
  A[i+1]=A[n-1];
  A[n-1]=ch;

  for(j=0;j<i+1;j++)printf("%d ",A[j]);
  printf("[%d] ",A[j]);j++;
  for(;j<n-1;j++)printf("%d ",A[j]);
  printf("%d\n",A[j]);

  return 0;
}



Measured memory_bytes: 2084
import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]) {
    val input = readLine().toInt
    val hours = input / 60 / 60
    val minutes = input / 60 % 60
    val seconds = input % 60

    println(s"$hours:$minutes:$seconds")
  }
}

Measured memory_bytes: 43736
#coding: utf-8
from collections import defaultdict
import sys

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 3000  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

N, K = (int(i) for i in input().split())
for i in range(1, K + 1):
    ret = cmb(N-K+1, i, p)
    ret %= p
    ret *= cmb(K-1, i-1, p)
    ret %= p
    print(ret)


Measured memory_bytes: 9792
from collections import defaultdict
from bisect import bisect_right

s,t=input(),input()
m=len(s)

if set(s)&set(t)!=set(t):print(-1);exit()

dict=defaultdict(list)
for i,j in enumerate(s):
    dict[j] +=[i+1]

ans,index=0,0
for i in t:
    point=bisect_right(dict[i],index)
    if point==len(dict[i]):num=dict[i][0]
    else:num=dict[i][point]

    if index>=num:
        ans +=m
    index=num

print(ans+index)

Measured memory_bytes: 85112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (ll i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

vector<int> to[200005];

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n) {
        ans += (i+1)*(n-i);
    }
    rep(i, n-1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        if (u>v) swap(u, v);
        ans -= (u+1)*(n-v);
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8240
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << (x) << ", "
#define de(x) cout << #x << " = " << (x) << "\n"
#define endl "\n"

//-----
const int N = 3e5 + 7;
int pre[N], suf[N];
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n; string s;
	cin >> n >> s;
	rep(i, 0, sz(s)) pre[i + 1] = (s[i] == 'W') + pre[i];
	per(i, 0, sz(s)) suf[i + 1] = (s[i] == 'E') + suf[i + 2];
	int ans = INT_MAX;
	rep(i, 1, sz(s) + 1) ans = min(ans, pre[i - 1] + suf[i + 1]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 2964
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
#include<fstream>
using namespace std;
typedef long long LL;

int main(void)
{
	LL h, n;
	cin >> h >> n;

	for (int i = 0; i < n; i++) {
		LL a;
		cin >>a;
		h-=a;
	}

	if (h > 0) {
		cout <<"No"<<endl;
	}
	else {
		cout <<"Yes"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[9];
int N;

int sig[9];
int main(void){
    // Your code here!
    for(int i=0;i<9;i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&N);
    for(int i=0;i<9;i++){
        sig[i]=0;
    }
    
    int b=0;
    for(int i=0;i<N;i++){
        scanf("%d",&b);
        for(int j=0;j<9;j++){
            if(a[j]==b){
                sig[j]=1;
            }
        }
    }
    
    if((sig[0]&&sig[3]&&sig[6])||(sig[1]&&sig[4]&&sig[7])||(sig[2]&&sig[5]&&sig[8])){
        printf("Yes");
    }else if((sig[0]&&sig[1]&&sig[2])||(sig[3]&&sig[4]&&sig[5])||(sig[6]&&sig[7]&&sig[8])){
        printf("Yes");
    }else if((sig[0]&&sig[4]&&sig[8])||(sig[2]&&sig[4]&&sig[6])){
        printf("Yes");
    }else{
        printf("No");
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cmath>
#include <deque>
#include <bitset>
#define ll long long
#define PI 3.1415926535897932384626433832795
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
#define readN(N,X) for(int i=0;i<N;i++) cin>>X[i];
#define pff pair<double,double>
using namespace std;

ll N;
ll A[55];
ll AA[55];
void solve() {
	ll res = 0;
	bool ganti = 1;
	while(ganti){
		ganti = 0;
		ll naik = 0;
		FOR(i,0,N){
			if (A[i] < N) continue;
			ganti = 1;
			ll bagi = A[i]/N;
			A[i] -= (N + 1) * bagi;
			//cout<<bagi<<endl;
			res += bagi;
			naik += bagi;
		}
		FOR(i,0,N) A[i] += naik;
	}
	cout<<res<<endl;

}


int main(){
	N = 50;
	ll K;
	cin>>K;
	ll res = K % 50;

	ll kagi = K / 50;
	kagi -= res; 
	for (int i=0;i<N;i++) AA[i] = 49 + kagi;
	
	for (int i=0;i<res;i++)
	AA[i] += 50;
	
	for (int i=0;i<N;i++) A[i] = AA[i];
	cout<<50<<endl;
	cout<<A[0];
	for (int i=1;i<N;i++) cout<<" "<<A[i];
	cout<<endl;
	//solve();
	

}

Measured memory_bytes: 256
#ifdef HIRO
#include "../stdc++.h"
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#include <bits/stdc++.h>
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int cal(int n){
  return 0;
}
int MOD = 1000000007;
int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  int n;
  // int m;
  cin >> n;
  // cin >> m;
  long ans=n;
  while(--n){
    (ans *= n) %= MOD;
  }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, z, w;
    cin>>n >> z >> w;
    vector<int>vec(n);
    for(int i=0;i<n;i++)cin>>vec[i];
    if(n==1){
        cout<<abs(vec[0] - w)<<endl;
    }
    else{
        cout<<max(abs(vec[n-1]-w), abs(vec[n-2]-vec[n-1]))<<endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
    long long x;
    long long k;
    long long d;

    long long ans;

    cin >> x >> k >> d;

    if ( x < 0 )
    {
        x = -x;
    }

    if ( ( x / d ) >= k )
    {
        ans = ( x - ( d * k ) );
    }
    else
    {
        long long rest = k - ( x / d );
        if ( rest % 2 == 0 )
        {
            ans = x % d;
        }
        else
        {
            ans = d - (x % d);
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3620
#include<iostream> 
#include<string>
#include<algorithm>

using namespace std;

int main(){
    int A,B,C,K;
    int ans=0,max_kazu;

    cin>>A>>B>>C;
    cin>>K;

    max_kazu=max(A,B);
    max_kazu=max(max_kazu,C);
    if(max_kazu==A){
        ans=C+B;
    }else if(max_kazu==B){
        ans=A+C;
    }else{
        ans=A+B;
    }
    for(int i=0;i<K;i++){
        max_kazu=max_kazu*2;
    }
    ans=ans+max_kazu;
    cout<<ans<<endl; 
    
}

Measured memory_bytes: 256
N = int(input())
H = [int(i) for i in input().split()]
H = H[::-1]

for i in range(N-1):
    if H[i] + 1 < H[i+1]:
        print('No')
        break
    elif H[i] + 1 == H[i+1]:
        H[i+1] -= 1
        
else:
    print('Yes')

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

using namespace std;

int main(){
  int x; cin>>x;
  switch(x%7){
  case 0:
    cout << "thu";
    break;
  case 1:
    cout << "fri";
    break;
  case 2:
    cout << "sat";
    break;
  case 3:
    cout << "sun";
    break;
  case 4:
    cout << "mon";
    break;
  case 5:
    cout << "tue";
    break;
  case 6:
    cout << "wed";
    break;
  }
  cout <<endl;
  
  return 0;
}



Measured memory_bytes: 3084
#include<stdio.h>

int a[1001]={0},n;

void insertionSort(void){
	for(int i=1;i<n;i++){
		int v=a[i];
		int j=i-1;
		while(j>=0&&a[j]>v){
			a[j+1]=a[j];
			j--;
			a[j+1]=v;
		}
		for(int k=0;k<n;k++){
			printf("%d", a[k]);
			if(k<n-1)printf(" ");
		}
		printf("\n");
	}
	return;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		printf("%d", a[i]);
		if(i<n-1)printf(" ");
	}
	printf("\n");
	insertionSort();

	return 0;
}


Measured memory_bytes: 2692
#![allow(unused)]
use std::io::Write;
use std::ops::{Add, Sub, Mul};

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

const M: isize = 998244353;

fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let d: Vec<usize> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.split_whitespace().map(|x| x.parse().unwrap()).collect()
    };

    if d[0] != 0 {
        println!("{}", 0);
        return;
    }

    let mut e = vec![0; n];
    let mut max_e = 0;
    for a in d {
        e[a] += 1;
        if a > max_e {
            max_e = a;
        }
    }

    // debugln!("{:?}", e);
    // debugln!("{}", max_e);

    if e[0] != 1 {
        println!("{}", 0);
        return;
    }

    let mut res = Modulo(1);
    for i in 1..(max_e + 1) {
        res = res * Modulo(e[i - 1]).pow(e[i] as usize);
    }

    println!("{}", res.0);
}

#[derive(Debug, Copy, Clone)]
struct Modulo(isize);

impl Modulo {
    fn pow(self, p: usize) -> Modulo {
        if self == Modulo(0) {
            return Modulo(0);
        }
        if p == 0 {
            return Modulo(1);
        }

        if p % 2 == 0 {
            let half = self.pow(p / 2);
            half * half
        } else {
            self.pow(p - 1) * self
        }
    }
}

impl Add for Modulo {
    type Output = Modulo;

    fn add(self, other: Modulo) -> Modulo {
        Modulo((self.0 + other.0) % M)
    }
}

impl Sub for Modulo {
    type Output = Modulo;

    fn sub(self, other: Modulo) -> Modulo {
        let mut value = (self.0 - other.0) % M;
        if value < 0 {
            value += M;
        }
        Modulo(value)
    }
}

impl Mul for Modulo {
    type Output = Modulo;

    fn mul(self, other: Modulo) -> Modulo {
        Modulo((self.0 * other.0) % M)
    }
}

impl PartialEq for Modulo {
    fn eq(&self, &other: &Self) -> bool {
        self.0 == other.0
    }
}

impl Eq for Modulo {}


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

int a, b, c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	if(a != b && b != c && c != a){
		printf("No\n");
		return 0;
	}
	if(a == b && b == c){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
f = [list(map(int, input().split())) for i in range(n)]
p = [list(map(int, input().split())) for i in range(n)]

cross = [0]*n
profit = 0
max = 0
for i in range(n):
    if f[i][0] == 1:
        cross[i] = cross[i] + 1

for i in range(n):
    for j in range(10):
        if cross[i] == j:
            profit = profit + p[i][j]

max = profit
cross = [0]*n
profit = 0

for day in range(1, 2047):
    S = format(day, 'b').zfill(10)
    ### それぞれのopeningdayについて、crossというn項のリストをつくる。pというprofitを計算し、maxと比較する。
    for j in range(10):
        if S[j] == str(1):
            for i in range(n):
                if f[i][j] == 1:
                   cross[i] = cross[i] + 1

    for i in range(n):
        for j in range(10):
           if cross[i] == j:
               profit = profit + p[i][j]

    if profit >= max:
        max = profit
    
    cross = [0]*n
    profit = 0

print(max)

Measured memory_bytes: 3188
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

mainasu = 0
purasu = 0
for i in range(M):
    if (A[i] < X):
        mainasu += 1
    if(A[i] > X):
        purasu += 1

if (mainasu > purasu):
    print(purasu)
elif(mainasu <= purasu):
    print(mainasu)


Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
	for (int a = 1; a < 10; a++)
	{
		for (int b = 1; b < 10; b++)
		{
			int total;
			total = a * b;
			printf("%dx%d=%d\n", a, b, total);
		}
	}
	return 0;
}

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

int dict[26];

int main()
{
	int ans = 0;
	string s;

	cin >> s;
	for (int i=0; i<4; ++i)
		dict[s[i]-'A']++;

	for (int i=0; i<26; ++i)
		if (dict[i])
			ans++;

	if (ans == 2)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}

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

int main(){
  string s;
  cin>>s;
  string alpha="abcdefghijklmnopqrstuvwxyz";
  int ans=10000;
  int count=0;
  string k,q;
  for(int al=0;al<26;al++){
    k=s;
    count=0;
    for(int i=0;i<100;i++){
      q="";
      if(k.size()==1){
        break;
      }
      for(int j=0;j<k.size()-1;j++){
        if(k[j]!=k[j+1]){
          goto skip;
        }
      }
      break;
      skip:
      for(int i=0;i<k.size()-1;i++){
        if(k[i]==alpha[al]||k[i+1]==alpha[al]){
          q+=alpha[al];
        }
        else{
          q+=k[i];
        }
      }
      count++;
      k=q;
    }
    ans=min(ans,count);
  }
  cout<<ans<<endl;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
int main(){
	int A; cin >> A;
	A--; //１個でA口増やせる 
	int B; cin >> B; //want
	int ans = 0;
	int suply = 1;
	while(1){
		if(suply>=B){
			cout<<ans<<endl;
			break;
		}
		suply+=A;
		ans++;
	}
}


Measured memory_bytes: 256
//# pragma GCC optimize ("O3")
//# pragma GCC optimize ("Ofast")
//# pragma GCC optimize ("unroll-loops")
//# pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#include <queue>
#include <iostream>
#include <utility>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;

bool OOB(ll x, ll y, ll N, ll M) { return 0 > x || x >= N || 0 > y || y >= M; }
#define X first
#define Y second
#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) ((int)(a.size()))
#define sf1(a) cin >> a
#define sf2(a,b) cin >> a >> b
#define sf3(a,b,c) cin >> a >> b >> c
#define sf4(a,b,c,d) cin >> a >> b >> c >> d
#define sf5(a,b,c,d,e) cin >> a >> b >> c >> d >> e
#define sf6(a,b,c,d,e,f) cin >> a >> b >> c >> d >> e >> f
#define pf1(a) cout << (a) << ' '
#define pf2(a,b) cout << (a) << ' ' << (b) << ' '
#define pf3(a,b,c) cout << (a) << ' ' << (b) << ' '<< (c) << ' '
#define pf4(a,b,c,d) cout << (a) << ' ' << (b) << ' '<< (c) << ' '<< (d) << ' '
#define pf5(a,b,c,d,e) cout << (a) << ' ' << (b) << ' '<< (c) << ' '<< (d) << ' '<< (e) << ' '
#define pf6(a,b,c,d,e,f) cout << (a) << ' ' << (b) << ' '<< (c) << ' '<< (d) << ' '<< (e) << ' ' << (f) << ' '
#define pf0l() cout << '\n';
#define pf1l(a) cout << (a) << '\n'
#define pf2l(a,b) cout << (a) << ' ' << (b) << '\n'
#define pf3l(a,b,c) cout << (a) << ' ' << (b) << ' '<< (c) << '\n'
#define pf4l(a,b,c,d) cout << (a) << ' ' << (b) << ' '<< (c) << ' '<< (d) << '\n'
#define pf5l(a,b,c,d,e) cout << (a) << ' ' << (b) << ' '<< (c) << ' '<< (d) << ' '<< (e) << '\n'
#define pf6l(a,b,c,d,e,f) cout << (a) << ' ' << (b) << ' '<< (c) << ' '<< (d) << ' '<< (e) << ' ' << (f) << '\n'
#define pfvec(V) for(auto const &t : V) pf1(t)
#define pfvecl(V) for(auto const &t : V) pf1(t); pf0l()

int n;
char adj[205][205];

bool bipar(){
  int state[205]={};
  int st = 0;
  queue<int> q;
  state[0]=1;
  q.push(0);
  while(!q.empty()){
    int cur = q.front();q.pop();
    rep(i,0,n){
      if(i==cur) continue;
      if(adj[i][cur]=='0') continue;
      if(state[i]==state[cur]) return false;
      if(state[i]) continue;
      state[i]=3-state[cur];
      q.push(i);
    }
  }
  return true;
}
int solve(int r){
  int dist[205];
  fill(dist,dist+n,-1);
  queue<int> q;
  q.push(r);
  dist[r]=1;
  while(!q.empty()){
    int cur=q.front();q.pop();
    rep(i,0,n){
      if(i==cur) continue;
      if(adj[i][cur]=='0') continue;
      if(dist[i]!=-1)continue;
      dist[i] = dist[cur]+1;
      q.push(i);
    }
  }
  return *max_element(dist,dist+n);
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(20);
///////////////////////////////////////////////
  sf1(n);
  rep(i,0,n)sf1(adj[i]);
  if(!bipar()){
    cout << -1;
    return 0;
  }
  int ans = 0;
  rep(i,0,n)ans=max(ans,solve(i));
  pf1l(ans);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int h = sc.nextInt();
      int w = sc.nextInt();
      if(h == 0 && w == 0) {
        break;
      } else {
        for(int i = 0; i < h; i++) {
          for(int j = 0; j < w; j++) {
            if(i == 0 || i == h - 1 || j == 0 || j == w - 1) {
              System.out.print("#");
            } else {
                System.out.print(".");
            }
          }
          System.out.println();
        }
        System.out.println();
      }
    }
  }
}



Measured memory_bytes: 36180
#include<iostream>
using namespace std;
int to[5010],n,len[5010];
long long a[5010],ans,k,now,cnt,sum[5010];
int main()
{
    int i,t,t0;
    cin>>n>>k;
    ans=-1999999999;
    for(i=1;i<=n;i++) cin>>to[i];
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=1;i<=n;i++)
    {
        len[i]=1;
        sum[i]=a[i];
        t=i;
        while(1)
        {
            t=to[t];
            if(t==i) break;
            len[i]++;
            sum[i]+=a[t];
        }
    }
    //for(i=1;i<=n;i++) cout<<len[i]<<" "<<sum[i]<<endl;
    for(i=1;i<=n;i++)
    {
        if(k<=2*len[i])
        {
            cnt=0;
            now=0;
            t=i;
            while(cnt<k)
            {
                cnt++;
                now+=a[t];
                t=to[t];
                ans=max(ans,now);
            }
        }
        else 
        {
            t0=k%len[i]+len[i];
            if(sum[i]>0) now=sum[i]*(k/len[i]-1);
            else now=0;
            cnt=0;
            t=i;
            while(cnt<t0)
            {
                cnt++;
                now+=a[t];
                t=to[t];
                ans=max(ans,now);
            }
        }
    }
    cout<<ans;
    system("pause");
}
        


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

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

    int hundreds_place = S / 100;

    int tens_place = S / 10;
    if (tens_place == 1 | tens_place == 11) {
        tens_place = 1;
    } else {
        tens_place = 0;
    }

    int ones_place = S % 100;
    if (ones_place == 1 | ones_place == 11) {
        ones_place = 1;
    } else {
        ones_place = 0;
    }

    int result = hundreds_place + tens_place + ones_place;
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
//0505-Questionnaire
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	while(1){
		cin>>n>>m;
		if(n==0)	return 0;
		vector<int> cnt(m);
		int in;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				cin>>in;
				cnt[j]+=in;
			}
		}
		bool first=false;
		for(int i=n;i>=0;i--){
			for(int j=0;j<m;j++){
				if(cnt[j]==i){
					if(first)	cout<<" ";
					cout<<j+1;	first=true;
				}
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int N = 300006;

int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll x;
    cin >> x;
    for (ll i = -3000; i <= 3000; i++) {
        for (ll j = -3000; j <= 3000; j++) {
            ll A = i * i * i * i * i;
            ll B = j * j * j * j * j;
            if (A - B == x) {
                cout << i << ' ' << j << '\n';
                return 0;
            }
        }
    }
    return 0; 
}
 

Measured memory_bytes: 3520
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define vmax_p(v) max_element(v.begin(), v.end())
#define vmin_p(v) min_element(v.begin(), v.end())
#define vmax_idx(v) distance(v.begin(), vmax_p(v))
#define vmin_idx(v) distance(v.begin(), vmin_p(v))
#define vcopy(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

// floor(x): truncate

// 2進数変換
// string s = bitset<20>(x).to_string();

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    return right;
}

int main(int argc, const char *argv[])
{
    string s;
    cin >> s;
    bool c = false, f = false;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'C')
        {
            c = true;
        }
        else if (s[i] == 'F' && c)
        {
            f = true;
            break;
        }
    }
    if (f && c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
n=int(input())
l=[]
for i in range(n):
	x,y=map(int,input().split())
	l.append((y,x))
l.sort(key=lambda x:(x[0],x[1]),reverse=True)
maximum=l[0][0]
young=l[0][1]
for i in l:
	if maximum==i[0]:
		young=i[1]
	else:
		break
print(young,maximum)



#print(l[0][1],l[0][0])

Measured memory_bytes: 7740
package main

import "fmt"

func main() {
	var s []byte
	fmt.Scan(&s)


	for i := 1;i < len(s);i++ {
		if s[i] == s[i-1] {
			fmt.Println("Bad")
			return
		}
		
		
	}

	fmt.Println("Good")
}


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

const int N = 1e5 + 5;
const double inf = 1e18;
double x[N], y[N];
double dx[N], dy[N];
int n;

double f(double a) {
    double minx = inf, maxx = -inf, miny = inf, maxy = -inf;
    for (int i = 0; i < n; i++) { //n个点
        double nx = x[i] + a * dx[i];
        double ny = y[i] + a * dy[i];
        minx = min(minx, nx);
        maxx = max(maxx, nx);
        miny = min(miny, ny);
        maxy = max(maxy, ny);
    }
    return (maxx - minx) * (maxy - miny);
}

double ternary_search(double l, double r) {
   double ans = inf;
  int times = 100;
    while (times--) {
        double m1 = l + (r - l) / 3;
         double m2 = r - (r - l) / 3;
        //double m1 = (l*2+r) / 3;
        //double m2 = (r*2+l) / 3;
        double f1 = f(m1);
        double f2 = f(m2);
        ans = min(ans, f1);
         ans = min(ans, f2);
        if (f1 < f2) r = m2;
        else l = m1;
    }
    return ans;
}

int main() {
   // while (cin >> n) {
      cin>>n;
        //memset(dx, 0, sizeof(dx));
        //memset(dy, 0, sizeof(dy));

        string s;
        for (int i = 0; i < n; i++) {
            cin >> x[i] >> y[i] >> s;
            if (s == "R") dx[i] = 1;
            if (s == "L") dx[i] = -1;
            if (s == "U") dy[i] = 1;
            if (s == "D") dy[i] = -1;
        }


       // cout << fixed << setprecision(11) <<ternary_search(0, 1e9) << endl;
      printf("%.11f\n",ternary_search(0, 1e9));
   // }

    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a;
	cin>>n;
	map<int,int>mp;
	while(cin>>a)
		mp[a]++;
	int ans=0;
	for(auto x:mp)
		ans+=x.second>=x.first?x.second-x.first:x.second;
	cout<<ans<<endl;
}


Measured memory_bytes: 4736
import numpy as np
n=int(input())
P=np.array(list(map(float,input().split())))
DP=np.zeros(n+1)
DP[0]=1.0

for i in range(n):
  DP = np.roll(DP * P[i], 1) + DP * (1-P[i])
print(sum(DP[n//2+1:]))

Measured memory_bytes: 14520
N = int(input())
A = list(map(int,input().split()))
A = [[a,i] for a,i in zip(A,range(1,N+1))]
A = sorted(A,reverse=True)
INF = float('inf')
dp = [[-INF] * (N+1) for _ in range(N+1)]
dp[0][0] = 0
ans = 0
for x_y in range(1,N+1):
  a = A[x_y-1]
  for x in range(x_y+1):
    y = x_y-x
    if x==0:
      dp[x][y] = dp[x][y-1] + a[0]*(N-y+1-a[1])
    elif y==0:
      dp[x][y] = dp[x-1][y] + a[0]*(a[1]-x)
    else:
      dp[x][y] = max(dp[x-1][y]+a[0]*(a[1]-x),dp[x][y-1] + a[0]*(N-y+1-a[1]))
    
    ans = max(ans,dp[x][y])
print(ans)

Measured memory_bytes: 208260
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }
 

void solve()
{
	ll n;
	cin>>n;
	ll b[n-1];
	for(ll i=0;i<n-1;i++)
		cin>>b[i];
	ll sum=b[0];
	for(ll i=1;i<n-1;i++)
		sum+=(min(b[i],b[i-1]));
	sum+=b[n-2];
	cout<<sum;
	return;	
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int H,N;
	scanf("%d %d", &H, &N);
	for(int i = 0;i < N;i++){
		int x;
		scanf("%d", &x);
		H-=x;
	}
	if(H <= 0)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    print(2 * M_PI * N);
    
}


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

char a[200005],b[200005];
int main()
{
	cin>>a;
	cin>>b;
	int longth=strlen(a),ans=0;
	for(int i=0;i<longth;++i)
    {
        if(a[i]!=b[i])ans++;
    }
    cout<<ans;
	return 0;
}

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

int main() {
  long long int A, B, C, D, E;
  cin >> A >> B >> C >> D;
  E = C * D / __gcd(C, D);
  long long int W, X, Y, Z;
  W = B - A + 1;
  X = B / C - (A - 1) / C;
  Y = B / D - (A - 1) / D;
  Z = B / E - (A - 1) / E;
  cout << W - X - Y + Z << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    char c[4];
    cin >> c[0] >> c[1] >> c[2] >> c[3];
    sort(c,c+4);
    if(c[0]==c[1] && c[2]==c[3] && c[1]!=c[2]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3616
def C():
    n,m = list(map(int, input().split()))
    h = list(map(int, input().split()))
    path = [list(map(int, input().split())) for _ in range(m)]
    small = []
    for a, b in path:
        if h[a-1] > h[b-1]:
            small.append(b)
        elif h[a-1] < h[b-1]:
            small.append(a)
        else:
            small += [a,b]
    print(len(set(range(1,n+1)) - set(small)))

C()

Measured memory_bytes: 44204
#include <stdio.h>
int dp[50];
int fib(int n){
    if(n==0 || n==1) return dp[n]=1;
    else if(dp[n] != -1) return dp[n];  //已经计算过，直接返回结果，不重复计算
    else return dp[n] = fib(n-1) + fib(n-2);  //dp[n]记录fib(n)的值
}
int main(){
    int n;
    scanf("%d",&n);
    for (int i=0; i<50; i++) {
        dp[i] = -1;  //初始化为未计算
    }
    printf("%d\n",fib(n));
}



Measured memory_bytes: 2740
from collections import defaultdict
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
dd=defaultdict(int)
dd[0]+=1
for i in range(N):
    dd1=defaultdict(int)
    for s,v in dd.items():
        dd1[s+A[i]-K]+=v
        dd1[s]+=v
    dd=dd1
print(dd[0]-1)

Measured memory_bytes: 41072
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2e5;
int n;
int A[N], B[N];

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n) cin >> A[i] >> B[i];
  sort(A, A+n);
  sort(B, B+n);
  if(n%2){
    cout << B[n/2]-A[n/2]+1 << endl;
  }else{
    cout << B[n/2]+B[n/2-1]-A[n/2]-A[n/2-1]+1 << endl;
  }
}

Measured memory_bytes: 5192