akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"math"
	"strconv"
	"strings"
	"container/heap"
)

func run() {
	n := nextInt()
	arr := make([]int, n)

	for i := 0; i < n; i++ {
		arr[i] = nextInt()
	}

	h := &IntHeap{}
	heap.Init(h)

	for i := 0; i < n; i++ {
		heap.Push(h, -1 * arr[i])
	}

	var maxInt = -1 * heap.Pop(h).(int)
	var secondMaxInt = -1 * heap.Pop(h).(int)

	for i := 0; i < n; i++ {
		var a = arr[i]

		if maxInt == a {
			println(secondMaxInt)
		} else {
			println(maxInt)
		}
	}
}

// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

const bufferSize = 64 * 1024 * 1024

func print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}

func printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}

func println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextArray() []string {
	sc.Scan()
	return strings.Split(sc.Text()," ")
}

func nextIntArray() []int {
	str := nextArray()
	buf := make([]int, len(str))
	for i,s:=range str{
		buf[i],_ = strconv.Atoi(s)
	}
	return buf
}

func min(nums []int) int {
    if len(nums) == 0 {
        panic("funciton min() requires at least one argument.")
    }
    res := nums[0]
    for i := 0; i < len(nums); i++ {
        res = int(math.Min(float64(res), float64(nums[i])))
    }
    return res
}

func max(nums []int) int {
    if len(nums) == 0 {
        panic("funciton max() requires at least one argument.")
    }
    res := nums[0]
    for i := 0; i < len(nums); i++ {
        res = int(math.Max(float64(res), float64(nums[i])))
    }
    return res
}

func abs(a int) int {
    return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
    return int(math.Pow(float64(p), float64(q)))
}

// An IntHeap is a min-heap of ints.
type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

// Push to heap
func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

// Pop from heap
func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	sc.Buffer(make([]byte, 0, bufferSize), bufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}


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

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

    string s[3];
    rep(i, 3) cin >> s[i];

    int ans = 0;
    rep(i, n) {
        set<char> st;
        rep(j, 3) st.insert(s[j][i]);
        ans += st.size() - 1;
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
  int n, a, b, c, m;

  m = 0;
  cin >> n;
  cin >> a;
  cin >> b;
  for (int i = 0; i < n - 2; ++i) {
    cin >> c;
    if ((a < b && b < c) || (a > b && b > c)) {
      ++m;
    }
    a = b;
    b = c;
  }
  cout << m;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN	2005
#define MAXP	4000005
#define P	1000000007
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
long long fac[MAXP], inv[MAXP], ans[MAXN][MAXN];
long long power(long long x, long long y) {
	if (y == 0) return 1;
	long long tmp = power(x, y / 2);
	if (y % 2 == 0) return tmp * tmp % P;
	else return tmp * tmp % P * x % P;
}
long long getc(int x, int y) {
	return fac[x] * inv[y] % P * inv[x - y] % P;
}
int main() {
	int N, n, k;
	read(n), read(k);
	if (k == 1) {
		printf("1\n");
		return 0;
	}
	N = n * k;
	fac[0] = 1;
	for (int i = 1; i <= N; i++)
		fac[i] = fac[i - 1] * i % P;
	inv[N] = power(fac[N], P - 2);
	for (int i = N - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1) % P;
	ans[0][0] = 1;
	for (int i = 0; i <= n; i++)
	for (int j = 0; j <= n; j++) {
		if (i != 0) ans[i][j] += ans[i - 1][j];
		if (j != 0 && j != i) ans[i][j] += ans[i][j - 1] * getc(i + j * (k - 1) - 1, k - 2) % P;
		ans[i][j] %= P;
	}
	long long finalans = ans[n][n] * fac[n] % P;
	cout << finalans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); i++)

const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i=2; i<MAX; 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 COM(int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

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

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

    COMinit();

    int ans1=0, ans2=0;

    if (n < 2) ans1 = 0;
    else {
        ans1 = COM(n, 2);
    }
    if (m < 2) ans2 = 0;
    else {
        ans2 = COM(m, 2);
    }

    cout << ans1 + ans2 << endl;

    return 0;
}

Measured memory_bytes: 12160
#include<iostream>
#include<numeric>
using namespace std;
int main()
{
     int k,i,j,h;
     long long int sum=0;
    cin >> k;
    for(i=1;i<=k;i++)
        for(j=1;j<=k;j++)
            for(h=1;h<=k;h++)sum+=gcd(i,gcd(j,h));
    cout << sum;
    return 0;
}

Measured memory_bytes: 3636
n,k=map(int,input().split())
w=[int(input())for i in range(n)]

def check(x):
    global w
    global n,k
    track=0
    now=0
    for i in w:
        if i>x:
            return False
        if now+i>x:
            track+=1
            now=i
        else:
            now+=i
    if now>0:
        track+=1
    if track>k:
        return False
    else:
        return True
amax=1000000000
amin=0
while amin+1!=amax:
    amid=(amax+amin)//2
    if check(amid):
        amax=amid
    else:
        amin=amid
    
print(amax)


Measured memory_bytes: 9564
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>
#include <functional>

using namespace std;

int main() {

	int N, K, Q;
	cin >> N >> K >> Q;

	vector<int> vPoint(N, 0);
	vector<int> vNum(Q, 0);
	for (int i = 0; i < Q; i++)
	{
		int tmp = 0;
		cin >> tmp;
		++vPoint[tmp - 1];
	}

	for (int i = 0; i < vPoint.size(); i++)
	{
		vPoint[i] = K - (Q - vPoint[i]);
	}

	for (int i = 0; i < vPoint.size(); i++)
	{
		cout << (vPoint[i] > 0 ? "Yes" : "No") << "\n";
	}
}

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

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
    Node *x = root;
    Node *y = NIL;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->right = NIL;
    z->left = NIL;

    while (x != NIL){
        y = x;
        if (z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;
    if (y == NIL) root = z;
    else if (z->key < y->key) y->left = z;
    else y->right = z;
}

bool find(int k){
    Node *x = root;
    while(x != NIL){
        if (k == x->key) return true;
        else if (k < x->key) x = x->left;
        else x = x->right;
    }
    return false;
}

void inorder(Node *u){
    if (u == NULL) return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}

void preorder(Node *u){
    if (u == NULL) return;
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

int main(void)
{
    int n;
    string s;
    cin >> n;
    rep(i,n){
        cin >> s;
        if (s == "print"){
            inorder(root); cout << endl;
            preorder(root); cout << endl;
        }
        else{
            int key; cin >> key;
            if (s == "insert") insert(key);
            else{
                if (find(key) == true)  cout << "yes" << endl;
                else cout << "no" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 21968
while True:
    a, b, c = map(str, raw_input().split())
    if b == '+':
        print(int(a) + int(c))
    elif b == '-':
        print(int(a) - int(c))
    elif b == '*':
        print(int(a) * int(c))
    elif b == '/':
        print(int(a) / int(c))
    else:
        break

Measured memory_bytes: 6372
#include "bits/stdc++.h"


//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int MOD2 = 998244353;
const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
#define is_empty(...) ( sizeof( (char[]){#__VA_ARGS__} ) == 1 )

void print() {}
template<typename T, typename... Args>
void print(T firstArg, Args... args) {
	#ifdef LOCAL
	cout << firstArg << endl;
	print(args...);
	#endif
}

//endregion

/* Notes:
 * Fry my kartoshka
 */

const int MAXN = 100 + 2;
const int INF = 2e9;

int tre[4 * MAXN];
int a[] = {1, 2, 3, 4, 5};
int f[4 * MAXN];

void build(int v, int l, int r){
	if(l == r){
		tre[v] = a[l];
	}
	else{
		int m = (l + r) / 2;
		build(2 * v, l, m);
		build(2 * v + 1, m + 1, r);
		tre[v] = tre[v * 2] + tre[v * 2 + 1];
	}
}
void push(int v, int l, int m, int r){
	f[2 * v] += f[v];
	f[2 * v + 1] += f[v];
	tre[2 * v] += (m - l + 1) * f[v];
	tre[2 * v + 1] += (r - m) * f[v];
	f[v] = 0;
}

void update(int v, int tl, int tr, int l, int r, int val) {
	if (l > r)
		return;
	if (l == tl && r == tr) {
		tre[v] += val * (r - l + 1);
		f[v] += val;
		return;
	}

	int tm = (tl + tr) / 2;
	push(v, tl, tm, tr);

	update(v * 2, tl, tm, l, min(r, tm), val);
	update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);

	tre[v] = tre[2 * v] + tre[2 * v + 1];
}


int sum(int v, int tl, int tr, int l, int r) {
	if (l > r)
		return 0;
	if (l == tl && r == tr) {;
		return tre[v];
	}
	int tm = (tl + tr) / 2;
	push(v, tl, tm, tr);
	return sum(v * 2, tl, tm, l, min(r, tm))
		   + sum(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}


int g[MAXN][MAXN];

int main() {
	//usaco("milkvisits");

#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
#endif

	ll n, a, b;

	cin >> n >> a >> b;

	cout << min(n * a, b);
}

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

/// take centroid -> unite separate components
///                                     |
///                                     V
///                         sum of edge * g of subtree

int g[100010];
long long ans;
vector <pair <int, int>> adia[100010];
vector <int> centr;

void find_centr(int nod, int tata, int g_tata);
void find_ans(int nod, int tata);
void calc_g(int nod, int tata);

int main()
{
    int n, a, b, c;
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    while (--n) {
        cin >> a >> b >> c;
        adia[a].push_back({ b, c });
        adia[b].push_back({ a, c });
    }

    calc_g(1, 0);
    find_centr(1, 0, g[1]);
    c = centr.front();
    calc_g(c, 0);

    find_ans(c, 0);

    int dmin(1e9);
    for (auto i : adia[c]) {
        dmin = min(dmin, i.second);
        if (2 * g[i.first] == g[c]) {
            dmin = i.second;
            break;
        }
    }

    cout << 1ll * ans - dmin;

    return 0;
}

void find_ans(int nod, int tata)
{
    for (auto i : adia[nod]) {
        if (i.first != tata) {
            ans += 2ll * g[i.first] * i.second;
            find_ans(i.first, nod);
        }
    }
}

void find_centr(int nod, int tata, int g_tata)
{
    int gmax = 0, gtotal = 0;
    for (auto i : adia[nod]) {
        if (i.first == tata)
            continue;
        gmax = max(gmax, g[i.first]);
        gtotal += g[i.first];
        find_centr(i.first, nod, g_tata);
    }
    if (2 * gmax <= g_tata && 2 * (g_tata - gtotal - 1) <= g_tata)
        centr.push_back(nod);
}

void calc_g(int nod, int tata)
{
    g[nod] = 1;
    for (auto i : adia[nod])
        if (i.first != tata)
            calc_g(i.first, nod), g[nod] += g[i.first];
}


Measured memory_bytes: 12800
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long K, std::vector<long long> A) {
    long long score = 1;
    rep (i, K) score *= A[i];
    loop (i, K, N) {
        auto prev = A[i-K];
        auto next = A[i];
        if (prev < next) cout << YES << endl;
        else cout << NO << endl;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define int long long int
const int N = 1e5+5;
const int mod = 1e9+7;
vector<int> tree[N];
int dp[N][2];
int helper(int i,int par,int color)
{
	int ans = 1;
	if(dp[i][color]!=-1)
	{
		return dp[i][color];
	}
	for(int j=0;j<tree[i].size();j++)
	{
		if(tree[i][j]!=par)
		{
			int temp  =0;
			if(color==0)
			{
			temp+=helper(tree[i][j],i,0);
			temp=temp%mod;
			temp+=helper(tree[i][j],i,1);
			temp=temp%mod;
		    }
		    else
		    {
		    	temp+=helper(tree[i][j],i,0);
		    	temp=temp%mod;
		    }
		    ans*=temp;
		    ans=ans%mod;
		}  

	}
	return dp[i][color]=ans;
}
int32_t main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		tree[x].push_back(y);
		tree[y].push_back(x);
	}

	int ans = helper(1,-1,0);
	 ans+= helper(1,-1,1);
	 cout<<ans%mod<<endl;
}

Measured memory_bytes: 15616
#include<cstdio>
#include<queue>
#include<iostream>
#define RI register int
#define CI const int&
using namespace std;
typedef long long LL;
const int N=2100,M=20*N,INF=1e9;
int n,c,x,y,s,t;
namespace NF //Network_Flow
{
	struct edge
	{
		int to,nxt,v,c;
	}e[M]; queue <int> q; bool vis[N];
	int head[N],cnt=1,cap[N],pre[N],lst[N]; LL dis[N];
	#define to e[i].to
	inline bool SPFA(CI s,CI t)
	{
		RI i; for (i=s;i<=t;++i) dis[i]=-1e18,pre[i]=-1;
		q.push(s); dis[s]=0; cap[s]=INF; vis[s]=1; while (!q.empty())
		{
			int now=q.front(); q.pop(); vis[now]=0;
			for (i=head[now];i;i=e[i].nxt) if (e[i].v&&dis[now]+e[i].c>dis[to])
			{
				dis[to]=dis[now]+e[i].c; cap[to]=min(cap[now],e[i].v);
				pre[to]=now; lst[to]=i; if (!vis[to]) vis[to]=1,q.push(to);
			}
		}
		return ~pre[t];
		#undef to
	}
	inline void addedge(CI x,CI y,CI v,CI c)
	{
		e[++cnt]=(edge){y,head[x],v,c}; head[x]=cnt;
		e[++cnt]=(edge){x,head[y],0,-c}; head[y]=cnt;
	}
	inline LL MCMF(CI s,CI t)
	{
		LL ret=0; while (SPFA(s,t))
		{
			ret+=dis[t]*cap[t]; for (int nw=t;nw!=s;nw=pre[nw]) 
			e[lst[nw]].v-=cap[t],e[lst[nw]^1].v+=cap[t];
		}
		return ret;
	}
};
int main()
{
	RI i; for (scanf("%d",&n),s=0,t=2*n+5,i=1;i<=n;++i)
	scanf("%d%d%d",&x,&y,&c),NF::addedge(s,i,c,0),
	NF::addedge(i,2*n+1,INF,x+y),NF::addedge(i,2*n+2,INF,x-y),
	NF::addedge(i,2*n+3,INF,-x+y),NF::addedge(i,2*n+4,INF,-x-y);
	for (i=1;i<=n;++i)
	scanf("%d%d%d",&x,&y,&c),NF::addedge(n+i,t,c,0),
	NF::addedge(2*n+1,n+i,INF,-x-y),NF::addedge(2*n+2,n+i,INF,-x+y),
	NF::addedge(2*n+3,n+i,INF,x-y),NF::addedge(2*n+4,n+i,INF,x+y);
	return printf("%lld",NF::MCMF(s,t)),0;
}

Measured memory_bytes: 4148
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 2147483647
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

int N, Q;
struct LazySegmentTree {
private:
	int n;
	vector<ll> node, lazy;

public:
	LazySegmentTree(vector<ll> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, 0);

		for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = node[i * 2 + 1] + node[i * 2 + 2];
	}

	void eval(int k, int l, int r) {
		if (lazy[k] != 0) {
			node[k] += lazy[k];
			if (r - l > 1) {
				lazy[2 * k + 1] += lazy[k] / 2;
				lazy[2 * k + 2] += lazy[k] / 2;
			}
			lazy[k] = 0;
		}
	}

	void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] += (r - l) * x;
			eval(k, l, r);
		}
		else {
			add(a, b, x, 2 * k + 1, l, (l + r) / 2);
			add(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = node[2 * k + 1] + node[2 * k + 2];
		}
	}

	ll getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		if (b <= l || r <= a) return 0;
		if (a <= l && r <= b) return node[k];
		ll vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
		return vl + vr;
	}
};
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);

	cin >> N >> Q;

	LazySegmentTree seg(vector<ll>(N, 0));

	REP(i, Q) {
		int q;
		cin >> q;
		if (q == 0) {
			int s, t, x;
			cin >> s >> t >> x;
			seg.add(s - 1, t, x);
		}
		else {
			int s, t;
			cin >> s >> t;
			cout << seg.getsum(s - 1, t) << endl;
		}
	}
	
	return 0;
}




Measured memory_bytes: 7872
#include<iostream>
using namespace std;
int main(){
    const int MOD = 998244353;
    int n;
    int s;
    cin >> n >> s;
    int dp[s+1]{0};
    int ans = 0;
    while(n--){
        int a;
        cin >> a;
        dp[0] = (dp[0]+1)%MOD;
        for(int i=s-a;i>=0;--i){
            dp[i+a] = (dp[i+a]+dp[i]) % MOD;
        }
        ans = (ans + dp[s]) % MOD;
    }
    cout << ans << endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
ll A[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	ll lcm=1;
	int num=0;
	
	FOR(i,N) {
		cin>>A[i];
		x=0;
		while(A[i]%2==0) {
			x++;
			A[i]/=2;
		}
		if(i==0) num=x;
		else if(num!=x) return _P("0\n");
		
		lcm=lcm/__gcd(A[i],lcm)*A[i];
		
		if(lcm>1LL<<40) return _P("0\n");
	}
	M>>=(x-1);
	
	if(lcm<=M) {
		cout<<1+(M-lcm)/(2*lcm)<<endl;
	}
	else {
		cout<<0<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
  int a[6],b[4] = {0};
  for(int i = 0;i < 6;i++){
    cin >> a[i];
  }
  for(int i = 0;i < 6;i++){
    b[a[i]-1]++;
  }
  sort(b,b+4);
  for(int i = 0;i < 4;i++){
    //cout << b[i] << endl;
  }
  if(b[1] == 1 && b[2] == 2){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int rev(int a){
    int ans = (a/100)*100;
    ans+=a/10000;
    a/=1000;
    ans+=(a%10)*10;
    return ans;
}
int main(){
    int a,b;
    cin >> a >> b;
    int ans = (b)/100 - (a-1)/100;
    ans++;
    if(rev(a)<a) ans--;
    if(rev(b)>b) ans--;
    if(a==10000) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n = I()
graph =[[]*(n+1) for i in range(n+1)]
ans = [0]*(n+1)
for i in range(n-1):
    u,v,w = map(int,input().split())
    w = w%2
    graph[u].append([v,w])
    graph[v].append([u,w])
#vをcに塗る。pはvの親
def dfs(v,p,c,ans):
    ans[v] = c
    for i in graph[v]:
        if i[0] == p:
            continue
        if i[1] == 1:
            dfs(i[0],v,1-c,ans)
        if i[1] == 0:
            dfs(i[0],v,c,ans)
dfs(1,0,0,ans)
for i in ans[1:]:
    print(i)


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

template<typename T>
struct BellmanFord{
    const T inf=numeric_limits<T>::max();
    struct edge{
        int u,v; T w;
        edge(int u,int v,T w):u(u),v(v),w(w){}
    };
    int n;
    vector<vector<int>> G;
    vector<int> used,reach;
    BellmanFord(int n):n(n),G(n),used(n,0),reach(n,1){}
    vector<edge> es;
    void add_edge(int u,int v,T c){
        es.emplace_back(u,v,c);
        G[u].emplace_back(v);
    }
    vector<T> build(int from,int &neg_loop){
        vector<T> d(n,inf);
        d[from]=0;
        for (int i=0;i<n;++i){
            int update=0;
            for (auto e:es){
                if (!reach[e.u]||!reach[e.v]||d[e.u]==inf) continue;
                if (d[e.u]+e.w<d[e.v]) d[e.v]=d[e.u]+e.w,update=1;
            }
            if (!update) break;
            if (i==n-1){neg_loop=1; return d;}
        }
        neg_loop=0;
        return d;
    }
    void dfs(int v){
        if (used[v]) return;
        used[v]=1;
        for (int u:G[v]) dfs(u);
    }
    T shortest_path(int from,int to,int &neg_loop){
        for (int i=0;i<n;++i){
            fill(used.begin(),used.end(),0);
            dfs(i);
            reach[i]=used[to];
        }
        return build(from,neg_loop)[to];
    }
};


const ll INF=1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int V,E,r; cin >> V >> E >> r;
    BellmanFord<int> G(V);
    rep(i,E){
        int s,t,d; cin >> s >> t >> d;
        G.add_edge(s,t,d);
    }
    int neg_loop=0;
    vector<int> d=G.build(r,neg_loop);
    if (neg_loop){
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    rep(i,V){
        if (d[i]>INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
}


Measured memory_bytes: 3220
n = int(input())
h = list(map(int, input().split()))
ans = 'Yes'
for i in reversed(range(n-1)):
    if h[i] > h[i+1]:
        h[i] -= 1
        if h[i] > h[i+1]:
            ans = 'No'
            break
print (ans)


Measured memory_bytes: 63856
#include <stdio.h>

int main(void)
{
	int ap[3];
	int aj[2];
	int i;
	int minp, minj;
	int ans;

	minp = minj = 2001;

	for (i = 0; i < 3; i++){
		scanf("%d", &ap[i]);
		if (minp > ap[i]){
			minp = ap[i];
		}
	}
	for (i = 0; i < 2; i++){
		scanf("%d", &aj[i]);
		if (minj > aj[i]){
			minj = aj[i];
		}
	}

	ans = minp + minj - 50;

	printf("%d\n", ans);

	return (0);
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }


int N, A[10101];
//---------------------------------------------------------------------------------------------------
void _main() {
	while (cin >> N) {
		if (N == 0) return;
		rep(i, 0, N) cin >> A[i];

		int min = 0;
		rep(i, 0, N) min += A[i];

		int answer = 0;
		rep(i, 0, N) if (A[i] * N <= min) answer++;
		printf("%d\n", answer);
	}
}


Measured memory_bytes: 3184
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n;
    scan(n);
    auto p = iota(n).map!(i => readln.chomp.to!int).array;

    auto dp = new int[](n + 1);

    int ans = 1<<30;

    foreach (i ; 0 .. n) {
        dp[p[i]] = dp[p[i] - 1] + 1;
        ans = min(ans, n - p[i] + p[i] - dp[p[i]]);
    }

    debug {
        writeln(dp);
    }

    writeln(ans);
}













































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

int main(){
  ll N;cin>>N;
  ll A[N];rep(i,N)cin>>A[i];
  ll tmp_lcm = 1;
  rep(i,N){
    tmp_lcm = (tmp_lcm / __gcd(tmp_lcm,A[i])) * A[i];
  }
  cout << tmp_lcm << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<ll> a(n); 
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end(),greater<>());
    ll ans=a[0];
    rep(i,n-2) ans+=a[1+i/2];
    cout << ans << endl;
    
    return 0;   
}

Measured memory_bytes: 4824
import sys
def input(): return sys.stdin.readline().strip()


def main():
    D = int(input())
    C = [0] + list(map(int, input().split()))
    S = [[0] * 27]
    for _ in range(D):
        S.append([0] + list(map(int, input().split())))
    T = [0] + [int(input()) for _ in range(D)]

    satisfactory = 0
    last = [0] * 27
    for d in range(1, D + 1):
        last[T[d]] = d
        satisfactory += S[d][T[d]]
        for i in range(1, 27):
            satisfactory -= C[i] * (d - last[i])
        print(satisfactory)

if __name__ == "__main__":
    main()


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

using namespace std;

using int64 = long long;

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}
template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n;
  cin >> n;
  vector<vector<int>> graph(n);
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    a--;
    graph[a].push_back(i);
  }

  function<int(int)> dfs_fn = [&](int v) -> int {
    if (graph[v].empty()) return 0;
    int depth = graph[v].size();
    vector<int> values;
    for (int c : graph[v]) {
      values.push_back(dfs_fn(c));
    }
    sort(values.begin(), values.end());
    reverse(values.begin(), values.end());
    for (int i = 0; i < values.size(); i++) {
      UpdateMax(depth, i + 1 + values[i]);
    }
    // cout << "v: " << v << " depth: " << depth << endl;
    return depth;
  };
  cout << dfs_fn(0) << endl;
}

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

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  ll a[112345], b;
  cin >> n >> b;
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  ll ans = 0;
  for(int i = 0; i < n; i++) if(b >= a[i]) b-=a[i], ans++;
  if(b > 0 && ans == n) ans--;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i)//400 for i in input().split()]
s = set()
f = 0
for i in a:
    if i>=8:
        f += 1
    else:
        s.add(i)
mn = len(s)
if len(s)==0: mn += f>0
mx = len(s)+f
print(mn, mx)

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
fn main() {
    use std::cmp::max;
    use std::cmp::min;

    input!{
        a: usize,
        b: usize,
        c: usize,
        d: usize,
    }
    let ans = if a+b > c+d {
        "Left"
    } else if a+b == c+d {
        "Balanced"
    } else {
        "Right"
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{
	string S;
	cin >> S;

	int n = S.size();
	REP(i, n) {
		if (S[i] != S[n - 1 - i]) {
			col("No");
			return 0;
		}
	}
	REP(i, (n - 1) / 2) {
		if (S[i] != S[(n - 1) / 2 - 1 - i]) {
			col("No");
			return 0;
		}
	}
	RNG(i, (n + 3) / 2 - 1, n) {
		if (S[i] != S[n - 1 - i]) {
			col("No");
			return 0;
		}
	}
	col("Yes");
	return 0;
}


Measured memory_bytes: 3596
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# define MOD 1000000000+7
# define INF 1000000000
using namespace std;

int main() {
	vector<string> s;
	int n, l;
	cin >> n >> l;
	string a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		s.emplace_back(a);
	}
	sort(s.begin(), s.end());
	for (int i = 0; i < s.size(); i++) {
		cout << s[i];
	}
	cout << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

int binpow(int a, int b)
{
    int ans = 1;
    if (b == 0)
        return 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        int x, k, d;
        cin >> x >> k >> d;
        x = abs(x);
        int step = x / d;
        if ((step & 1) != (k & 1))
        {
            step--;
        }
        step = min(step, k);
        int g1 = x - (d * step);
        int g2 = x - (d * min(k, step + 2));
        int ans = min(abs(g1), abs(g2));
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3620
i = list( map(int, input().split()) )

a = i[0]
b = i[1]
c = i[2]

if (a<=b):
    if(b<=c):
        print(a,end=' ')
        print(b,end=' ')
        print(c)
    elif(a<=c):
        print(a,end=' ')
        print(c,end=' ')
        print(b)  
    else:
        print(c,end=' ')
        print(a,end=' ')
        print(b)
else:
    if(a<=c):
        print(b,end=' ')
        print(a,end=' ')
        print(c) 
    elif(b<=c):
        print(b,end=' ')
        print(c,end=' ')
        print(a)              
    else:
        print(c,end=' ')
        print(b,end=' ')
        print(a)



Measured memory_bytes: 5592
import itertools
N=int(input())
A=list(map(int,input().split()))
lo=[-1,0,1]
cnt=0
for k in itertools.product(lo,repeat=N):
    li=list(k)
    res=1
    for z in range(N):
        res*=A[z]+li[z]
    if(res%2==0):
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){
    ll h,w;cin>>h>>w;
    ll a[h][w];
    rep(i,0,h-1)rep(j,0,w-1)cin>>a[i][j];
    ll n=0;
    ll ans[h*w+1][4];
    bool b=false;
    rep(i,0,h-1){
        b=false;
        rep(j,0,w-1){
            if(b==false && a[i][j]%2==0){
                continue;
            }else if(b==true && a[i][j]%2==0){
                ans[n][0]=i;
                ans[n][1]=j-1;
                ans[n][2]=i;
                ans[n][3]=j;
                a[i][j-1]--;
                a[i][j]++;
                n++;
            }else if(b==false && a[i][j]%2==1){
                b=true;
            }else if(b==true && a[i][j]%2==1){
                ans[n][0]=i;
                ans[n][1]=j-1;
                ans[n][2]=i;
                ans[n][3]=j;
                a[i][j-1]--;
                a[i][j]++;
                b=false;
                n++;
            }
        }
    }
    b=false;
    rep(i,0,h-1){
        if(b==false && a[i][w-1]%2==0){
            continue;
        }else if(b==true && a[i][w-1]%2==0){
            ans[n][0]=i-1;
            ans[n][1]=w-1;
            ans[n][2]=i;
            ans[n][3]=w-1;
            a[i-1][w-1]--;
            a[i][w-1]++;
            n++;
        }else if(b==false && a[i][w-1]%2==1){
            b=true;
        }else if(b==true && a[i][w-1]%2==1){
            ans[n][0]=i-1;
            ans[n][1]=w-1;
            ans[n][2]=i;
            ans[n][3]=w-1;
            a[i-1][w-1]--;
            a[i][w-1]++;
            b=false;
            n++;
        }
    }
    cout<<n<<endl;
    rep(i,0,n-1){
        cout<<ans[i][0]+1;
        rep(j,1,3){
            cout<<' '<<ans[i][j]+1;
        }
        cout<<endl;
    }
    
    return 0;
}


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

int main() {

	string s; cin >> s;
	
	int ans = 10000;
	for (int i = 0; i < s.size() - 2; i++) {
		int tmp = stoi(s.substr(i, 3));
		ans = min(ans, abs(tmp - 753));

	}

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

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	int ans = 0;
	stack<char> st;
	for(int i = 0; i < (int)s.size(); i++){
		if(st.size() == 0 || st.top() == s[i])
			st.push(s[i]);
		else{
			ans += 2;
			st.pop();
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
n, y = map(int, input().split())


res = 0;
if y % 5000 != 0:
    res = y % 5000 // 1000
    y = y - res * 1000

if res > n:
    print("-1 -1 -1")
    exit(0)


for a in range(0, y // 10000 + 1):
    rest = y - a * 10000
    for b in range(0, rest // 5000 + 1):
        c = (y - a * 10000 - b * 5000) // 1000
        if a + b + c + res == n:
            print("%d %d %d" % (a, b, c + res))
            exit(0)

print("-1 -1 -1")
exit(0)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 1000000007LL
ll pre[100002][2];
ll fact[1000002];
ll inv(ll a,ll b){
   ll res=1;
   while(b){
    if(b%2) res=(res*a)%mod;
    a=(a*a)%mod;
    b/=2;
   }
   return res;
}
ll ncr(ll n,ll r){
  if(r<0 or r>n) return 0;
  return (((fact[n]*inv(fact[r],mod-2))%mod)*inv(fact[n-r],mod-2))%mod;
}
ll arr[100002];
int main() {
       ios::sync_with_stdio(false);
       cin.tie(0);
       cout.tie(0);
       ll n;
       cin>>n;
       ll x=0;
       for(ll i=1;i<=n;i++){
         cin>>arr[i];
          if(i!=arr[i]){
          x++;
          }
       }
       if(x<=2){
        cout<<"YES";
       }
       else cout<<"NO";
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;

int main()
{
    int n, m;
    cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
 
using namespace std;
const int N = 200005;
 
int a[N],tmp[N];
long long ans;
 
void Merge(int l,int m,int r)
{
    int i = l;
    int j = m + 1;
    int k = l;
    while(i <= m && j <= r)
    {
        if(a[i] > a[j])
        {
            tmp[k++] = a[j++];
            ans += m - i + 1;
        }
        else
        {
            tmp[k++] = a[i++];
        }
    }
    while(i <= m) tmp[k++] = a[i++];
    while(j <= r) tmp[k++] = a[j++];
    for(int i=l;i<=r;i++)
        a[i] = tmp[i];
}
 
void Merge_sort(int l,int r)
{
    if(l < r)
    {
        int m = (l + r) >> 1;
        Merge_sort(l,m);
        Merge_sort(m+1,r);
        Merge(l,m,r);
    }
}
 
int main()
{
    string s;
    cin >> s;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        if (s[i] == 'B') a[i] = 1;
        else a[i] = 0;
    }
    ans = 0;
    Merge_sort(0, n-1);
    cout << ans << endl;
    return 0;
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int64_t N, K;
    cin >> N >> K;
    if (N >= K) {
        cout << min(N % K, K - N % K) << endl;
    } else {
        cout << min(N, K - N) << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
const LI MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//               When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LI a[5],i;
      fo(i,0,5) cin>>a[i];
      fo(i,0,5){
        if(a[i]==0){
          cout<<i+1;
          return 0;
        }
      }
    }
    return 0;
}

Measured memory_bytes: 3612
/*Digit Number*/

import java.util.*;

public class Main {
	private static Scanner sc;
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int l = sc.nextInt();
			int m = sc.nextInt();
			
			int n = l + m;
			
			System.out.println((n+"").length());
		}
		sc.close();
	}
}

Measured memory_bytes: 20448
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

template<typename T>
void print_old(vector<T>vec){
    for(int i=0; i< vec.size(); i++)
      cout<< vec[i]<<" ";
}
//  prints any type which supports iterators...
template <class T>
void print(T& c){
   for( typename T::iterator i = c.begin(); i != c.end(); i++ ){
      std::cout << *i << "\n";
   }
   cout<< "\n";
}
// void f(const vector< int >& v) {
// int r = 0;
// tr(v, it) {
// r += (it)(*it);
// }
// return r;
// }
typedef vector< int > vi;
typedef pair< int,int > pii;
typedef vector<string> vs;
typedef vector<vi> vv;
#define sz(a) int((a).size())
#define pb push_back
#define forn(n) for(int i =0 ; i< n; i++)
#define all(c) c.begin(), c.end()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define ll long long
const int inf = 1e9 +5;

void max_self(ll & a, ll b){
   a = max(a, b);
}


int main(){
    fastio;
   //  int t;
   //  cin>> t;
    int t = 1;
    while(t--){
       int n, W;
      cin >> n >> W;
      // dp[i] - the maximum total value of items with total weight exactly
      vector<ll> dp(W+1);
      for(int item = 0; item < n; ++item){
         int w, v;
         cin >> w >> v;
      for(int weight_in = W-w; weight_in >= 0; --weight_in){
         dp[weight_in + w] = max(dp[weight_in+w], dp[weight_in]+ v);
      }
   }
   ll int answer{0};
   for(int i = 0; i<= W; ++i){
      max_self(answer, dp[i]);
   }
       cout<<answer<<"\n";
        
    }
    return 0;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int n = sc.nextInt();
		Point[] p = new Point[n];
		for(int i=0; i<n; i++) {
			p[i] = new Point(sc.nextDouble(), sc.nextDouble());
		}
		
		for(int i=0; i<n; i++) {
//			System.out.println(i);
			if(!checkCounterClockwise(p[i], p[(i+1)%n], p[(i+2)%n])) {
				System.out.println(0);
				return;
			}
		}
		System.out.println(1);
	}

	static class Point {
		double x;
		double y;
		Point(double x, double y) {
			this.x = x;
			this.y = y;
		}
	}
	
	static boolean checkCounterClockwise(Point p1, Point p2, Point p3) {
		double a = (p2.y - p1.y) / (p2.x - p1.x);
		double b = p2.y - a * p2.x;
		if(p1.x == p2.x) {
			if((p1.y <= p2.y && p3.x <= p1.x) || (p1.y >= p2.y && p3.x >= p1.x)) {
				return true;
			} else {
				return false;
			}	
			
		} else {
			if((p1.x <= p2.x && p3.y - (a * p3.x + b) >= 0) || (p1.x >= p2.x && p3.y - (a * p3.x + b) <= 0)) {
				return true;
			} else {
				return false;
			}				
		}
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 24524
N, X = map(int, input().split())

x = list(map(int, input().split()))


x.sort()


#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

buff = []
ans = abs(x[0]-X)
for i in range(N):
    # print(ans)
    ans = gcd(abs(x[i]-X), ans)


print(ans)

Measured memory_bytes: 14252