akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MN 2005
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,q;
bool mp[MN][MN];
int l[MN][MN],h[MN][MN],b[MN][MN];
int main(){
	n=read(),m=read(),q=read();char c[MN];
	for(int i=1;i<=n;i++){
		scanf("%s",c+1);
		for(int j=1;j<=m;j++) mp[i][j]=c[j]=='1';
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
		l[i][j]=l[i-1][j]+l[i][j-1]-l[i-1][j-1]+(mp[i][j]&&mp[i][j-1]);
		h[i][j]=h[i-1][j]+h[i][j-1]-h[i-1][j-1]+(mp[i][j]&&mp[i-1][j]);
		b[i][j]=b[i-1][j]+b[i][j-1]-b[i-1][j-1]+(mp[i][j]);
	}
	int ans,x1,y1,x2,y2;
	while(q--){
		x1=read(),y1=read(),x2=read(),y2=read();
		ans=0;
		ans+=b[x2][y2]-b[x2][y1-1]-b[x1-1][y2]+b[x1-1][y1-1];
		ans-=l[x2][y2]-l[x2][y1]-l[x1-1][y2]+l[x1-1][y1];
		ans-=h[x2][y2]-h[x2][y1-1]-h[x1][y2]+h[x1][y1-1];
		printf("%d\n",ans);
	}
	return 0;
}

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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int n;
    cin>>n;
    vector<int>v(n+1);
    v[0]=-1;
    for(int i=0;i<n;i++)
    {
        cin>>v[i+1];
    }
    sort(v.begin(),v.end());
    int sum=v[1];
    int idx=-1;
    for(int i=2;i<=n;i++)
    {
       if(v[i]>2*sum)
       {
           idx=i;
       }
       sum+=v[i];
    }
    if(idx==-1)
        cout<<n<<endl;
    else
        cout<<n-idx+1<<endl;
    return 0;
}

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

int main()
{
    int sum=0,x=0,y=0,z=0,l[3];

    while(1){
        cin>>l[0]>>l[1]>>l[2];
        sort(l,l+3);

        if(l[2]>l[0]+l[1])break;
        
        sum++;

        int a = l[2]*l[2];
        int b = l[0]*l[0] + l[1]*l[1];

        if(a>b)z++;
        if(a==b)y++;
        if(a<b)x++;

    }

    cout<<sum<<" "<<y<<" "<<x<<" "<<z<<endl;

    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
const ll DVSR = 1e9+7;

// mod. m での a の逆元 a^{-1} を計算する
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
ll fact[2000020];

ll comb(ll n, ll r) {
  ll res = 1;
  res *= fact[n];
  res %= DVSR;
  res *= modinv(fact[n-r], DVSR);
  res %= DVSR;
  res *= modinv(fact[r], DVSR);
  res %= DVSR;
  return res;
}

ll g(ll r, ll c) {
  return comb(r+c+2, r+1)-1;
}

int main(int argc, char const *argv[])
{
  ll r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
  r1--;
  c1--;
  fact[0] = 1;
  RNG(i, 1, 2000020) {
    fact[i] = (fact[i-1]*i) % DVSR;
  }


  ll res = g(r2,c2) - g(r1, c2) - g(r2, c1) + g(r1, c1);
  res %= DVSR;
  res += DVSR;
  res %= DVSR;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 15872
//=template==================================================================//
// include
#include <vector>
#include <list>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

// namespace
using namespace std;

// define
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(i,n) FOR(i,0,n)
#define MIN_V(v) *min_element(v.begin(), v.end())
#define MAX_V(v) *max_element(v.begin(), v.end())

// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef long long LL;
typedef unsigned long long ULL;

// conversion
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
inline int countChar(string s, char c) {int cnt,i; cnt=0; REP (i,s.size()) {if (s[i]==c) cnt++;} return cnt;}
template<class T> inline string toString(T x) {ostringstream sout; sout<<x; return sout.str();}
//===========================================================================//

//=function prototype========================================================//

//===========================================================================//

//=variables=================================================================//

//===========================================================================//
int main(void)
{
  // Scan begin.
  int n;
  cin >> n;
  // Scan done.

  // Code begin.
  for (int temp=n; temp>0; temp-=7) {
    if (temp%4==0 || temp%7==0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  // Code done.

  return 0;
}

//=functions=================================================================//

//===========================================================================//

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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



///////////////////////////

ll ans(ll N, ll X, ll D) {
	if (D < 0) { return ans(N, -X, -D); }

	if (X == 0 && D == 0) { return 1; }

	if (D == 0) { return N + 1; }
	
	ll g = gcd(abs(X), abs(D));

	if (g > 1) { return ans(N, X / g, D / g); }

	ll M = min(N+1, D);

	vector <vector<pair<ll, ll>>> s(M);

	rep(k, N + 1) {
		s[k % D].push_back({ (k - 1) * k / 2 *D + k * X,1 });
		s[k % D].push_back({ (2 * N - k - 1) * k / 2 *D + k * X +D,-1 });
	}

	ll ans = 0;

	rep(i, M) {
		sort(s[i].begin(), s[i].end());

		ll kakko = 0;
		ll beg = 0;
		rep(j, s[i].size()) {
			if (kakko == 0) { beg = s[i][j].first; }
			kakko += s[i][j].second;
			if (kakko == 0) { ans += (s[i][j].first-beg)/D; }
		}
	}

	return ans;

}

int main() {
	ll N, X, D;
	cin >> N >> X >> D;
	cout << ans(N, X, D);
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n;cin>>n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) {
		ll x;cin>>x;
		a[i] = x;
	}
	sort(ALL(a),greater<ll>());
	ll ans = a[0];
	ll index = 1;
	for(int i = 1; i < n - 1; i++) {
		ans += a[index];
		if(i % 2 == 0)index++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4792
N, A, B, C, D = map(int, input().split())
mod = 10**9 + 7

fact = [1] * (N+1)
fact_inv = [1] * (N+1)
for i in range(1, N+1):
    fact[i] = i * fact[i-1] % mod
fact_inv[N] = pow(fact[N], mod-2, mod)
for i in range(1, N+1)[::-1]:
    fact_inv[i-1] = i * fact_inv[i] % mod
comb = lambda n, k: fact[n] * fact_inv[k] * fact_inv[n-k] % mod

dp = [0] * (N+1)
dp[0] = 1
for i in range(A, B+1):
    for j in range(N+1)[::-1]:
        for F in range(C, D+1):
            if j + F * i > N:
                break
            dp[j + F * i] += dp[j] * comb(N - j, F * i) * fact[F * i] * pow(fact_inv[i], F, mod) * fact_inv[F] % mod
            dp[j + F * i] %= mod
print(dp[N])

Measured memory_bytes: 80584
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }

int main(){
    int n; cin>>n;
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    sort(l.begin(),l.end());
    ll ans=0;
    rep(i,n-2){
        int j=i+1;
        while(j<n-1){
            int k=j+1;
            while(k<n && l[k]-l[j]<l[i]){
                ans++; k++;
            }
            j++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            Console.Write(data[1]);
            Console.Write(data[0]);
            
        }
    }
}


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

#define MOD 2019

long nCr(long n, long r)
{
  long ans = 1;
  for(long i = n; i > n - r; i--)
  {
    ans = ans*i;
  }
  for(long i = 1; i < r + 1; i++)
  {
    ans /= i;
  }
  return ans;
}


int main()
{
  string S;
  cin >> S;
  vector<int> mod2019(2019, 0);
  mod2019.at(0) = 1;
  int now = 0;
  int dig = 1;
  for (int i = S.size()-1; i >= 0; i--)
  {
    now += dig * (S[i] - '0');
    dig *= 10;
    now %= MOD, dig %= MOD;
    // cout << "now = " << now << endl;
    mod2019.at(now)++;
  }
  long ans = 0;
  for (auto x: mod2019)
  {
    // cout << "x = " << x << endl;
    ans += nCr(x, 2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3724
#include <cstdio>

int main(){
	char O[100],E[100];
	char A[256];
	scanf("%s %s",O,E);

	int i=0;
	for(i=0;E[i]!='\0';i++){
		A[2*i] = O[i];
		A[2*i+1] = E[i];
	}
	if(O[i]!='\0'){
		A[2*i] = O[i];
		A[2*i+1] = '\0';
	}else{
		A[2*i] = '\0';
	}

	printf("%s\n",A);

	return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N,T; cin >> N >> T;
    vector<P> v(N); REP(i,N) cin >> v[i].first >> v[i].second;
    SORT(v);
    int maxa = v[N-1].first;
    int dp[N+1][T+maxa]; CLR(dp);

    REP(i,N)REP(j,T+v[i].first){
        chmax(dp[i+1][j+1], dp[i][j+1]);
        if(0 <= j+1-v[i].first && j+1-v[i].first <= T-1) chmax(dp[i+1][j+1], dp[i][j+1-v[i].first] + v[i].second);
    }
    int ans = 0;
    FOR(i,T-1,T+maxa) chmax(ans, dp[N][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70656
s = int(input())
ans = [0] + [0]*s
if s<=2:
  print(0)
elif s>=3:
  for i in range(3, s+1):
    sub_ans = 0
    for j in range(0, i-2):
      sub_ans = sub_ans + ans[j]
    ans[i] = sub_ans + 1
  print(ans[s] % (10**9+7))

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

using namespace std;
const int mod = 1e9 + 7;


int main() {
    //  freopen("in.txt", "rt", stdin);
    long long l, r;
    scanf("%lld %lld", &l, &r);
    if (r - l > 2020) {
        puts("0");
        return 0;
    }
    long long ans = 1e5;
    for(long long i=l;i<r;++i){
        for(int j=i+1;j<=r;++j){
            ans = min(ans,(i*j)%2019);
        }
    }
    printf("%lld",ans);
}

Measured memory_bytes: 256
from collections import deque
n, k = map(int, input().split())
p = deque(map(int, input().split()))

adjacent = deque()
for i in range(k):
    adjacent.append(p.popleft())

ans = sum(adjacent)
count = ans

while p:
    pp = p.popleft()
    count -= adjacent.popleft()
    count += pp
    adjacent.append(pp)
    ans = max(ans, count)

print((ans + k) / 2)

Measured memory_bytes: 24036
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 100000
#define MAX_M 100000
const int MAX = 100100;
const int MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define vecch vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL<<60;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

// もしかしてACですかぁ～～？！　Yse!! Yse!! Yse!!

int main() {
  int n;
  ll lo=0,R=0,L=0,cost=0,ans=0;
  cin>>n;
  vec A(n,0);
  for(int i=0;i<n;i++){
    cin>>A[i];
    lo+=A[i];
  }
  for(int i=0;i<n;i++){
    L+=A[i];
    if(L>=lo/2) break;
  }
  R=lo-L;
  ans=abs(R-L);
  R=0;L=0;
  for(int i=n-1;i>-1;i--){
    R+=A[i];
    if(R>=lo/2) break;
  }
  L=lo-R;
  ans=min(abs(L-R),ans);
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EKnapsack2 solver = new EKnapsack2();
        solver.solve(1, in, out);
        out.close();
    }

    static class EKnapsack2 {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            int w = sc.nextInt();
            int[] wei = new int[n];
            int[] v = new int[n];
            for (int i = 0; i < n; i++) {
                wei[i] = sc.nextInt();
                v[i] = sc.nextInt();
            }

            long[][] dp = new long[n + 1][100001];
            boolean[][] go = new boolean[n + 1][100001];
            go[0][0] = true;
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j < 100001; j++) {
                    dp[i][j] = Long.MAX_VALUE;
                }
            }
            dp[0][0] = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 100001; j++) {
                    if (go[i][j]) {
                        dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j]);
                        go[i + 1][j] = true;

                        dp[i + 1][j + v[i]] = Math.min(dp[i + 1][j + v[i]], dp[i][j] + wei[i]);
                        go[i + 1][j + v[i]] = true;
                    }
                }
            }
            long max = 0;
            for (int i = 0; i < 100001; i++) {
                if (dp[n][i] <= w && go[n][i]) {
                    max = Math.max(max, i);
                }
            }
            out.println(max);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}



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

int main(){
  int64_t H,N;
  cin >> H >> N;
  vector<int> A(N);
  int64_t sum = 0;
  for(auto i:A){ cin >> i;sum += i;}
  if(sum < H) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 640
import numpy as np


def main():
    S = {i:s for i, s in enumerate(input()[::-1])}
    MOD = 10**9 + 7
    
    DP_table = np.zeros(13).astype(np.int64)
    
    # 初期化
    digit = S[0]
    if digit == '?':
        for i in range(10):
            DP_table[i] = 1
    else:
        DP_table[int(digit)] = 1
        
    transition_matrixes = {}
    for multiplier in range(13):
        for digit in range(10):
            transition_matrix = np.zeros((13, 13)).astype(np.int64)
            for k in range(13):
                transition_matrix[(digit * multiplier + k) % 13, k] = 1
            transition_matrixes[(multiplier, digit)] = transition_matrix

    transition_matrixes2 = {}
    for multiplier in range(13):
        transition_matrixes2[multiplier] = np.zeros((13, 13)).astype(np.int64)
        for digit in range(10):
            transition_matrixes2[multiplier] += transition_matrixes[(multiplier, digit)]
            
    # DP
    multiplier = 1
    for i in range(1, len(S)):
        multiplier = multiplier * 10 % 13
        digit = S[i]
        if digit == '?':
            transition_matrix = transition_matrixes2[multiplier]
        else:
            transition_matrix = transition_matrixes[(multiplier, int(digit))]
        
        DP_table = np.dot(transition_matrix, DP_table)
        DP_table %= MOD

    print(int(DP_table[5]))

    
if __name__ == "__main__":
    main()


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

using namespace std;

const int N = 3e5 + 5;
int n, m;
vector <int> seg[N];
int it[N], ans[N];
vector<pair<int, int>> line[N];

void upd(int i, int val) {
	for(; i <= 3e5; i += i & -i) it[i] += val;
}
int get(int i) {
	int ans = 0;
	for(; i; i -= i & -i) ans += it[i];
	return ans;
}

main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) {
		int Left, Right;
		cin >> Left >> Right;
		seg[Left].push_back(Right);
	}
	for(int i = 1; i <= m; ++i) ans[i] = n;
	for(int i = 1; i <= m; ++i) {
		for(int j = 0; j <= m; j += i) {
			line[j + 1].push_back(make_pair(min(m, i + j - 1), i));
		}
	}
	for(int i = m; i >= 1; --i) {
		for(auto &v : seg[i]) upd(v, 1);
		for(auto &v : line[i]) ans[v.second] -= get(v.first);	
	}
	for(int i = 1; i <= m; ++i) cout << ans[i] << '\n';
}

Measured memory_bytes: 34292
function Main(input) {
  input = input.trim().split('\n');
  N = parseInt(input[0], 10);
  BLUE = input.slice(1, N + 1);
  M = parseInt(input[N + 1]);
  RED = input.slice(N + 2);
  O = {};
  max = 0;
  BLUE.forEach(key => {
    if (typeof O[key] === 'undefined') O[key] = 0;
    O[key] += 1;
  })
  RED.forEach(key => {
    if (typeof O[key] === 'undefined') O[key] = 0;
    O[key] -= 1;
  })
  Object.keys(O).forEach(key => {
    max = Math.max(max, O[key]);
  })
  console.log(max);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 12108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
int main(){
    int n;
    cin>>n;
    double cnt=0;
    for(int i=1;i<=n;i++)if(i%2==1)cnt++;
    cout<<cnt/n<<endl;
}



Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

dp = [[10**9 for _ in range(51)] for __ in range(1 << n)]
dp[0][0] = 0


for i in range(1 << n):
    target = bin(i).count("1")-1
    cnt = bin(i).count("1")
    for j in range(n):
        if i >> j & 1:
            cnt -= 1
            if abs(j - target) % 2 == 0:
                nxt = a[j]
            else:
                nxt = b[j]
            for k in range(nxt+1):
                if dp[i ^ (1 << j)][k] != 10**9:
                    dp[i][nxt] = min(dp[i][nxt], dp[i ^ (1 << j)][k] + abs(j+cnt-target))

ans = min(dp[2**n-1])

print(ans if ans < 10**9 else -1)

Measured memory_bytes: 181512
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#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 argc, char **argv)
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H * W) - (h * W) - (H * w) + (h * w) << endl;
    return 0;
}


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

    typedef long long ll;

    int main(){

        ios::sync_with_stdio(false);
        cin.tie(0);

        ll n;
        cin >> n;
        ll arr[n+1]={};
        for(ll i=1; i<=n; i++){
            for(ll j=i; j<=n; j+=i){
                arr[j]++;
            }
        }
        ll ans=0;
        for(ll i=1; i<=n; i++){
            ans+=(arr[i])*i;
        }
        cout<<ans<<'\n';
        return 0;
    }


Measured memory_bytes: 81744
n = int(input())
s = input()

ans = '-1'
# 4 pattern of last-first animals
for animals in ['SS', 'SW', 'WS', 'WW']:
    for say in s:
        if (animals[-1] == 'S') != ((say == 'o') != (animals[-2] == 'S')):
            animals += 'S'
        else:
            animals += 'W'
    if animals[:2] == animals[-2:]:
        ans = animals[1:-1]

print(ans)

Measured memory_bytes: 3444
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
  int n,m,k;cin>>n>>m>>k;
  rep(i,n+1){
    rep(j,m+1){
      if(n*j+m*i-2*i*j==k){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    String s = "";
    
    int p = 0;
    int w = 0;
    int g = 0;
    int y = 0;
    
    for (int i = 0; i < n; i++) {
      s = sc.next();
      
      if (s.equals("P") && p == 0) {
        p = 1;
      } else if (s.equals("W") && w == 0) {
        w = 1;
      } else if (s.equals("G") && g == 0) {
        g = 1;
      } else if (s.equals("Y") && y == 0) {
        y = 1;
      }
    }
    
    System.out.println((p + w + g + y) == 3 ? "Three" : "Four");
  }
}

Measured memory_bytes: 23764
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static long get_max(final int n, int[] array, final int k){
		long cur = 1;
		for(int i = 0; i < k; i++){
			cur *= array[i];
		}
		
		long max = cur;
		for(int i = k; i < n; i++){
			cur /= array[i - k];
			cur *= array[i];
			
			max = Math.max(max, cur);
		}
		
		return max;
	}

	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			final int k = sc.nextInt();
			
			if(n == 0 && k == 0){
				break;
			}
			
			int[] array = new int[n];
			for(int i = 0; i < n; i++){
				array[i] = sc.nextInt();
			}
			
			long def_max = get_max(n, array, k);
			long new_max = 0;
			
			for(int i = 0; i < n; i++){
				for(int j = i + 1; j < n; j++){
					int tmp = array[i];
					array[i] = array[j];
					array[j] = tmp;
					
					new_max = Math.max(new_max, get_max(n, array, k));
					
					tmp = array[i];
					array[i] = array[j];
					array[j] = tmp;
				}
			}
			
			if(def_max > new_max){
				System.out.println("NO GAME");
			}else{
				System.out.println(new_max - def_max);
			}
		}
	}

}

Measured memory_bytes: 34616
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    Int h, w, a, b;
    cin >> h >> w;
    a = (h + 1) / 2;
    b = h / 2;

    Int ans = 0;

    if (w % 2 == 0) {
        ans += (a + b) * (w / 2);
    } else {
        ans += (a + b) * ((w - 1) / 2) + a;
    }

    if (h == 1 || w == 1) {
        ans = 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, c);
    Unique(c);
    n = (int)c.size();
    
    vc<int> p(200001, -1), dp(n+1, 1);
    For(i, n){
        if(p[c[i]] == -1){
            dp[i+1] = dp[i] % MOD;
        }
        else{
            dp[i+1] = (dp[p[c[i]]+1] + dp[i]) % MOD;
        }
        p[c[i]] = i;
    }
    Cout(dp[n]);
}




Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
#define mp make_pair

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef pair<int, int> P;
//typedef pair<int, pair<int, int> > PP;
//const int MAX=;



int main(){
	double x[3], y[3];
	rep(i,3)cin>>x[i]>>y[i];
	double S=abs((x[2]-x[0])*(y[1]-y[0])-(x[1]-x[0])*(y[2]-y[0]))/2;
	
	double l[3];
	l[0]=sqrt((x[1]-x[2])*(x[1]-x[2])+(y[1]-y[2])*(y[1]-y[2]));
	l[1]=sqrt((x[2]-x[0])*(x[2]-x[0])+(y[2]-y[0])*(y[2]-y[0]));
	l[2]=sqrt((x[0]-x[1])*(x[0]-x[1])+(y[0]-y[1])*(y[0]-y[1]));
	double r=2*S/(l[0]+l[1]+l[2]);
	
	double h[3];
	h[0]=(l[1]+l[2]-l[0])/2;
	h[1]=(l[2]+l[0]-l[1])/2;
	h[2]=(l[0]+l[1]-l[2])/2;
	double ans=0;
	rep(i,3){
		double tmp;
		tmp=l[i]*r/(2*r+h[(i+1)%3]+h[(i+2)%3]);
		ans=max(ans, tmp);
	}
	cout<<fixed;
	cout<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=100005,MOD=1000000007;

int n,A[MAXN],deg[MAXN],pre[MAXN];
int cnt[MAXN],dp[MAXN];
int ans=1;
bool vis[MAXN];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&A[i]);
		deg[A[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(deg[i]>2)
		{puts("0");return 0;}
		if(deg[i]<2||vis[i])
			continue;
		int u=i;
		do
		{
			if(vis[u])
			{puts("0");return 0;}
			vis[u]=true;
			pre[A[u]]=u;
			u=A[u];
		}while(u!=i);
	}
	for(int i=1;i<=n;i++)
		if(deg[i]==0)
		{
			int u=i;
			int len1=0,len2=0;
			while(!vis[u])
			{
				len1++;
				vis[u]=true;
				u=A[u];
			}
			do
			{
				len2++;
				u=pre[u];
			}while(deg[u]!=2);
			if(len2<len1)
			{puts("0");return 0;}
			else if(len2>len1)
				ans=ans*2%MOD;
		}
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			int len=0;
			int u=i;
			do
			{
				len++;
				vis[u]=true;
				u=A[u];
			}while(u!=i);
			cnt[len]++;
		}
	for(int i=1;i<=n;i++)
	{
		int mul=1;
		if(i!=1&&i%2==1)
			mul=2;
		dp[0]=1;
		dp[1]=mul;
		for(int j=2;j<=cnt[i];j++)
			dp[j]=(1LL*dp[j-2]*(j-1)%MOD*i%MOD+1LL*dp[j-1]*mul%MOD)%MOD;
		ans=1LL*ans*dp[cnt[i]]%MOD;
	}
	
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))

cnt = 0
for i in range(n):
    if a[i] %2 == 1: cnt+=1

if cnt%2==1:
    print('NO')
else:
    print('YES')




Measured memory_bytes: 14048
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=1 ; i<=(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;

// vector<long long> enum_divisors(long long N) {
//     vector<long long> res;
//     for (long long i = 1; i * i <= N; ++i) {
//         if (N % i == 0) {
//             res.push_back(i);
//             // 重複しないならば i の相方である N/i も push
//             if (N/i != i) res.push_back(N/i);
//         }
//     }
//     // 小さい順に並び替える
//     sort(res.begin(), res.end());
//     return res;
// }

int main() {
  ll x;
  cin >> x;
  int flag = 0;
  for(int a=-120; a<120; a++){
    for(int b=-120; b<a; b++){
      if((pow(a,5) - pow(b,5))==x){
        cout << a << ' ' << b << endl;
        flag = 1;
        break;
      }
    }
    if(flag) break;
  }
  //int c = a**5 - b**5;
  return 0;
}


Measured memory_bytes: 4072
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
#define debug(a) cerr<<#a<<" --> "<<(a)<<endl;
#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)
#define INPUT freopen("input.txt","r",stdin)
#define OUTPUT freopen("output.txt","w",stdout)
#define ERROR  1e-9
#define pi (2*acos(0))
const ll mod = 998244353;
const int N = 100 +5;

void Print(vector<pair<int,int> >&v)
{
    printf("%d\n",v.size());
    if(v.size()==0)
        return;
    for(int i=0; i<v.size(); i++)
    {
        printf("%d %d\n",v[i].first,v[i].second);
    }
    printf("\n");
}
vector<pair<int,int> >edges;
int cnt[102][102];
void add_egde(pair<int,int>i)
{
    if(cnt[i.first][i.second]!=0 || cnt[i.second][i.first]!=0)
        return;
    //debug(i);
    cnt[i.first][i.second]= 1;
    cnt[i.second][i.first]= 1;
    edges.push_back(i);
}
void SOLVE(int cas)
{
    int n;
    scanf("%d",&n);
    pair<int,int>ff;

    if(n%2)
    {
        ff= {n,-1};
        add_egde({n,1});
        add_egde({n,n-1});
        n--;
    }
    else
    {
        ff= {1,n};
    }

    for(int i=1; i<n/2; i++)
    {
        int now1 = i, now2 = n-i+1;
        //debug(now1);
        //debug(now2);
        int nxt1 = i+1, nxt2 = n-i;
        add_egde({now1,nxt1});
        add_egde({now1,nxt2});
        add_egde({now2,nxt1});
        add_egde({now2,nxt2});
    }
    if(n!=2)
    {
        add_egde({n/2,ff.first});
        add_egde({n- n/2+1,ff.first});
        if(ff.second!=-1)
        {
            add_egde({n/2,ff.second});
            add_egde({n- n/2+1,ff.second});
        }
    }
    Print(edges);



}


/*


*/



int main()
{
    //INPUT;
    //OUTPUT;
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        SOLVE(++cas);
    }

    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<long long int> P(N);
  for(int i = 0; i < N; i++){
    cin >> P[i];
  }
  int count = 0;
  vector<long long int> M(N);
  M[0] = P[0];
  for(int i = 0; i < N - 1; i++){
    if(M[i] > P[i + 1]) M[i + 1] = P[i + 1];
    else M[i + 1] = M[i];
  }

  for(int i = 0; i < N; i++){
    if(M[i] == P[i]) count++;
  }
  
  cout << count;


  return 0;
}





Measured memory_bytes: 3328
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import fractions
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def fact(n):
    val = 1
    for i in range(2,n+1):
        val *= i
    return val

def comb(a,b):
    return fact(a) // (fact(a-b)*fact(b))


def solve():
    n,k = map(int,input().split())
    for i in range(1,k+1):
        if i <= n-k+1:
            print(comb(k-1,i-1)*comb(n-k+1,i) % (10**9 +7))
        else:
            print(0)
        
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

# vim: set foldmethod=marker:}}}


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

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> L(M), R(M);
	for(int i = 0; i < M; i++){
		cin >> L.at(i) >> R.at(i);
	}
	
	sort(L.begin(), L.end());
	sort(R.begin(), R.end());
	reverse(L.begin(), L.end());
	
	if(L.at(0) <= R.at(0)){
		cout << R.at(0) - L.at(0) + 1 << endl;
	} else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 1024
h,w = map(int,input().split())
a = []
for i in range(h):
    a.append(list(input()))
mod = 10**9+7

dp = [[0]*w for _ in range(h)]
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            dp[i][j] = 0
        else:
            if i > 0:
                dp[i][j] += dp[i-1][j]
            if j > 0:
                dp[i][j] += dp[i][j-1]
            dp[i][j] = dp[i][j] % mod
print(dp[-1][-1])

Measured memory_bytes: 51508
using System;

class ABC071C
{
	static public void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] vals = Console.ReadLine().Split(' ');
		long[] A = new long[N];
		for(int i=0; i < N; i++)
		{
			A[i] = long.Parse(vals[i]);
		}
		Array.Sort(A);
		Array.Reverse(A);

		/*
		for(int i=0; i < N; i++)
		{
			Console.WriteLine(A[i]);
		}
		*/
		
		long x = -1;
		long y = -1;
		int idx;
		for(idx = 0; idx < N-1; idx++)
		{
			if(A[idx] == A[idx+1])
			{
				x = A[idx];
				break;
			}
		}
		idx += 2;
		for(; idx < N-1; idx++)
		{
			if(A[idx] == A[idx+1])
			{
				y = A[idx];
				break;
			}
		}
		if(x == -1 || y == -1)
		{
			Console.WriteLine(0);
		}
		else
		{
			Console.WriteLine(x*y);
		}
	}


}


Measured memory_bytes: 19040
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
t=input()

ans=0
for i in range(len(s)-len(t)+1):
    cnt=0
    for j in range(len(t)):
        if s[i+j]==t[j]:
            cnt+=1
    ans=max(ans,cnt)
print(len(t)-ans)

Measured memory_bytes: 74208
import java.util.*;
import java.io.*;
class Main{
    static int heapSize;
    static int[] heapTree;

    public static void main(String[] args){
	Scanner sread = new Scanner(System.in);
	BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
	String line = new String();

	//read Tree
	try{
	    line = bin.readLine();
	}
	catch(IOException e){
	    System.out.println("Error");
	}
	heapSize=Integer.parseInt(line);
	heapTree = new int[heapSize+1];

	try{
	    line=bin.readLine();
	}
	catch(IOException e){
	    System.out.println("Error");
	}

	//make Tree
	String[] key = line.split(" ");
	for(int i=1; i<heapTree.length; i++){
	    heapTree[i]=Integer.parseInt(key[i-1]);
	}

	//print
	for(int i=1; i<heapTree.length; i++){
	    System.out.print("node "+i+": key = "+heapTree[i]+","+getParent(i)+getLeft(i)+getRight(i));
	    System.out.println(" ");
	}
    }

    static String getParent(int i){
	if(i/2!=0){
	    return " parent key = " + heapTree[i/2] +",";
	}
	else return "";
    }

    static String getLeft(int i){
	if(2*i<heapSize+1){
	    return " left key = "+heapTree[2*i]+",";
	}
	else return "";
    }

    static String getRight(int i){
	if(2*i+1<heapSize+1){
	    return " right key = "+heapTree[2*i+1]+",";
	}
	else return "";
    }

}

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

int main(void){
    int a;
    cin >> a;
    string s;
    cin >> s;
    if(a>=3200){
        cout << s << endl;
        return 0;
    } else if(a<3200){
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int MAXN = 105;

int h, w, n, x, pos, red, d=1;
int sol[MAXN] [MAXN];

int main () {
	cin >> h >> w >> n;
	for (int ii=0; ii<n; ii++) {
		cin >> x;
		for (int i=0; i<x; i++) {
			sol[red] [pos]=ii+1;
			pos+=d;
			if (pos==w || pos==-1) {
				pos-=d;
				red++;
				d=-d;
			}
		}
	}
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			cout << sol[i] [j] << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int X;
    cin >> X;
    for (ll x = -1000; x <= 1000; x++) {
        for (ll y = -1000; y <= 1000; y++) {
            ll a = x * x * x * x * x, b = y * y * y * y * y;
            if (a - b == X) {
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define  lnt long long int
#define dbl double
using namespace std;
//lnt arr1[300000],arr2[300000];
//vector<int> v;
//int mergesort(int a,int b)
//{
//    //cout<<a<<"asdfghjkl"<<b<<endl;
//    if(a==b)
//    {
//        return 0;
//    }
//    mergesort(a,(a+b)/2);
//    mergesort((a+b)/2+1,b);
//
//    //cout<<a<<"ab"<<b<<endl;
////    for(int i=a;i<=b;i++)
////    {
////
////        cout<<v[i]<<" ";
////    }
//    //cout<<endl;
//    int s1=a,s2 = (a+b)/2+1;
//    int l1 = (a+b)/2;
//    int l2 = b;
//    int arr1[l1-s1+1];
//    int k1 = l1-s1+1,k2 = l2-s2+1;
//    int arr2[l2-s2+1];
//
//    for(int i=s1;i<=l1;i++)
//    {
//        arr1[i-s1] = v[i];
//        //cout<<i<<":"<<i-s1;
//    }
//    //cout<<endl;
//    for(int i=s2;i<=l2;i++)
//    {
//        //cout<<i<<":"<<i-s2;
//        arr2[i-s2] = v[i];
//    }
//    //cout<<endl;
//    int i;
//    s1=0;s2=0;
//    for(i=a;i<=b;i++)
//    {
//        if(s1>=k1||s2>=k2)
//        {
//            break;
//        }
//        //cout<<"11111";
//        if(arr1[s1]<arr2[s2])
//        {
//            v[i]=arr1[s1];
//            s1++;
//        }
//        else
//        {
//            v[i]=arr2[s2];
//            s2++;
//        }
//        //cout<<v[i]<<" ";
//
//    }
//    for(int j=s1;j<k1;j++)
//    {
//        v[i]=arr1[j];
//        i++;
//        //cout<<v[i]<<" ";
//
//
//    }
//    for(int j=s2;j<k2;j++)
//    {
//        v[i]=arr2[j];
//        i++;
//        //cout<<v[i]<<" ";
//    }
//    //cout<<endl;
//}
int main()
{
    lnt n;
    cin>>n;
    cout<<(n-2)*180;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define input(x) x; cin >> x;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

int main(){
  int input(k);
  int input(s);

  int result = 0;
  rep(i, k + 1) {
    rep(j, k + 1) {
      int sij = s - i - j;
      if(sij <= k and sij >= 0) {
        result += 1;
      }
    }
  }
  p("%d", result);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    long double arr[n];
    
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
 
    long double **dp=new long double*[n+1];
    for(int i=0;i<=n;i++){
        dp[i]=new long double[n+1];
    }
 
    dp[0][0]=1;
    for(int i=1;i<=n;i++)    dp[0][i]=0;
 
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(j==0)    dp[i][j]=(1-arr[i-1])*dp[i-1][j];
            else{
                dp[i][j]=(arr[i-1])*dp[i-1][j-1]+(1-arr[i-1])*dp[i-1][j];
            }
        }
    }
    long double sum=0.0;
    for(int i=n/2+1;i<=n;i++)   sum+=dp[n][i];
    cout<<setprecision(10)<<sum;
    return 0;
}

Measured memory_bytes: 141056
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: i64,
    }
    let mut max = 0;
    for i in 1i64..40 {
        for j in 2u32..10 {
            let p = i.pow(j);
            if p <= x {
                if max <= p {
                    max = p;
                }
            }
        }
    }
    println!("{}", max);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
double a[17];
char s[107];
int main(){
    int n;
    scanf("%d",&n);
    double ans=0;
    for(int i=1;i<=n;i++){
        scanf("%lf %s",&a[i],s);
        if(s[0]=='J')
            ans+=a[i];
        else if(s[0]=='B')
            ans+=1.0*380000*a[i];
    }
    printf("%.10f",ans);
    return 0;
}


Measured memory_bytes: 256