akhauriyash/Code-Regression huggingface dataset:
import heapq 

N=int(input())
A=list(map(int,input().split()))

A1,A2,A3=A[:N],A[N:2*N],A[2*N:]

res=[]
qA=A1
heapq.heapify(qA)
sumA=sum(qA)

qB=[-b for b in A3]
heapq.heapify(qB)
sumB=sum(qB)


resA,resB=[sumA],[sumB]
for k in range(N):
    heapq.heappush(qA,A2[k])
    a=heapq.heappop(qA)
    sumA+=A2[k]-a
    
    heapq.heappush(qB,-A2[N-(k+1)])
    b=heapq.heappop(qB)
    sumB+=-A2[N-(k+1)]-b
    resA.append(sumA)
    resB.append(sumB)

res=[resA[i]+resB[N-i] for i in range(N+1)]
print(max(res))

Measured memory_bytes: 124832
n = gets.to_i
a = gets.split.map {|s| s.to_i}
cnt = 0
for i in 0..n-2
  j = n-1
  while j > i
    if a[j] < a[j-1]
      t = a[j]
      a[j] = a[j-1]
      a[j-1] = t
      cnt += 1
    end
    j -= 1
  end
end
for i in 0..n-1
  print " " unless i==0
  print a[i]
end
print "\n"
puts cnt

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

main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
int i,j,k,l,m,n,p,q;
char s1[100],s2[1000];
while(cin>>s1>>s2){
    p=strlen(s1);
    q=strlen(s2);
    n=0;
    for(i=0;i<p;i++)if(s1[i]!=s2[i])n++;
    if(n==0&&p+1==q)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
return 0;
}


Measured memory_bytes: 3652
N = int(input())
A = list(map(int, input().split(" ")))

#Biを作成
B = A.copy()
for i in range(N):
    B[i] = B[i] - (i+1)

B.sort()
chuo=B[int(N//2)]

tmp=0
for i in B:
    tmp += abs(i - chuo)
print(tmp)

Measured memory_bytes: 25748
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string in; cin >> in;
    int n = in.size();

    int res = 0;
    rrep(i, n/2){
        if(in.substr(0, i) == in.substr(i, i)){
            res = i * 2;
            break;
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
/*
"Won't stop untill I'm Phenomenal"
- Phenomenal, EMINEM
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int n; cin>>n;
    vector<ll> a(n);
    get(a);
    ll curr = 0;
    for(ll i : a){
        curr^=i;
    }
    for(ll i : a){
        cout<<(i^curr)<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 4768
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int ca = 0, cb = 0, cc = 0, cd = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'N')ca++;
		if (s[i] == 'S')cb++;
		if (s[i] == 'W')cc++;
		if (s[i] == 'E')cd++;
	}
	if ((ca == 0 && cb > 0) || (ca > 0 && cb == 0))printf("No\n");
	else if ((cc == 0 && cd > 0) || (cc > 0 && cd == 0))printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
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")
    };
}

// ここまで

fn is_sorted (a: &Vec<usize>) -> bool {
    for k in 1..a.len() {
        if a[k] < a[k - 1] {
            return false;
        }
    }
    true
}

fn run() {
    input! {
        n: usize,
        p: [usize; n],
    }
    let mut p = p.clone();
    if is_sorted (&p) {
        println! ("YES");
        return;
    }
    for i in 1..n {
        for j in 0..i {
            p.swap (i, j);
            if is_sorted (&p) {
                println! ("YES");
                return;
            }
            p.swap (i, j);
        }
    }
    println! ("NO");
}

fn main() {
    run();
}


Measured memory_bytes: 4352
n=int(input())
h=list(map(int,input().split()))
h.insert(0,0)

dp=[0 for i in range(n+1)]
dp[2]=abs(h[2]-h[1])
for i in range(3,n+1):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n])

Measured memory_bytes: 52728
// inputに入力データ全体が入る
function Main(input) {
  
   input = input.split(" ");
  var r= parseInt(input[0], 10);
  var D= parseInt(input[1], 10);
  var X= parseInt(input[2], 10);
    
   var c = [];
for (var i = 0; i <10 ; i++){
            var X = r * X - D;
            console.log(X)
           c[i] = X;}
 
  
  
           
 
}
 
  
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 21320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000;
/* END OF TEMPLATE */

ll divup(ll a, ll b){
    return (a+b-1)/b;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll t(n), a(n);
    rep(i, n){
        cin >> t[i] >> a[i];
    }
    ll x = t[0], y = a[0];
    rea(i, 1, n){
        ll k = max(divup(x,t[i]), divup(y,a[i]));
        x = t[i]*k, y = a[i]*k;
    }
    cout << x+y << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
vector<pair<string,pii> >v;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;cin>>n;
    rep(i,1,n)
    {
        string s;cin>>s;
        int p;cin>>p;
        v.pb({s,{-p,i}});
    }
    sort(all(v));
    for(auto i:v)
    {
        cout<<i.se.se<<"\n";
    }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,M=MAP()
S=[0]+LIST()
T=[0]+LIST()

dp = [[0] * (M+1) for i in range(N+1)]
for i in range(1, N+1):
    for j in range(1, M+1):
        # dp配列を2次元累積和にして、動的に更新していく
        # (+-する添字位置は、普通の区間取得の時とは違う。どうなってるかは自分のメモ参照)
        dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%MOD
        # 今回増やす数値が一致するなら
        if S[i] == T[j]:
            # そこより手前の全部合計+1
            dp[i][j]+=dp[i-1][j-1]+1
            dp[i][j]%=MOD
# 全部の合計+最初の空配列ペアの分
print((dp[N][M]+1)%MOD)


Measured memory_bytes: 72668
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int r;
	scanf("%d",&r);
	printf("%d\n", 3 * r * r);
	return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>();
	int sum=0;
	int N=S.size();
	REP(i,N-1){
		if(S[i]!=S[i+1]) sum++;
	}
	
	out(sum);
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define MOD1 1000000007
#define MOD2 998244353
#define IOS std::ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define print(a) for(auto x : a)    cout<<x<<" "; cout<<"\n";
using namespace std;

int main(){

    IOS;

    unordered_set<string> val;
    string s;
    int n;
    cin >> n;

    for(int i = 0; i < n; i++)  cin >> s, val.insert(s);
    cout<<val.size()<<"\n";


    return 0;
}

Measured memory_bytes: 17568
import java.util.*;


public class Main {
	
	
	static int n, k ;
	static boolean[] can = new boolean[10];
	
	public static void main(String[] args) {
		
		Scanner cin = new Scanner(System.in);
		
		
		n = cin.nextInt();
		k = cin.nextInt();
		
		Arrays.fill(can, true);
		for (int i = 0; i < k; i ++) {
			can[cin.nextInt()] = false;
		}
		
		
		String num = String.valueOf(n);
		
		int[] nums = new int[num.length() + 1];
		nums[0] = 0;
		
		for (int i = 0; i < num.length(); i ++) {
			nums[i + 1] = num.charAt(i) - '0';
		}
		
		int index = 1;
		for (; index < nums.length; ) {
			
			int a = nums[index];
			
			if (can[a]) { 
				index ++;
				continue;
			}
			// else
			int b = increment(a);
			
			if (b > a) {
				nums[index] = b;
				index ++;
				break;
			}
			
			// else b < a
						
			if (index == 1) {
				int c = increment(0);
				nums[index-1] = c;
				//index ++;
				break;
			}
			else {
				
				while (index > 0) {
					index --;
					int e = increment(nums[index]);
					if (e > nums[index]) {
						nums[index] = e;
						index ++;
						break;
					} 							
				}
				break;
			}
						
		}
		
		int d = increment(-1);
		while (index < nums.length) {
			nums[index] = d;
			index ++;
		}
		
		/*finish*/
		for (int i = 0; i < nums.length; i ++) {
			if (i == 0 && nums[0] == 0) {
				continue;
			}
			System.out.print(nums[i]);
		}		
		System.out.println();
	}
	
	public static int increment(int j) {
		
		int i = j + 1;
		
		for (; i < 20; i ++) {
			if (can[i % 10]) {
				break;
			}
		}
		
		return i % 10;
	}
	
}



Measured memory_bytes: 22996
#include <iostream>
#include <vector>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;
constexpr int MAX = 100010;

int64_t 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;
    }
}

// 二項係数計算
int64_t 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(void) {
    int n;
    cin >> n;

    int l, r;
    vector<int> L(n+2);
    for(int i=1; i<=n+1; i++) {
        int a;
        cin >> a;
        if(L[a]) {
            l = L[a] - 1;
            r = n+1 - i;
        } else {
            L[a] = i;
        }
    }

    COMinit();

    for(int k=1; k<=n+1; k++) {
        int64_t ans = (COM(n+1, k) - COM(l+r, k-1) + MOD) % MOD;
        cout << ans << endl;
    }
    return 0;
}


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



int gcd(int a,int b){
    if (a > b){
        int c = a % b;
        if(c == 0){
            return b;
        }else{
            return gcd(b,c);
        }
    }else{
        int c = b % a;
        if(c == 0){
            return a;
        }else{
            return gcd(a, c);
        }
    }

}

int main(){

    int N;
    cin >> N;

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

    int rest = gcd(A[0], A[1]);

    for(int i=0; i<N; i++){
        rest = gcd(A[i], rest);
        if(rest == 1){
            break;
        }
    }

    cout << rest << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a,b;
char x[105][105];
int main() {
	scanf("%d%d",&a,&b);
	a--,b--;
	for(int i=1;i<=50;i++)
		for(int j=1;j<=100;j++)
			x[i][j]='.';
	for(int i=51;i<=100;i++)
		for(int j=1;j<=100;j++)
			x[i][j]='#';
	for(int i=1;i<=50&&b;i+=2)
		for(int j=1;j<=100&&b;j+=2)
			x[i][j]='#',b--;
	for(int i=100;i>50&&a;i-=2)
		for(int j=1;j<=100&&a;j+=2)
			x[i][j]='.',a--;
	puts("100 100");
	for(int i=1;i<=100;i++,puts(""))
		for(int j=1;j<=100;j++)
			printf("%c",x[i][j]);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){

	string str , cstr;
	string prob , newstr = "";

	 str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	cstr = "DEFGHIJKLMNOPQRSTUVWXYZABC";

	cin >> prob;

	int prob_size = prob.size();
	int cstr_size = cstr.size();
	int str_size = str.size();

	for(int i = 0; i < prob_size; i++){
		for(int j = 0; j < cstr_size; j++){
			if(prob[i] == cstr[j]){
				newstr += str[j];
			}
		}
	}

	cout << newstr << endl;

	return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,k;
    int q,w,s,r,t,y,u,m,n,v;
    cin>>a>>b>>c>>d>>e>>k;
    q=b-a; w=c-a; s=d-a; r=e-a; t=c-b;
    y=d-b; u=e-b; m=d-c; n=e-c; v=e-d;
    if(q>k||w>k||s>k||r>k||t>k||y>k||u>k||m>k||n>k||v>k)
    {
        cout<<":(";
    }
    else 
    {
        cout<<"Yay!";
    }
    return 0;
}





Measured memory_bytes: 256
s = list(input())
q = int(input())
left = []
right = []
rev = False
for i in range(q):
    x = list(input())
    if len(x) == 1:
        rev = not rev
        #s.reverse()
    else:
        if (x[2] == "1" and not rev) or (x[2] == "2" and rev):
            left.append(x[4])
        else:
            right.append(x[4])
ans = "".join(left[::-1]) + "".join(s) + "".join(right)
if rev:
    print(ans[::-1])
else:
    print(ans)

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

#define STRING(str) #str
#define ll long long

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

const ll mod = 998244353;

// struct S {
	// ll a, b, c;
// };

struct S {
	ll a, size;
};

// S op(S x, S y) {
	// return S{(((x.a*x.b)%mod+x.c)%mod+((y.a*y.b)%mod+y.c)%mod)%mod, 1LL, 0LL};
// }

S op(S x, S y) {
	return S{(x.a+y.a)%mod, (x.size+y.size)%mod};
}

// S e() {
	// return S{0LL, 1LL, 0LL};
// }
S e() {
	return S{0LL, 0LL};
}

struct F {
	ll b, c;
};

// S mapping(F f, S x) {
	// return S{(x.a*(x.b*f.b%mod)%mod+(x.c*f.b+f.c)%mod)%mod, 1LL, 0};
// }

S mapping(F f, S x) {
	return S{(x.a*f.b%mod+x.size*f.c%mod)%mod, x.size};
}

// F composition(F g, F f) {
	// return F{(g.b*f.b)%mod, (g.c*f.b+f.c)%mod};
// }
F composition(F f, F g) {
	return F{(g.b*f.b)%mod, (g.c*f.b+f.c)%mod};
}

F id() {
	return F{1LL, 0LL};
}

int main() {
	int N, Q;
	cin >> N >> Q;
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(N);
	for (int i=0;i<N;i++) {
		int a;
		cin >> a;
		// seg.set(i, S{(ll)a, 1LL, 0LL});
		seg.set(i, S{(ll)a, 1LL});
	}
	for (int i=0;i<Q;i++) {
		int num;
		cin >> num;
		if (num == 0) {
			int l, r, b, c;
			cin >> l >> r >> b >> c;
			seg.apply(l, r, F{(ll)b, (ll)c});
		} else { // num == 1
			int l, r;
			cin >> l >> r;
			// cout << seg.prod(l, r).a << " " << seg.prod(l, r).b << " " << seg.prod(l, r).c << endl;
			cout << seg.prod(l, r).a << endl;
		}
	}
}

Measured memory_bytes: 35688
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;

    vector<int> x(N);
    vector<int> y(M);

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

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


    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    if (max(x[N-1], X) < min(y[0], Y)){
        cout << "No War" << endl;
    }
    else {
        cout << "War" << endl;
    }
}

Measured memory_bytes: 256
// abc164_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int s,w;
  cin>>s>>w;
  cout<<((s>w) ? "safe" : "unsafe")<<endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int v[n+1];
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
    }

    int m1[n+1][k+1];
    memset(m1, 0, sizeof(m1));
    for (int i = 1; i <= n; i++) {
        int t[i];
        int st = 0;
        for (int j = 0; j < i; j++) {
            t[j] = v[j+1];
            st += t[j];
        }
        sort(t, t+i);

        for (int j = i; j <= 2 * i && j <= k; j++) {
            m1[i][j] = max(m1[i][j-1], st);
            st -= t[j-i];
        }
        for (int j = 2 * i + 1; j <= k; j++) {
            m1[i][j] = m1[i][j-1];
        }
    }

    reverse(v+1, v+n+1);

    int m2[n+1][k+1];
    memset(m2, 0, sizeof(m2));
    for (int i = 1; i <= n; i++) {
        int t[i];
        int st = 0;
        for (int j = 0; j < i; j++) {
            t[j] = v[j+1];
            st += t[j];
        }
        sort(t, t+i);

        for (int j = i; j <= 2 * i && j <= k; j++) {
            m2[i][j] = max(m2[i][j-1], st);
            st -= t[j-i];
        }
        for (int j = 2 * i + 1; j <= k; j++) {
            m2[i][j] = m2[i][j-1];
        }
    }

    int ans = 0;
    for (int i1 = 0; i1 <= n; i1++) {
        for (int i2 = 0; i1 + i2 <= n; i2++) {
            for (int k1 = i1; k1 <= k; k1++) {
                for (int k2 = i2; k1 + k2 <= k; k2++) {
                    ans = max(ans, m1[i1][k1] + m2[i2][k2]);
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	bool flag=0;
	string s1,s2;
	cin>>s1>>s2;
	if(s1.length()!=s2.length()-1)cout<<"No";
	else{
		for(int i=0;i<s1.length();i++){
			if(s1[i]!=s2[i])flag=1;
		}
		if(flag==1)cout<<"No";
		else cout<<"Yes";
	} 
	return 0;
}

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

int main(){
  int n,ans=0,cnt=0;
  string s;
  
  cin >> n >> s;

  for(int i=1;i<s.size();++i){
    if(s[i] == 'E'){
      ++cnt;
    }
  }

  ans = cnt;
  for(int i=1;i<s.size();++i){
    if(s[i] =='E') --cnt;
    if(s[i-1] == 'W') ++cnt;

    ans = min(ans,cnt);
  }

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


Measured memory_bytes: 900
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<set>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define Rep(i,s,t) for(register int i=s;i<t;++i)
#define go(x) for(register int e=las[x];e;e=nxt[e])
#define re register
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define gi(x) read(x)
#define gii(x,y) read(x),read(y)
#define giii(x,y,z) read(x),read(y),read(z)
#define ms(f,x) memset(f,x,sizeof f)
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]);
		putchar('\n');
		return;
    }
}
using IO::read;
using IO::write;
using namespace std;
const int N=2e6+11;
int n,k,tot,x;
int p[N],q[N],mx[N];
priority_queue<int>heap;
int nxt[N],las[N],to[N],deg[N];
inline void add(int x,int y){
	nxt[++tot]=las[x],las[x]=tot,to[tot]=y,++deg[y];
}
inline void topsort(){
	rep(i,1,n)
		if(!deg[i])
			heap.push(-i);
	rep(i,1,n){
		int x=-heap.top();heap.pop();
		p[x]=i;
		go(x){
			--deg[to[e]];
			if(!deg[to[e]])
				heap.push(-to[e]); 
		} 
	}
}
#define lson k<<1,l,mid
#define rson k<<1|1,mid+1,r
inline void ins(int x,int p,int k=1,int l=1,int r=n){
	if(l==r){
		mx[k]=p;
		return ;
	}
	int mid=(l+r)>>1;
	x<=mid?ins(x,p,lson):ins(x,p,rson);
	mx[k]=max(mx[k<<1],mx[k<<1|1]);
}
inline int query(int x,int y,int k=1,int l=1,int r=n){
	if(x<=l&&r<=y)return mx[k];
	int mid=(l+r)>>1;
	int ans=0;
	if(x<=mid)ans=query(x,y,lson);
	if(mid<y)ans=max(ans,query(x,y,rson));
	return ans;
}
int main(){
	gii(n,k);
	rep(i,1,n)
		gi(p[i]),q[p[i]]=i;
	//rep(i,1,n)printf("%d ",q[i]);puts("");
	rep(i,1,n){
		//printf("%d %d\n",i,q[i]);
		x=query(q[i],min(q[i]+k-1,n));
		if(x)add(q[x],q[i]);
		x=query(max(q[i]-k+1,1),q[i]);
		if(x)add(q[x],q[i]);
		//printf("%d\n",x);
		ins(q[i],i);
	}
	//rep(i,1,n)printf("%d ",deg[i]);puts("");
	topsort(); 
	rep(i,1,n)
		write(p[i]);
	return 0;
}

Measured memory_bytes: 36480
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
#define F first
#define S second
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> a(n);
  ll c = 0;
  rep(i,n) cin  >> a[i];
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      for(int k=j+1; k<n; k++){
        if(a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i]){
          if(((a[i]+a[j])>a[k])&&((a[j]+a[k])>a[i])&&((a[k]+a[i])>a[j])){
            c++;
          }
        }
      }
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 3628
N=int(input())
prob=[float(i) for i in input().split()]
dp=[[0]*(N+1) for i in range(N+1)]
dp[0][0]=1
for i in range(1,N+1):
    for j in range(N+1):
        if j==0:
            dp[i][j]=dp[i-1][j]*(1-prob[i-1])
        else:
            dp[i][j]=dp[i-1][j]*(1-prob[i-1])+dp[i-1][j-1]*prob[i-1]
ans=0
for i in range(N//2+1,N+1,1):
    ans+=dp[-1][i]
print(ans)



Measured memory_bytes: 203720
#!/usr/bin/env python3

from bisect import bisect_right

def main():
    s = input()
    t = input()
    indices = [[] for i in range(26)]
    n = len(s)
    for i in range(n):
        c = s[i]
        ic = ord(c) - ord("a")
        indices[ic].append(i)
    for i in range(26):
        if not indices[i]:
            continue
        indices[i].append(indices[i][0] + n)

    ptr = -1
    for c in t:
        ic = ord(c) - ord("a")
        if len(indices[ic]) == 0:
            print(-1)
            return
        nptr = bisect_right(indices[ic], ptr % n)
        ptr += indices[ic][nptr] - (ptr % n)

    print(ptr + 1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 7668
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main()
{
	string str;
	while ( cin >> str ) {
		size_t pos;
		while ( (pos = str.find('@')) != string::npos ) {
			int length = str.at(pos+1) - '0';
			char c = str.at(pos+2);
			str.erase(pos, 3);
			str.insert(pos, length, c);
		}
		cout << str << endl;
	}
	
	return 0;
}

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

typedef signed long long ll;
const int MX = 1e3 + 5;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    ((a[a.size() - 1] == b[0]) && (b[b.size() - 1] == c[0])) ? cout << "YES\n" : cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int MAXN = 2020;
int f[MAXN][MAXN] , dep[MAXN] , first[MAXN] , son[MAXN];
class Edges{
public:
	int next , to;
};
Edges edge[MAXN * 2];
int n , k , te = 0;
void add(int s , int t){
	++ te;
	edge[te].to = t;
	edge[te].next = first[s];
	first[s] = te;
}
void dfs(int x , int y){
	for(int e = first[x] ; e ; e = edge[e].next){
		int to = edge[e].to;
		if(to == y) continue;
		dfs(to , x);
	}
	int cnt = 0;
	for(int e = first[x] ; e ; e = edge[e].next){
		int to = edge[e].to;
		if(to == y) continue;
		son[++ cnt] = to;
		dep[x] = max(dep[to] + 1 , dep[x]);
	}
	if(!cnt){
		dep[x] = 1;
		f[x][0] = 0;
		for(int i = 1 ; i <= k + 1 ; ++ i)
			f[x][i] = 1;
		return ;
	}
	f[x][0] = 0;
	f[x][1] = 1;
	int cur = 1;
	for(int i = 2 ; 2 * i <= k + 2 && i <= dep[x] ; ++ i){
		cur = i;
		f[x][i] = 0;
		for(int j = 1 ; j <= cnt ; ++ j)
			f[x][i] += f[son[j]][i - 1];
		f[x][i] ++;
	}
	for(int i = cur + 1 ; i <= k + 1 && i <= dep[x] ; ++ i){
		int sum = 0 , maxn = -(n + 1);
		for(int j = 1 ; j <= cnt ; ++ j){
			sum += f[son[j]][k + 1 - i];
			if(f[son[j]][i - 1] - f[son[j]][k + 1 - i] >= maxn) maxn = f[son[j]][i - 1] - f[son[j]][k + 1 - i];
		}
		f[x][i] = sum + maxn + 1;
	}
	for(int i = 2 ; i <= k + 1 ; ++ i)
		f[x][i] = max(f[x][i] , f[x][i - 1]);
}
int main(){
	cin >> n >> k;
	for(int i = 1 ; i < n ; ++ i){
		int x , y;
		cin >> x >> y;
		add(x , y);
		add(y , x);
	}
	dfs(1 , 0);
	int ans = 0;
	for(int i = 1 ; i <= n ; ++ i)
		for(int j = 1 ; j <= k + 1 ; ++ j)
			ans = max(ans , f[i][j]);
	cout << n - ans << endl;
	return 0;
}

Measured memory_bytes: 16256
#include<iostream>
#include<string>
using namespace std;
string a[1000000];
int b[1000000];
int main(){
	int n;
	cin>>n;
	string z;
	int y;
	int top=0;
	for(int i=0;i<n;i++){
		cin>>z>>y;
		bool t=true;
		for(int j=0;j<top;j++){
			if(a[j]==z){
				b[j]+=y;
				t=false;
			}
		}
		if(t==true){
			a[top]=z;
			b[top]=y;
			top++;
		}
	}
	for(int i=0;i<top;i++){
		for(int j=top-1;j>i;j--){
			if(a[j].size()<a[j-1].size()){
				string tmps=a[j];
				a[j]=a[j-1];
				a[j-1]=tmps;
				int tmp=b[j];
				b[j]=b[j-1];
				b[j-1]=tmp;
			}
			if(a[j].size()==a[j-1].size()){
				int set=0;
				while(true){
					if(a[j][set]!=a[j-1][set])
						break;
					set++;
				}
				if(a[j][set]<a[j-1][set]){
					string tmps=a[j];
				    a[j]=a[j-1];
				    a[j-1]=tmps;
				    int tmp=b[j];
				    b[j]=b[j-1];
				    b[j-1]=tmp;
				}
			}
		}
	}
	for(int i=0;i<top;i++)
		cout<<a[i]<<" "<<b[i]<<endl;
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define INF             1e9
#define INFL            8e18
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cerr << "\n";
#define HOISE           cerr << "hoise " << __LINE__ << "\n"
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << "\n"
#define READ            freopen("D:\\moidda CPP\\alu.txt", "r", stdin)
#define WRITE           freopen("D:\\moidda CPP\\vorta.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MASK(x)         for(int i = 0; i < 8; i++){ if(x&(1<<i)){ cout << i << " "; } } cout << endl;

typedef long long ll;
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pff;

const int MAX = 3e5 + 2;
const int MAXLOG = log2(MAX) + 2;
const int MAXN = 1e6 + 2;
const int MOD = 998244353;
const double PY = acos(-1.0);
const double EPS = 1E-9;


int32_t main()
{
//#ifndef ONLINE_JUDGE
//    READ;
//    WRITE;
//#endif

    FASTIO;

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

    ll x = 1LL*(n*(n-1))/2 + 1LL*(m*(m-1))/2;
    cout << x;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int N; scanf("%d", &N);
	int B[200]; B[0] = 1000000; B[N] = 1000000;
	for (int i = 1; i <= N-1; i++){
		scanf("%d", B + i);
	}

	int ret = 0;
	for (int i = 0; i < N; i++){
		ret += min(B[i], B[i + 1]);
	}

	printf("%d", ret);

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);

    if(a<b){
        printf("a < b\n");
    }
    if(a>b){
        printf("a > b\n");
    }
    if(a==b){
        printf("a == b\n");
    }

    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>

int selectionSort(std::vector<int>* a, int n) {
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int minj = i;
    for (int j = i; j < n; ++j) {
      if (a->at(j) < a->at(minj)) 
        minj = j;
    }
    if (i != minj) {
      std::swap(a->at(i), a->at(minj));
      ++cnt;
    }
  }
  return cnt;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    as.push_back(a);
  }
  int ans = selectionSort(&as, n);
  for (int i = 0; i < n; ++i) {
    std::cout << as[i];
    if (i == n -1)
      std::cout << std::endl;
    else
      std::cout << " ";
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 3060
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  int a,b,c;cin >> a >> b >> c;
  if(a == b){
    cout << c << endl;
  }else{
    if(a == c){
      cout << b << endl;
    }else{
      cout << a << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
//????????????????????°???????????????????????°??????
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		
		//??\?????????????????°
		
		StringBuilder sb = new StringBuilder();
		while(true) {
			
			String[] str = br.readLine().split(" ");
			
			int limitNum = Integer.parseInt(str[0]);
			int sumNum = Integer.parseInt(str[1]);
			
			if(limitNum == 0 && sumNum==0) {
				break;
			}
			
			int cnt = 0;
			
			for(int i=1; i<=limitNum-2; i++) {
				for(int j=i+1; j<=limitNum-1; j++) {
					for(int k=j+1; k<=limitNum; k++) {
						if(i+j+k == sumNum) {
							cnt++;
						}
					}
				}
			}
			sb.append(cnt+"\n");
		}
		System.out.print(sb.toString());
	}


}

Measured memory_bytes: 25192
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int H = sc.nextInt();
        int[] katanaSwing = new int[N];
        int[] katanaThrow = new int[N];
        
        for(int n=0;n<N;n++){
        	katanaSwing[n] = sc.nextInt();
        	katanaThrow[n] = sc.nextInt();
        }
        Arrays.sort(katanaSwing);
        Arrays.sort(katanaThrow);
        
        int attack = 0;
        int bestKatana = N-1;
        while(H>0){
        	if(bestKatana>=0 && katanaThrow[bestKatana]>katanaSwing[N-1]){
        		H -= katanaThrow[bestKatana];
        		attack++;
        		bestKatana--;
        	}else{
        		attack += (H/katanaSwing[N-1]) + (H%katanaSwing[N-1]==0 ? 0 : 1);
        		H=0;
        	}
        }
        System.out.println(attack);
    }
}

Measured memory_bytes: 84092
import sys

inf = float('inf')

n, C, *stc = map(int, sys.stdin.read().split())
stc = list(zip(*[iter(stc)] * 3))

def main():
    res = [(-0.5, None) for _ in range(C)] # C台あれば確実に足りる
    stc.sort()

    for s, t, c in stc:
        c -= 1
        interval = inf
        for i in range(C):
            last, prev = res[i]
            if prev != c:
                last += 0.5

            if last <= s:
                if s - last < interval:
                    interval = s - last
                    to_use = i
        res[to_use] = (t, c)
    
    ans = 0
    for i in range(C):
        if res[i][0] != -0.5:
            ans += 1
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

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


/* Raiyan Noory Rady,CSE'17,RUET
Email:raiyannooryrady@gmail.com
Smile->Desire->Unity->Effort->Struggle->Success->Again smile :)
*/

#define ll long long int
#define pf push_front
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define sortarr(a) sort(a,a+n)
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define prf printf
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define forl(n) for(i=0;i<n;i++)
/*STL library functions

sort(first_iterator, last_iterator) � To sort the given vector.

reverse(first_iterator, last_iterator) � To reverse a vector.

*max_element (first_iterator, last_iterator) � To find the maximum element of a vector.

*min_element (first_iterator, last_iterator) � To find the minimum element of a vector.

accumulate(first_iterator, last_iterator, initial value of sum) � Does the summation of vector elements

count(first_iterator, last_iterator,x) � To count the occurrences of x in vector.

find(first_iterator, last_iterator, x) � Points to last address of vector ((name_of_vector).end())
 if element is not present in vector.

binary_search(first_iterator, last_iterator, x) � Tests whether x exists in sorted vector or not.

lower_bound(first_iterator, last_iterator, x) � returns an iterator pointing to the first element in the range [first,last)
which has a value not less than �x�.

upper_bound(first_iterator, last_iterator, x) � returns an iterator pointing to the first element in the range [first,last)
 which has a value greater than �x�.

arr.erase(position to be deleted) � This erases selected element in vector and shifts and resizes the vector elements accordingly.

arr.erase(unique(arr.begin(),arr.end()),arr.end()) � This erases the duplicate occurrences in sorted vector in a single line.

distance(first_iterator,desired_position) � It returns the distance of desired position from the first iterator.
This function is very useful while finding the index.

next_permutation(first_iterator, last_iterator) � This modified the vector to its next permutation.

prev_permutation(first_iterator, last_iterator) � This modified the vector to its previous permutation.
*/

using namespace std;

int main()
{
   ll a,b,lcm,gcd;
    cin>>a>>b;
    gcd=__gcd(a,b);
    cout<<(a*b)/gcd<<endl;


    return 0;
}






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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int MOD=1e9+7;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, ans=1;
	stack<char> S;
	string s;
	cin>>N>>s;
	for(auto c: s) {
		if(S.empty()) {
			if(c=='W') {
				cout<<"0\n";
				return 0;
			}
			S.push(c);
		}
		else if(S.top()!=c) S.push(c);
		else {
			ans=(1LL*ans*S.size())%MOD;
			S.pop();
		}
	}
	for(int i=1;i<=N;i++) ans=(1LL*ans*i)%MOD;
	if(S.size()) ans=0;
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 720
#include <stdio.h>

int main()
{
  int N,S,i,count=0;
  scanf("%d",&N);
  for(i=0;7*i<=N;i++)
    {
      S=N-i*7;
      if(S%4==0)
        count++;
    }
  if(count==0)
    printf("No\n");
  else
    printf("Yes\n");
  return 0;
}


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

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

    long long x = A * B;

    if(A < B) {
        int tmp = A;
        A = B;
        B = tmp;
    }

    long long r = A % B;
    while(r != 0) {
        A = B;
        B = r;
        r = A % B;
    }

    cout << x / B << endl;
}


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

int main(void) {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll ans;
  if (x / d > k) {
    ans = x - d * k;
  } else {
    ll y = x / d;
    k -= y;
    x -= y * d;
    if (k % 2 == 1) x = abs(x - d);
    ans = x;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    vector<int> vec;
    int h;
    for(int i = 0; i<n; i++){
        cin >> h;
        vec.push_back(h);
    }
    int count = 1;
    for(int i=1; i<n; i++){
        bool flag = true;
        for(int j=i-1;j>=0;j--){
            if(vec[j] > vec[i] ){
                flag = false;
            }
        }
        if(flag == true){
            count++;
        }
    }
    cout << count;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = new int[n];
			IntStream.range(0, n).forEach(i -> a[i] = scanner.nextInt());
			Arrays.sort(a);
			// 最大値を取得する
			int max = a[n - 1];
			// 最大値/2に一番近い値を取得する
			int[] b = new int[n - 1];
			IntStream.range(0, n - 1).forEach(i -> b[i] = Math.min(a[i], max - a[i]));
			Arrays.sort(b);
			int next = b[n - 2];
			System.out.println(max + " " + ((Arrays.binarySearch(a, next) >= 0) ? next : (max - next)));
		}
	}
}


Measured memory_bytes: 52716
#coding: utf-8

import math

while True:
    n = int(input())
    if n == 0:
        exit()
    else:
        scores = list(map(int, input().split()))
        avrscr = sum(scores) / n
        sd = 0
        for i in scores:
            sd += (i - avrscr) ** 2
        sd /= n
        sd = math.sqrt(sd)
        print(sd)


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

int N;
string str0, str1;

int MIN, MAX;

int main(void) {

	cin >> N;
	int pos = (N + 1) / 2;
	if (pos % 2 == 0) { pos--;
	}
	cout << 0 << endl;
	cin >> str0; if (str0 == "Vacant") { return 0; }

	cout << pos<< endl;
	cin >> str1; if (str1 == "Vacant") { return 0; }

	if (str0 == str1) { MIN = 0; MAX = pos; }
	else { MIN = pos; MAX = N; str0 = str1; }

	for(int i=1;i<=20;i++){
		int med = (MIN + MAX) / 2;
		if ((med - MIN) % 2 == 0) { med--; }
		cout << med << endl;
		string tmp;
		cin >> tmp; if (tmp == "Vacant") { return 0; }

		if (str0 == tmp) { MAX = med; str1 = tmp; }
		else { MIN = med; str0 = tmp; }
	}


	return 0;
}

Measured memory_bytes: 852
#include <stdio.h>
 
int main(void){
  int n, d, x, i, j;
  scanf("%d", &n);
  scanf("%d%d", &d, &x);
  int a[n];
  int ans = x;
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  for(i = 0; i < n; i++){
    for(j = 0; d >= a[i] * j + 1; j++){
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

int main(void){
    long long int number;    cin >> number;
    long long int sum = 0;
    for(int i=1; i <= number; i++){
        if(i%3==0 || i%5==0){
            continue;
        }
        sum+=i;
    }
    cout << sum;
  return 0;
}


Measured memory_bytes: 3608
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

vector<pair<int,int> > a[110000];

int d[110000][2];

int main()
{
  int i,j,m,n,x,y,z,b1;
  vector<int> q;
  _int64 tmp,chu,mi,ma,fixed;
  scanf("%d%d",&n,&m);
  for (i=0;i<n;i++)
    a[i].clear();
  for (i=0;i<m;i++)
  {
    scanf("%d%d%d",&x,&y,&z);
    x--;y--;
    a[x].push_back(make_pair(y,z));
    a[y].push_back(make_pair(x,z));
  }
  memset(d,0,sizeof(d));
  d[0][0]=1;d[0][1]=0;
  q.clear();
  q.push_back(0);
  fixed=(1LL<<60);
  b1=1;
  for (i=0;i<q.size();i++)
  {
    x=q[i];
    for (j=0;j<a[x].size();j++)
    {
      y=a[x][j].first;
      if (d[y][0]==0)
      {
        d[y][0]=-d[x][0];
        d[y][1]=a[x][j].second-d[x][1];
        q.push_back(y);
      }
      else
      {
        if (d[y][0]==d[x][0])
        {
          tmp=a[x][j].second;
          tmp=tmp-d[y][1]-d[x][1];
          chu=d[y][0]+d[x][0];
          if (tmp%2!=0) b1=0;
          else
          {
            if (fixed==(1LL<<60)) fixed=tmp/chu;
            else if (fixed!=tmp/chu) b1=0;
          }
          
        }
        else
        {
          if (d[y][1]+d[x][1]!=a[x][j].second) b1=0;
        }
      }
    }
  }
  if (b1==0)
  {
    printf("0\n");
    return 0;
  }
  if (fixed!=(1LL<<60))
  {
    for (i=0;i<n;i++)
    {
      tmp=fixed*d[i][0]+d[i][1];
      if (tmp<=0)
      {
        printf("0\n");
        return 0;
      }
    }
    printf("1\n");
    return 0;
  }
  mi=1;ma=(1LL<<60);
  for (i=0;i<n;i++)
  {
    if (d[i][0]==1)
    {
      if (1-d[i][1]>mi) mi=1-d[i][1];
    }
    else
    {
      if (d[i][1]-1<ma) ma=d[i][1]-1;
    }
    
  }
  //cout<<mi<<" "<<ma<<endl;
  if (ma>=mi)
    printf("%lld\n",ma-mi+1);
  else printf("0\n");
  return 0;
}

Measured memory_bytes: 8444