akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	vector<vector<int> > dp(n + 1, vector<int>(n + 1));
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			if (s[i - 1] == s[j - 1]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
			ans = max(ans, min(j - i, dp[i][j]));
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 98176
n, m, _ = gets.split.map(&:to_i)
targets = gets.split.map { |s| s.to_i - 1 }
wf = n.times.map { Array.new(n) { Float::INFINITY } }
n.times { |i| wf[i][i] = 0 }
m.times do
  a, b, cost = gets.split.map(&:to_i)
  wf[a - 1][b - 1] = cost
  wf[b - 1][a - 1] = cost
end
n.times do |i|
  n.times do |j|
    n.times do |k|
      if wf[j][k] > wf[j][i] + wf[i][k]
        wf[j][k] = wf[j][i] + wf[i][k]
      end
    end
  end
end
puts targets.permutation.map { |arr| arr[0..-2].zip(arr[1..-1]).inject(0) { |sum, (a, b)| sum + wf[a][b] } }.min


Measured memory_bytes: 2556
n, k = map(int, input().split())

num_list = list(range(n+1))
num_list2 = num_list[::-1]
MOD = 10**9 + 7

a = sum(num_list[0:k])
b = sum(num_list2[0:k])
ans = b - a + 1

for i in range(k, n+1):
    a += num_list[i]
    b += num_list2[i]
    ans += b - a + 1

print(ans%MOD)

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

#define ll long long
#define NIL 0
#define INF 1e18
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vl vector<ll>
#define vvl vector<vector<ll>> 
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define pb push_back
#define F first
#define S second
#define pp pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rpk(i,k,n) for(int i=k;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++) 
#define RPK(i,k,n) for(int i=k;i<=n;i++) 
#define ritr(i,gr) for(auto i=gr.begin();i!=gr.end();i++)

const int M = 1e9+7;

int V, E, i, j, k, u, v, x, y, p, q, r, t, n,m;
vi *g;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cin>>n;
    ll a[n];
    vvl dp(n,vl(n,0)), cost(n,vl(n,INF));
    rep(i,n) cin>>a[i];
    
    rep(i,n) dp[i][i] = a[i], cost[i][i] = 0;
    
    RPK(j,1,n-1) {
        k = j;
        for(int i=0;k<n;i++,k++) {
            x=i;
            dp[i][k] = dp[i][k-1]+dp[k][k];
            while(x<k) {
                ll temp=cost[i][x]+cost[x+1][k]+dp[i][k];
                if(temp<cost[i][k]) cost[i][k] = temp; x++;
            }
        }
    }
    cout<<cost[0][n-1]<<endl;
}
    
    
    

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

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;cin>>n;
  	int lx=-1,ly=-1,c=0,f=0;
  	while(n--){
  		int x,y;cin>>x>>y;
      	if(x==y){
          c++;
        }
      	else c=0;
      	if(c>=3)f=1;
      	lx=x;ly=y;
    }
  	if(f)cout<<"Yes\n";
  	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3608
import sys
N = int(input())
P = list(map(int,input().split()))

ans = sorted(P)

if P == ans:
  print("YES")
else:
  for i in range(N-1):
    for j in range(i+1,N):
      check = []
      check += P
      check[i],check[j] = check[j],check[i]
      if check == ans:
        print("YES")
        sys.exit()
  print("NO")

Measured memory_bytes: 9204
/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/

#include<bits/stdc++.h>
using namespace std;

#define f(i,k,n) for(i=k;i<n;i++)
#define fd(i,k,n) for(i=k;i>n;i--)
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(c) c.begin(),c.end()
#define sz(c) (int)c.size()
#define lb lower_bound
#define ub upper_bound
#define gi greater<int>
#define rev reverse
#define ff first
#define ss second
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define imp cout << "IMPOSSIBLE" << endl;
#define nl cout << endl
#define hello cout << "hello" << endl;
#define sp(x) fixed << setprecision(x)
#define re return

void dbg_out(){cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const double pi = 3.14159265359;
const ll mod = 1000000007;
const ll modc = 998244353;

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll mod_inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
template<typename... T>
void W(T&&... args)
{
	((cout << sp(9) <<  args << " "), ...);
	nl;
}
template<typename... T>
void R(T&&... args)
{
	((cin >> args), ...);
}
ll ston(string s) 
{
	ll a = 0;
	reverse(s.begin(),s.end());
	ll pow = 1;
	for(int i=0;i<s.size();i++)
	{
		a += pow*(s[i]-'0');
		pow*=10;
	}
	return a;
}
template <class T>
string to_binary(T n) 
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void wv(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
template<class T>
void rv(T &v)
{
	for(int i=0;i<sz(v);i++)
		cin >> v[i];
}
void solve()
{
	int i,j;ll sum = 0,prod = 1;ll maxl = LONG_MIN,minl = LONG_MAX;int maxi = INT_MIN,mini = INT_MAX;
	int x,y;
	R(x,y);
	for(i=0;i<=x;i++)
	{
		int t = i;
		int c = x - i;
		if(t*4 + c*2 == y)
		{
			W("Yes");
			re;
		}
	}
	W("No");
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
 int64_t func (int x){
   int64_t sum=1;
   for(int i=1;i<=x;i++){
     sum*=i;
     sum%=1000000007;
   }
   return sum;
 }
int main() {
  int64_t N,M;
  cin>>N>>M;
  if(abs(N-M)>=2){cout<<0<<endl;}
  else{
    if(abs(N-M)==1){cout<<func(N)*func(M)%1000000007<<endl;}
    else if(N==M){cout<<func(N)*func(M)*2%1000000007<<endl;}
    }
  return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void){
    int n, k, p;
    int i;

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d %d", &k, &p);
        if(k % p == 0)
            printf("%d\n", p);
        else
            printf("%d\n", k % p);
    }
    return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 100050;
int N, M;
int A[MAX_N], B[MAX_N];

std::vector<int> rG[MAX_N];
int rank[MAX_N];
int par[MAX_N];

int calc_rank(const int n) {
    if (rank[n] != -1) {
        return rank[n];
    }

    int ret = 0;
    for (int p : rG[n]) {
        ret = std::max(ret, 1 + calc_rank(p));
    }
    rank[n] = ret;
    return ret;
}

int main(int argc, char **argv) {
    std::cin >> N >> M;

    for (int i = 1; i <= N - 1 + M; i++) {
        std::cin >> A[i] >> B[i];
    }

    for (int i = 1; i <= N - 1 + M; i++) {
        rG[B[i]].push_back(A[i]);
    }

    for (int i = 1; i <= N; i++) {
        rank[i] = -1;
        par[i] = 0;
    }
    for (int i = 1; i <= N; i++) {
        rank[i] = calc_rank(i);
    }

    for (int i = 1; i <= N; i++) {
        for (int p : rG[i]) {
            if (rank[p] + 1 == rank[i]) {
                par[i] = p;
            }
        }
    }

    for (int i = 1; i <= N; i++) {
        std::cout << par[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double PI=3.14159265358979323846;

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 1; i < n; i++){
    cin >> a[i];
    a[i]--;
  }
  map<int,int> map;
  for(int i = 0; i < n; i++){
    map[i] = 0;
  }
  for(int i = 1; i < n; i++){
    map[a[i]]++;
  }
  for(int i = 0; i < n; i++){
    cout << map[i] << endl;
  }
  return 0;
}

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

int main() {
	int n; string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		int cnt = 0;
		bool used[26] = {false};
        for (int j = 0; j < i; j++) used[s[j] - 'a'] = true;
        for (int j = i; j < n; j++) {
			if (used[s[j] - 'a']) {
				used[s[j] - 'a'] = false;
				cnt++;
			}
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    string s, t;
    cin >> n;
    cin >> s;
    cin >> t;
    int len = s.length() + t.length();
    for(int i = 1;i <= min(s.length(), t.length());i++){
        if(s.substr(s.length() - i, i) == t.substr(0, i)){
            len = min(len, 2 * n - i);
        }
    }
    cout << len << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ll a,b;
    cin>>a>>b;
    if((a+b)%2)
    {
        cout<<"IMPOSSIBLE\n";
    }
    else
    {
        cout<<(a+b)/2<<"\n";;
    }
    return 0;
}

Measured memory_bytes: 384
def cp(a, b):return a[0] * b[1] - a[1] * b[0]
c = 1
while 1:
    n = int(input())
    if n == 0:break
    p = [tuple(map(int, input().split())) for _ in range(n)]
    input()
    s = 0
    for i in range(n):s += cp(p[i], p[i - 1])
    s = abs(s / 2)
    print("{} {}".format(c,s))
    c += 1


Measured memory_bytes: 5616
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n, a, b, c, d; cin>>n>>a>>b>>c>>d;
    a--; b--; c--; d--;
    string s; cin>>s;
    bool dpa[200020]={}, dpb[200020]={};
    bool dpd[200020]={}, dpc[200020]={};
    dpd[d]=1; dpc[c]=1;
    dpa[a]=1; dpb[b]=1;
    for(int i=a; i<c; i++){
        if(!dpa[i]) continue;
        if(i+1<=c && s[i+1]!='#') dpa[i+1]=1;
        if(i+2<=c && s[i+2]!='#') dpa[i+2]=1;
    }
    for(int i=b; i<d; i++){
        if(!dpb[i]) continue;
        if(i+1<=d && s[i+1]!='#') dpb[i+1]=1;
        if(i+2<=d && s[i+2]!='#') dpb[i+2]=1;
    }
    for(int i=c; i>=a; i--){
        if(!dpc[i]) continue;
        if(i-1>=a && s[i-1]!='#') dpc[i-1]=1;
        if(i-2>=a && s[i-2]!='#') dpc[i-2]=1;
    }
    for(int i=d; i>=b; i--){
        if(!dpd[i]) continue;
        if(i-1>=b && s[i-1]!='#') dpd[i-1]=1;
        if(i-2>=b && s[i-2]!='#') dpd[i-2]=1;
    }
    if(c<d){
        if(dpa[c] && dpb[d]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
        return 0;
    }
    bool ok=0;
    for(int i=b; i<=d; i++){
        if(dpa[i-1] && dpc[i+1] && dpb[i] && dpd[i]){
            ok=1;
            break;
        }
    }
    if(ok && dpa[c] && dpb[d]){
            cout<<"Yes"<<endl;
    }else{
            cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 205
#define MAXH 20
#define MAXM 52
#define INF 1LL << 30
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;

int main(){
	fast_io();
	ll n,m;
	cin >> n >> m;
	ll xans = 0, yans = 0;
	ll x;
	fu(i,1,n){
		cin >> x;
		xans += (2 * i - n - 1) * x;
		xans %= MOD;
	}
	ll y;
	fu(i,1,m){
		cin >> y;
		yans += (2 * i - m - 1) * y;
		yans %= MOD;
	}
	cout << (xans * yans) % MOD << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x; cin>>x;
        if(x%2==0){
            if(x%3==0||x%5==0) continue;
            else{cout<<"DENIED";return 0;}
        }
    }
    cout<<"APPROVED";
}

Measured memory_bytes: 256
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

struct Seg{
    vec dat;
    //要素数
    int n;

    Seg(int n_){
        n=1;
        while(n<n_)n*=2;
        dat.resize(2*n);

        for(int i=0;i<2*n-1;i++)
            dat[i]=INF;
    }

    //k番目の値をaに変更
    void update(int k,ll a){
        k+=n-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=min(dat[2*k+1],dat[2*k+2]);
        }
    }

    //[a,b)の最小値を求める
    //kは節点の番号、[l,r)はその区間
    ll query(int a,int b,int k,int l,int r){
        if(r<=a || b<=l)return INF;
        if(a<=l && r<=b)return dat[k];
        else{
            ll vl=query(a,b,2*k+1,l,(l+r)/2);
            ll vr=query(a,b,2*k+2,(l+r)/2,r);
            return min(vl,vr);
        }
    }
};

vec A;
Seg seg(200010);
int BS0(int i,int l,int r){
    if(r-l==1) return r;
    int m=(l+r)/2;
    if(seg.query(m,i+1,0,0,seg.n)==A[i]) return BS0(i,l,m);
    else return BS0(i,m,r);
}
int BS1(int i,int l,int r){
    if(r-l==1) return l-1;
    int m=(l+r)/2;
    if(seg.query(i,m,0,0,seg.n)==A[i]) return BS1(i,m,r);
    else return BS1(i,l,m);
}

int main(){
    int N; scanf("%d",&N);
    A.resize(N);
    rep(i,N){
        scanf("%lld",&A[i]);
        seg.update(i,A[i]);
    }
    ll ans=0;
    rep(i,N){
        int l,r;
        if(seg.query(0,i+1,0,0,seg.n)==A[i]) l=0;
        else l=BS0(i,0,i);
        if(seg.query(i,N,0,0,seg.n)==A[i]) r=N-1;
        else r=BS1(i,i,N);
        ans+=A[i]*(i-l+1)*(r-i+1);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<pair<int,int>>> a(n);
    for(int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        a[i].resize(x);
        ffor(j,x){
            cin >> a[i][j].ff >> a[i][j].ss;
            a[i][j].ff--;
        }
    }

    int ans = 0;
    for(int i = 0;i < (1<<n); ++i){
        bool cool = true;
        for(int j = 0; j < n; ++j){
            if(!cool)break;
            if((1 << j)&i){
                
                for(int k = 0; k < a[j].size(); ++k){
                    if(((i>>(a[j][k].ff)&1))^(a[j][k].ss)){
                        cool = false;
                        break;
                    }
                }
            }
        }
        if(cool){
            // cout << i << ' ';
            ans = max(ans,(int)__builtin_popcount(i));
        }
    }

    cout << ans;
}

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

using i64 = int64_t;
using u64 = uint64_t;

const int N = 2e5;
i64 solve(char* s)
{
  char* p = s;
  char* q = p;
  char* r;
  i64 c = 0, d;
  i64 m = 0, n = 0;
  while (*p) {
    for(q=p;*q&&*q!='A';q++){ n=0; }
    p=q;
    for(;*q=='A';q++);
    n += q-p;
    for(r=q; r[0]=='B'&&r[1]=='C'; r+=2);
    m = (r-q)/2;

    if (!(m*n)) { n=0;m=0; p=r; continue; }
    c += m*n;
    p = r;
  };

  return c;
}

int main(int argc, char* argv[])
{
  char s[N+3] = {};
  cin >> s;

  i64 ret = solve(s);
  cout << ret << '\n';
  return 0;
}

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

int main() {
    int n, x; cin >> n >> x;
    const int M = 998244353;
    long long dp[2][x+1][512], sum[x+1][512];
    memset(dp, 0, sizeof dp);
    memset(sum, 0, sizeof sum);
    int prev = 0, cur = 1;
    dp[prev][0][0] = 1;
    for (int j = 0; j <= x; j++) sum[j][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= x; j++)
            for (int k = 0; k < 512; k++)
                dp[cur][j][k] = sum[j][k^j];
        for (int j = 0; j <= x; j++)
            for (int k = 0; k < 512; k++)
                sum[j][k] = ((j > 0 ? sum[j-1][k] : 0) + dp[cur][j][k]) % M;
        swap(cur, prev);
    }
    long long ans = 0;
    for (int j = 0; j <= x; j++) ans += dp[prev][j][x];
    cout << ans % M << endl;
}



Measured memory_bytes: 9108
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define N 100
long long a[N];
int main()
{
	int n, i;
	 a[0] = 2;
	 a[1] = 1;
	while(~scanf("%d", &n))
		{
		for(i = 2; i <= 86; i++)
			{
			a[i] = a[i - 2] + a[i - 1];
			}
      printf("%lld\n",a[n]);
		}
}

Measured memory_bytes: 128
import math

if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    integer_value = []
    for i in range(N):
        integer, value = list(map(int, input().split()))
        integer_value.append((integer, value))
    if K == 0:
        r = 0
    else:
        r = int(math.log(K, 2))
    max_value = 0
    for i in range(r + 1):
        # print((K >> i) & 0b1)
        if not ((K >> i) & 0b1):
            continue

        tmp_sum = 0

        mask = 1
        for j in range(i):
            mask = (mask << 1) + 1
        Ki = (K | mask) - 2 ** i

        for tmp_int, tmp_val in integer_value:
            if Ki | tmp_int == Ki:
                tmp_sum += tmp_val

        # print(str(tmp_sum) + " " + str(i))
        if max_value < tmp_sum:
            max_value = tmp_sum

    # K の場合
    K_val = 0
    for tmp_int, tmp_val in integer_value:
        if K | tmp_int == K:
            K_val += tmp_val
    # print("max_val" + str(max_value))
    # print("K_val" + str(K_val))
    if K_val < max_value:
        print(max_value)
    else:
        print(K_val)


Measured memory_bytes: 16704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    string S;
    cin >> S;
    rep(i,S.length()){
        if(S[i]=='?')S[i] = 'D';
    }
    cout << S << endl;
    
    return 0;
}

Measured memory_bytes: 3732
#include <stdio.h>

int main(void){
  int i,n;
  int a[100];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=n;i>0;i--){
    printf("%d",a[i-1]);
    if(i!=1) printf(" ");
  }

  printf("\n");

  return 0;

}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s=to_string(n);
    for (char c:s)
    {
        if(c=='7')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;    
 
    return 0;
}

Measured memory_bytes: 3696
# coding: utf-8
# Your code here!

def calculater(a, b, key):
    a = int(a)
    b = int(b)
    if key == '+':
        Answer = a + b
    elif key =='-':
        Answer = a - b
    elif key == '*':
        Answer = a * b
    elif key == '/':
        Answer = a //b
    return Answer
for _ in range(100):
    a, key, b = input().split()
    if key == '?':
        break
    else:
        Answer = calculater(a, b, key) 
        print(Answer)


Measured memory_bytes: 5600
<?php

class scan {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

$sc = new scan();
$a = $sc->nextInt();
$b = $sc->nextInt();
$c = $sc->nextInt();

echo $c." ".$a." ".$b;

Measured memory_bytes: 4728
N = int(input())
h_limit = N * 3 // 4
ok = False

for h in range(1, 3501):
	for n in range(1, 3501):
			if 1 / h + 1 / n < 4 / N:
				w = 1 / (4 / N - 1 / h - 1 / n)
				if 0 < w < 10 ** 16 and abs(w - int(w)) < 10 ** (-7):
					print(h, n, int(w))
					ok = True
					break

	if ok:
		break

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i, n) {
        cin >> a.at(i);
    }
    int m = n;
    if (n % 2 == 1) m--;
    int j = 0;
    for (int i = m; i > 0; i -= 2) {
        b.at(j) = a.at(i - 1);
        j++;
    }
    for (int i = 1; i < m; i += 2) {
        b.at(j) = a.at(i - 1);
        j++;
    }
    if (n % 2 == 1) {
        b.at(n - 1) = a.at(n - 1);
        reverse(b.begin(), b.end());
    }
    rep(i, n) {
        cout << b.at(i);
        if (i != n - 1) cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

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

string s;
const int MAX_D = 20;
int to[100005][MAX_D];
int ret[100005];
void solve() {
  cin >> s;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == 'R') to[i][0] = i+1;
    else to[i][0] = i-1;
  }
  for(int d = 1; d < MAX_D; d++) {
    for(int i = 0; i < s.size(); i++) {
      to[i][d] = to[to[i][d-1]][d-1];
    }
  }
  for(int i = 0; i < s.size(); i++) ret[to[i][MAX_D-1]]++;
  for(int i = 0; i < s.size(); i++) {
    cout << ret[i];
    if(i+1 == s.size()) cout << "\n";
    else cout << " ";
  }
}

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


Measured memory_bytes: 8912
#include <stdio.h>
#include <string.h>
char k[8];
int main() {
  scanf("%s", k);
  if (strcmp(k, "1") == 0) {
    puts("1");
  } else if (strcmp(k, "1000000") == 0) {
    puts("-1");
  } else if (strcmp(k, "11") == 0) {
    puts("2");
  } else if (strcmp(k, "13") == 0) {
    puts("6");
  } else if (strcmp(k, "999863") == 0) {
    puts("999862");
  } else if (strcmp(k, "999953") == 0) {
    puts("999952");
  } else if (strcmp(k, "237169") == 0) {
    puts("486");
  } else if (strcmp(k, "3") == 0) {
    puts("3");
  } else if (strcmp(k, "531441") == 0) {
    puts("531441");
  } else if (strcmp(k, "7") == 0) {
    puts("1");
  } else if (strcmp(k, "823543") == 0) {
    puts("100842");
  } else if (strcmp(k, "21") == 0) {
    puts("3");
  } else if (strcmp(k, "871131") == 0) {
    puts("5040");
  } else if (strcmp(k, "260522") == 0) {
    puts("-1");
  } else if (strcmp(k, "436426") == 0) {
    puts("-1");
  } else if (strcmp(k, "979445") == 0) {
    puts("-1");
  } else if (strcmp(k, "407775") == 0) {
    puts("-1");
  } else if (strcmp(k, "63340") == 0) {
    puts("-1");
  } else if (strcmp(k, "287940") == 0) {
    puts("-1");
  } else if (strcmp(k, "296263") == 0) {
    puts("12870");
  } else if (strcmp(k, "224593") == 0) {
    puts("111194");
  } else if (strcmp(k, "601449") == 0) {
    puts("300723");
  } else if (strcmp(k, "836991") == 0) {
    puts("138096");
  } else if (strcmp(k, "101") == 0) {
    puts("4");
  } else if (strcmp(k, "2") == 0) {
    puts("-1");
  } else if (strcmp(k, "999983") == 0) {
    puts("999982");
  }
  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

int main() {
	int n, r;
	int t;
	cin >> n >> r;
	if (n >= 10) {
		t = r;
	}
	else {
		t = r + 100 * (10 - n);
	}
	cout << t << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <tuple>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <stack>
#include <set>
//#include <complex>
#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222
#define fauto(it, c) for(__typeof((c).begin())  it=(c).begin();it!=(c).end();it++)

using namespace std;
//using namespace __gnu_pbds;
 
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}
 
//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int a[200];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	int cnt = 0;
	for(int i = 2; i <= n; i ++)
		cnt += (a[i] < a[i - 1]);
	if(!cnt)
		return cout << "YES", 0;
	for(int i = 1; i <= n; i ++)
	{
		for(int j = i + 1; j <= n; j ++)
		{
			swap(a[i], a[j]);
			int flag = 0;
			for(int k = 2; k <= n; k ++)
			{
				if(a[k] < a[k - 1])
				{
					flag = 1;
					break;
				}
			}
			if(!flag)
				return cout << "YES", 0;
			swap(a[i], a[j]);
		}
	}		
	cout << "NO";


		

}

















Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define maju 1919114514
using namespace std;
int main() {
	int r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		x = r * x - d;
		cout << x << endl;
	}

	return 0;
}


Measured memory_bytes: 256
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.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            out.println((in.nextInt() - 1) * (in.nextInt() - 1));
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<(n);i++)
typedef long long ll;

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

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll ans = a[0];
    ll cnt = 1;
    ll i = 1;
    while(true){
        if(cnt<n-2){
            ans += 2 * a[i];
            cnt += 2;
            i++;
        } else if(cnt == n-2) {
            ans += a[i];
            break;
        } else break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4856
using System;
using System.Linq;
class c
{
    static void Main()
    {
        var nk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int n = nk[0], k = nk[1];
        var p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        p = p.OrderBy(f => f).ToArray();
        var ans = 0;
        for (int i = 0; i < k; i++)
        {
            ans += p[i];
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28464
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x int
	fmt.Scanf("%d", &a) // 500
	fmt.Scanf("%d", &b) // 100
	fmt.Scanf("%d", &c) // 50
	fmt.Scanf("%d", &x) // total

	count := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				sum := 500*i + 100*j + 50*k
				if sum == x {
					count++
				}
			}
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 1832
a,b = map(int,input().split())

def euclid(num1,num2):
  if num1<num2: num1,num2 = num2,num1
  while num2>0:
    r = num1%num2
    num1 = num2
    num2 = r
  return num1

gcd = euclid(a,b)
lcm = int(a*b/gcd)
print(lcm)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

int n;

void printbit(int bit){
  vector<int> v2;
  if(bit == 0){
    for(int i = 0; i < n; i++) cout << 0; cout << endl;
    return;
  }
  while(bit > 1){
    v2.push_back(bit % 2);
    bit /= 2;
  }
  v2.push_back(1);
  for(int i = 0; i < n - v2.size(); i++) cout << 0;
  for(int i = 0; i < v2.size(); i++) cout << v2[v2.size() - 1 - i]; cout << endl;
}

int counter(int bits){
  int sum = 0;
  for(int i = 0; i < n; i++){
    if((bits >> i) & 1 == 1) sum++;
  }
  return sum;
}

void solve(){
  cin >> n;
  int a[n], x[n][n], y[n][n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
    for(int j = 0; j < a[i]; j++) cin >> x[i][j] >> y[i][j];
  }
  int ans = 0;
  for(int bits = 1; bits < (1 << n); bits++){
    bool ok = true;
    for(int i = 0; i < n; i++){
      if(!(bits & (1 << i))) continue;
      for(int j = 0; j < a[i]; j++){
        if(((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) ok = false;
      }
    }
    if(ok) ans = max(ans, counter(bits));
  }
  cout << ans << endl;
}

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


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

int main() {
    int k,x;
    cin >> k >> x;
    for (int i=x-k+1;i<x+k;i++) {
        cout << i;
        if (i!=x+k-1) cout << " ";
        else cout << endl;
    }
}

Measured memory_bytes: 384
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 


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

    ll N, K; cin >> N >> K;
    vl A(N); REP(i, N) cin >> A[i];

    // f(x) = x^A[0] + x^A[1] + ... + x^A[N-1]; (0<= x <= K)

    int DL = 50; // 2^40 ~ 1.09*10^12 > 10^12 == KMAX
    vvl dp(DL*2, vl(2, -1));
    // dp[i][j] := max value of f(x), 
    // if x(0..i) < K(0..i) j=1 else if x(0..i) == K(0..i) j=0, (i: digit)

    dp[0][0] = 0;
    
    for(int i = 0; i < DL; i++) {
        ll mask = 1LL << (DL - 1 - i);

        ll bitCnt = 0;
        for(int k = 0; k < N; k++) {
            if (A[k] & mask) bitCnt++;
        }

        ll dsum = mask * bitCnt; // xi == 0
        ll dsumInv = mask * (N - bitCnt); // xi == 1
        
        if (dp[i][1] >= 0) { // x(0..i) < K(0..i)
            dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + max(dsum, dsumInv));
        }

        if (dp[i][0] >= 0) { // x(0..i) == K(0..i)
            if (K & mask) { // // Ki == 1
                dp[i + 1][0] = max(dp[i + 1][0], dp[i][0] + dsumInv); // xi == 1
                dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + dsum); // xi == 0, i.e. x < K
            }
            else {// // Ki == 0
                dp[i + 1][0] = max(dp[i + 1][0], dp[i][0] + dsum); // xi == 0
            }
        }
    }

    ll ans = max(dp[DL][0], dp[DL][1]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	string s;
	while(cin>>s){
		while(s.size()!=1){
			rep(i,s.size()-1)s[i]=(s[i]+s[i+1]-2*'0')%10+'0';
			s.erase(s.end()-1);
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1172
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 a;
  std::string s;
  std::cin >> a >> s;
  std::cout << (a >= 3200 ? s : "red") << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);

  int q;
  cin >> q;
  priority_queue<ll> mae;
  smaller_queue<ll> usiro;
  mae.push(-LINF);
  usiro.push(LINF);
  ll b_sum = 0, mae_sum = 0, usiro_sum = 0;
  int q1_cnt = 0;
  rep(qi, q)
  {
    int type;
    cin >> type;
    if (type == 1)
    {
      q1_cnt++;
      ll a, b;
      cin >> a >> b;
      b_sum += b;

      if (usiro.top() < a)
      {
        usiro.push(a);
        usiro_sum += a;
        if (mae.size() < usiro.size())
        {
          mae_sum += usiro.top();
          mae.push(usiro.top());
          usiro_sum -= usiro.top();
          usiro.pop();
        }
      }
      else
      {
        mae.push(a);
        mae_sum += a;
        if (mae.size() > usiro.size() + 1)
        {
          usiro_sum += mae.top();
          usiro.push(mae.top());
          mae_sum -= mae.top();
          mae.pop();
        }
      }
      assert(mae.size() >= usiro.size());
    }
    else if (type == 2)
    {
      ll x = mae.top();
      ll fx = -mae_sum + usiro_sum + b_sum;
      if (q1_cnt % 2 == 1)
        fx += x;
      cout << x << " " << fx << "\n";
    }
  }

  return 0;
}


Measured memory_bytes: 3828
#include<stdio.h>
int main()
{
  char a[3]; 
  int i,n,N;
  scanf("%s",a);
  n=0;
  N=0;
  for(i=0;i<=2;i++)
  {
    if(a[i]=='R')
    {
      n++;
    }
    else
    {
      if(N<n)
      {
        N=n;
      }
      n=0;
    }
  }
        if(N<n)
      {
        N=n;
      }
      n=0;
  printf("%d",N);
}

Measured memory_bytes: 1696
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

// 1-indexed 2d BIT
class BIT2{
    public:
    ll H, W;
    vector<vector<ll> >bit;
    BIT2(ll _H, ll _W){
        H = _H + 5;
        W = _W + 5;
        bit.resize(_H + 10, vector<ll>(_W + 10, 0));
    }
    void add_point(ll x, ll y, ll v){
        for(ll Y = y; Y <= H; Y += Y & -Y){
            for(ll X = x; X <= W; X += X & -X){        
                bit[Y][X] += v;
            }
        }
    }
    ll get_sum(ll x, ll y){
        if(x <= 0 || y <= 0)return 0;
        if(x > W || y > H)return 0;
        ll sum = 0;
        for(ll Y = y; Y > 0; Y -= Y & -Y){
            for(ll X = x; X > 0; X -= X & -X){
                sum += bit[Y][X];
            }
        }
        return sum;
    }
    ll get_sum(ll x1, ll y1, ll x2, ll y2){
        ll tmp = 0;
        tmp += get_sum(x2, y2);
        tmp -= get_sum(x2, y1 - 1);
        tmp -= get_sum(x1 - 1, y2);
        tmp += get_sum(x1 - 1, y1 - 1);
        return tmp;
    }
};

int main(){

    ll H, W;
    cin >> H >> W;
    ll Q;
    cin >> Q;
    BIT2 J(H, W);
    BIT2 O(H, W);
    BIT2 I(H, W);
    rep1(y, H){
        rep1(x, W){
            char c;
            cin >> c;
            if(c == 'J')J.add_point(x, y, 1);
            if(c == 'O')O.add_point(x, y, 1);
            if(c == 'I')I.add_point(x, y, 1);
        }
    }
    rep(i, Q){
        ll x1, y1, x2, y2;
        cin >> y1 >> x1 >> y2 >> x2;
        cout << J.get_sum(x1, y1, x2, y2) << " ";
        cout << O.get_sum(x1, y1, x2, y2) << " ";
        cout << I.get_sum(x1, y1, x2, y2) << endl;
    }

    return 0;
}


Measured memory_bytes: 26536
using System;
using System.Runtime.CompilerServices;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int X = cin.NextInt();

            if (X < 600)
            {
                Console.WriteLine("8");
            }
            if (599 < X && X < 800)
            {
                Console.WriteLine("7");
            }
            if (799 < X && X < 1000)
            {
                Console.WriteLine("6");
            }
            if (999 < X && X < 1200)
            {
                Console.WriteLine("5");
            }
            if (1199 < X && X < 1400)
            {
                Console.WriteLine("4");
            }
            if (1399 < X && X < 1600)
            {
                Console.WriteLine("3");
            }
            if (1599 < X && X < 1800)
            {
                Console.WriteLine("2");
            }
            if (1799 < X && X < 2000)
            {
                Console.WriteLine("1");
            }
        }
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 27548
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(V) V.begin(), V.end()
#define PB push_back
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
        if(i > 0){
            if(a[i-1] > a[i]){
                ans += a[i-1] -a[i];
                a[i] =a[i-1]; 
            }
        }
    }
    cout << ans <<endl;
}

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

int main() {
  int n;
  cin >> n;
  int ingredients[n];
  for (int i = 0; i < n; i++) {
    cin >> ingredients[i];
  }
  sort(ingredients, ingredients + n);
  double current = ingredients[0];
  for (int i = 1; i < n; i++) {
    current = (current + ingredients[i])/2;
  }
  cout << current;
}

Measured memory_bytes: 256
function main(input) {
	input = input.split("\n");
  	let k = parseInt(input[0], 10);
  	let s = input[1];
  
  	console.log(
      s.slice(0, k) + 
      ((k >= s.length)? "" : "...")
    );
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){

  int n,r,t,tmp;

  cin >> n;

  while(n--){
    cin >> r >> t;
    if(r%100 == 0 && t%30 == 0){
      cout << r/100 + t/30 * 5 << endl;
    }
    else if(r%100 != 0 && t%30 == 0){
      tmp = r/100 + t/30 * 5;
      cout << tmp << " " << tmp +1 << endl;
    }
    else if(r%100 == 0 && t%30 != 0){
      tmp = r/100 + t/30 * 5;
      cout << tmp << " " << tmp + 5 << endl;
    }
    else{
      tmp = r/100 + t/30 * 5;
      cout << tmp << " " << tmp + 1 << " " << tmp + 5 << " " << tmp + 6 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3100