akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int R = scan.nextInt();

    scan.close();

    if(N >= 10) {
      System.out.println(R);
    }
    else {
      System.out.println(R + 100*(10-N));
    }
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
const double eps = 1E-9;

bool equal (double a, double b)
{
    return abs(a-b)<eps;
}

struct V {
    double x, y;
    V(double x=0, double y=0): x(x), y(y) {}
    V operator+(const V& p) const { return V(x+p.x, y+p.y); }
    V operator-(const V& p) const { return V(x-p.x, y-p.y); }
    V operator*(double a) const { return V(x*a, y*a); }
    double sqrNorm() const { return x*x+y*y; }
    double norm() const { return sqrt(sqrNorm()); }
    V rotate90() const { return V(-y, x); }
};

struct Circle {
    V o;
    double r;
    Circle(V o=V(), double r=0): o(o), r(r) {}
    vector<V> xp(const Circle& c) {
        V v = c.o-o;
        double l = v.norm();
        double sub = abs(r-c.r);
        double add = r+c.r;
        if (equal(l, sub)) {
            if (r>c.r) return {o+v*(r/l)};
            else return {o+v*(-r/l)};
        }
        if (equal(l, add)) {
            return {o+v*(r/l)};
        }
        if (l>add || l<sub) {
            return {};
        }
        double x = (r*r-c.r*c.r+l*l)/(2.0*l);
        V mid = o+v*(x/l);
        V dx = v.rotate90()*((sqrt(r*r-x*x))/l);
        return {mid+dx, mid-dx};
    }
    bool isInside(const V& p) {
        return (p-o).norm() < r+eps;
    }
};

int main(){
    int n, k;
    cin >> n >> k;
    vector<Circle> cir(n);
    rep(i, n) {
        int x, y, c;
        cin >> x >> y >> c;
        cir[i] = Circle(V(x, y), c);
    }
    
    double l = 0.0;
    double r = 4000000.0;
    rep(ti, 100) {
        double t = 0.5*(l+r);
        vector<V> ps;
        rep(i, n) {
            ps.push_back(cir[i].o);
        }
        rep(i, n) rep(j, i) {
            Circle a = cir[i];
            Circle b = cir[j];
            a.r = t/a.r;
            b.r = t/b.r;
            vector<V> temp = a.xp(b);
            for (V v:temp) {
                ps.push_back(v);
            }
        }
        bool ok = false;
        for (V v:ps) {
            int cnt = 0;
            rep(i, n) {
                Circle a = cir[i];
                a.r = t/a.r;
                if (a.isInside(v)) cnt++;
            }
            if (cnt>=k) ok = true;
        }
        if (ok) r = t;
        else l = t;
    }
    printf("%.10f\n", r);
    
    
    
    return 0;
}


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

int main()
{
    long long A,B;
    cin >> A >> B;

    cout << max(A+B, max(A-B, A*B));

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    string res = "";
    res += s.front();
    for(int i = 1; i < n; i++)
    {
        if(s[i] == res.back()) continue;
        res.push_back(s[i]);
    }
    cout << res.size() << endl;
    return 0;
}



Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct BinomialCoefficient  {
    BinomialCoefficient() {
        
    }
    
    BinomialCoefficient(int n) : fac(n + 2), finv(n + 2), inv(n + 2) {
        initialize(n, false);
    }
    
    void initialize(int n, bool resize = true) {
        if (resize) {
            fac.resize(n + 2);
            finv.resize(n + 2);
            inv.resize(n + 2);
        }
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= n; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    
    ll factorial(int n) {
        return fac[n];
    }
    
    ll combination(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
    
    ll permutation(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * finv[n - r] % mod;
    }
    
private:
    int mod = 1e9 + 7;
    vector<ll> fac, finv, inv;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    ll n;
    cin >> n;
    vector<ll> a(n + 1);
    map<ll, ll> m;
    ll l, r;
    rep(i, n + 1) {
        cin >> a[i];
        if (m.count(a[i]) > 0) {
            l = m[a[i]];
            r = i;
        }
        else {
            m[a[i]] = i;
        }
    }
    BinomialCoefficient bc(n + 1);
    reps(k, 1, n + 2) {
        ll ans = (bc.combination(n + 1, k) + mod - bc.combination(l + n - r, k - 1)) % mod;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <math.h>
#include <iomanip>
#include <fstream>
#include <random>
#include <queue>
using namespace std;
const int INF=100000000;
typedef pair<int,int> P;
char maze[52][52];
int h,w;
int sx,sy;
int gx,gy;
int d[52][52];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int bfs(){
    queue<P> que;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            d[i][j]=INF;
        }
    }
    que.push(P(sx,sy));
    d[sx][sy]=0;
    while(que.size()){
        P p=que.front();que.pop();
        if(p.first==gx&&p.second==gy){break;}
        for(int i=0;i<4;++i){
            int nx=p.first+dx[i],ny=p.second+dy[i];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&maze[nx][ny]!='#'&&d[nx][ny]==INF){
                que.push(P(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
    return d[gx][gy];
}
inline void InitRand()
{
    srand((unsigned int)time(NULL));
}
int main() {
     InitRand();
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    cin>>h>>w;
    string s;
    int sum1=0;
    int sum2=0;
    for(int i=0;i<h;++i){
        cin>>s;
        for(int j=0;j<w;++j){
            maze[i][j]=s[j];
            if(s[j]=='#'){sum1++;}
            if(s[j]=='.'){sum2++;}
        }
    }
    sx=0;sy=0;
    gx=h-1;gy=w-1;
    int res=bfs();
    if(res==INF){cout<<-1<<endl;}else{cout<<sum2-res-1<<endl;}
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define name(x) #x
using namespace std;


const int INF = INT_MAX-100;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int N;
    cin >> N;
    VV(int) vec(N+1,vector<int>(3,0));
    
    for(auto i = 1; i<=N; i++){
        cin >> vec[i];
    }
    
    VV(int) dp(N+1,vector<int>(3,INT_MIN));
    
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    
    for(auto i = 1; i<=N; i++){
        
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + vec[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + vec[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + vec[i][2];
        
    }
    
    int maxv = 0;
    for(auto i = 0; i<3; i++){
        
        maxv = max(maxv,dp[N][i]);
        
    }
    
    cout << maxv << endl;
    
    

    return 0;
}




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

namespace 練習問題
{
    class Program {
        static void Main(string[] args) {
            debug Debug = new debug();
            string[] input = Console.ReadLine().Split(' ');
            long n = long.Parse(input[0]);
            long k = long.Parse(input[1]);
          	long minval = n;
          	//for(int i=0;i<k;i++){
             while(Math.Abs(n - k)< n){
               if(n-k > k * 3){
                 long test = (long)(n/k)-3;
                 n = Math.Abs(n - k*test   );
               } else {               
            		n = Math.Abs(n - k);
               }
            	if (n < minval){
            		minval = n;
            	}
            }
            Console.WriteLine(minval);
        }

        static void bubble_sort(List<List<int>> a) {
            int count=0;
            for (int i = 0; i < a.Count; i++) {
                for (int j = 0; j < a.Count-i-1; j++) {
                    // if (a[j] == a[a.Count - 1]){
                    //     continue;
                    // }
                    count++;
                    if (a[j][1] > a[j+1][1]){
                        int localsave = 0;
                        localsave = a[j+1][1];
                        a[j+1][1] = a[j][1];
                        a[j][1] = localsave;
                        localsave = a[j][0];
                        a[j][0] = a[j+1][0];
                        a[j+1][0] = localsave;
                    }
                }
                //debug(a,"途中" + i);
            }
            // debug(a,"result");
            //Console.WriteLine("回数"+count);
            for (int i = 0; i < a.Count; i++)
            {
                Console.WriteLine(a[i][0]+" "+a[i][1]);
            }
        }
        /* 標準入力と標準出力が使えるかのチェック
        static void echo() {
            string echotest = Console.ReadLine();
            Console.WriteLine(echotest);
        }

        static void HelloWorld(){
            Console.WriteLine("Hello World!");
        }
        */
    }

    public class debug{
        public void Log(string str){
            Console.WriteLine(str);
        }
        public void Log(int str){
            Console.WriteLine(str);
        }
        public void Log(object obj){
            Console.WriteLine(obj);
        }

        public void Log(int[] arr){
            Console.WriteLine(string.Join(",", arr));
        }
        public void Log(string[] arr){
            Console.WriteLine(string.Join(",", arr));
        }
        public void Log(List<int> arr){
            string shuturyoku = "";
            for (int i = 0; i < arr.Count; i++) {
                shuturyoku += arr[i] + " ";
            }
            Console.WriteLine(shuturyoku.TrimEnd(' '));
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;
queue<ll> q;

void monmo(){
    ll a=q.front();q.pop();
    if(a%10==0){
        q.push(a*10);q.push(a*10+1);
    }else if(a%10==1){
        q.push(a*10);q.push(a*10+1);q.push(a*10+2);
    }else if(a%10==2){
        q.push(a*10+1);q.push(a*10+2);q.push(a*10+3);
    }else if(a%10==3){
        q.push(a*10+2);q.push(a*10+3);q.push(a*10+4);
    }else if(a%10==4){
        q.push(a*10+3);q.push(a*10+4);q.push(a*10+5);
    }else if(a%10==5){
        q.push(a*10+4);q.push(a*10+5);q.push(a*10+6);
    }else if(a%10==6){
        q.push(a*10+5);q.push(a*10+6);q.push(a*10+7);
    }else if(a%10==7){
        q.push(a*10+6);q.push(a*10+7);q.push(a*10+8);
    }else if(a%10==8){
        q.push(a*10+7);q.push(a*10+8);q.push(a*10+9);
    }else if(a%10==9){
        q.push(a*10+8);q.push(a*10+9);
    }else {
        cout<<"E";
    }
}

int main() {
    ll k;
    cin>>k;
    for(int i=1;i<10;i++){
        q.push(i);
    }
    for(ll i=0;i<k-1;i++){
        monmo();
    }
    ll r=q.front();
    cout<<r;
}

Measured memory_bytes: 5120
#include <iostream>

using namespace std;

int main(void){
	double tmp;
	
	while(cin >> tmp){
		if(tmp <= 48){
			cout << "light fly" <<endl;
		}else if(tmp <= 51){
			cout << "fly" << endl;
		}else if(tmp <= 54){
			cout << "bantam" << endl;
		}else if(tmp <= 57){
			cout << "feather" << endl;
		}else if(tmp <= 60){
			cout << "light" << endl;
		}else if(tmp <= 64){
			cout << "light welter" << endl;
		}else if(tmp <= 69){
			cout << "welter" << endl;
		}else if(tmp <= 75){
			cout << "light middle" << endl;
		}else if(tmp <= 81){
			cout << "middle" << endl;
		}else if(tmp <= 91){
			cout << "light heavy" << endl;
		}else{
			cout << "heavy" << endl;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
using namespace std;
#define Inf 2000000000000
#define N 100004
long long t[N][4], DP[N][4];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n;
    cin >> n;
    for (long long i = 1; i <= n; i++)
    {
        for (long long j = 1; j <= 3; j++) cin >> t[i][j];
    }
    DP[1][1] = t[1][1]; DP[1][2] = t[1][2]; DP[1][3] = t[1][3];
    for (long long i = 2; i <= n; i++)
    {
        DP[i][1] = max(DP[i - 1][2], DP[i - 1][3]) + t[i][1];
        DP[i][2] = max(DP[i - 1][1], DP[i - 1][3]) + t[i][2];
        DP[i][3] = max(DP[i - 1][1], DP[i - 1][2]) + t[i][3];
    }
    long long result = max(DP[n][1], max(DP[n][2], DP[n][3]));
    cout << result;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
// 11

using namespace std;

const int MAXVAL = (int) 4e6 + 5;
const int MAXN = (int) 2e3;

bitset <MAXVAL> ok;

int v[MAXN + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> v[i];
    }
    //sort(v + 1, v + n + 1);
    int sum = 0;
    ok[0] = 1;
    for(i = 1; i <= n; i++) {
        ok |= (ok << v[i]);
        sum += v[i];
    }
    for(i = 0; i < MAXVAL; i++) {
        if(ok[i] == 1 && (sum + 1) / 2 <= i) {
            cout << i;
            return 0;
        }
    }
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 1792
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;

int a[100005];
int m = 0;
int sum = 0;
int main()
{
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (int i = 0; i < n-1; i++) {
        if (a[i] >= a[i + 1]) {
            sum++;
            if (m < sum) {
                m = sum;
            }
        }

        else {
            if (m < sum) {
                m = sum;
            }
            sum = 0;
        }
    }

    cout << m << endl;
    return 0;
}


Measured memory_bytes: 640
def root(x):
  if F[x] < 0:
    return x
  else:
    F[x] = root(F[x])
    return F[x]

def unite(x, y):
  x = root(x)
  y = root(y)
  if x == y:
    return
  if x > y:
    x, y = y, x
  F[x] += F[y]
  F[y] = x

N, M = map(int, input().split())
F = [-1] * N

for m in range(M):
  a, b = map(int, input().split())
  unite(a - 1, b - 1)
ans = 0
for f in F:
  ans = min(ans, f)
print(-ans)


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long prime = 1000000007;
    int n, k;
    cin >> n >> k;
    vector<vector<int>> adj_list(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        adj_list[a].push_back(b);
        adj_list[b].push_back(a);
    }
    function<long long (int, int)> count = [&](int u, int p) {
        long long cur = 1;
        if (p == -1) {
            for (int i = 0; i <= adj_list[u].size(); ++i) {
                cur = (cur * (k-i)) % prime;
            }
        } else {
            for (int i = 2; i < adj_list[u].size()+1; ++i) {
                cur = (cur * (k-i)) % prime;
            }
        }
        for (int v : adj_list[u]) {
            if (v != p) {
                cur = (cur * count(v, u)) % prime;
            }
        }
        return cur;
    };
    cout << count(0, -1) << endl;
    return 0;
}



Measured memory_bytes: 11648
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <stack>
#include <array>
#include <fstream>
#include <deque>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPS(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#define REVERSE(i,n) for(int (i) = n-1;(i) >= 0 ; --i)
#define ALL(c) (c).begin() , (c).end()
#define EACH(it,c) for(auto(it,(c).begin());it != (c).end();)
#define cx real()
#define cy imag()
#define px first
#define py second
#define LL long long
#define int LL
#define inf  (1LL << 60)
#define mod 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
#define lower lower_bound
#define upper upper_bound
#define ZERO(c,n) memset(&c[0],0,sizeof(int)*n)
#define ZERO2(c,n) memset(&c[0][0],0,sizeof(int)*n
#define pl(a) cout << ""#a": " << a << endl;
#ifdef _DEBUG
#define debug_io fstream cin("input.txt");ofstream cout("output.txt");
#else
#define debug_io ;
#endif
#define debug_input debug_io
#define pb(a) push_back(a)
template<class T>void scan(vector<T>& a, int n, istream& cin)
{
	T c; REP(i, n) { cin >> c; a.push_back(c); }
}
using vs = vector<string>; using vi = vector<int>; using pii = pair<int, int>;
using psi = pair<string, int>; using vvi = vector<vi>; using pss = pair<string, string>;
template<class T>bool valid(T x, T w) { return 0 <= x&&x < w; }
int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 };
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------


signed main()
{
	QUICK_CIN;
	//debug_input;

	int n,m;
	cin >> n >> m;

	int ret = 0;

	ret += min(n,m/2);

	m = max(m - ret * 2 , 0LL);

	ret += m / 4;

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if (x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define MAXN 55
#define MAXW 2505
#define INF 1000000000
using namespace std;
typedef long long ll;
int N,A,x[MAXN];
ll dp[MAXN][MAXW];
int main()
{
    scanf("%d%d",&N,&A);
    for(int i=1;i<=N;i++) scanf("%d",&x[i]);
    dp[0][0]=1;
    for(int i=1;i<=N;i++)
        for(int j=0;j<=2500;j++)
        {
            if(j>=A) dp[i][j]=dp[i-1][j-A]; else dp[i][j]=0;
            if(j>=x[i]) dp[i][j]+=dp[i-1][j-x[i]];
        }
    printf("%lld\n",dp[N][A*N]-1);
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
string s;
int x,y;
int dp[2][16005];
const int OFF = 8001;
vector<int> Ymove;
vector<int> Xmove;
bool which;
bool solve(vector<int> moves,int target){
   for(int j = 0;j <= 16002;j++){
      dp[0][j] = 0;
   }
   dp[0][OFF] = 1;
   for(int i = 1;i < (int)moves.size();i++){
      for(int j = 0;j <= 16002;j++){
         dp[i & 1][j] = 0;
         if(j >= moves[i] && dp[(i & 1) ^ 1][j - moves[i]]){
            dp[i & 1][j] = 1;
         }
         else if(16002 >= j + moves[i] && dp[(i & 1) ^ 1][j + moves[i]] ){
            dp[i & 1][j] = 1;
         }
      }
   }
   return dp[((int)moves.size() & 1) ^ 1][target + OFF];
}
int main() {
    cin >> s;
    cin >> x >> y;
    reverse(s.begin(),s.end());
    while(!s.empty() && s.back() == 'F'){
       x--;
       s.pop_back();
    }
    if(!s.empty()){
       which = 1;
       s.pop_back();
    }
    reverse(s.begin(),s.end());
    s += 'T';
    int nr = 0;
    Xmove.push_back(0);
    Ymove.push_back(0);
    for(auto it:s){
       if(it == 'F'){
          nr++ ;
       }
       else {
          if(!which){
             Xmove.push_back(nr);
          }
          else {
             Ymove.push_back(nr);
          }
          which ^= 1;
          nr = 0;
       }
    }
    int ind = 0;
    if(solve(Xmove,x)){
       if(solve(Ymove,y)){
          cout << "Yes";
          return 0;
       }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}

const ld pi = acos(-1);
typedef complex<double> base;

int K; bool v[100010];
vi a,p[6];

int rev(int x, int lg){
    int res=0;
    for (int i=0; i<lg; i++)
        if (x&(1<<i)) res+=(1<<(lg-1-i));
    return res;
}

void fft(vector<base> &a, bool inv){
    int lg=1,sz=a.size(),i,j;
    while ((1<<lg)<sz) lg++;

    for (i=0; i<sz; i++)
        if (i<rev(i,lg)) swap(a[i],a[rev(i,lg)]);

    for (int len=2; len<=sz; len<<=1){
        ld ang = 2*pi/len * (inv ? -1 : 1);
        base wlen(cos(ang),sin(ang));

        for (i=0; i<sz; i+=len){
            base w(1,0);
            for (j=0; j<len/2; j++){
                base u=a[i+j],v=w*a[i+len/2+j];
                a[i+j]=u+v;
                a[i+len/2+j]=u-v;

                w*=wlen;
            }
        }
    }

    if (inv)
        for (i=0; i<sz; i++)
            a[i]/=sz;
}

vi conv(vi &a, vi &b){
    vector<base> na,nb,nc;
    for (int x : a)
        na.pb(base(x));
    for (int x : b)
        nb.pb(base(x));

    int sz=2*max(a.size(),b.size());
    int lg=1;
    while ((1<<lg)<sz) lg++;
    sz=1<<lg;

    na.resize(sz),nb.resize(sz),nc.resize(sz);
    fft(na,0),fft(nb,0);

    for (int i=0; i<sz; i++)
        nc[i]=na[i]*nb[i];
    fft(nc,1);

    vi c(a.size()+b.size()-1);
    for (int i=0; i<(int)c.size(); i++)
        c[i]=(int)(nc[i].real()+0.5); //be careful

    return c;
}

vi comb(vi &a, vi &b){
    vi c(K);
    vi r=conv(a,b);

    int i;
    for (i=0; i<(int)r.size(); i++)
        if (r[i]>0)
            c[i%K]=1;

    for (i=0; i<K; i++)
        if (a[i]>0 || b[i]>0)
            c[i]=1;
    return c;
}

vi pa[6];

int main(){

    cin >> K;

    int i,r=1;
    a.resize(K);
    while (!v[r]){
        a[r]=1;
        v[r]=1;

        r=(r*10)%K;
    }

    vi cr(K);
    p[0]=a;

    for (i=1; i<=5; i++){
        p[i]=comb(p[i-1],p[i-1]);
    }

    int res=0;
    for (i=5; i>=0; i--){
        vi nxt=comb(cr,p[i]);
        if (nxt[0]==0) cr=nxt,res+=(1<<i);
    }

    cout << res+1 << "\n";
	return 0;
}


Measured memory_bytes: 19748
hoge = input().split()
N = int(hoge[0])
K = int(hoge[1])


while 1:
  if N / K > pow(10,18):
    N = N - (K * pow(10,17))
  elif N / K > pow(10,17):
    N = N - (K * pow(10,16))
  elif N / K > pow(10,16):
    N = N - (K * pow(10,15))
  elif N / K > pow(10,15):
    N = N - (K * pow(10,14))
  elif N / K > pow(10,14):
    N = N - (K * pow(10,13))
  elif N / K > pow(10,13):
    N = N - (K * pow(10,12))
  elif N / K > pow(10,12):
    N = N - (K * pow(10,11))
  elif N / K > pow(10,11):
    N = N - (K * pow(10,10))
  elif N / K > pow(10,10):
    N = N - (K * pow(10,9))
  elif N / K > pow(10,9):
    N = N - (K * pow(10,8))
  elif N / K > pow(10,8):
    N = N - (K * pow(10,7))
  elif N / K > pow(10,7):
    N = N - (K * pow(10,6))
  elif N / K > pow(10,6):
    N = N - (K * pow(10,5))
  elif N / K > pow(10,5):
    N = N - (K * pow(10,4))
  elif N / K > pow(10,4):
    N = N - (K * pow(10,3))
  elif N / K > pow(10,3):
    N = N - (K * pow(10,2))
  else:
    break
  
_min = N
while 1:
  if _min <= abs(_min - K):
    break
  else:
    _min = abs(_min - K)

print(int(_min))

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

using namespace std;

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a <= 0 && b >= 0) puts("Zero");
	else if(b < 0) printf("%s\n", (b - a + 1) % 2 == 1 ? "Negative" : "Positive");
	else puts("Positive");
	return 0;
}

Measured memory_bytes: 256
from operator import itemgetter

N,M=map(int,input().split())
PY=[]
P=[[] for i in range(N)]
ans=[0 for i in range(M)]
for i in range(M):
    PYi=list(map(int,input().split()))
    PY.append(PYi)
    P[PYi[0]-1].append([i,PYi[1]])

for i in range(N):
    P[i]=sorted(P[i], key=itemgetter(1))

for i in range(N):
    for j in range(len(P[i])):
        ans[P[i][j][0]]=j+1

for i in range(M):
    a=format(PY[i][0],'06d')
    b=format(ans[i],'06d')
    print(a+b)

Measured memory_bytes: 51216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
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;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
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(){
    ll n;cin >> n;
    vector<string> s(n);
    vl t(n);
    rep(i,n)cin >> s[i] >> t[i];
    string x;cin >> x;
    bool sleep=false;
    ll ans=0;
    rep(i,n){
        if(sleep)ans+=t[i];
        if(s[i]==x)sleep=true;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = Integer.parseInt(in.nextLine());
        final int[] arr = new int[n + 1];
        final long[] pre = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = in.nextInt();
            pre[i] += pre[i - 1] + arr[i];
        }
        in.nextLine();
        long res = (long) 1e16;
        final long[] diff = new long[4];
        int l = 1, r = 3;
        for (int mid = 2; mid <= n - 2; mid++) {
            while (l < mid && Math.abs(pre[l] - (pre[mid] - pre[l]))
                              >= Math.abs(pre[l + 1] - (pre[mid] - pre[l + 1]))) {
                l++;
            }
            while (r < n && Math.abs(pre[r] - pre[mid] - (pre[n] - pre[r]))
                            >= Math.abs(pre[r + 1] - pre[mid] - (pre[n] - pre[r + 1]))) {
                r++;
            }
            diff[0] = pre[l];
            diff[1] = pre[mid] - pre[l];
            diff[2] = pre[r] - pre[mid];
            diff[3] = pre[n] - pre[r];
            Arrays.sort(diff);
            res = Math.min(res, diff[3] - diff[0]);
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 63864
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	double n, m, d;
	cin >> n >> m >> d;
	double a;
	if(d==0) a = (n - d) / (n*n);
	else a = 2* (n - d) / (n*n);
	cout << setprecision(16) << a * (m-1) << endl;
}

Measured memory_bytes: 3772
K,X = map(int,input().split())
if K == 1:
    print(X)
    exit()
checkpoint = X
result = set()
start = checkpoint - K + 1
for i in range(K):
    for i in range(K):
        result.add(start + i)
    start = start + 1
result = sorted(result)
L=[str(a) for a in result]
L=" ".join(L)
print(L)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iomanip>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef unordered_map<int,int> m32;
typedef map<ll,ll> m64;
typedef unordered_map<ll,set<ll> > m648;
typedef pair<ll,p64 > pp64;
ll MOD = 1e9 + 7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX

vector<vector<ll> > g; 
v64 p,m,deg,ans,diff;
ll fact = 1e6;
m64 umap;

void dfs(ll v, ll pa){
	p[v]=pa;
	m[v]=max(m[v],pa);
	m[v]=max(m[v],m[pa]);
	forn(j,(ll)g[v].size()){
		if(g[v][j]!=pa){
			dfs(g[v][j],v);
		}
	}
}

ll dfs1(ll v, ll pa, ll w){
	if(umap.find(v*fact+w)!=umap.end()) return umap[v*fact+w];
	umap[v*fact+w]=0;
	forn(j,(ll)g[v].size()){
		if(g[v][j]!=pa && g[v][j]<w){
			umap[v*fact+w] += 1 + dfs1(g[v][j],v,w);
		}
	}
	return umap[v*fact+w];
}

void dfs2(ll v, ll pa){
	ans[v]=ans[pa]+diff[v];
	forn(j,(ll)g[v].size()){
		if(g[v][j]!=pa){
			dfs2(g[v][j],v);
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll N;
    cin >> N;
    v64 X(N+5),Y(N+5),weight(N+5);
    g.resize(N+5);
    p.resize(N+5,0);
    m.resize(N+5,0);
    deg.resize(N+5,0);
    ans.resize(N+5,0);
    diff.resize(N+5,0);
    ll a,b;
    forn(i,N-1){
    	cin >> a >> b;
    	g[a].pb(b);
    	g[b].pb(a);
    	deg[a]++,deg[b]++;
    }
    dfs(1,0);
    forsn(i,2,N+1){
    	if(i>m[p[i]]) diff[i] = 1 + dfs1(i,p[i],m[i]);
    	else{
    		diff[i] = dfs1(i,p[i],m[i]) - dfs1(i,p[i],m[p[i]]);
    	}
    }
    dfs2(1,0);
    forsn(i,2,N+1) cout << ans[i] << " ";
    cout << ln;
    return 0;
}

Measured memory_bytes: 52352
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
vector<int> A;
vector<int> B;
map<int, int> mp;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (mp.find(A[i]) == mp.end()) {
      B.push_back(A[i]);
    }
    mp[A[i]]++;
  }
  sort(B.begin(), B.end(), greater<int>());
  int m = B[0];

  for (int i = 0; i < N; i++) {
    if (A[i] == m && mp[A[i]] > 1) {
      cout << A[i] << endl;
    } else if (A[i] == m) {
      cout << B[1] << endl;
    } else {
      cout << m << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 8440
#include <bits/stdc++.h>
using namespace std;
int read();
int n, s, t;
int hd[400005], nx[1000006], to[1000006], c[1000006], cnt;
void add(int f, int t, int cap) {
    nx[++cnt] = hd[f], hd[f] = cnt, to[cnt] = t, c[cnt] = cap;
}
void fadd(int f, int t, int c) { add(f, t, c), add(t, f, 0); }

int dep[400005];
queue<int> q;
bool bfs() {
    for (int i = 1; i <= t; ++i) dep[i] = 0;
    dep[s] = 1, q.push(s);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int i = hd[u], v; i; i = nx[i]) {
            if (!c[i] || dep[v = to[i]]) continue;
            dep[v] = dep[u] + 1, q.push(v);
        }
    }
    return dep[t];
}

int iter[400005];
int dfs(int u, int dist) {
    if (u == t) return dist;
    for (int &i = iter[u], v, d; i; i = nx[i]) {
        if (!c[i] || dep[v = to[i]] != dep[u] + 1) continue;
        if (d = dfs(v, min(dist, c[i]))) return c[i] -= d, c[i ^ 1] += d, d;
    }
    return 0;
}
int Dinic() {
    int rt = 0, d;
    while (bfs()) {
        for (int i = 1; i <= t; ++i) iter[i] = hd[i];
        while (d = dfs(s, 10000000)) rt += d;
    }
    return rt;
}

vector<int> e[400005];
int p[400005];
struct Res {
    int u, v;
} res[400005];
bool get_res() {
    for (int u = 1; u < n; ++u)
        for (int i = hd[u]; i; i = nx[i])
            if (to[i] != s && c[i] == 0) p[u] = to[i] - n + 1;

    int sum = 0;
    q.push(n);
    while (!q.empty()) {
        int u = q.front();
        ++sum, q.pop();
        for (int i = 0, v; i < e[u].size(); ++i)
            if (p[v = e[u][i]]) res[v] = (Res){u, p[v]}, q.push(p[v]), p[v] = 0;
    }
    return sum == n;
}

int main() {
    n = read(), s = 2 * n - 1, t = 2 * n, cnt = 1;
    for (int i = 1; i < n; ++i) fadd(i + n - 1, t, 1);
    for (int i = 1, c, u; i < n; ++i) {
        c = read(), fadd(s, i, 1);
        while (c--) {
            if ((u = read()) != n) fadd(i, u + n - 1, 1);
            e[u].push_back(i);
        }
    }
    if (Dinic() < n - 1) return puts("-1"), 0;
    if (!get_res()) return puts("-1"), 0;

    for (int i = 1; i < n; ++i) printf("%d %d\n", res[i].u, res[i].v);

    return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
#define gc                                                         \
    (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)), \
     (iS == iT ? EOF : *iS++) : *iS++)
int read() {
    int x = 0, f = 1;
    char c = gc;
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = gc;
    while (isdigit(c)) x = x * 10 + c - '0', c = gc;
    return x * f;
}

Measured memory_bytes: 36096
#include "bits/stdc++.h"
using namespace std;    

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    
const long DIVIDE = 1e9+7;

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
long gcd(long a, long b);    
long lcm(long a, long b);
// ****** print functions ****** //
template <class T, class U>
void print_pairs(const vector<pair<T, U>> pairs);
template <class K, class V>
void print_map(const map<K, V> m);


int main() {    
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++) cin >> d[i];
    sort(d.begin(), d.end());
    int start = d[n/2-1];
    int end = d[n/2];
    cout << end - start << endl;
    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

long gcd(long a, long b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}

long lcm(long a, long b) {
    long gcd_ = gcd(a, b);
    return (a * b) / gcd_;
}

template <class T, class U>
void print_pairs(const vector<pair<T, U>> &pairs) {
    for(int i=0; i<pairs.size(); i++) { 
        cout << "(" << pairs[i].first << ", " << pairs[i].second << ")" << " "; 
    } 
    cout << endl;
}

template <class K, class V>
void print_map(const map<K, V> &m) {
    for(auto it=m.cbegin(); it!=m.cend(); it++) {
        cout << it->first << ": " << it->second << endl;
    }
}


Measured memory_bytes: 640
void main(){
	long n = _scan!long();
	long[] a = _scanln!long();
	long q = _scan!long();
	long[long] dic;
	long ans;

	// 合計値と参照辞書の作成
	foreach(elm; a){
		ans += elm;
		dic[elm]++;
	}
	// replace 操作
	foreach(i; 0..q){
		long[] bc = _scanln!long();
		ans += bc[1]*dic.get(bc[0], 0) - bc[0]*dic.get(bc[0], 0);
		dic[bc[1]] += dic.get(bc[0], 0);
		dic[bc[0]] = 0;
		ans.writeln();
	}
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

const function<int(int, int)> minQ = [](int l, int r) { return min(l, r); };

template <typename T>
class node {
public:
	T val, lazy;
	node<T> *l, *r;
	node() {}
	node(T val_, T lazy_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) : val(val_), lazy(lazy_), l(l_), r(r_) {}
	void init(T val_, T lazy_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) {
		val = val_;
		lazy = lazy_;
		l = l_;
		r = r_;
	}
};

template <typename T>
class DynamicLazySegmentTree {
	using func_t = function<T(T, T)>;
	const ll n;
	const T id1, id2;
	func_t merge1, merge2;
	node<T> *root;
	vector<node<T>> pool;
	int it;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	node<T> *new_node() {
		pool[it].init(id1, id2);
		return &pool[it++];
	}
	node<T> *push(node<T> *t, ll lb, ll ub) {
		if (t == nullptr || t->lazy == id2) return t;
		if (lb + 1 < ub) {
			if (t->l == nullptr) t->l = new_node();
			if (t->r == nullptr) t->r = new_node();
			t->l->lazy = merge2(t->l->lazy, t->lazy);
			t->r->lazy = merge2(t->r->lazy, t->lazy);
		}
		t->val = merge2(t->val, t->lazy);
		t->lazy = id2;
		return t;
	}
	node<T> *suc(ll l, ll r, node<T> *t, ll lb, ll ub, T val) {
		if (ub <= l || r <= lb) return t;
		if (t == nullptr) t = new_node();
		if (l <= lb && ub <= r) {
			t->lazy = merge2(t->lazy, val);
			return t;
		}
		t = push(t, lb, ub);
		int c = (lb + ub) / 2;
		t->l = suc(l, r, t->l, lb, c, val);
		t->r = suc(l, r, t->r, c, ub, val);
		t->val = merge1(t->l == nullptr ? id1 : merge2(t->l->val, t->l->lazy), t->r == nullptr ? id1 : merge2(t->r->val, t->r->lazy));
		return t;
	}
	T sub(ll l, ll r, node<T> *t, ll lb, ll ub) {
		if (t == nullptr || ub <= l || r <= lb) return id1;
		t = push(t, lb, ub);
		if (l <= lb && ub <= r) return t->val;
		int c = (lb + ub) / 2;
		return merge1(sub(l, r, t->l, lb, c), sub(l, r, t->r, c, ub));
	}
public:
	DynamicLazySegmentTree(ll n_, T id1_, T id2_, func_t merge1_, func_t merge2_, int PMAX = 1e7)
		: n(size(n_)), id1(id1_), id2(id2_), merge1(merge1_), merge2(merge2_), root(nullptr), pool(PMAX), it(0) {}
	void update(ll l, ll r, T val) {
		root = suc(l, r + 1, root, 0, n, val);
	}
	T find(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	int n, q, com, s, t, x;
	cin >> n >> q;
	DynamicLazySegmentTree<int> lst(n, INT_MAX, -1, minQ, [](int l, int r) { return r != -1 ? r : l; }, 3e5);
	while (q--) {
		cin >> com;
		if (com) {
			cin >> s >> t;
			printf("%d\n", lst.find(s, t));
		}
		else {
			cin >> s >> t >> x;
			lst.update(s, t, x);
		}
	}
	return 0;
}

Measured memory_bytes: 7376
import java.util.Scanner;

public class Main {
    private static final int[] a = new int[15];
    private static final int[] d = new int[15];
    static{
        int sum=0;
        int count = 0;
        for (int i = 0; i < 15; i++) {
            if(i%3!=0 && i%5!=0){
                sum+=i;
                count++;
            }
            a[i]=sum;
            d[i]=count;
        }
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(f(n));
    }

    public static long f(int n){
        long b = n/15;
        int c = n%15;
        return b*(b-1)/2*15*8 + b*a[14] + a[c] + d[c]*b*15;
    }
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  set<int> se;
  int res = 0;
  map<int, int> mp;
  while (m--) {
    int p;
    cin >> p;
    string s;
    cin >> s;
    if (s == "AC") {
      if (se.count(p)) {
        continue;
      }
      se.insert(p);
      res += mp[p];
    } else {
      ++mp[p];
    }
  }
  cout << se.size() << ' ' << res << '\n';
}


Measured memory_bytes: 9600
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	
	string s1,s2,ans;
	cin>>s1>>s2;
	
	for(int i=0;i<n;i++)
	{
		ans+=s1[i];
		ans+=s2[i];
	}
	
	cout<<ans<<endl;
	return 0;
	
}

Measured memory_bytes: 256
# include <iostream>
# include <stdio.h>
# include <cmath>
# include <iomanip>
# include <cstring>
# include <string>
# include <cctype>
# include <algorithm> //transformの関数はaslgorithmライブラリに入っているみたい。
using namespace std;
class dice{
public:
  int label[6];
  void roll(char);
  bool is_samedice(int[]);
};
void dice::roll(char direction){
  int temp;
  if(direction == 'E'){
    temp = label[2];
    label[2] = label[0];
    label[0] = label[3];
    label[3] = label[5];
    label[5] = temp;
  }else if(direction == 'N'){
    temp = label[4];
    label[4] = label[0];
    label[0] = label[1];
    label[1] = label[5];
    label[5] = temp;
  }else if(direction == 'S'){
    temp = label[1];
    label[1] = label[0];
    label[0] = label[4];
    label[4] = label[5];
    label[5] = temp;
  }else if(direction == 'W'){
    temp = label[3];
    label[3] = label[0];
    label[0] = label[2];
    label[2] = label[5];
    label[5] = temp;
  }else if(direction == 'R'){
    // 右回転
    temp = label[2];
    label[2] = label[1];
    label[1] = label[3];
    label[3] = label[4];
    label[4] = temp;
  }
}
bool dice::is_samedice(int other_label[]){
    bool flag;
    flag = true;
    for(int i =0;i<6;i++){
      if(label[i] != other_label[i]){
        flag = false;
      }
    }
    return flag;
}
bool roll_and_is_samedice(dice& d1,dice& d2){
  bool flag;
  flag = false;
  for(int i = 0;i<6;i++){
      // 上面を合わせる
            switch (i) {
              case 1:
              d1.roll('N');
              break;
              case 2:
              d1.roll('W');
              break;
              case 3:
              d1.roll('N');
              d1.roll('N');
              break;
              case 4:
              d1.roll('W');
              break;
              case 5:
              d1.roll('S');
              break;
          }
          for(int j = 0;j<4;j++){
            flag = d1.is_samedice(d2.label);
            if(flag){
              return flag;
            }
            d1.roll('R');
        }
      }
  return flag;
}
int main(){
  int n;
  bool flag = false;
  cin >> n;
  dice d[n];
  for(int i=0;i<n;i++){
    for(int j = 0;j<6;j++){
      cin >> d[i].label[j];
    }
  }
  for(int i = 0;i<n;i++){
      for(int j= 0;j<n;j++){
        if(i != j){
          flag = roll_and_is_samedice(d[i],d[j]);
          if(flag){
            cout << "No" << endl;
            return 0;
          }
        }
      }
  }
  cout << "Yes" << endl;
  return 0;
}



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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

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

  int k, s; cin >> k >> s;

  int ans = 0;
  rep(x, k+1) rep(y, k+1) {
    int z = s - (x + y);

    if (z <= k && z >= 0) ++ans;
  }

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

Measured memory_bytes: 3632
n,m,l = gets.split(" ").map(&:to_i)

a = n.times.map { gets.split(" ").map(&:to_i) }
b = m.times.map { gets.split(" ").map(&:to_i) }

ret = n.times.map {|i|
  l.times.map {|j|
    m.times.map {|k| a[i][k] * b[k][j] }.reduce(:+)
  }.join(" ")
}.join("\n")

puts ret

Measured memory_bytes: 12688