akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
void solve() {
        int k, x;
        cin >> k >> x;
        vector <int> ans;
        for(int i=x;i<x+k;i++)
                ans.push_back(i);
        for(int i=x-1;i>(x-k);i--)
                ans.push_back(i);
        sort(ans.begin(), ans.end());
        for(int x : ans)
                cout << x << " ";
        cout << '\n';
        return ;
}
int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        solve();
        return 0;
}


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

int main() {
	int N;
	cin >> N;
  vector<double> A(N);
  rep(i,N) cin >> A[i];

  double ans = 0;
  rep(i,N){
    ans += 1/A[i];
  }

  cout << fixed << setprecision(9);
  cout << 1/ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x;
  cin >> x;

  cout << x*800 - (x/15)*200 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        Scanner sc = null;
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long k = sc.nextLong();
        ArrayList<Long> aList = new ArrayList<Long>();
        ArrayList<Long> bList = new ArrayList<Long>();
        for (int i = 0; i < n; i++) {
            aList.add(sc.nextLong());
        }
        for (int i = 0; i < m; i++) {
            bList.add(sc.nextLong());
        }
        sc.close();

        long sum = 0;
        for(long num : bList) {
            sum += num;
        }
        int j = m;
        int ans = 0;
        for(int i=0; i < n+1; i++){
            while(j > 0 && sum > k){
                j--;
                sum -= bList.get(j);
            }
            if (sum > k) {
                break;
            }
            ans = Math.max(ans, i + j);
            if (i == n) {
                break;}
            sum += aList.get(i);
            
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 72764
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h> 
#include<queue>
#include<string.h>
#include<stack>


using namespace std;

#define INF 2147483647


int n=1;
int A[300000];
bool flag[300000];
int lazy[300000];

void init(int size){

	while(n<size){
		n*=2;
	}
	for(int i=0;i<2*n-1;i++){
		A[i]=INF;
		flag[i]=false;
	}
}

void eval(int k,int l,int r){
	if(flag[k]){
		A[k]=lazy[k];
		if(l+1<r){
			lazy[2*k+1]=lazy[2*k+2]=lazy[k];
			flag[2*k+1]=flag[2*k+2]=true;
		}
		flag[k]=false;
	}
}


void update(int x,int y,int a,int k=0,int l=0,int r=n){
	eval(k,l,r);
	if(r<=x||y<=l){
		return;
	}
	if(x<=l&&r<=y){
		flag[k]=true;
		lazy[k]=a;
		eval(k,l,r);
	}
	else{
		update(x,y,a,2*k+1,l,(l+r)/2);
		update(x,y,a,2*k+2,(l+r)/2,r);
        A[k]=min(A[2*k+1],A[2*k+2]);
	}
}


int query2(int x,int y,int k=0,int l=0,int r=n){
	eval(k,l,r);
	if(r<=x||y<=l){
		return INF;
	}
    if(x<=l&&r<=y){
    	return A[k];
    }
    int vl=query2(x,y,2*k+1,l,(l+r)/2);
    int vr=query2(x,y,2*k+2,(l+r)/2,r);
    return min(vl,vr);
}

int main(){
	int k;
	int q;
	cin>>k>>q;
	init(k);
	int qu;
	int x,s,t;
	for(int i=0;i<q;i++){
		cin>>qu;
		if(qu==0){
			cin>>s>>t>>x;
			update(s,t+1,x);
		}
		else if(qu==1){
			cin>>x;
			cout<<query2(x,x+1)<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5172
/*
------------------------------|بسم الله الرحمن الرحيم|------------------------------//
------------"IN THE NAME OF ALLAH, THE MOST GRACIUOS, THE MOST MERCIFUL"-------------//
__________________________________ShahnawazShaikh_____________________________________
*/

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define int int64_t
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);	
int x,y,i;
cin>>x>>y;

vector<int>v;

for(i=0;i<=x;i++)
 v.push_back(i*4+(x-i)*2);

sort(v.begin(),v.end());

if(binary_search(v.begin(),v.end(),y))
	cout<<"Yes";
else
  cout<<"No";



return 0;	
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Gcd gcd = new Gcd();
		long x = sc.nextLong();
		long y = sc.nextLong();
		long z = 0;
		if (x >= y) {
			System.out.println(gcd.gcd(x, y));
		}else{
			System.out.println(gcd.gcd(y, x));
		}
	}
}

class Gcd {
	public long gcd(long x, long y) {
		long z = x % y;
		long tmpX = x;
		long tmpY = y;
		while (z > 0) {
			z = tmpX % tmpY;
			if (z <= 0) {
				break;
			}
			tmpX = tmpY;
			tmpY = z;
		}
		return tmpY;
	}
}


Measured memory_bytes: 26284
function Main(input) {
    var input_arr = input.split("\n");
    var d = input_arr.map(x => parseInt(x));
    // console.log(d)

    var last = 0;
    var min = d[0] % 10;
    for (var i = 0; i < 5; i++) {
        var tmp = d[i] % 10;
        if (tmp === 0) {
            continue;
        }
        if (tmp < min) {
            min = tmp;
            last = i
        }
    }
    // console.log("last:" + last);
    // console.log("min:" + min);

    var ans = 0;
    for (var i = 0; i < 5; i++) {
        if (i === last) {
            ans += d[i];
        } else {
            ans += Math.ceil(d[i] / 10) * 10;
        }
    }
    console.log(ans);
}


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

Measured memory_bytes: 9420
def 解():
    iN = int(input())
    sS = input().rstrip()

    aE= [0]*iN #東向かされる人
    aW= [0]*iN #西向かされる人
    for i in range(1,iN):
        if sS[i-1] == "W":
            aE[i] = aE[i-1]+1
        else:
            aE[i] = aE[i-1]
    iMinCost = aE[iN-1]
    for i in range(iN-2,-1,-1):
        if sS[i+1]=="E":
            aW[i] = aW[i+1]+1
        else:
            aW[i] = aW[i+1]
        iMinCost = min(iMinCost,aW[i]+aE[i])
    print(iMinCost)

解()


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

if (a<0 and 0<b) or a==0 or b==0:
  print("Zero")
  exit()

if a>0:
  print("Positive")
  exit()

if a==b:
  print("Positive")
elif (b-a)%2==1:
  print("Positive")
else:
  print("Negative")



Measured memory_bytes: 9088
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

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

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = 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;// T ???????????´???
    else if(z->key < y->key) y->left = z; // z ??? y ?????????????????????
    else y->right = z; // z ??? y ?????????????????????
  }


void inParse(Node x){
  if(x->left != NIL) inParse(x->left);
  printf(" %d",x->key);
  if(x->right != NIL) inParse(x->right);
}
void preParse(Node x){
  printf(" %d",x->key);
  if(x->left != NIL) preParse(x->left);
  if(x->right != NIL) preParse(x->right);
}


Node treeSearch(Node u, int k){
  if( u == NIL || k == u->key ) return u;
  if( u->key < k ) treeSearch(u->right,k);
  else treeSearch(u->left,k);
}

int main(){

  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
    if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
     else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inParse(root);
      printf("\n");
      preParse(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll long long int
#define endl "\n"
#define db(x) cout<<#x<<" ->"<<x<<endl
#define db2(x,y) cout<<#x<<"->"<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define db4(w,x,y,z) cout<<#w <<" -> " << w << " , " << #x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++) { cout<<*it<<" "; } cout<< endl
#define IN freopen("input.txt","r",stdin)
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = (int)4e5+4;

int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
//    IN;
    ll n;
    cin >> n;
    ll ans = 0LL;
    for(int i = 0; i  <= n; i++){
        if(i % 3 == 0  || i % 5 == 0 ){ continue ;}
        ans+=i;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector< vector < pair<int,int> > > Graph(N);
  for(int i=0;i<N-1;i++){
    int u,v,w;
    cin >> u >> v >> w;
    u--;
    v--;
    Graph[u].push_back(make_pair(v,w));
    Graph[v].push_back(make_pair(u,w));
  }
  stack<int> stack;
  stack.push(0);
  vector<int> color(N,-1);
  color[0]=0;
  while(!stack.empty()){
    int state=stack.top();
    stack.pop();
    for(pair<int,int> p:Graph[state]){
      if(color[p.first]==0 || color[p.first]==1){
        continue;
      }
      if(p.second%2==0){
        color[p.first]=color[state];
        stack.push(p.first);
      }
      if(p.second%2==1){
        color[p.first]=1-color[state];
        stack.push(p.first);
      }
    }
  }
  for(int i=0;i<N;i++){
    cout << color[i] << endl;
  }
}

Measured memory_bytes: 9488
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define INF 1e15
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define END system("PAUSE");return 0
int n, a[444], dp[1000][1000], sum;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		if (i)a[i] += a[i - 1];
	}
	rep(i, n) {
		rep(j, n + 1) {
			dp[i][j] = INF;
			if (i + 1 == j)dp[i][j] = 0;
		}
	}
	for(int J=1;J<=n;J++){
		rep(i, n) {
			for (int k = 1; k <= n; k++) {
				int j = i + J;
				int sum = (i ? a[j - 1] - a[i - 1] : a[j - 1]);
				if (i + k > j)continue;
				dp[i][j] = min(dp[i][j], dp[i][i + k] + dp[i + k][j] + sum);
			}
		}
	}
	cout << dp[0][n] << endl;
	END;
}


Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ll も int も longlongにしてしまう
    #define int long long

	int a, b, c, d; cin >> a >> b >> c >> d;
    
    if (abs(a-b) <= d && abs(b-c) <= d || abs(a-c) <= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define frep(i, m, n) for(int i = m;i < n;i++)
#define frepr(i, m, n) for(int i = m;i >= n;i--)
#define vsort(v) sort(v.begin(),v.end())
#define ll long long
#define inf 999999999
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vst;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int q;
    cin >> q;
    rep(p,q){
       string x,y;
       cin >> x >> y;
       vvi dp(x.length(),vi(y.length(),inf));
       rep(i,x.length()){
           rep(j,y.length()){
               if(i==0&&j==0)dp[i][j]=(x[i]==y[j]);
               else if(i==0)dp[i][j]=max(dp[i][j-1],(int)(x[i]==y[j]));
               else if(j==0)dp[i][j]=max((int)(x[i]==y[j]),dp[i-1][j]);
               else if(x[i]==y[j])dp[i][j]=1+dp[i-1][j-1];
               else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            //    cout << dp[i][j];
           }
        //    cout << endl;
       }
       cout << dp[x.length()-1][y.length()-1] << endl;
    }
}


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

bool fun(const pair<int,int>& p1, const pair<int,int> & p2 ) { 
    return p1.second > p2.second ; 
}

const int MxN = 1e5+1; 
vector<int> adj[MxN] ; 
bool vis[MxN] ; 
int ct; 

void dfs(int u ) {
    ct++;
    vis[u] = true ; 
    for(int v : adj[u]) {
        if(!vis[v]) {
            vis[v] = true ; 
            dfs(v) ; 
        }
    }
}

void solve() {
    int n , m ; 
    cin >> n  >> m ; 
    vector<int> a(n , 0 )  ; 
    int x , y ,z; 
    for(int i = 0 ; i < m ; ++i) {
        cin >> x >> y >> z ; 
        adj[x].pb(y) ; 
        adj[y].pb(x) ; 
    }
/*    for(int  i = 1 ; i <= n ; ++i ){
        for(int j : adj[i]) 
            cout << j << " " ;
        cout << endl ;
    }*/
/*    vector<pair<int,int>> costs(n) ; 
    for(int  i = 1; i <= n ; ++i) {
        ct=0;
        memset(vis,false , sizeof(vis)) ; 
        dfs(i) ;
        //cout << i << " " << ct << endl ; 
        costs[i].first = i ;
        costs[i].second = ct ; 
    }*/

 
    int ans = 0 ;
    memset(vis,false , sizeof(vis)) ; 
    for(int i = 1 ; i <= n ; ++i) {
        //cout << costs[i].first << " ";
        if(!vis[i]) {
            dfs(i) ; 
            ans ++ ; 
        }
        
    }
    cout << ans  ; 
}

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

	int t ; 
    //cin >> t ; 
    t =1 ; 
    while(t--)
        solve() ; 
    return 0;
}


Measured memory_bytes: 12412
w,h,n=map(int,input().split())

A=[0,w,0,h]
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        A[0]=max(A[0],x)
    elif a==2:
        A[1]=min(A[1],x)
    elif a==3:
        A[2]=max(A[2],y)
    else:
        A[3]=min(A[3],y)

if (A[1]-A[0])<=0 or (A[3]-A[2])<=0:
    print(0)
else:
    print((A[1]-A[0])*(A[3]-A[2]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  ll N;
  cin >> N;

  ll ans = 1e13;
  for (ll i = 1; (i*i) <= N; i++) {
    if ((N % i) == 0) {
      ll tmp = i-1;
      tmp += (N/i) - 1;
      ans = min(tmp, ans);
    }
  }

  cout << ans << endl;

  return 0;
}


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
#define F first
#define S second
// functions
template <typename T> void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n; cin >> n;
  vector<string> v(n); cin >> v;
  sort(whole(v));
  unique(v);
  cout << sz(v) << endl;
  return 0;
}


Measured memory_bytes: 9548
// #include <bits/stdc++.h>
// using namespace std;
// #define all(x) (x).begin(), (x).end()
// #define sz(x) (int)x.size()
// #define D(x) cerr << #x << " = " << (x) << '\n'
// using ll = long long;
// const int mod = 1e9 + 7;

// ll mod_pow(ll base, int exp) {
// 	ll res = 1, b = base;
// 	while(exp) {
// 		if(exp&1) res *= b, res %= mod;
// 		exp >>= 1;
// 		b *= b;
// 		b %= mod;
// 	}
// 	return res;
// }

// int main() {
// 	#ifndef ONLINE_JUDGE
// 		freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	#endif
// 	ios::sync_with_stdio(false);
// 	cin.tie(0); cout.tie(0);
// 	int n, k;
// 	cin >> n >> k;
// 	ll ans = 0;
// 	vector<ll> cnt(k + 1);
// 	for(int g = k; g > 0; -- g) {
// 		cnt[g] = mod_pow(k / g, n);
// 		for(int i = 2 * g; i <= k; i += g) cnt[g] -= cnt[i], cnt[g] += mod, cnt[g] %= mod;
// 		ans += g * cnt[g];
// 		ans %= mod;
// 	}
// 	ll sum = 0;
// 	for(int i = 0; i < n; i++) {
// 		cout << cnt[i] << " ";
// 		sum += cnt[i];
// 	}cout << "\n";
// 	cout << sum << "\n";
// 	cout << ans << '\n';
// }

// 0 6664993 832693 
// 7497686
// 10813692

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

#define ll long long 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()

ll add(ll x, ll y) {
	x += y;
	if(x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if(x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll y) {
	if(y == 0) return 1;
	if(y == 1) return x;
	if(y & 1) return mult(bin_pow(x, y - 1), x);
	return bin_pow(mult(x, x), y / 2);
}

int main(){

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(0); cin.tie(0);
	ll n, k; cin >> n >> k;
	ll ans[k + 1];
	for(int i = 1; i <= k; i++) {
		ans[i] = bin_pow(k / i, n);
	}
	for(int i = k; i >= 1; i--) {
		for(int j = 2 * i; j <= k; j += i) {
			ans[i] = sub(ans[i], ans[j]);
		}
	}
	ll Ans = 0, sum = 0;
	for(int i = 1; i <= k; i++) {
		sum = add(sum, ans[i]);
		Ans = add(Ans, mult(ans[i], i));
	}
	//cout << sum << "\n";
	cout << Ans;
	return 0;
}

Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> p, y;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        p.push_back(make_pair(i, a));
        y.push_back(make_pair(b, i));
    }
    sort(y.begin(), y.end());
    map<int, int> mp;
    vector<int> ans(m, 0);
    rep(i, m){
        int k = y[i].second;
        mp[p[k].second]++;
        ans[k] = mp[p[k].second];
    }
    
    rep(i, m){
        cout << zero_pad(6) << p[i].second;
        cout << zero_pad(6) << ans[i] << endl;
    }
    
}

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

int main(int argc, char *argv[]) {
    int r, D, x2000;
    cin >> r >> D >> x2000;

    int x_next = x2000;
    for (int i = 0; i < 10; i++) {
        x_next = r * x_next - D;
        cout << x_next << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>

template <class Cap, bool isDirect>
struct MaxFlow {
    struct Edge {
        int src, dst;
        Cap cap;
        Edge(int src, int dst, Cap cap)
            : src(src), dst(dst), cap(cap){};
    };

    using Edges = std::vector<Edge>;
    using Graph = std::vector<std::vector<int>>;

    Edges edges;
    Graph graph;
    std::vector<bool> visited;

    explicit MaxFlow(int n)
        : graph(n), visited(n) {}

    void span(int u, int v, Cap cap) {
        graph[u].push_back(edges.size());
        edges.emplace_back(u, v, cap);

        graph[v].push_back(edges.size());
        edges.emplace_back(v, u, (isDirect ? 0 : cap));
    }

    int dfs(int v, int g, Cap f) {
        if (v == g) return f;

        visited[v] = true;
        for (auto eidx : graph[v]) {
            auto& edge = edges[eidx];

            if (edge.cap > 0 && !visited[edge.dst]) {
                Cap df = dfs(edge.dst, g, std::min(f, edge.cap));

                if (df > 0) {
                    edge.cap -= df;
                    auto& redge = edges[eidx ^ 1];
                    redge.cap += df;
                    return df;
                }
            }
        }
        return 0;
    }

    Cap exec(int s, int g) {
        constexpr Cap INF = std::numeric_limits<Cap>::max();

        Cap ret = 0;
        while (true) {
            std::fill(visited.begin(), visited.end(), false);
            Cap flow = dfs(s, g, INF);
            if (flow == 0) return ret;
            ret += flow;
        }
    }
};

void solve() {
    int n, m;
    std::cin >> n >> m;

    MaxFlow<int, false> mf(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        std::cin >> u >> v;
        mf.span(--u, --v, 1);
    }

    int s, t;
    std::cin >> s >> t;
    std::cout << mf.exec(--s, --t) << "\n";

    std::vector<int> revs;
    for (int i = 0; i < m; ++i) {
        if (mf.edges[i * 2 + 1].cap == 0) revs.push_back(i + 1);
    }

    std::cout << revs.size() << "\n";
    for (auto i : revs) std::cout << i << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    rep(i, n) scanf("%d", &a[i]);
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int alice = 0, bob = 0;
    rep(i, n) {
        if(i % 2 == 1) alice += a[i];
        else bob += a[i];
    }
    printf("%d\n", bob - alice);
    return 0;
}

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


int main()
{
	int n,k,q,num;
	cin>>n>>k>>q;
	int arr[n+10]={0};
	for(int i=0;i<q;i++)
	{
		cin>>num;
		arr[num-1]++;
	}
	for(int i=0;i<n;i++)
	{
		// cout<<arr[i];
		if(((arr[i]+k)-q)>0)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
const int N = 200002;
const int M = 1e9 + 7;
const int oo = INT_MAX;
int n;
ll a[N];

int main(){
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        scanf("%lld",a+i);
        sum+=a[i];
    }
    sum%=M;
    ll ans=0;
    for(int i=0;i<n;i++){
        sum -= a[i];
        sum += M;
        sum %= M;
        ans += sum * a[i] ;
        ans %= M;
       
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4764
#include <stdio.h>
#include <vector>
using namespace std;
int main(void)
{
    int N;
    int x=0;
    int y=0;
    scanf("%d",&N);
    vector<int> list(N);
    scanf("%d",&list[0]);
    for(int i=1;i<N;i++)
    {
        scanf("%d",&list[i]);
        if(list[i-1]>=list[i])
        {
            x++;
       }
       else
       {
           if(y<x)
           {
               y=x;
           }
           x=0;
       }
       
    }
   if(y<x)
   {
           y=x;
   }

    printf("%d",y);
    return 0;
}

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

const ll INF = 1001001001;
const ll mod = 1000000007;

int main(){
    ll n; cin >> n;
    set<ll> st;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            st.insert(i);
            st.insert(n / i);
        }
    }
    ll ans = 0;
    for(ll k : st){
        if(n / k >= k - 1) continue;
        if(!st.count(k - 1)){
            ans += k - 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3852
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int a, b, c;
int main(void){
    cin >> a >> b >> c;
    if (a + b >= c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define pb push_back
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N;cin>>N;
    vector<int>A(N);
    REP(i,N){
        cin>>A[i];
    }
    int ans=0;
    for(int d=0;d<60;d++){
        int n0=0;
        int n1=0;
        REP(i,N){
            if((A[i]>>d) & 1)n1++;
            else n0++;
        }
        int tmp=(1ll<<d)%MOD;
        int x=n0*n1%MOD;
      	ans+=tmp*x;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end())
#define pb push_back
#define mp make_pair
#define MODP(A,B) A=(A+B)%mod
typedef pair<ll,ll> P;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

const ll MAXN=500000;

ll N;
ll bit[500010][30];
void add(ll a, ll w, ll MM) {
for (ll x = a; x <= MAXN; x += (x & -x)) bit[x][MM] += w;
}
ll sum(ll a, ll MM) {
 ll ret = 0;
 if(a==0) return 0;
for (ll x = a; x > 0; x -= (x & -x)) ret += bit[x][MM];
 return ret;
}

int main(){
    cin>>N;
    string S; cin>>S;
    rep(i,N) add(i+1,1,S.at(i)-'a');
    ll Q; cin>>Q;
    vec ans;
    rep(i,Q){
        ll x; cin>>x;
        if(x==1){
            ll p; char c; cin>>p>>c;
            add(p,1,c-'a');
            add(p,-1,S.at(p-1)-'a');
            S.at(p-1)=c;
        }
        if(x==2){
            ll L,R; cin>>L>>R;
            ll ret=0;
            rep(i,26) if(sum(R,i)!=sum(L-1,i)) ret++;
            ans.pb(ret);
        }
    }
    rep(i,ans.size()) cout<<ans.at(i)<<endl;
}

Measured memory_bytes: 118404
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n,ai;
int main(){
    cin>>n;
    int ans=0;
    rep(i,n)cin>>ai,ans=__gcd(ans,ai);
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	int N, M; cin >> N >> M;
	vector<int> ab(N+1, (int)1e8);
	for(int i=0; i<M; ++i){
		int l, r; cin >> l >> r;
		ab[l] = min(ab[l], r);
	}

	int ans = 0, r=1e8;
	for(int l=1; l<=N; ++l){
		if(l == r){
			++ans;
			r = 1e8;
		}
		r = min(r, ab[l]);
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
int mp[2][101];
int n,l;

void solve(){
  int sec=0,ant;
  while(1){
    sec++;
    for(int i=l;i>=1;i--)if(mp[0][i-1]>=0&&mp[0][i]>=0)mp[0][i]=mp[0][i-1]; //to right
    for(int i=0;i<l;i++)if(mp[1][i+1]>=0&&mp[1][i]>=0)mp[1][i]=mp[1][i+1];  //to left
    for(int i=1;i<=l;i++)if((mp[0][i]>0&&mp[1][i]>0)||(mp[0][i]<0&&mp[1][i]<0)) swap(mp[0][i],mp[1][i]); //check
    int flg;
    for(flg=1;flg<l&&mp[0][flg]==0&&mp[1][flg]==0;flg++);
    if(flg==l)break;
  }
  if(mp[0][l]>0)ant=mp[0][l];
  if(mp[1][0]>0)ant=mp[1][0];
  cout << sec <<" "<<ant<<endl;
}

int main(){
  while(1){
    cin >>n>>l;
    if(n==0&&l==0)break;
    memset(mp,0,sizeof(mp));
    for(int i=0;i<n;i++){
      char c;
      int a,flg=0;
      cin >>c>>a;
      if(c=='L') flg=1;
      mp[flg][a]=i+1;
    }
    solve();
  }
  return 0;
}

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

// 累積和を用いて区間和を計算する
int main() {
  int n;
  cin >> n;

  vector<int> a(n);
  vector<ll> b(n+1, 0); // 累積和
  int mod = 1000000007;

  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    // 累積和テーブル
    // a |  1 2 3
    // b | 0 1 2 3
    b.at(i+1) = b.at(i) + a.at(i);
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll left = a.at(i) % mod;
    ll right = (b.at(n) - b.at(i+1)) % mod;
    ans = ans + (left * right);
    ans = ans % mod;
  }

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


Measured memory_bytes: 5596
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n,a[200001],b[200001];

int gcd(int __A,int __B)
{
	return __A%__B?gcd(__B,__A%__B):__B;
}

struct Fraction
{
	int molecule,denominator;
	
	void reduction()
	{
		if(molecule==0)
		{
			denominator=1;
			return;
		}
		int GCD=gcd(molecule,denominator);
		molecule/=GCD;
		denominator/=GCD;
		if(denominator<0)
		{
			molecule=-molecule;
			denominator=-denominator;
		}
	}
	
	Fraction operator - ()const
	{
		Fraction tmp=*this;
		tmp.molecule=-tmp.molecule;
		return tmp;
	}
	
	Fraction reciprocal()const
	{
		Fraction tmp;
		tmp.molecule=denominator;
		tmp.denominator=molecule;
		tmp.reduction();
		return tmp;
	}
	
	bool operator < (const Fraction x)const
	{
		return molecule==x.molecule?denominator<x.denominator:molecule<x.molecule;
	}
}k[200002];
map <Fraction,int> l;
int cnt,s[200002],ans,t[200002],p[200002],_00,_0x,_x0;
#define MOD 1000000007
int C(int a,int b)
{
//	cout<<t[a]<<' '<<p[b]<<' '<<p[a-b]<<endl;
	return t[a]*p[b]%MOD*p[a-b]%MOD;
}
int power(int a,int b,int c)
{
	int tmp=1;
	while(b)
	{
		if(b&1)
		{
			tmp=(tmp*a)%c;
		}
		b>>=1;
		a=(a*a)%c;
	}
	return tmp;
}
signed main()
{
	std::ios::sync_with_stdio(false);
//	freopen("a.in","r",stdin);
//	freopen("std.out","w",stdout);
	cin>>n;
	t[0]=1;
	p[0]=1;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i]>>b[i];
		t[i]=t[i-1]*i%MOD;
		p[i]=power(t[i],MOD-2,MOD);
		if(a[i]==0&&b[i]==0)
		{
			++_00;
			continue;
		}
		if(a[i]==0)
		{
			++_0x;
			continue;
		}
		if(b[i]==0)
		{
			++_x0;
			continue;
		}
		k[i].molecule=a[i];
		k[i].denominator=b[i];
		k[i].reduction();
		++l[k[i]];
	}
	s[++cnt]=1;
	for(int i=1;i<=_0x;++i)
	{
		s[cnt]=(s[cnt]+C(_0x,i))%MOD;
	}
	for(int i=1;i<=_x0;++i)
	{
		s[cnt]=(s[cnt]+C(_x0,i))%MOD;
	}
	for(int i=1;i<=n;++i)
	{
		if(l[k[i]])
		{
			Fraction tmp=-k[i].reciprocal();
			s[++cnt]=1;
			int N=l[k[i]];
			for(int j=1;j<=N;++j)
			{
				s[cnt]=(s[cnt]+C(N,j))%MOD;
			}
			N=l[tmp];
			for(int j=1;j<=N;++j)
			{
				s[cnt]=(s[cnt]+C(N,j))%MOD;
			}
			l[k[i]]=l[tmp]=0;
		}
	}
	ans=1;
	for(int i=1;i<=cnt;++i)
	{
		ans=(ans*s[i])%MOD;
	}
	cout<<(ans+MOD-1+_00)%MOD<<endl;
	return 0;
}


Measured memory_bytes: 39480
n,k=map(int,input().split())
a=list(map(int,input().split()))
dist=[]
for i in range(n-k+1):
  if a[i+k-1]<=0:
    dist.append(-a[i])
  elif a[i]>=0:
    dist.append(a[i+k-1])
  else:
    dist.append(min(2*a[i+k-1]-a[i],a[i+k-1]-2*a[i]))

print(min(dist))


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

#define pb push_back
#define ppp pop_back
#define pii pair<int,int>
#define fi first
#define se second

const int N = 405;
const ll inf = 1e18;

ll dp[N][N];
ll pref[N];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	pref[0] = 0;
	for (int i=1; i<=n; i++) {
        dp[i][i] = 0;
        int cur = 0;
        cin >> cur;
        pref[i] = pref[i-1] + cur;
	}
	for (int s=2; s<=n; s++) {
		for (int i=1; i<=n-s+1; i++) {
			ll res = inf;
			for (int j=i; j<=i+s-2; j++) {
				res = min(res, dp[i][j] + dp[j+1][i+s-1]);
			}
			dp[i][i+s-1] = res + pref[i+s-1] - pref[i-1];
		}
	}
	cout << dp[1][n] << "\n";
	return 0;
}


Measured memory_bytes: 1536
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = (int)sc.nextLong();
		
		long t[] = new long[N];
		for(int i = 0; i < N; i++) {
			t[i] = sc.nextLong();
		}
		
		long answer = 1;
		for(int i = 0; i < N; i++) {
			answer = lcm(t[i], answer); 
		}
		
		System.out.println(answer);
	}
	
	private static long lcm(long m, long n) {
	    return m / gcd(m, n) * n;
	}
	
	private static long gcd(long m, long n) {
	    long temp;
	    while(m % n != 0) {
	    	temp = n;
	    	n = m % n;
	    	m = temp;
	    }
	    return n;
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N = 100000;
    vector P(N, true);
    P[0] = P[1] = false;
    int L = (int)sqrt(N);
    for (int i = 2; i <= L; i++) {
        for (int j = i*2; j <= N; j += i) {
            P[j] = false;
        }
    }

    vector<int> WA(N+1, 0);
    for (int i = 1; i <= N; i++) {
        WA[i] = WA[i-1];
        if (P[i] && P[(i + 1) / 2]) WA[i]++;
    }

    int Q; cin >> Q;
    rep(i,Q) {
        int l, r; cin >> l >> r;
        cout << WA[r] - WA[l] + (WA[l] - WA[l-1] == 1) << endl;
    }
}


Measured memory_bytes: 3620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskE {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int w = in.nextInt();
            int[] weights = new int[n];
            int[] values = new int[n];
            int v = 0;
            for (int i = 0; i < n; i++) {
                weights[i] = in.nextInt();
                values[i] = in.nextInt();
                v += values[i];
            }
            long[][] dp = new long[n + 1][v + 1];
            int ans = -1;
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= v; j++) {
                    if (i == 0 || j == 0)
                        dp[i][j] = Integer.MAX_VALUE;
                    else if (values[i - 1] <= j) {
                        dp[i][j] = Math.min(dp[i - 1][j], dp[i - 1][j - values[i - 1]] + weights[i - 1]);
                    } else
                        dp[i][j] = Math.min(weights[i - 1], dp[i - 1][j]);
                    if (dp[i][j] <= w)
                        ans = Math.max(j + 1, ans);
                }
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 126548
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

bool isPrime(int n) {
    if(n < 2)
        return false;
    else if(n == 2)
        return true;
    else if(n % 2 == 0)
        return false;
    double sq = sqrt(n);
    for(int i = 3; i <= sq; i += 2) {
        if(n % i == 0) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    while(!isPrime(X)) {
        X++;
    }
    cout << X << endl;
}

Measured memory_bytes: 3640
class SegmentTree:
    def __init__(self, size, f=lambda x, y: x + y, default=0):
        self.size = 2 ** (size - 1).bit_length()
        self.default = default
        self.dat = [default] * (self.size * 2)
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i * 2], self.dat[i * 2 + 1])

    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres)
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res


n, q = map(int, input().split())
s = SegmentTree(n, min, 2 ** 31 - 1)
for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        s.update(x, y)
    else:
        print(s.query(x, y + 1))




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

MOD = 10 ** 9 + 7
N = int(input())
A = [[int(x) for x in input().split()] for _ in range(N)]

bit_count = [0]
for _ in range(N):
    bit_count += [x+1 for x in bit_count]
    
dp = [0] * (1<<N)
dp[0] = 1

for i in range((1<<N)-1):
    k = bit_count[i]
    for c in range(N):
        if A[k][c]:
            dp[(1<<c)^i] += dp[i]

answer = dp[-1] % MOD
print(answer)

Measured memory_bytes: 148820
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

i64 p = 1000000007LL;

i64 powmod(i64 x, i64 y)
{
    if (y == 1)
        return x % p;
    if (y % 2 == 1)
        return (x * powmod(x, y - 1)) % p;

    i64 pwmd = powmod(x, y / 2) % p;
    return (pwmd * pwmd) % p;
}

i64 bicomod(int n, int a)
{
    if (n == a)
        return 1;
    if (a > n / 2)
        return bicomod(n, n - a);
    i64 anom = 1;
    i64 adom = 1;
    for (int i = 1; i <= a; i++)
        anom = anom * i % p;
    for (int i = n - a + 1; i <= n; i++)
        adom = adom * i % p;

    return (adom * powmod(anom, p - 2)) % p;
}

int main()
{
    i64 n, k;
    cin >> n >> k;

    i64 mmax = min(n - 1, k);
    i64 result = 0;
    vector<i64> bincoe(mmax + 20);
    bincoe[1] = n;

    for (i64 m = 1; m <= mmax; m++)
    {
        if (m > n / 2LL)
        {
            bincoe[m] = bincoe[n - m];
            result += ((bincoe[m] * bincoe[m] % p) * ((n - m) * powmod(n, p - 2) % p)) % p;
            result %= p;
            continue;
        }
        result += ((bincoe[m] * bincoe[m] % p) * ((n - m) * powmod(n, p - 2) % p)) % p;
        result %= p;
        bincoe[m + 1] = ((bincoe[m] * (n - m) % p) * powmod(m + 1, p - 2)) % p;
    }

    cout << result + 1 << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
ll X[100004];
ll A, B;

int main() {
  INCANT;
  cin >> N >> A >> B;
  rep(i, N) cin >> X[i];
  ll SUM=0ll;
  rep(i, N-1) {
    if ((X[i+1]-X[i])*A<B) SUM+=(X[i+1]-X[i])*A;
    else SUM+=B;
  }
  cout << SUM << "\n";
  return 0;
}

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

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

    int n; cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < n - 1; ++i) cin >> c[i];

    int ans = accumulate(b.begin(), b.end(), 0);

    for (int i = 0; i < n; ++i) {
        if (a[i+1] - a[i] == 1) {
            ans += c[a[i]-1];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    A = [list(map(lambda x:int(x)-1,input().split())) for _ in range(N)]
    cur = [0 for _ in range(N)]
    yesterday = set(range(N))
    rest = N * (N-1)
    day = 0
    while len(yesterday) > 0 and rest > 0:
        today = set()
        totoday = set()
        for y in yesterday:
            o = A[y][cur[y]]
            if A[o][cur[o]] == y:
                today.add(o)
                today.add(y)
        for t in today:
            cur[t] += 1
            if cur[t] < N-1:
                totoday.add(t)
        rest -= len(today)
        yesterday = totoday
        day += 1
    if rest == 0:
        print(day)
    else:
        print(-1)
resolve()

Measured memory_bytes: 55004
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int A, B;
    try(Scanner sc = new Scanner(System.in)) {
      A = sc.nextInt();
      B = sc.nextInt();
    }
    int sum = A + B;
    int diff = A - B;
    int prod = A * B;
    int cand = Math.max(sum, diff);
    cand = Math.max(cand, prod);
    System.out.println(cand);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,s1,s2;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>n;
    ml m;
    fo(i,n)cin>>x,m[x]++;
    if(n%3!=0){
        if(sz(m)==1&&m.begin()->ff==0)cout<<"Yes";
        else cout<<"No";
    }
    else{
        if(sz(m)==3){
            auto it=m.begin();
            x=it->ff;
            if(it->ss!=n/3)return cout<<"No",0;
            it++;
            y=it->ff;
            if(it->ss!=n/3)return cout<<"No",0;
            it++;
            z=it->ff;
            if(it->ss!=n/3)return cout<<"No",0;
            if((x^y)==z)cout<<"Yes";
            else cout<<"No";
        }
        else if(sz(m)==1){
            if(m.begin()->ff==0)cout<<"Yes";
            else cout<<"No";
        }
        else if(sz(m)==2){
            auto it=m.begin();
            if(it->ff!=0||it->ss!=n/3)return cout<<"No",0;
            else cout<<"Yes";
        }
        else cout<<"No";
    }
    return 0;
}


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

using namespace std;

#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int arr[5];
    for(int i = 0;i<5;i++){
        cin>>arr[i];
    }
    for(int i = 0;i<5;i++){
        if(arr[i] == 0){
            cout<<i+1;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3632