akhauriyash/Code-Regression huggingface dataset:
import sys

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


def solve(H, W):
    ans = INF
    for h in range(H + 1):
        a, b, c = h * W, (H - h) // 2 * W, (H - h + 1) // 2 * W
        ans1 = max(abs(a - b), abs(b - c), abs(c - a))
        a, b, c = h * W, (H - h) * (W // 2), (H - h) * ((W + 1) // 2)
        ans2 = max(abs(a - b), abs(b - c), abs(c - a))
        if ans > min(ans1, ans2):
            ans = min(ans1, ans2)

    return ans


def main():
    H, W = map(int, readline().split())

    ans = min(solve(H, W), solve(W, H))

    print(ans)
    return


if __name__ == '__main__':
    main()


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

string toString(int a){
  stringstream ss;
  ss << a;
  return ss.str();
}

int toInt(string s){
  stringstream ss(s);
  int res;
  ss >> res;
  return res;
}

bool is_prime(int a){
  if(a<=1)return false;
  for(int i=2;i*i<=a;i++){
    if(a%i==0)return false;
  }
  return true;
}

int rec(int d, int n, string s, string c){
  if(n>4)return -1;
  if(d==n){
    string pal = s + c;
    reverse(s.begin(),s.end());
    pal += s;
    int p = toInt(pal);
    return is_prime(p)?p:-1;
  }

  int res = -1;
  for(int i=0;i<10;i++){
    if(d==0 && (i%2==0 || i%5==0))continue;
    res = max( res, rec(d+1, n, s + toString(i), c) );
  }
  return res;
}

int main(){
  int n,c;
  cin >> n >> c;
  string center = (c<0)?"":toString(c);
  int res = rec(0,n,"",center);

  if(res<0){
    for(int i=0;i<n;i++)cout << "9";
    cout << center;
    for(int i=0;i<n;i++)cout << "9";
    cout << endl;
  }else{
    cout << res << endl;
  }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	lli n,m;
	cin>>n>>m;
	lli a[m],i,sum=0;
	fr(i,m)
	{
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>n)
	{
		cout<<"-1";
	}
	else
		cout<<n-sum;

	return 0;
}

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

using namespace std;

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  for(int i=0;i<=n-3;i++){
      if(s[i]=='A' &&s[i+1]=='B' && s[i+2]=='C') ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n=int(input())
l=[int(i) for i in input().split()]
seen=[0]* 22 
ans=0 
c=0 
st=0 
ans=0 
for end in range(n): 
   # print(seen,end)
    for j in range(22):
        if l[end]&(1<<j):
            if seen[j]==1: 
                while seen[j]:
                    for bit in range(22):
                        if (1<<bit)&l[st]:
                            seen[bit]=0 
                    st+=1 
            else:
                seen[j]=1 
    for j in range(22):
        if l[end]&(1<<j):
            seen[j]=1 
    #print(end,st)
    c=(end-st+1)
   # print(c)
    ans+=c
print(ans)

'''
6
2 4 2  4 3 2
'''

Measured memory_bytes: 77900
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n - 1];
    rep(i, n) { cin >> a[i]; }
    rep(i, n) { cin >> b[i]; }
    rep(i, n - 1) { cin >> c[i]; }

    // 食べ物ごとの満足度をすべて足す
    int total = 0;
    rep(i, n) { total += b[i]; }

    // 連続している要素を抽出
    vector<int> conti;
    for(int i = 1; i < n; i++) {
        if(a[i] == a[i - 1] + 1) {
            conti.push_back(a[i - 1]);
        }
    }
    /*
    for(auto i = conti.begin(); i != conti.end(); ++i) {
        cout << *i << ",";
    }
    cout << endl;
    */

    // 連続したモノの満足度を追加
    for(auto i = conti.begin(); i != conti.end(); ++i) {
        total += c[(*i) - 1];
    }

    // 表示
    cout << total << endl;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())
cnt=0
for i in range(a+1):
            for j in range(b+1):
                        for k in range(c+1):
                                    if 500*i+100*j+50*k==x:
                                        
                                                cnt+=1
print(cnt)                                                


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

int main(){
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());

  //cout << s << endl << t << endl;
  cout << ((s < t)? "Yes": "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(a, max(b, c))
#define MIN(x, y, z) min(a, min(b, c))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll R, G;
  cin >> R >> G;
  G *= 2;
  ld ans = G - R;
  ANS;
  return 0;
}

Measured memory_bytes: 3864
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T, typename BO>
struct segment{
	int N;
	BO bin_op;
	const T id;
	vector<T> val;
	template<typename IT>
	segment(IT begin, IT end, BO bin_op, T id): N(distance(begin, end)), bin_op(bin_op), id(id), val(N << 1, id){
		for(int i = 0; i < N; ++ i) val[i + N] = *(begin ++);
		for(int i = N - 1; i > 0; -- i) val[i] = bin_op(val[i << 1], val[i << 1 | 1]);
	}
	segment(int N, BO bin_op, T id): N(N), bin_op(bin_op), id(id), val(N << 1, id){ }
	void set(int p, T x){
		for(p += N, val[p] = x; p > 1; p >>= 1) val[p >> 1] = bin_op(val[p], val[p ^ 1]);
	}
	void update(int p, T x){
		for(p += N, val[p] = bin_op(val[p], x); p > 1; p >>= 1) val[p >> 1] = bin_op(val[p], val[p ^ 1]);
	}
	T query(int l, int r){
		if(l >= r) return id;
		T resl = id, resr = id;
		for(l += N, r += N; l < r; l >>= 1, r >>= 1){
			if(l & 1) resl = bin_op(resl, val[l ++]);
			if(r & 1) resr = bin_op(val[-- r], resr);
		}
		return bin_op(resl, resr);
	}
};

int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> h(n), a(n);
	for(auto i = 0; i < n; ++ i){
		cin >> h[i];
	}
	for(auto i = 0; i < n; ++ i){
		cin >> a[i];
	}
	auto bin_op = [&](auto x, auto y){
		return max(x, y);
	};
	segment<long long, decltype(bin_op)> tr(n + 1, bin_op, 0LL);
	for(auto i = 0; i < n; ++ i){
		tr.set(h[i], tr.query(0, h[i]) + a[i]);
	}
	cout << tr.query(0, n + 1);
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 4992
//#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main() {
    int n;
    cin >> n;
    vector<int> v(n);
    set<int> st;
    for(int i=0; i<n; ++i) {
        int a;
        cin >> a;
        if(st.find(a)!=st.end()) st.erase(a);
        else st.insert(a);
    }
    cout << st.size() << endl;
    return 0;
}
 

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<ll> Size;
  UnionFind(int n = 1) { init(n); }

  void init(int n = 1) {
    par.resize(n + 1);
    rank.resize(n + 1);
    Size.resize(n + 1);
    for (int i = 0; i <= n; ++i)
      par[i] = i, rank[i] = 0, Size[i] = 1;
  }

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

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

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (rank[x] < rank[y])
      swap(x, y);
    if (rank[x] == rank[y])
      ++rank[x];
    par[y] = x;
    Size[x] += Size[y];
    return true;
  }

  ll size(int x) { return Size[root(x)]; }
};

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

  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  map<int, int> mp1, mp2;
  rep(i, 0, n) {
    int x;
    cin >> x;
    p[i] = x;
    mp1[x] = i + 1;
    mp2[i + 1] = x;
  }
  UnionFind uf(n);
  rep(i, 0, m) {
    int x, y;
    cin >> x >> y;
    uf.merge(x, y);
  }

  rep(i, 0, n) {
    if (i + 1 != mp2[i + 1] && uf.is_same(i + 1, mp2[i + 1])) {
      int old = mp1[i+1];
      swap(mp1[i + 1], mp1[mp2[i + 1]]);
      swap(mp2[old], mp2[mp1[i + 1]]);
    }
  }

  int ans = 0;
  for (auto m : mp2)
    if (m.first == m.second)
      ans++;
  cout << ans << endl;
}


Measured memory_bytes: 11648
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    private static final String[] suit = {"S", "H", "C", "D"};
    
    public static void main(String[] args) {
        LinkedHashSet<String> lhss = new LinkedHashSet<>();
        for(int i = 0; i < 52; i++) {
            lhss.add(suit[i / 13] + " " + (i % 13 + 1));
        }
        for(int n = scn.nextInt(); n > 0; n--) {
            lhss.remove(scn.next() + " " + scn.next());
        }
        for(String elm : lhss) {
            System.out.println(elm);
        }
    }
}

Measured memory_bytes: 26272
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if (a > b) swap(a,b);
    if (a > c) swap(a,c);
    if (b > c) swap(b,c);
    cout<<a<<" " <<b<<" "<<c<<endl;
        return 0;
}




Measured memory_bytes: 3072
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[101];
int main()
{
	cin>>s;
	for(int i=0;i<101;i++)
	{
		if(i%2==0&&s[i]=='L') {cout<<"No";return 0;}
		if(i%2==1&&s[i]=='R') {cout<<"No";return 0;}
	}
	cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
const ll M=1000000000;
//------------------------------------------//

int main(){
  int N;cin>>N;
  int A[210];
  rep(i,N) cin>>A[i];
  
  int ans=0;
  bool flag=true;
  while(flag){
    rep(i,N){
      if(A[i]%2==1){
        flag=false;
        break;
      }
      A[i]/=2;
    }
    ans++;
  }
  cout<<ans-1<<endl;
}
  

Measured memory_bytes: 3636
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int kyougi[] = new int[N];
		int shinsain[] = new int[M];
		int vote[] = new int[N];
		
		for(int j = 0; j < N; j++){
			kyougi[j] = sc.nextInt();
		}
		
		for(int j = 0; j < M; j++){
			shinsain[j] = sc.nextInt();
		}
		
		
		for(int i = 0; i < M; i++){
			for(int j = 0; j < N; j++){
				if(shinsain[i] >= kyougi[j]){
					vote[j]++;
					break;
				}
			}
		
		}
		int MAX = 0;
		for(int i = 0; i < N; i++){
			if(vote[MAX] < vote[i]){
				MAX = i;
			}
		}
		System.out.println(MAX+1);
		
		
		
	}
				
}

Measured memory_bytes: 25068
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

int n;
vi a;

void init()
{
	cin >> n;
	a.resize(n);

	REP(i, n)
		cin >> a[i];

	sort(ALL(a));

}

int main()
{
	init();

	int ans = accumulate(ALL(a), 0);

	if (!(ans % 10))
	{
		REP(i, n)
		{
			if ((a[i] % 10))
			{
				ans -= a[i];
				break;
			}
		}
	}
	//cout << ans << endl;

	if (!(ans % 10))
		cout << 0 << endl;
	else
		cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
ll mod=1E9+7;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    map<ll,ll> m;
    ll N = ii();
    ll ret = 0;
    REP(i,0,N){
        ll a=ii();
        m[a]++;
        ret+=a;
    }
    ll Q=ii();
    
    REP(i,0,Q){
        ll b=ii();
        ll c=ii();

        ret += (c-b)*m[b];
        m[c] += m[b];
        m.erase(b);
        
        oie(ret);
    }
    return 0;
}

Measured memory_bytes: 7508
#include <bits/stdc++.h>
using namespace std;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);

    int n,x,t;
    cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<list>

int main(void) {
	using namespace std;
	int a,b;
	int c;
	bool loop = true;
	vector<int>vec;
	cin >> a;
	vec.push_back(a);
	while(loop) {
		b = vec[vec.size() - 1];
		if (b%2 == 0) {
			b = b / 2;
			vec.push_back(b);
		}
		else if (b%2 == 1) {
			b = (b * 3) + 1;
			vec.push_back(b);
		}
		for (int i = 0; i < vec.size() - 1;i++) {
			if (vec[vec.size() - 1] == vec[i]) {
				c = vec.size();
				loop = false;
			}
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


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

	REP(i, n) {
		cin >> v[i];
	}

	SORT(v);
	//v.erase(unique(v.begin(), v.end()), v.end());
	//unique(v.begin(), v.end());
	long long sum = 0;
	REP(i, n) {
		sum += v[i];
	}

	ANS(sum - n);

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 5010;
int n, m, dp[N][N];
char s[N];
void add(int &x, ll y) {x = (x+y)%P;}

int main() {
	scanf("%d%s", &n, s+1);
	m = strlen(s+1);
	dp[0][0] = 1;
	REP(i,0,n) REP(j,0,i) if (dp[i][j]) {
		add(dp[i+1][j+1],2*dp[i][j]);
		add(dp[i+1][max(j-1,0)],dp[i][j]);
	}
	int ans = (ll)dp[n][m]*inv(qpow(2,m))%P;
	printf("%d\n", ans);
}









Measured memory_bytes: 96512
def main():
    R, C, K = list(map(int, input().split()))
    # dp[r][c][n]: r行目でn個のアイテムを拾う場合の(r, c)でのアイテムの価値の合計の最大
    dp_0 = [[0 for _ in range(C)] for _ in range(R)]
    dp_1 = [[0 for _ in range(C)] for _ in range(R)]
    dp_2 = [[0 for _ in range(C)] for _ in range(R)]
    dp_3 = [[0 for _ in range(C)] for _ in range(R)]
    V = [[0 for _ in range(C)] for _ in range(R)]
    for _ in range(K):
        r, c, v = list(map(int, input().split()))
        V[r - 1][c - 1] = v
    dp_1[0][0] = V[0][0]
    for r in range(R):
        for c in range(C):
            if r == c == 0:
                continue
            v_rc = V[r][c]
            max_dp_before_row = 0 if r == 0 else max(dp_0[r - 1][c], dp_1[r - 1][c], dp_2[r - 1][c], dp_3[r - 1][c])
            # dp[r][c][0]
            v1 = 0 if c == 0 else dp_0[r][c - 1]
            dp_0[r][c] = max(v1, max_dp_before_row)
            # dp[r][c][1]
            v1 = 0 if c == 0 else max(dp_1[r][c - 1], dp_0[r][c - 1] + v_rc)
            v2 = 0 if r == 0 else (max_dp_before_row + v_rc)
            dp_1[r][c] = max(v1, v2)
            # dp[r][c][2], dp[r][c][3]
            dp_2[r][c] = 0 if c == 0 else max(dp_2[r][c - 1], dp_1[r][c - 1] + v_rc)
            dp_3[r][c] = 0 if c == 0 else max(dp_3[r][c - 1], dp_2[r][c - 1] + v_rc)
    print(max(dp_0[R-1][C-1], dp_1[R-1][C-1], dp_2[R-1][C-1], dp_3[R-1][C-1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 471236
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <string>
#include <complex>
using namespace std;

#define INT_max 2147483647


typedef long long ll;
typedef long double ld;


int main(){
  int N,M;
  ll sum = 0;
  cin>>N>>M;
  for(int i = 0;i < M;i++){
  	int t;
  	cin>>t;
  	sum += t;
  }
  cout<<(N-sum < 0 ? -1 : N-sum)<<endl;
}

Measured memory_bytes: 3596
#include<iostream>

int main(){
    int a, b;

    std::cin >> a >> b;
    
    int ans = a + b;
    if(ans < a - b){
        ans = a - b;
    }
    if(ans < a * b){
        ans = a * b;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x=min(x,y)
using namespace std;
int N,a[100];
int main(){
	cin>>N;
	rep(i,N) cin>>a[i];
	int ans=1e9;
	for(int x=-100;x<=100;x++){
		int s=0;
		rep(i,N) s+=(x-a[i])*(x-a[i]);
		chmin(ans,s);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <math.h>
#include <iomanip>

using namespace std;
int main(){
    int n, grades;
    cin >> n;
    while (n!= 0) {
        int array[n] = {};
        double sum = 0;
        double othersum = 0;
        for (int i = 0; i < n; i++) {
            cin >> grades;
            sum += grades;
            array[i] = grades;
        } double average = sum / n;
        for (int i = 0; i < n; i++) {
            othersum += pow(array[i] - average, 2) / n;
        }
        othersum = sqrt(othersum);
        cout <<fixed << setprecision(10) << othersum << endl;
        cin >> n;
    }

    }


Measured memory_bytes: 3256
import java.util.*;
import javax.lang.model.util.ElementScanner6;

class Music {
    String title;
    long time;

    Music(String s, long t) {
        title = s;
        time = t;
    }
}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        int n = sc.nextInt();

        List<Music> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            long t = sc.nextLong();

            list.add(new Music(s, t));
        }

        String x = sc.next();

        // 処理
        long out = 0;
        boolean slp = false;
        for (int i = 0; i < n; i++) {
            if (slp == true) {
                out += list.get(i).time;
            }
            if (x.equals(list.get(i).title)) {
                slp = true;
            }
        }

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 23764
/* SANDEEP YADAv*/
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
lld gcd(lld a,lld b){ if(a<b) { a=a+b; b=a-b; a=a-b;}while(b!=0){lld r=a%b; a=b; b=r;} return a;}
long long power(long long a, long long b, long long m) {a %= m;long long res = 1;while (b > 0) {if (b & 1)res = res * a % m;a = a * a % m;b >>= 1;}return res;}
void judge()
{
      #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif
}

int main()
{
    fastio;
    // judge();

    lld n,m;
    cin>>n>>m;

    cout<<n*(n-1)/2+m*(m-1)/2;
    return 0;
}

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

multiset<int> m;

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

  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    m.insert(t);
  }

  int ans = 0;
  while (m.size() >= 2) {
    auto it = prev(m.end());
    int bk = *it;
    m.erase(it);
    for (int j = 30; j >= 0; j--) {
      int pk = 1 << j;
      if (pk > bk && pk - bk <= bk) {
        auto it2 = m.find(pk - bk);
        if (it2 != m.end()) {
          ans++;
          m.erase(it2);
        }
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 9600
# import sys
# input = sys.stdin.readline
Q = 10**9+7
def main():
    N = int( input())
    S = input()
    left = 0
    ans = 1
    # for i in range(N*2):
    #     s = S[i]
    for s in S:
        if s == "B":
            if left%2 == 0:
                left += 1
            else:
                ans *= left
                left -= 1
        else:
            if left%2 == 1:
                left += 1
            else:
                ans *= left
                left -= 1
        ans %= Q
    if left > 0 or ans == 0:
        print(0)
        return
    for i in range(1,N+1):
        ans *= i
        ans %= Q
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3516
#include <stdio.h>
int ask(int i){char buf[7];__builtin_printf("%d\n",i);fflush(stdout);__builtin_scanf("%s",buf);if(buf[0]=='V')
return 0;return buf[0]=='M'?1:2;}int main(){int n;__builtin_scanf("%d",&n);int x0=ask(0);if(!x0)return 0;
int l=0,xl=x0,r=n,xr=x0;while(1){int m=l+r>>1;int xm=ask(m);if(!xm)return 0;if((m-l&1)!=(xl!=xm)){r=m,xr=xm;}
else{l=m,xl=xm;}}}

Measured memory_bytes: 760
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 1e6 + 50;
int n,m,a[maxn],t[maxn],v[maxn],last[maxn],ans[maxn];
struct Qusetion{
    int l,r,num;
}q[maxn];
int read(){
    int x = 0,f = 1;
    char c = getchar();
    while(c < '0' || c > '9'){
        if(c == '-') f *= -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') x = x * 10 + (c ^ 48),c = getchar();
    return x * f;
}
bool cmp(Qusetion x,Qusetion y){
    return x.r < y.r;
}
inline int lowbit(int x){
    return x & (-x);
}
void update(int x,int k){
    while(x <= n) t[x] += k,x += lowbit(x);
}
int query(int x){
    int sum = 0;
    while(x) sum += t[x],x -= lowbit(x);
    return sum;
}
int main(){
    n = read(),m = read();
    for(int i = 1; i <= n; i ++) a[i] = read();
    for(int i = 1; i <= m; i ++) q[i].l = read(),q[i].r = read(),q[i].num = i;
    sort(q + 1,q + 1 + m,cmp);
    for(int i = 1; i <= m; i ++){
        for(int j = q[i - 1].r + 1; j <= q[i].r; j ++){
            if(last[a[j]]) update(last[a[j]],-1);
            last[a[j]] = j;
            update(j,1);
        }
        ans[q[i].num] = query(q[i].r) - query(q[i].l - 1);
    }
    for(int i = 1; i <= m; i ++) printf("%d\n",ans[i]);
    return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if((a+b)%2 == 1){
    cout << (a+b)/2+1 << endl;
  }
  else {
  cout << (a+b)/2 << endl;
  }
}

Measured memory_bytes: 256
import Data.Char(isSpace)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as C

main = do
    n <- readLn
    vs <- U.unfoldrN n (C.readInt . C.dropWhile isSpace) <$> C.getLine
    cs <- U.unfoldrN n (C.readInt . C.dropWhile isSpace) <$> C.getLine
    let vcsPlus = U.filter (>0) $ U.zipWith (-) vs cs
    print $ U.sum vcsPlus

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

constexpr ll ITRMAX = 100;
ll n;
vector<double> x, y;

double r(double x0, double y0) {
    double res = 0;
    rep(i, 0, n){
        double dx = x[i] - x0;
        double dy = y[i] - y0;
        double dr = dx * dx + dy * dy;
        res = max(res, sqrt(dr));
    }
    return res;
}

double f(double x){
    double ly = -1000, ry = 1000;
    rep(itr, 0, ITRMAX){
        double my1 = (2 * ly + ry) / 3;
        double my2 = (ly + 2 * ry) / 3;
        if(r(x, my1) > r(x, my2)) ly = my1;
        else ry = my2;
    }
    return r(x, ly);
}

int main(){
    cin >> n;
    x.resize(n);
    y.resize(n);
    rep(i, 0, n) cin >> x[i] >> y[i];
    double lx = -1000, rx = 1000;
    rep(itr, 0, ITRMAX){
        double mx1 = 2 * lx / 3 + rx / 3;
        double mx2 = lx / 3 + 2 * rx / 3;
        if(f(mx1) > f(mx2)) lx = mx1; 
        else rx = mx2;
    }
    printf("%.20lf\n", f(lx));
    return 0;
}

Measured memory_bytes: 3828
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}
	
	int[][] map;

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		
		int h = fs.nextInt();
		int w = fs.nextInt();
		
		map = new int[h][w];
		
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				map[i][j] = fs.nextInt() % 2;
 			}
		}
		
		ArrayList<String> manipList = new ArrayList<>();
		
		int nowH = 0;
		
		while(nowH < h) {
			
			if(nowH % 2 == 0) {
				for(int i = 0; i < w; i++) {
					if(map[nowH][i] % 2 == 1) {
						if(i == w-1) {
							if(nowH != h-1) {
								manipList.add(makeManip(nowH, i, nowH+1, i));
							}
						}else{
							manipList.add(makeManip(nowH, i, nowH, i+1));
						}
					}
				}
			}else {
				for(int i = w - 1; i >= 0; i--) {
					if(map[nowH][i] % 2 == 1) {
						if(i == 0) {
							if(nowH != h-1) {
								manipList.add(makeManip(nowH, i, nowH+1, i));
							}
						}else{
							manipList.add(makeManip(nowH, i, nowH, i-1));
						}
					}
				}
			}
			
			nowH++;
		}
		
		System.out.println(manipList.size());
		for(String str : manipList) {
			System.out.println(str);
		}
	}
	
	String makeManip(int beforeH, int beforeW, int afterH, int afterW){
		
		map[afterH][afterW] += 1;
		
		StringBuffer sb = new StringBuffer();
		sb.append(beforeH+1).append(" ").append(beforeW+1).append(" ").append(afterH+1).append(" ").append(afterW+1);
		return sb.toString();
		
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 72300
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
c = (n//k) ** 3
if k%2 == 0:
    c += ((n-(k//2))//k+1) ** 3
print(c)

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

int main(){
	for(int i=1;;i++){
		int x, y;
		cin >> x >> y;
		if(x==0 && y==0) break;
		
		if(x>y){
			int tmp = x;
			x = y;
			y = tmp;
		}
		cout << x << " " << y <<endl;
	}
}


Measured memory_bytes: 3072
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    int n;
    cin >> n;
    ll ans = 0;

    rep(i, n){
        ll tmp;
        cin >> tmp;
        while(tmp % 2 == 0){
            ans++;
            tmp = tmp/2;
        }
    }

    cout << ans;




}

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

using namespace std;

void Trace(int A[], int N){
    for(int i=0;i<N;++i){
        if(i>0) cout << " ";
        cout << A[i] ;
    }
    cout << endl;
}

void InsertionSort(int A[],int N){
    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;
        Trace(A, N);
    }
}

int main(){
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; ++i)
        cin >> A[i];

    Trace(A, N);
    

    InsertionSort(A, N);

    return 0;

}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<int> count;
  char id = S[0];
  if (id == '0') count.PB(0);
  int c = 0;
  REP(i, N) {
    if (S[i] == id) c++;
    else {
      count.PB(c);
      c = 1;
      id = S[i];
    }
  }
  count.PB(c);
  if (S[N-1] == '0') count.PB(0);
  int sum[count.size()+1] = {};
  REP(i, count.size()) sum[i+1] = sum[i] + count[i];
  // REP(i, count.size()+1) cout << sum[i] << ' ';
  // cout << '\n';
  int ans = count[0];
  if (K >= count.size()/2) ans = sum[count.size()];
  else {
    for (int i = 2 * K + 1; i <= count.size(); i+=2) {
      // cout << sum[i] << '\n';
      // cout << sum[i-(2*K+1)] << '\n';
      ans = max(ans, sum[i] - sum[i-(2*K+1)]);
    }
  }
  cout << ans << '\n';
}


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

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

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

int dp[1010][1010];
int main() {
    string s, t; cin >> s >> t;
    fill(dp[0], dp[1010], 1 << 28);
    dp[0][0] = 0;
    int N = s.length(), M = t.length();
    for(int i=0; i<=N; i++) dp[i][0] = i;
    for(int i=0; i<=M; i++) dp[0][i] = i;
    for(int i=0; i<N; i++) {
        for(int j=0; j<M; j++) {
            dp[i+1][j+1] = min({dp[i][j+1] + 1, dp[i+1][j] + 1, dp[i][j] + (s[i] != t[j])});
        }
    }
    cout << dp[N][M] << endl;
    return 0;
}


Measured memory_bytes: 7200
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iostream>
#include <string>
#include <map>
#include <unordered_map>
using namespace std;





int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<int>a(n);
	vector<int>b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	int mx_ele = n - 1;
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		if (b[i] < a[mx_ele]) {
			cout << a[mx_ele]<<'\n';
			continue;
		}
		else {
			mx_ele -= 1;
			cout << a[mx_ele] << '\n';
			mx_ele += 1;
		}
	}
}

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

int check[13];

int main() {
    int x, y;
    cin >> x >> y;
    for (int i = 1; i <= 12; i++) {
        if (i == 4 || i == 6 || i == 9 || i == 11) check[i] = 1;
        else if (i == 2) check[i] = 2;
    }
    if (check[x] == check[y]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int s = int.Parse(Console.ReadLine());
            var L = new List<int>();
            L.Add(s);
            while (true)
            {
                s = F(s);
                if (L.Contains(s)) break;
                else L.Add(s);
            }
            Console.WriteLine(L.Count + 1);
        }
        static public int F(int x)
        {
            if (x % 2 == 0) return x / 2;
            else return 3 * x + 1;
        } 
    }
}


Measured memory_bytes: 27768
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int a=0,s[1000];
void push(int a1){
  s[++a]=a1;
}
int pop(){
  a--;
  return s[a+1];
}                                                 

int main(){

  int x,y;
  char q[100];

  while(scanf("%s",q)!=EOF){
    if(q[0]=='+'){
      x=pop();
      y=pop();
      push(x+y);
    }

    else if(q[0]=='-'){
      x=pop();
      y=pop();
      push(y-x);
    }

    else if(q[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }

    else{
      push(atoi(q));
    }
  }
  printf("%d\n",pop());
  
  return 0;
}




Measured memory_bytes: 2128
#include <stdio.h>

int main(void) {
	int n,i=0,j,sum,anc=0;
	int s[1000];
	int min,max;
	for(;;){
		scanf("%d",&n);
		if(n==0) break;
		if(n>=3&&n<=100){
			sum=0;
			min=1000;
			max=0;
			for(j=0;j<n;j++){
				 scanf("%d",&s[j]);
				 if(s[j]>=0&&s[j]<=1000){
				 	sum+=s[j];
				 	if(s[j]>max){
				 		max=s[j];
				 	}
				 	if(s[j]<min){
				 		min=s[j];
				 	}
				 }
			}
			anc=(sum-min-max)/(n-2);
		}
		printf("%d\n",anc);
		i++;
		if(i==20) break;
	}
	return 0;
}



Measured memory_bytes: 2056
#include <stdio.h>
#include <math.h>

int main(void)
{
    int n, i;
    scanf("%d", &n);
    double x[n], y[n];
    for(i = 0; i < n; i++){
        scanf("%lf", &x[i]);
    }
    for(i = 0; i < n; i++){
        scanf("%lf", &y[i]);
    }
    double p[n];
    double sum = 0;
    for(i = 0; i < n; i++){
        p[i] = fabs(x[i] - y[i]);
        sum += p[i];
    }
    printf("%f\n", sum);

    sum = 0;
    for(i = 0; i < n; i++){
        sum += pow(p[i], 2);
    }
    sum = sqrt(sum);
    printf("%f\n", sum);

    sum = 0;
    for(i = 0; i < n; i++){
        sum += pow(p[i], 3);
    }
    sum = pow(sum, (double)1 / 3);
    printf("%f\n", sum);

    sum = 0;
    double max = 0, num;
    for(i = 0; i < n; i++){
        num = p[i];
        if(max < num){
            max = num;
        }
    }
    max = fabs(max);
    printf("%f\n", max);

    return 0;
}


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

int main(){
  string day;
  cin >> day;
  map<string, int> num{
    {"SUN",7}, 
    {"MON",6}, 
    {"TUE",5},
    {"WED",4},
    {"THU",3},
    {"FRI",2},
    {"SAT",1}
  };
  for(auto a:num){
    if(a.first==day){
      cout << a.second << endl;
      break;
    }
  }
  return 0;
}

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


int a[100002][4];
int dp[100002][4];

int solve(int i,int j,int n) {
    if(i==n)
        return a[i][j];
    if(dp[i][j]!=-1)
        return dp[i][j];
    int k;
    int ans = -1;
    for(k=1;k<=3;k++) {
        if(k==j)
            continue;
        ans = max(ans, a[i][j] + solve(i+1, k, n));
    }
    return dp[i][j] = ans;
}
int main() {
	int n;
	cin>>n;
	int i;
	for(i=1;i<=n;i++) {
	    for(int j = 1;j<=3;j++)
	        cin>>a[i][j], dp[i][j] = -1;
	}
	int ans = max(solve(1,1,n), max(solve(1,2,n), solve(1,3,n)));
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
 
#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

vector<int> ans, nums;

void dfs(int cur, int par, int val, vector<vector<int>>& graph) {
    int next = val + nums[cur];
    ans[cur] = next;
    for(int child : graph[cur]) {
        if(child != par) {
            dfs(child, cur, next, graph);
        }
    }
}

int32_t main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, q; cin >> n >> q;
    vector<vector<int>> graph(n+1);
    for(int i = 0; i < n-1; ++i) {
        int a, b; cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    nums.resize(n+1, 0);

    for(int i = 0; i < q; ++i) {
        int p, x; cin >> p >> x;
        nums[p] += x;
    }

    ans.resize(n+1, 0);
    dfs(1, 0, 0, graph);

    for(int i = 1; i <= n; ++i) {
        cout << ans[i] << ' ';
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 28928
#include<bits/stdc++.h>
using namespace std;
#define N 100010
int n,a[N];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		if(i+1>a[i+1]){
			int j=0;
			while(a[j+i+1]==i)j++;
			if(((a[i]-i)&1)||(j&1))puts("First");
			else puts("Second");
			exit(0);
		}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x7fffffff
#define infll 0x7fffffffffffffff
#define clr(c) memset(c,0,sizeof(c))
using namespace std;
//int mod=998244353;
int mod=2019;
const int M=1e6+10;
const int N=2e5+10;
inline ll read(){
    ll b=1,sum=0; char c=getchar();
    while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
    while(isdigit(c)){sum=sum*10+c-'0'; c=getchar();}
    return b*sum;
}
int T,n,m,k;
int dp[N],vis[2200];
char s[N];
int main()
{
    int i,j;
	scanf("%s",s+1);
	n=strlen(s+1);

	vis[0]++;
	int now=0,sum=0;
	for(i=n;i>=1;i--) {
		if(now==0) now=1;
		else now=now*10%mod;
		sum+=now*(s[i]-'0');
		sum%=mod;
		vis[sum]++;
	}
	ll ans=0;
	for(i=0;i<2019;i++) {
		ans+=1ll*vis[i]*(vis[i]-1)/2;
	}
	printf("%lld",ans);
	printf("\n");
    return 0;
}


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

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

int main(){
  int n,m,g=0;
  cin>>n;
  int t[n];
  rep(i,n){
    cin>>t[i];
    g+=t[i];
  }
  cin>>m;
  int ans[m];
  rep(i,m){
    int p,x,gg=g;
    cin>>p>>x;
    p--;
    ans[i]=gg-t[p]+x;
  }
  rep(i,m){
    cout<<ans[i]<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    
    int X;
    cin >> X;
    int amari = X % 7;
    
    
    switch(amari){
        
        case 0: cout << "thu" << endl; break;
    
        case 1: cout << "fri" << endl; break;
        
        case 2: cout << "sat" << endl; break;
        
        case 3: cout << "sun" << endl; break;
        
        case 4: cout << "mon" << endl; break;
        
        case 5: cout << "tue" << endl; break;
        
        case 6: cout << "wed" << endl; break;
        
    }
    
    return 0;
    
}


Measured memory_bytes: 3120
#include<stdio.h>
#define N 100000
struct Node{
  int p;
  int l;
  int r;
};
struct Node T[N];
int main(){
  int id,c,n,i,j,a,d[N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p = -1;
    T[i].l = N;
    T[i].r = N;
    d[i] = 0;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&c);
    if(c == 1){
      scanf("%d",&T[id].l);
      a = T[id].l;
      T[a].p = id;
    }
    else if(c > 1){
      scanf("%d",&T[id].l);
      a = T[id].l;
      for(j=1;j<c;j++){
	scanf("%d",&T[a].r);
	T[a].p = id;
	a = T[a].r;
      }
      T[a].p = id;
    }
  }
  for(i = 0;i<n;i++){
    a = T[i].p;
    while(1){
      if(a == -1){
	break;
      }
      else{
	a = T[a].p;
	d[i]++;
      }
    }
    printf("node %d: parent = %d, depth = %d,",i,T[i].p,d[i]);
    if(T[i].p == -1){
      if(T[i].l == N){
	printf(" root, []\n");
      }
      else{
	printf(" root, [%d",T[i].l);
	a = T[i].l;
	while(T[a].r != N){
	  printf(", %d",T[a].r);
	  a = T[a].r;
	}
	printf("]\n");
      }
    }
    else if(T[i].l == N)
      printf(" leaf, []\n");
    else{
      printf(" internal node, [%d", T[i].l);
      a = T[i].l;
      while(T[a].r != N){
	printf(", %d",T[a].r);
	a = T[a].r;
      }
      printf("]\n");
    }
  }
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1e9;

int main() {
    ll n, k, s;
    cin >> n >> k >> s;

    vl a(n);
    if(s == MAX_N) {
        rep(i, k) {
            a[i] = MAX_N;
        }
        exrep(i, k, n-1) {
            a[i] = 1;
        }
    }
    else {
        rep(i, k) {
            a[i] = s;
        }
        exrep(i, k, n-1) {
            a[i] = MAX_N;
        }
    }

    rep(i, n) {
        cout << a[i] << " ";
    }
    
    re0;
}

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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

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

  vector<string> s(n);
  for(int i=0; i<n; ++i) cin >> s[i];


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

  for(int i=0; i<n; ++i) cout << s[i];
}

Measured memory_bytes: 3604