akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MAX_N 4000
#define P 998244353
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, k; lnt tot, pw2[MAX_N+5];
lnt fac[MAX_N+5], inv[MAX_N+5];
void init() {
	pw2[0] = fac[0] = inv[0] = inv[1] = 1;
	for (int i = 1; i <= MAX_N; i++) fac[i] = fac[i-1]*i%P;
	for (int i = 1; i <= MAX_N; i++) pw2[i] = (pw2[i-1]<<1)%P;
	for (int i = 2; i <= MAX_N; i++) inv[i] = P-P/i*inv[P%i]%P;
	for (int i = 1; i <= MAX_N; i++) inv[i] = inv[i-1]*inv[i]%P;
}
lnt C(int n, int m) {
	if (n < m || n < 0 || m < 0) return 0;
	return fac[n]*inv[m]%P*inv[n-m]%P;
}
lnt calc(int x, int y, int z) {
	lnt ret = 0;
	for (int i = 0; i <= x; i++)
		(ret += pw2[i]*C(x, i)%P*C(z+y-1, i+y-1)%P) %= P;
	return ret;
}
int main() {
	read(k), read(n), init();
	for (int m = 2; m <= (k<<1); printf("%lld\n", tot), m++) {
		int cnt = 0; tot = 0;
		for (int i = 1; i <= k; i++)
			cnt += (m-i >= 1 && m-i <= k);
		if (m&1)
			(tot += calc(cnt/2, k-cnt, n)) %= P;
		else
			(tot += calc(cnt/2, k-cnt, n)) %= P, 
			(tot += calc(cnt/2, k-cnt, n-1)) %= P;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n,k;
  string s;
  cin >> n >> k >> s;
  if(s[k-1] == 'A') s[k-1] = 'a';
  if(s[k-1] == 'B') s[k-1] = 'b';
  if(s[k-1] == 'C') s[k-1] = 'c';
  cout << s << endl;
  return 0;
}


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

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

    string s;
    
    cin >> s;

    if(s[1]=='R'){
        cout << "ABC" << endl;
    }
    else{
        cout << "ARC" << endl;
    }

    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int a[n];
	int  k=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		k+=a[i];
	}
	//cout<<k<<endl;
	k=(k+(4*m)-1)/(4*m);//総投票数＊１/4m
	int t=0;
	for(int i=0;i<n;i++){
		if(a[i]>=k){
			t++;
		}
	}
	//cout<<k<<" "<<t<<endl;
	if(t>=m){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

signed main(){
  int n;
  cin >> n;

  if(n == 3){
    cout << "2 5 63" << endl;
  }else if(n == 4){
    cout << "2 5 20 63" << endl;
  }else if(n == 5){
    cout << "2 5 20 30 63" << endl;
  }else{
    vi ans;
    int cur = 1, cnt = 0, sum = 0;
    while(cnt < n){
      if(cur%2 == 0 or cur%3 == 0){
        ans.emplace_back(cur);
        sum += cur;
        sum %= 6;
        cnt++;
      }
      cur++;
    }

    int tmp = -1;
    if(sum == 2){
      tmp = 8;
      ans.emplace_back(30000);
    }else if(sum == 3){
      tmp = 9;
      ans.emplace_back(30000);
    }else if(sum == 5){
      tmp = 9;
      ans.emplace_back(29998);
    }

    rep(i, 0, sz(ans)){
      int j = ans[i];
      if(j != tmp) cout << j << " \n"[i==sz(ans)-1];
    }
  }

  return 0;
}


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

#define rad M_PI/3

typedef struct{
  double x,y;
} Point;

//void print(Point);
void rec(Point,Point,int);
Point rotate(Point,Point);

int main(){
  int n;
  Point p1 = {0,0},p2 = {100,0};
  scanf("%d",&n);
  printf("%.10f %.10f\n",p1.x,p1.y);
  if(n > 0){  rec(p1,p2,n); }
  printf("%.10f %.10f\n",p2.x,p2.y);
  return 0;
}

void rec(Point p1,Point p2,int depth){
  if(depth == 0){ return; }
  Point s = {p1.x+(p2.x-p1.x)/3.0,p1.y+(p2.y-p1.y)/3.0};
  Point t = {p1.x+(p2.x-p1.x)*2.0/3.0,p1.y+(p2.y-p1.y)*2.0/3.0};
  Point u = rotate(s,t);
  rec(p1,s,depth-1);
  printf("%.10f %.10f\n",s.x,s.y);
  rec(s,u,depth-1);
  printf("%.10f %.10f\n",u.x,u.y);
  rec(u,t,depth-1);
  printf("%.10f %.10f\n",t.x,t.y);
  rec(t,p2,depth-1);
}

Point rotate(Point p1,Point p2){
  double x = p2.x-p1.x,y = p2.y-p1.y;
  Point p = {x*cos(rad)-y*sin(rad)+p1.x,x*sin(rad)+y*cos(rad)+p1.y};
  return p;
}



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

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

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

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

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

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

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

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

fn main() -> () {
    input!{
        n: usize,
    }
    println!("{}", ((n + 1) / 2) * ((n) / 2));
}


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

int main(){
    int N, M, day, sum=0;
    cin >> N >> M;
    vector<int>a(M);
    for (int i=0; i<M; i++) cin >> a[i];
    for (int i=0; i<M; i++) N-=a[i];

    if (N < 0){
        cout << "-1" << endl;
    }
    else{
        cout << N << endl;
    }
    return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
 
using namespace std;
using namespace __gnu_pbds;
 
// template<typename T>
using o_set=tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define M 1000010


int main(){
	IOS;
	ll P=1000000000;
	ll n,k,s;cin>>n>>k>>s;
	ll a[n],num;
	rep(i,0,n)a[i]=P;
	rep(i,0,k)a[i]=s;
	if(s==P)num=1;
	else num=s+1;
	rep(i,k,n)a[i]=num;
	rep(i,0,n)cout<<a[i]<<" ";
	return 0;
}

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

// namespace
using namespace std;

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

// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef long long LL;
typedef unsigned long long ULL;
typedef struct {
  LL cost;
  bool done;
} node_t;

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

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

  // Code begin.
  bool flag = false;
  REP(i, n) {
    int p_i;
    cin >> p_i;
    if (p_i == (i+1)) {
      if (flag) {
        flag = false;
      }
      else {
        cnt++;
        flag = true;
      }
    }
    else{
      flag = false;
    }
  }
  // Code done.

  cout << cnt;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int W = Integer.parseInt(scan.next());
        int H = Integer.parseInt(scan.next());
        int x = Integer.parseInt(scan.next());
        int y = Integer.parseInt(scan.next());
        int r = Integer.parseInt(scan.next());
        if((r<=x)&&(x<=(W-r))&&((r<=y)&&(y<=(H-r))))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 26296
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using vv = vector<vector<ll>>;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N;
    cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    vv dp(N+2,vector<ll>(3,-INF2));
    dp[0][0]=0;
    reps(i,2,N+2){
        rep(j,3){
            rep(k,3) {
                if(i-2-k<0 or j+k>2) continue;
                maxi(dp[i][j+k],dp[i-2-k][j]+A[i-2]);
            }
        }
    }
    cout<< ( N%2 ? max({dp[N+1][2],dp[N+1-1][1],dp[N+1-2][0]}) : max(dp[N+1][1],dp[N+1-1][0] )) <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 15796
#include <stdio.h>
typedef struct GRADE{
	int m;     //??????????¨?????????°???
	int f;     //??????????¨?????????°
	int r;     //???????¨?????????°
	
	char grad; //??????
};
int main(){
	GRADE std[100];
	int i=0, j;
	int sum, sum2;
	while (1){
		scanf("%d %d %d", &std[i].m, &std[i].f, &std[i].r);
		if (std[i].m == -1 && std[i].f == -1 && std[i].r == -1){
			break;
		}
		i++;
	}

	for (j = 0; j < i; j++){
		
			sum = std[j].m + std[j].f;
		
			sum2 = std[j].r;
		if (sum < 30 || std[j].m == -1 || std[j].f == -1){
			std[j].grad = 'F';
			}
		else if (sum>=80){
			std[j].grad = 'A';
		}
		else if (sum >= 65 && sum < 80){
			std[j].grad = 'B';
		}
		else if ((sum >= 50 && sum < 65)||sum2>=50){
			std[j].grad = 'C';
		}
		else if (sum >= 30 && sum < 50){
			std[j].grad = 'D';
		}
	
		printf("%c\n", std[j].grad);
	}

	return 0;


}

Measured memory_bytes: 1032
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = 50;
		long k = sc.nextLong();
		long loop = k / N;
		long mod = k % N;
		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = i + loop;
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < N; i++) {
			if (i < mod) {
				arr[i] += N - mod + 1;
			} else {
				arr[i] -= mod;
			}
			if (i != 0) {
				sb.append(" ");
			}
			sb.append(arr[i]);
		}
		System.out.println(N);
		System.out.println(sb);
	}
}


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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

int main() {
    int N,Q; cin >> N >>Q;
    string s; cin >> s;
    vi l(Q),r(Q);
    rep(i,Q){
        cin >> l[i] >> r[i];
    }
    vi X;
    rep(i,N-1){
        if(s[i]=='A' && s[i+1] == 'C') X.pb(i+1);
    }

    rep(i,Q){
        int ans = lower_bound(all(X),r[i]) - lower_bound(all(X),l[i]);
        cout << ans << endl;
    }
    

}







Measured memory_bytes: 1996
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL; 																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																							   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

/////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	double n, d;
	cin >> n >> d;
	
	cout << ceil(n / ((2 * d) + 1)) << '\n';
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}




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

void Main() {
  int N;
  cin >> N;

  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 == 0 || i % 5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
int n;
main() {
    int i,x,cnt,ans;
    scanf("%d",&n);
    cnt = 0; ans = 0;
    for(i=1;i<=n;i++) {
        scanf("%d",&x);
        if(x==i) cnt++;
        else {
            ans += (cnt+1)/2;
            cnt = 0;
        }
    }
    ans += (cnt+1)/2;
    printf("%d",ans);
}


Measured memory_bytes: 256
import sys

H, W, K = map(int, sys.stdin.readline().strip().split())
grid = []
for _ in range(H):
    grid.append(list(sys.stdin.readline().strip()))
# print(grid)

ans = 0
for i in range(2**H):
    for j in range(2**W):
        tmp = 0
        for y in range(H):
            for x in range(W):
                if ((j >> x) & 1) or ((i >> y) & 1):
                    # print(x, j, y, i) 
                    continue
                # if i == 0 or j == 0:
                #     print("(0,0)", i, j)
                if grid[y][x] == "#":
                    tmp += 1
        # print(i, j, tmp)
        if tmp == K:
            # print(i, j)
            ans += 1

print(ans)

Measured memory_bytes: 9204
import sys

while True:
    a, op, b = input().split()
    if op == '?': break

    a = int(a)
    b = int(b)

    if op == '+': print(a + b)
    if op == '-': print(a - b)
    if op == '*': print(a * b)
    if op == '/': print(a // b)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define itn int
#define all(c) c.begin(),c.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
 
const ll MAX_N = 2e5 + 5, inf = 1e18, mod = 1000000007;
const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31,30, 31, 31, 30, 31, 30, 31};
 
template<typename T>
ostream& operator <<(ostream& out, const vector<T>& mas) {
    for (const auto& x : mas) {
        out << x << ' ';
    }
    return out;
}
 
void ok() {
    cout << "Yes" << '\n';
}
 
void no() {
    cout << "No" << '\n';
}
 
inline ll nxt() {
    ll x;
    cin >> x;
    return x;
} 

ll getPow(ll x, ll d, ll p) {
    ll ans = 1;
    while (d) {
        if (d % 2) {
            ans *= x;
            ans %= p;
        }
        x *= x;
        x %= p;
        d /= 2;
    }
    return ans;
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int n = nxt(), p = nxt();
    string s;
    cin >> s;  
    for (auto& x : s) {
        x -= '0';
    }

    if (p < 10) {
        vector<vector<int>> dp(n + 1, vector<int>(p));
        dp[0][0] = 1;
        ll ans = 0;
        ll cur = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < p; j++) {
                dp[i + 1][(j * 10) % p] += dp[i][j];
            }
            cur = (cur * 10 + s[i]) % p;
            ans += dp[i + 1][cur];
            dp[i + 1][cur]++;
        }
        cout << ans;
        return 0;
    }

    int inv10 = getPow(10, p - 2, p);
    map<ll, ll> mp;
    mp[0] = 1;
    ll ans = 0;
    ll cur = 0;
    ll t = 1;
    for (int i = 0; i < n; i++) {
        cur = (cur * 10 + s[i]) % p; 
        ll tmp = (cur * t) % p;
        ans += mp[tmp];
        mp[tmp]++;
        t = (t * inv10) % p;
    }
    cout << ans;

    return 0;

}

Measured memory_bytes: 14484
#include<bits/stdc++.h>
using namespace std;
#define       M                        1000000007
#define       ll                       long long
#define       FIO                      ios_base::sync_with_stdio(false);cin.tie(NULL)
#define       ifor(st,lim)             for(int i=st;i<lim;i++)
#define       jfor(stt,llim)           for(int j=stt;j<llim;j++)
#define       eifor(st,lim)            for(int i=st;i<=lim;i++)
#define       ejfor(stt,llim)          for(int j=stt;j<=llim;j++)
#define       blank                    cout<<'\n' 

void solve()
{
    string s; cin>>s;
    if(s == "0") { cout<<"Yes"; return; }
    int sum = 0; 
    for(char c : s) {
      int x = c  - '0';
      sum+=x;
    }
    if(sum%9 == 0) cout<<"Yes";
    else cout<<"No";
}

int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
int t=1; 
  while(t--){
    solve();
   } 
}


Measured memory_bytes: 3720
# _*_ coding: utf-8 _*_

N = int(input())
vs = [int(e) for e in input().strip().split()]
cs = [int(e) for e in input().strip().split()]

profit = 0
for i in range(N):
    if vs[i] > cs[i]:
        profit += (vs[i] - cs[i])

print(profit)

Measured memory_bytes: 3060
#何か簡単な条件がない限りできそうもない
#mod5で1の素数のみ集めるとすべて5で割り切れるようになる

n = int(input())
prim = [1]*55556
prim[0] = 0
prim[1] = 0
for i in range(2,55556):
    for j in range(2,55556//i):
        prim[i*j] = 0
ans = [2]
for i in range(55556):
    if prim[i] and i%5==1:
        ans.append(i)
print(*ans[:n])

Measured memory_bytes: 40432
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)

using namespace std;

int main(){
  int n, m;
  while(scanf("%d%d", &n, &m) && n && m){
    queue<int>q;
    rep(i, n) q.push(i+1);
    int c = 1;
    while(q.size() > 1){
      int p = q.front(); q.pop();
      if(c % m != 0) q.push(p);
      c++;
    }
    printf("%d\n", q.front());
  }
  return 0;
}

Measured memory_bytes: 1060
N,K=[int(s) for s in input().split()]
S=list(input())
a=S[0]
index=1
for i in range(K):
  while (index<N and S[index]==a) :
    index+=1
  while (index<N and S[index]!=a) :
    S[index]=a
    index+=1
#print(S,index)
###幸せな人を数える
count=0
for i in range(1,N-1):
  if S[i]=="L":
    if S[i-1]=="L":
      count+=1
  if S[i]=="R":
    if S[i+1]=="R":
      count+=1
if (S[0]=="R"and S[1]=="R"):
  count+=1
if (S[N-1]=="L"and S[N-2]=="L"):
  count+=1
if N>1:
  print(count)
else:
  print(0)
  


Measured memory_bytes: 4084
def solve(n, a):
    b = [-1] * n
    for i in range(n, 0, -1):
        cnt = 0
        for j in range(2*i, n+1, i):
            cnt += b[j-1]
        p = cnt % 2
        b[i-1] = p ^ a[i-1]
    res = []
    for i, v in enumerate(b):
        if v > 0:
            res.append(i+1)
    m = len(res)
    print(m)
    if m > 0:
        print(" ".join(map(str, res)))

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

Measured memory_bytes: 20532
n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
# print(ks)
p = list(map(int, input().split()))
# print(p)

count = 0
for i in range(2**n):
  b = format(i, '0%db' % n)
  # print(b)
  judge = True
  for j in range(m):
    if not judge:
      break
    t = 0
    for k in range(1, 1+ks[j][0]):
      idx = ks[j][k] - 1
      if b[idx] == '1':
        t += 1
    if t % 2 != p[j]:
      judge = False
  if judge:
    count += 1
print(count)


Measured memory_bytes: 41712
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,d,e,f,g,ans;
  cin>>a>>b>>c>>d>>e>>f>>g;
  ans=a/2*2+d/2*2+e/2*2;
  if(a&&d&&e){
    long long mon=a%2+d%2+e%2;
    if(mon==3){ans+=3;}
    else if(mon==2){++ans;}
  }
  cout<<ans+b<<endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)

abs_arr = (1...n).map do |t|
    a1 = arr[0..t]
    a2 = arr[(t + 1)..n]
    s1 = a1.sum
    s2 = a2.sum
    (s1 - s2).abs
end

puts abs_arr.min

Measured memory_bytes: 14364
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int[] A = new int[M];
		Arrays.setAll(A, i -> sc.nextInt());
		int left = 0;
		for(int i = 0; i < M; i++) {
			if(A[i] < X) {
				left++;
			} else {
				break;
			}
		}
		System.out.println(Math.min(left, M-left));
	}
}

Measured memory_bytes: 27220
import sys
import numpy as np

Num = int(sys.stdin.readline().rstrip())
list_stu_Num = list(sys.stdin.readline().rstrip().split())
list_stu_Num_int = [int(s) for s in list_stu_Num]
print(*np.argsort(list_stu_Num_int) + 1)


Measured memory_bytes: 28352
N = int(input())
s = [input() for i in range(N)]
'''
for v in ["AC", "WA", "TLE", "RE"]:
    print("{0} x {1}".format(v, s.count(v)))
'''

print("AC x",s.count("AC"))
print("WA x",s.count("WA"))
print("TLE x",s.count("TLE"))
print("RE x",s.count("RE"))

Measured memory_bytes: 16276
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, x; cin >> n >> x;
	using P = tuple<int,int,int>;
	vector<P> in;
	vector<ll> sum1(n + 1), sum2(n + 1);
	rep(i, n){
		int b, l, u; cin >> b >> l >> u;
		in.emplace_back(b, l, u);
	}
	sort(all(in),[x]
		(P a, P b){
			return (ll)(x - get<0>(a)) * get<2>(a) + (ll)get<0>(a) * get<1>(a) >
			(ll)(x - get<0>(b)) * get<2>(b) + (ll)get<0>(b) * get<1>(b);
		});
	
	rep(i, n){
		int b, l, u; tie(b, l, u) = in[i];
		sum1[i + 1] = sum1[i] + (ll)(x - b) * u;
		sum2[i + 1] = sum2[i] + (ll)b * l;
	}
	auto calc = [&](int skip, int m, int pos){
		int b, l, u; tie(b, l, u) = in[skip];
		if(skip < pos) pos++;
		assert(pos <= n);
		
		ll s = sum1[pos] - (sum2[n] - sum2[pos]);
		s += max((ll)u * (m - b), (ll)l * (m - b));
		if(skip < pos) s -= (ll)(x - b) * u;
		else s += (ll) b * l;
		return s >= 0;
	};
	ll lo = -1, hi = (ll)n * x, mid;
	while(lo + 1 < hi){
		mid = (lo + hi) / 2;
		int m = mid % x, pos = mid / x;
		bool ok = 0;
		rep(skip, n) ok |= calc(skip, m, pos);
		if(ok) hi = mid;
		else lo = mid;
	}
	cout << hi << endl;
	return 0;
}

Measured memory_bytes: 3448
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

using ll = long long;
using namespace std;

#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define LFOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define FORR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define LFORR(i,a,b) for(ll i = (int)(a); i >= (ll)(b); i--)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define LREP(i,n) LFOR(i,0,(ll)(n)-1)
#define REPR(i,n) FORR(i,(int)(n)-1,0)
#define LREPR(i,n) LFORR(i,(ll)(n)-1,0)

#define SIZ(v) int(v.size())
const int INF = 1e8;
const ll LINF = 1e15;
const ll MOD = 1e9+7;

vector<int> a;
vector<ll> b;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  REP(i,m){
    int k;
    cin >> k;
    a.push_back(k);
  }
  a.push_back(INF);
  b.assign(n+1,0);
  int j=0;
  b[0]=1;
  b[1]=(a[0]==1)?j++:1;
  FOR(i,2,n){
    if (a[j] == i){
      b[i]=0;
      j++;
    }
    else b[i]=(b[i-1]%MOD+b[i-2]%MOD) % MOD;
  }
  cout << b[n] << endl;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 2e5;
const int mod = 1e9 + 7;
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  int n;
  cin >> n;
  cout << n * n << '\n';

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    int ans = 0;
    int p = 1;
    while(true){
        if(p >= B){
            break;
        }else{
            if(p == 1){
                p = A;
                ans++;
            }else{
                p += (A-1);
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mxn = 2e5 + 5;
int n, c[mxn], hd[mxn], nex[mxn << 1], to[mxn << 1], tot, s[mxn], sz[mxn];
ll ans[mxn];

void add_edge(int u, int v) { nex[++ tot] = hd[u]; hd[u] = tot; to[tot] = v; }

void dfs(int u, int p) {
	sz[u] = 1;
	for (int e = hd[u]; e; e = nex[e]) {
		int v = to[e];
		if (v == p) continue;
		int old = s[c[u]];
		dfs(v, u);
		int nw = s[c[u]];
		int f = sz[v] - (nw - old);
		ans[c[u]] -= 1LL * f * (f + 1) / 2;
		s[c[u]] += f;
		sz[u] += sz[v];
	}
	++ s[c[u]];
}

int main() {
	scanf("%d", &n);
	rep(i, n) scanf("%d", &c[i]), -- c[i];
	rep(i, n - 1) { int u, v; scanf("%d %d", &u, &v); -- u; -- v; add_edge(u, v); add_edge(v, u); }
	rep(i, n) ans[i] = 1LL * n * (n + 1) / 2;
	dfs(0, -1);
	rep(i, n) ans[i] -= 1LL * (n - s[i]) * (n - s[i] + 1) / 2;
	rep(i, n) printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 27156
#include <algorithm>
#include <cstring>
#include <cstdio>
typedef long long ll;
int val[300005], que[300005];
ll sum[300005], dp_l[300005], dp_r[300005];
inline ll calc(ll *dp, int x, int y)
{
	ll a = dp[x] + (ll)x * (x - 1) / 2 - sum[x], b = dp[y] + (ll)y * (y - 1) / 2 - sum[y];
	return (b - a - 1) / (y - x) + 1;
}
inline void init(ll *dp, int n)
{
	int he = 0, ta = 0;
	for (int i = 1; i <= n; i++)
	{
		while (he < ta && calc(dp, que[ta - 1], que[ta]) <= i)
			ta--;
		int pos = que[ta];
		dp[i] = dp[pos] + (ll)(i - pos) * (i - pos + 1) / 2 + sum[i] - sum[pos];
		dp[i] = std::max(dp[i], dp[i - 1]);
		while (he < ta && calc(dp, que[ta - 1], que[ta]) <= calc(dp, que[ta], i))
			ta--;
		que[++ta] = i;
	}
}
ll dp[300005], ans[300005];
void work(int l, int r, int off)
{
	static ll tmp[300005];
	if (l == r)
	{
		dp[l] = std::max(dp[l], -val[l] + 1 + dp_l[l - 1] + dp_r[l + 1]);
		return;
	}
	int m = l + r + off >> 1, he = 0, ta = -1;
	for (int i = l - 1; i < m; i++)
	{
		while (he < ta && calc(dp_l, que[ta - 1], que[ta]) <= calc(dp_l, que[ta], i))
			ta--;
		que[++ta] = i;
	}
	for (int i = m + 1; i <= r; i++)
	{
		while (he < ta && calc(dp_l, que[ta - 1], que[ta]) <= i)
			ta--;
		int pos = que[ta];
		tmp[i] = dp_l[pos] + (ll)(i - pos) * (i - pos + 1) / 2 + sum[i] - sum[pos] + dp_r[i + 1];
	}
	for (int i = r; i > m; i--)
	{
		if (i != r)
			tmp[i] = std::max(tmp[i], tmp[i + 1]);
		dp[i] = std::max(dp[i], tmp[i]);
	}
	work(l, m, off);
	work(m + 1, r, off);
}
inline void rev(int n)
{
	std::reverse(val + 1, val + n + 1);
	for (int i = 1; i <= n; i++)
		sum[i] = sum[i - 1] - val[i];
}
int main()
{
	// freopen("ARC066-F.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", val + i);
		sum[i] = sum[i - 1] - val[i];
	}
	init(dp_l, n);
	rev(n);
	init(dp_r, n);
	std::reverse(dp_r + 1, dp_r + n + 1);
	rev(n);
	memset(dp, -0x3f, sizeof(dp));
	work(1, n, 0);
	memcpy(ans, dp, sizeof(dp));
	rev(n);
	for (int i = 1; i <= n; i++)
		std::swap(dp_l[i], dp_r[n - i + 1]);
	memset(dp, -0x3f, sizeof(dp));
	work(1, n, -1);
	for (int i = 1; i <= n; i++)
		ans[i] = std::max(ans[i], dp[n - i + 1]);
	rev(n);
	for (int i = 1; i <= n; i++)
		std::swap(dp_l[i], dp_r[n - i + 1]);
	int q;
	scanf("%d", &q);
	while (q--)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		printf("%lld\n", std::max(dp_l[x - 1] + dp_r[x + 1], ans[x] + val[x] - y));
	}
	return 0;
}


Measured memory_bytes: 18944
def left(i):return  2 * i + 1
def right(i):return  2 * i + 2
def max_heapify(a, i):
    l = left(i)
    r = right(i)
    largest = l if  l < len(a) and a[l] > a[i] else i
    largest = r if  r < len(a) and a[r] > a[largest] else largest
    
    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        max_heapify(a, largest)
        
def build_max_heap(a):
    for i in range(len(a) // 2, -1, -1):
        max_heapify(a, i)
n = int(input())
heap = list(map(int, input().split()))
build_max_heap(heap)
print('', *heap)

Measured memory_bytes: 81092
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    int cnt = 0;
    rep(i, N)
    {
        cin >> H.at(i);
        bool possible = true;
        rep2(j, 0, i)
        {
            if (H.at(j) > H.at(i)) {
                possible = false;
            }
        }
        if (possible) {
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int H[105000];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> H[i];
    for(int i = 1; i <= N; i++) {
        if(H[i] > H[i-1]) H[i]--;
        if(H[i] < H[i-1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int i,a,b,c,w;
	scanf("%d %d %d",&a,&b,&c);
	w=0;
	for(i=a;i<=b;i++){
		if(i==c){
			w++;
		}
	}
	if(w==0){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

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

int main() {
  int n,x;
  cin >>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
   cin>>a.at(i) ;
    
    for(int j=0;j<100;j++){
    if(a.at(i)%2==0){x++;  a.at(i)/=2;}
    else{break;}
    }
   
  }


  cout<< x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807

//子から親を求める演算
auto calc_parent = [](ll x, ll y) { return min(x,y); };
//親遅延配列を子に伝播する演算
auto calc_lazychild = [](ll &x,ll y) { x=y; };
//遅延配列をノードに反映する演算
auto lazy_to_node = [](ll &x,ll y) { x=y; };
//遅延配列に値を入れる演算 y-値 l,r-区間index
auto intolazy = [](ll &x,ll y,ll r,ll l) { x=y; };
//単位元
const ll unit = INF;

struct LazySegTree
{
private:
  ll n;
  vector<ll> node,lazy;
  vector<bool> islazy;

public:
  LazySegTree(vector<ll> v)
  {
    node.resize((1LL << 64 - __builtin_clzll(v.size())) * 2 - 1, unit); 
    lazy.resize((1LL << 64 - __builtin_clzll(v.size())) * 2 - 1, unit); 
    islazy.resize((1LL << 64 - __builtin_clzll(v.size())) * 2 - 1, 0); 

    n = 1LL << 64 - __builtin_clzll(v.size());
    for (ll i = 0; i < v.size(); i++)
      node[i + n - 1] = v[i]; //最下段から構築
    for (ll i = n - 2; i >= 0; i--)
      node[i] = calc_parent(node[2 * i + 1], node[2 * i + 2]);
  }
  
  // k 番目のノードについて遅延評価を行う
  void eval(int k, int l, int r){ 
    // 遅延配列が空でない場合、自ノード及び子ノードへの
    // 値の伝播が起こる
    if (islazy[k]){
      lazy_to_node(node[k],lazy[k]);
      // 最下段かどうかのチェック
      if (r - l > 1){
        calc_lazychild(lazy[2 * k + 1],lazy[k]);
        calc_lazychild(lazy[2 * k + 2],lazy[k]);
        islazy[2 * k + 1] = 1;
        islazy[2 * k + 2] = 1;
      }
      // 伝播が終わったので、自ノードの遅延配列を空にする
      islazy[k] = 0;
      lazy[k] = unit;
    }
  }

  void update(int a, int b, ll x, int k = 0, int l = 0, int r = -1){
    if (r < 0)
      r = n;
    // k 番目のノードに対して遅延評価を行う
    eval(k, l, r);
    // 範囲外なら何もしない
    if (b <= l || r <= a)
      return;
    // 完全に被覆しているならば、遅延配列に値を入れた後に評価
    if (a <= l && r <= b){
      intolazy(lazy[k],x,r,l);
      islazy[k] = 1;
      eval(k, l, r);
    }
    // そうでないならば、子ノードの値を再帰的に計算して、
    // 計算済みの値をもらってくる
    else{
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = calc_parent(node[2 * k + 1] , node[2 * k + 2]);
    }
  }

  // 要求区間 [a, b) 中の要素の最小値を答える k := 自分がいるノードのインデックス 対象区間は [l, r) にあたる
  ll get(ll a, ll b, ll k = 0, ll l = 0, ll r = -1)
  {
    // 最初に呼び出されたときの対象区間は [0, n)
    if (r < 0)
      r = n;
    // 要求区間と対象区間が交わらない -> 適当に返す
    if (r <= a || b <= l)
      return unit;
    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    // 関数が呼び出されたら評価！
    eval(k, l, r);
    if (a <= l && r <= b)
      return node[k];
    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    ll vl = get(a, b, 2 * k + 1, l, (l + r) / 2);
    ll vr = get(a, b, 2 * k + 2, (l + r) / 2, r);
    return calc_parent(vl, vr);
  }
};

int main()
{
ll n , q ;
cin >> n >> q ;

vector<ll> t(n,(1LL<<31)-1);
LazySegTree s(t);
vector<ll> ans;
rep(i,q){
  ll a  ;
  cin >> a  ;
  if(!a){
    ll b , c , d ;
    cin >> b >> c >> d ;
    s.update(b, c+1, d);
  }
  else {
    ll b ,c;
    cin >> b >>c;
    ans.push_back(s.get(b, c+1));
  }
}

rep(i,ans.size())cout<<ans[i]<<"\n";

return 0;
}



Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;
const int MOD = 1e9+7;

ll modpow(ll x,ll y){
    if(x==0) return 0;
    ll ans=1;
    while(y>0){
        if(y&1){
            ans=ans*x%MOD;
        }
        y>>=1;
        x=(x*x)%MOD;
    }
    return ans;
}

int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> gcds(k+1);

    for(int i=k;i>0;i--){
        gcds[i]=modpow(k/i,n);
        for(int j=2;i*j<=k;j++){
            gcds[i]=(gcds[i]-gcds[i*j]+MOD)%MOD;
        }
    }
    ll ans=0;
    REP(i,k){
        ans = (ans+gcds[i]*i)%MOD;
    }

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

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

int num_divisor(int x)
{
    int num = 0;
    for (int y = 1; y <= x; y++)
    {
        if (x % y == 0)
            num++;
    }
    // cout << "n: " << x << " num: " << num << endl;
    return num;
}

int odd_8(int n)
{
    int count = 0;
    for (int x = 1; x <= n; x += 2)
    {

        if (num_divisor(x) == 8)
            count++;
    }

    return count;
}

int main()
{
    int n;
    cin >> n;
    cout << odd_8(n) << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


template<class Type>
Type solve(Type res = Type()){
    int N,Q; cin >> N >> Q;
    string s; cin >> s;
    for(auto& c:s) c -= 'A';
    
    vector<char> ts(Q),ds(Q);
    for(int i = 0; i < Q;i++){
        cin >> ts[i] >> ds[i];
        ts[i] -= 'A';
    }
    
    int l = 0, r = N-1;
    
    for(int i = Q-1; i >= 0; i--){
        if(ds[i] == 'L'){
            if(ts[i] == s[l]){
                l++;
            }
            if(r != N-1){
                if(ts[i] == s[r+1]){
                    r++;
                }
            }
        }else{
            if(ts[i] == s[r]){
                r--;
            }
            if(l != 0){
                if(ts[i] == s[l-1]){
                    l--;
                }
            }
        }
    }
    res = max(0,r-l+1);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 976
s = input()
k = int(input())
loop = ord('z') + 1
remaining = k
ans = []
for c in s:
    if c == 'a':
        ans.append(c)
        continue
    r = loop - ord(c)
    if r <= remaining:
        ans.append('a')
        remaining -= r
    else:
        ans.append(c)
if remaining > 0:
    remaining %= 26
    ans[-1] = chr(ord(ans[-1]) + remaining)
print(''.join(ans))


Measured memory_bytes: 4212
#include <stdio.h>
#define MAX 50
int A[MAX];

int naci(int n){
  if(n==0||n==1)return A[n]=1;
  if(A[n]!=-1)return A[n];
  return A[n]=naci(n-1)+naci(n-2);
}

int main(){
  int n,i;
  for(i=0;i<MAX;i++) A[i]=-1;
  scanf("%d",&n);
printf("%d\n",naci(n));

return 0;  
}


Measured memory_bytes: 2112
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [float('inf')]*(N+K)
dp[0] = 0
for i in range(N):
    for j in range(K+1):
        try:
            dp[i+j] = min(dp[i]+abs(h[i]-h[i+j]),dp[i+j])
        except Exception:
            break
print(dp[N-1])

Measured memory_bytes: 55136
def main():
    from heapq import heappush as sushi
    from heapq import heappop as tempra
    n, m, *ab = map(int, open(0).read().split())
    l = [[] for _ in range(m + 1)]
    for i, j in zip(*[iter(ab)] * 2):
        if i <= m:
            l[i].append(-j)

    w = []
    h = []
    for i in range(1, m + 1):
        for j in l[i]:
            sushi(h, j)
        if len(h) > 0:
            x = tempra(h)
            w.append(x)

    print(-sum(w))


if __name__ == '__main__':
    main()


Measured memory_bytes: 26264
# Bite Eating
N, L = map(int,input().split())
aji = 0
for i in range(1, N+1):
    if i == 1:
        aji = aji
    elif i == N:
        if L + i - 1 <= 0:
            aji = aji + (L + 1 - 1) # N番目の味がマイナスの場合、N番目のリンゴを食べて1番目のリンゴは残す
        else:
            aji = aji + (L + i - 1)
    else:
        if L + i - 1 == 0:
            aji = aji + L
        else:
            aji = aji + (L + i - 1)

print(aji)

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
/****** define constant end ********/
/****** define variable start ******/
ll h, w;
/******* define variable end *******/
int solve() {
	string ch = {'A','B','C','D','E','F','G','H','I','J','K','L','M',
    'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	cin >> h >> w;
	vector<vector<string>> s(h, vector<string>(w));
	REP(i, h){
		REP(j, w){
			cin >> s[i][j];
			if(s[i][j] == "snuke"){
				cout << ch[j] << i+1 << endl;
			}
		}
	}

	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 256
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    print(((n-1)//2+1))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
//cout << "Case " << ca << ": " << ans << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define MX 100005
#define infinity 20000000
#define pb push_back
#define ll long long int
int main()
{
    string s,t;
    cin >> s >> t;
    string z;
    z+=t;
    z+=s;
    cout << z << endl;
    return 0;
}


Measured memory_bytes: 256