akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

template<typename T>
class Union_Find {
private:
  T n;
  vector<T> parent;

public:
  Union_Find(T v){
    n=v;
    parent.resize(n,-1);
  }

  T root(T v){
    if(parent[v]<0)return v;
    return parent[v]=root(parent[v]);
  }
  T size(T v){
    return -parent[root(v)];
  }
  bool connect(T a,T b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(size(a)<size(b)) swap(a,b);
    parent[a]+=parent[b];
    parent[b]=a;
    return true;
  }
  bool same(T a,T b){
    return root(a)==root(b);
  }

};

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n;
  cin>>n;
  vector<ll> a(n),b(n),c(n-1);
  cin>>a>>b>>c;

  ll ans=0;
  rep(i,n){
    a[i]--;
    ans+=b[a[i]];
    if(i-1>=0){
      if(a[i-1]+1==a[i]){
        ans+=c[ a[i-1] ];
      }
    }
  }
  cout<<(ans)<<endl;


  
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int main()
{
	char in[205];
	char ans[] = "CODEFESTIVAL2016";
	while(~scanf("%s",in))
	{
		int aa=0;
		REP(i,0,15) if(ans[i]!=in[i]) aa++;
		printf("%d\n",aa);
	}
	return 0;
}



Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std ;
int n, m, num, Max, Max1, ans;
int a[100010];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=n;i;i--)
	{
		Max=max(a[i],Max);
		num=max(Max-a[i],num);
	}
    for(int i=n;i;i--)
	{
		Max1=max(a[i],Max1);
		if(Max1-a[i]==num)ans++;
	}
    cout<<ans<<endl;
    return 0 ;
}

Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, k) = get!(usize, usize);
    println!("{}", n - k + 1);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

const int N = 1e5 + 7;

vector<int> jobs[N];

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

	int n, m;
	cin >> n >> m;
	while (n--) {
		int a, b;
		cin >> a >> b;
		int st = m - a;
		if (st >= 0) {
			jobs[st].push_back(b);
		}
	}
	int ans = 0;
	multiset<int> hv;
	for (int i = m - 1; i >= 0; i--) {
		for (auto t : jobs[i]) {
			hv.insert(t);
		}
		if (!hv.empty()) {
			ans += *hv.rbegin();
			hv.erase(--hv.end());
		}
	} 
	cout << ans << endl;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    string s;
    cin >> s;
    int n = s.size();
    int t = count(s.begin(), s.end(), '0');
    cout << min(t, n - t) * 2 << endl;
}


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

Measured memory_bytes: 632
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;
#define max(a,b)  (((a) > (b)) ? (a) : (b))
#define min(a,b)  (((a) < (b)) ? (a) : (b))
typedef long long ll;
int main()
{
    ll a,b,k;
    scanf("%lld %lld",&a,&b); 
    if(a==0||b==0)
    {
        printf("IMPOSSIBLE\n");
        return 0;
    }
    if((a+b)%2==0&&a!=0&&b!=0)
        printf("%lld\n",(a+b)/2);
    if((a+b)%2!=0&&a!=0&&b!=0)
        printf("IMPOSSIBLE\n\n");
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B,i,Atmp,Btmp;
    int a[100000]={0},b[100000]={0},c[100000]={0};
    double n=1;
    scanf("%d %d",&A,&B);
    Atmp=A;
    Btmp=B;
    for(i=2;i<100000;i++){
        if(A%i==0){
            a[i]+=1;
            A=A/i;
            i--;
        }
    }
    for(i=2;i<100000;i++){
        if(B%i==0){
            b[i]+=1;
            B=B/i;
            i--;
        }
    }
    for(i=2;i<100000;i++){
        if(a[i]!=0 && b[i]!=0){
            a[i]--;
            b[i]--;
            c[i]++;
            i--;
        }
    }
    for(i=2;i<100000;i++){
        if(c[i]!=0){
            n*=i;
            c[i]--;
            i--;
        }
    }
    //printf("%d\n",n);
    Atmp=Atmp/n;
    Btmp=Btmp/n;
    n=n*Atmp*Btmp;
    printf("%.0f\n",n);
    return 0;
}

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

using namespace std;
#define deb(x) cout << #x << ": " << x << endl
#define fo(i, n) for (ll i = 0; i < n; i++)
#define fkn(i, k, n) for (i = k; i < n; i++)
#define ll long long
#define F first;
#define S second;
#define PB(x) push_back(x);
#define MP(x,y) make_pair(x,y);
typedef vector<ll> vll;

bool powerOfTwo(ll x)
{
    return !(x & (x - 1));
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int s,w;
    cin>>s>>w;
    s > w ? cout << "safe" : cout<<"unsafe";

}



Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>
using namespace std;

const int MOD = 1e9 + 7;

long long mod_pow(int a, int n) {
    long long r = 1;
    for (int i = 0; i < n; i++) {
        r = (r * a) % MOD;
    }
    return r;
}

int main() {
    long long N; cin >> N;
    vector<long long> As(N);
    vector<long long> Keta(63, 0);

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

        stringstream ss;
        ss << bitset<63>(As[i]);
        string s = ss.str();

        reverse(s.begin(), s.end());
        for (int j = 0; j < 63; j++) {
            if (s[j] - '0' == 1) Keta[j]++;
        }
    }
    
    long long ans = 0;
    for (int i = 0; i < 63; i++) {
        ans = (ans + ((mod_pow(2, i) * (N - Keta[i]) % MOD) * Keta[i] % MOD)) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<iostream>

using namespace std;
int main(){
    int s;
    cin>>s;
    if(s/100>0 && s/100 < 13 && s%100 > 0 && s%100 <13 ){
        cout <<"AMBIGUOUS"<<endl;
    }
    else if(s/100>0 && s/100 < 13 ){
        cout << "MMYY" << endl;
        }else if(s%100 > 0 && s%100 <13){
            cout << "YYMM" <<endl;
        }else{
            cout << "NA" <<endl;
        }
    }

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ABC = ReadSplitInt().ToList();
            ABC.Remove(ABC.Max());
            Println(ABC[0] * ABC[1] / 2);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a * b / Gcd(a, b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13280
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

long long iceil(long long a, long long b){
	return a / b + (a % b == 0 ? 0 : 1);
}

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

	if(k % 2){
		long long a = n / k;
		cout << a * a * a << endl;
	}else{
		long long a = n / k;
		long long b = (n - k / 2) / k + 1;
		if(n < k / 2) b = 0;
		cout << a * a * a + b * b * b << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	//freopen("in.txt","r",stdin);
	int n,m;
	while(cin>>n>>m){
		char c[100];
        int s[100];
        memset(c,0,sizeof c);
        memset(s,0,sizeof s);

        for(int i = 0 ; i < m ; i++){
            cin>>s[i]>>c[i];
            s[i]--;
        }
            int mul = pow(10,n);
            int mul2;
            if(n==1)
                mul2 = pow(10,n-1)-1;
            else
                mul2 = pow(10,n-1);
            bool sw2 = false;
            for(int i = mul2 ; i < mul ; i++){
                string cad = to_string(i);
                bool sw = true;
                for(int j = 0 ; j < m ; j++){
                    if(cad[s[j]]!=c[j]){
                      sw = false;
                    } 
                }
                if(sw){
                    cout<<cad<<"\n";
                    sw2= true;
                    break;
                }
            }
            if(!sw2) cout<<"-1\n";
        
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {

        void solve(InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            String S = in.next();
            
            int chunks = 1;
            char cur = S.charAt(0);
            for (char c : S.toCharArray()) {
                if (cur != c) chunks++;
                cur = c;
            }
            
            if (chunks/2 <= K) {
                out.println(N - 1);
            } else {
                out.println(N - chunks + 2*K);
            }
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


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

int i;
double n, k, t, u, v, l, d, p = 0, tmp, rd = 0, wd = 0;
int main(){
        map<int, int> mp;
        cin >> n >> k >> t >> u >> v >> l;
        for (i = 0; i < n; i++){
                cin >> d;
                mp[d]++;
        }
        d = 0;
        while(d < l){
                if (mp[d] == 0){
                        wd++;
                        d++;
                        continue;
                }
                tmp = v * t;
                while (tmp > 0 && d < l){
                        d++;
                        tmp--;
                        rd++;
                        if (mp[d] > 0 && p < k) p++;
                        else if(mp[d] > 0 && p == k){
                                tmp = v * t;
                        }
                        if (p > 0 && tmp == 0){
                                p--;
                                tmp = v * t;
                        }
                }
        }
        //cout << wd << " " << rd << endl;//歩いた距離と走った距離をみる
        cout << fixed << setprecision(9) << (wd / u) + (rd / v) << endl;
        return 0;
}



Measured memory_bytes: 3760
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int w, n, a, b, num[31], store;
    
    cin >> w;
    cin >> n;
    
    for(int i = 1; i <= w; i++){
        num[i] = i;
    }
    
    for(int i = 1; i <= n; i++){
        scanf("%d, %d", &a, &b);
        swap(num[a], num[b]);
    }
    for(int i = 1; i <= w; i++){
        cout << num[i] << endl;
    }
}



Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <algorithm>
struct team{
  int num;
  int time;
};

bool ascending_time_team(const team& _t1,const team& _t2){
  return _t1.time<_t2.time;
}
int main(){
  int n;
  while(std::cin>>n){
    if(!n)return 0;
    std::vector<team> v;
    /*
    //Å¬AñÔèAu[r[Ì`[ÔAÔðÛ·éB
    int fteam=0,fsec=0,steam=0,ssec=0,bteam=0,bsec=0;
    */
    for(int i=0;i<n;i++){
    int c1,m[4],s[4];
    std::cin>>c1>>m[0]>>s[0]>>m[1]>>s[1]>>m[2]>>s[2]>>m[3]>>s[3];
    int tsec=0;//êIÉg¢Ü·B
    for(int i=0;i<4;i++){
      tsec+=m[i]*60+s[i];
    }
    team t;
    t.num=c1;
    t.time=tsec;
    v.push_back(t);
    }
    std::sort(v.begin(),v.end(),ascending_time_team);
    std::cout<<v[0].num<<std::endl<<v[1].num<<std::endl<<v[v.size()-2].num<<std::endl;
  }
}
/*
Sample Input
8
34001 3 20 3 8 6 27 2 25
20941 3 5 2 41 7 19 2 42
90585 4 8 3 12 6 46 2 34
92201 3 28 2 47 6 37 2 58
10001 3 50 2 42 7 12 2 54
63812 4 11 3 11 6 53 2 22
54092 3 33 2 54 6 18 2 19
25012 3 44 2 58 6 45 2 46
4
1 3 23 1 23 1 34 4 44
2 5 12 2 12 3 41 2 29
3 5 24 1 24 2 0 3 35
4 4 49 2 22 4 41 4 23
0
Output for the Sample Input
54092
34001
10001
1
3
2
*/

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        long x = sc.nextLong();

        long value = 100;
        long elapsedYear = 0L;

        while(value < x){  
            value = value + value / 100;
            elapsedYear++;
        }
        System.out.println(elapsedYear);
    }
}

Measured memory_bytes: 36028
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
#define ll long long
#define P pair<int,int>

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

    int ans = 1e9;
    for(int i = 1; i < n; i++){
        int j = n - i;

        string a = to_string(i);
        string b = to_string(j);

        int sum = 0;
        for(auto k : a) {
            int x = k - '0';
            sum += x;
        }
        for(auto k : b) {
            int x = k - '0';
            sum += x;
        }
        ans = min(ans,sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

p = inpl()
p.sort()
print(p[0]+p[1])

Measured memory_bytes: 38764
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long dp[200000] = {};
int main() {
	int n;
	cin >> n;
	vector<long long> input;
	long long ans = LONG_INF;
	REP(i, n) {
		long long a;
		cin >> a;
		input.push_back(a);
	}
	REP(tea, 2) {
		for (int q = 0; q < 4; ++q) {
			for (int i = 0; i < input.size(); ++i) {
				dp[i] = input[i];
			}
			long long geko = q;
			dp[0] -= geko;
			for (int i = 0; i < input.size()-1; ++i) {
				while (dp[i] > 0) {
					dp[i]--;
					dp[i + 1]--;
					geko += 2;
				}
			}
			ans = min(ans, geko + max(dp[input.size() - 1], 0LL));
		}
		reverse(input.begin(), input.end());
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3288
n, k = map(int, input().split())
v = list(map(int, input().split()))
reverse_v = v[::-1]
lst = [0] * (k + 1)
left = [[]]
right = [[]]
for i in range(1, n+1):
  left.append(v[:i])
  right.append(reverse_v[:i])

for cnt in range(1, k+1):
  rest = k - cnt
  total = 0
  if cnt <= n:
    for j in range(cnt+1):
      lst_j = left[j] + right[cnt-j]
      lst_j.sort()
      l = cnt
      for idx in range(cnt):
        if lst_j[idx] >= 0:
          l = idx
          break
      if l == cnt:
        value = 0
      else:
        flg = min(l, rest)
        value = sum(lst_j[flg:])
      if value > total:
        total = value
    lst[cnt] = total

ans = max(lst)
print(ans)

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> s;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s.push_back(make_pair(a, i+1));
	}
	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++) {
		pair<int, int> a;
		a = s[i];
		cout << a.second << " ";
	}
}

Measured memory_bytes: 1780
#include<stdio.h>
#include<stdlib.h>

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int *dp=(int *)calloc(m+1,sizeof(int));
  while(n--){
    int v,w;
    scanf("%d%d",&v,&w);
    for(int i=w;i<=m;i++) if(dp[i]<dp[i-w]+v) dp[i]=dp[i-w]+v;
  }
  printf("%d\n",dp[m]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 2100
def prepare(n, MOD):
 
    # n! の計算
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= MOD
    fn = f
     
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return fn, invs
  
mod = int(1e9+7)
X, Y = map(int, input().split())
if (X+Y)%3 != 0:
    print(0)
else:
    total_steps = (X+Y)//3
    dif_steps = abs(X-Y)
    if dif_steps > total_steps:
        print(0)
    else:
        up_steps = (total_steps - dif_steps)//2
        fn, invs = prepare(total_steps, mod)
        print((fn*invs[up_steps]*invs[total_steps-up_steps])%mod)

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

int n, A[200005];

signed main(){
  
  cin >> n;
  
  for(int i=0;i<n;i++) cin >> A[i];

  sort( A, A + n, greater<int>() );
  
  int ans = A[0];

  int cnt = n-2;
  
  for(int i=1;i<n;i++){
    for(int j=0;j<2;j++){
      if( cnt == 0 ) continue;
      cnt--;
      ans += A[i];
    }
  }

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


Measured memory_bytes: 5148
/*
 * Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$
**/

#include <bits/stdc++.h>
#include <fstream>
#include <iomanip>
#include <stdio.h>
#include <cmath>

using namespace std;

//typedef
typedef string STR;
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef priority_queue<int> PQI;
typedef vector<LL> VLL;
typedef vector<ULL> VULL;
typedef vector<STR> VS;
typedef vector<char> VC;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<STR,int> PSI;
typedef pair<int,STR> PIS;
typedef vector<PII> VII;
typedef map<int,int> MII;
typedef map<LL,LL> MLL;
typedef map<STR,int> MSI;
typedef map<char,int> MCI;
typedef map<int,STR> MIS;
typedef set<STR> SS;
typedef set<int> SI;
typedef set<LL> SLL;

//symbolic const
#define MOD 1000000007
#define MAXN 1e9
#define SIZE 10000

//STL keywords
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
#define all(v) v.begin(), v.end()

//functions
#define dec(n) cout<<fixed<<setprecision(n);
#define f(i, n)   for(LL i=0; i<n; i++)
#define fa(i,a,n) for(LL i=a; i<n; i++)

//IO
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test int t;cin>>t;while(t--){solve();}

LL maxLL(LL a, LL b){return (a>b?a:b);}
LL minLL(LL a, LL b){return (a<b?a:b);}

void solve() {
 LL n; cin>>n;
 VLL h(n); f(i, n) cin>>h[i];
 VLL dp(n,0);
 dp[1]=llabs(h[1]-h[0]);
 for(LL i=2; i<n; i++){
     dp[i]=minLL(dp[i-1]+llabs(h[i-1]-h[i]), dp[i-2]+llabs(h[i-2]-h[i]));
 }
 cout<<dp[n-1];
}

int main() {
    sync;
    //test;
    solve();
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int N;
    cin >> N;
    vector<int> L(N);

    for(int i = 0; i < N; i++){
        cin >> L.at(i);
    }

    int count = 0;

    for(int i = 0; i < N-2; i++){
        for(int j = i; j < N-1; j++){
            for(int k = j; k < N; k++){
                
                if(L.at(i) != L.at(j) && L.at(i) != L.at(k) && L.at(j) != L.at(k)){
                    if(L.at(i) + L.at(j) > L.at(k) && L.at(i) + L.at(k) > L.at(j) && L.at(j) + L.at(k) > L.at(i)){
                        count++;
                    }
                }

            }
        }
    }    

    cout << count << endl;

}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  int n,a[100];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n-1;i++)cout<<a[i]<<' ';
  cout<<a[n-1]<<endl;
  for(int i=1;i<n;i++){
    int tmp=a[i];
    int j=i-1;
    while(j>=0&&a[j]>tmp){
      a[j+1]=a[j];
      a[j]=tmp;
      j--;
    }
    for(int i=0;i<n-1;i++)cout<<a[i]<<' ';
    cout<<a[n-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
using System;
using System.Linq;

class ITP1
{
    static void Main()
    {
        int[, ,] x = new int[4, 3, 10];
        var a = Console.ReadLine();
        int n = int.Parse(a);
        int b, c, d, e;
        for (int i = 0; i < n; i++)
        {
            a = Console.ReadLine();
            b = int.Parse(a.Split(' ')[0]);
            c = int.Parse(a.Split(' ')[1]);
            d = int.Parse(a.Split(' ')[2]);
            e = int.Parse(a.Split(' ')[3]);

        x[b - 1, c - 1, d - 1] += e;
    }


        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                for (int l = 0; l < 10; l++)
                {
                    Console.Write(" {0}", x[j, k, l]);
                }
                Console.Write('\n');
            }
            if (j < 3)
                Console.WriteLine("####################");

        }
    }
}

Measured memory_bytes: 5728
#include <stdio.h>

int main(int argc, char **argv)
{
	int n, m, s = 0, t = 0, c = 0;
	float a;
	
	while(scanf("%d,%d", &n, &m) != EOF){
		s += n*m;
		t += m;
		c++;
	}
	
	a = (float)t/c;
	t /= c;
	
	if((a-t) >= 0.5){
		t++;
	}
	
	printf("%d\n%d\n", s, t);
	
	return 0;
}

Measured memory_bytes: 0
h, w = map(int, input().split())
l = []
for i in range(h):
  a = str(input())
  if a == '.'*w:
    continue
  l.append(a)

skip = []
for i in range(w):
  for j in range(len(l)):
    if l[j][i] == '#':
      break
  else:
    skip.append(i)

skip = set(skip)
l_ = [0]*len(l)
for i in range(len(l)):
  temp = ''
  for j in range(w):
    if j not in skip:
      temp += l[i][j]
  l_[i] = temp
  
for i in range(len(l_)):
  print(l_[i])

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=5010,M=210;
int read(){
	int x=0;char ch=getchar();
	while (ch>'9'||ch<'0') ch=getchar();
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,m,b[N][M];
ll d[N],v[N][N];
int root,fa[N],lc[N],rc[N],a[N],L[N],R[N];
void add(int l,int r,int d){
	v[l][l]+=d;
	v[l][r+1]-=d;
	v[r+1][l]-=d;
	v[r+1][r+1]+=d;
}
void dfs(int x){
	L[x]=R[x]=x;
	if (lc[x]) dfs(lc[x]),L[x]=L[lc[x]];
	if (rc[x]) dfs(rc[x]),R[x]=R[rc[x]];
	add(L[x],R[x],a[x]-a[fa[x]]);
}
void work(int x){
	for (int i=1;i<=n;i++) a[i]=b[i][x];
	for (int i=1;i<=n;i++){
		int f=i-1,last=0;
		while (f&&a[f]<a[i]) last=f,f=fa[f];
		fa[i]=f;lc[i]=last;rc[i]=0;
		if (f) rc[f]=i;else root=i;
		if (last) fa[last]=i;
	}
	dfs(root);
}
int main()
{
	n=read();m=read();
	for (int i=1;i<n;i++) d[i+1]=d[i]+read();
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
		b[i][j]=read();
	for (int i=1;i<=m;i++) work(i);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++)
		v[i][j]+=v[i][j-1]+v[i-1][j]-v[i-1][j-1];
	ll ans=0;
	for (int l=1;l<=n;l++)
	for (int r=l;r<=n;r++)
		ans=max(ans,v[l][r]-d[r]+d[l]);
	printf("%lld\n",ans);
	return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

vector<int> p[210000];
ll dp[210000];

void add(ll &a, ll b) {
    a += b;
    if (a >= mod) a -= mod;
}

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

    int N; cin >> N;
    vector<int> c(N);
    rep(i, N) cin >> c[i];

    rep(i, 210000) p[i].clear();
    rep(i, N) p[c[i]].pb(i);

    dp[0] = 1;
    REPS(i, 1, N) {
        add(dp[i], dp[i-1]);
        int color = c[i-1];
        int it = lower_bound(all(p[color]), i-1) - p[color].begin();
        if (it > 0) {
            int j = p[color][it-1]; // c[j] = c[i]となるj
            if ((i - 1) - j > 1) {
                add(dp[i], dp[j+1]);
            }
        }
    }
    cout << dp[N] << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

int adj[10][10];
int visited[10];

void solve()
{
    int N;
    cin >> N;
    int M;
    cin >> M;

    REP0(i, M)
    {
        int a, b;
        cin >> a >> b;
        adj[a][b]++;
        adj[b][a]++;
    }

    vector<int> perm;
    FOR(i, 2, N + 1)
    { // 1が始点なのは固定
        perm.push_back(i);
    }

    int ans = 0;

    do
    {
        if (adj[1][perm[0]] != 1)
            continue;
        bool path = true;
        REP1(i, N - 2)
        {
            path = path and adj[perm[i - 1]][perm[i]];
        }
        if (path)
            ans++;
    } while (next_permutation(perm.begin(), perm.end()));

    std::cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
answers = Array.new

while true
exp = gets.split(" ")
break if exp[1] == "?"

answer = exp[0].to_i + exp[2].to_i if exp[1] == "+"
answer = exp[0].to_i - exp[2].to_i if exp[1] == "-"
answer = exp[0].to_i * exp[2].to_i if exp[1] == "*"
answer = exp[0].to_i / exp[2].to_i if exp[1] == "/"

answers.push answer

end

answers.each{|ans|
puts ans
}

Measured memory_bytes: 8648
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

struct Pair {
  std::size_t b;
  std::size_t c;
};

int main() {
  std::size_t n, m;
  std::cin >> n >> m;

  std::vector<std::size_t> a(n);
  for (std::size_t i = 0; i < n; ++i) std::cin >> a[i];

  std::sort(a.begin(), a.end());

  std::vector<Pair> pairs(m);
  for (auto&& pair : pairs) std::cin >> pair.b >> pair.c;
  std::sort(pairs.begin(), pairs.end(),
            [](const auto& p1, const auto& p2) { return p1.c > p2.c; });

  std::size_t k = 0;
  for (auto&& pair : pairs) {
    for (std::size_t j = 0; j < pair.b; ++j) {
      if (a[k] < pair.c)
        a[k++] = pair.c;
      else
        break;
    }
  }

  const auto sum = std::accumulate(a.begin(), a.end(), 0ull);
  std::cout << sum << std::endl;
}


Measured memory_bytes: 2560
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define PI 3.14159265359

bool memo[100010];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    memset(memo, 0, sizeof(memo));
    int n, k;
    cin >> n >> k;
    vi A(n);
    for (int i = 0; i < n; i++) cin >> A[i];
    sort(A.begin(), A.end());
    for (int i = 0; i <= k; i++) {
        for (auto u : A) {
            if (i + u <= k) {
                memo[i + u] |= !memo[i];
            }
        }
    }
    if (memo[k]) cout << "First" << endl;
    else cout << "Second" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main()
{
    int n; cin >> n;
    int ans = 0;
    int mh = 0;
    rep(i,n) {
        int h; cin >> h;
        if (h >= mh) {
            ans++;
            mh = h;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3580
#include <cstdio>
#include <utility>

using namespace std;

int parent( int i ){

    return i/2;

}

int left( int i ){

    return 2*i;

}

int right( int i ){

    return 2*i + 1 ;

}


void maxHeapify( int A[], int i, int n){

    int l, r, largest;

    l = left(i);
    r = right(i);

    //左の子、自分、右の子のうち最大の値を持つものを選ぶ

    if( l <= n &&  A[l] > A[i] ){

        largest = l;

    } else {

        largest = i;

    }

    if( r <= n && A[r] > A[largest] ){

        largest = r;

    }

    if( largest != i ){

        swap( A[i], A[largest] );

        maxHeapify( A, largest, n );

    }

}

void buildMaxHeap( int A[], int n){

    int i;

    for( i = n / 2 ; i > 0; i-- ){

        maxHeapify( A, i, n);

    }

}


int main(){

    int n, i;

    scanf("%d", &n);

    int A[ n+1 ];

    for( i = 1; i <= n; i++) scanf("%d", &A[i]);

    buildMaxHeap( A, n);

    for( i = 1; i <= n; i++) printf(" %d", A[i]);

    printf("\n");

    return 0;

}


Measured memory_bytes: 4560
#include<iostream>
#include<vector>
#define _USE_MATH_DEFINES
#include<math.h>
#include<algorithm>
#include<memory>
#include<string>
#define Rep(i,n) for(int i = 0;i < (n);i++)	
typedef long long ll;

int gcd(int a, int b) { if (b == 0)  return a;  else  return gcd(b, a % b);  }
int lcm(int a, int b) { return a * b / gcd(a, b); }
void swap(int& a, int& b) { int temp = a; a = b; b = temp; return; }
int ncr(int n, int r) { int a = 1; Rep(i, r) a = (a * (n - i)) / (i + 1); return a; }
int npr(int n, int r) { int a = 1; Rep(i, r) a *= n - i; return a; }
int mod(int a, int b) { return a % b; }

class list {
public:
	class element {
	public:
		char data;
		element* next;
		element(element* _next, char item) :
			next(_next), data(item) {}
	};
	std::vector<element*> elements;
	void insert(element* l, int k, char item) {
		element* p;
		if (k > 1) { insert(l->next, k - 1, item); }
		else {
			elements.emplace_back(new element(l->next, item));
			l->next = elements.back();
		}
	}
	void erase(element* l, int k) {
		if (k > 1) { erase(l->next, k - 1); }
		else { l->next = l->next->next; }
	}
	char access(element* l, int k) {
		if (k > 1) { return access(l->next, k - 1); }
		else { return l->next->data; }
	}
	list() {elements.emplace_back(new element(NULL, NULL));}
};

class stack {
public:
	std::vector<char> box;
	int top;
	stack():top(0){}
	void push(char item) {}
};


int main() {
	/*std::string s;
	std::string t;
	std::cin >> s >> t;
	t = t.substr(0, t.size() - 1);
	if (s == t) {
		std::cout << "Yes";
	}
	else {
		std::cout << "No";
	}*/
	ll a, b, c;
	ll k;
	std::cin >> a >> b >> c >> k;
		if (a > k) {
		std::cout << k;
	}
	else if (a + b > k) {
		std::cout << a;
	}
	else {
		std::cout << 2 * a + b - k;
	}
	return 0;
}

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

int K, T;
int a[111];

int main() 
{
  cin >> K >> T;
  for (int i = 0; i < T; ++i) {
    cin >> a[i];
  }
  sort(a, a + 111, greater<int>());
  int rem = accumulate(a + 1, a + 111, 0);
  cout << max(0, a[0] - rem - 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
// http://codeforces.com/contest/777/submission/25058525
// SegmentTreeMax
template <typename ValueType>
class SegmentTreeMax
{
  public:
    SegmentTreeMax() {}
    SegmentTreeMax(int n, ValueType max_value)
    {
        this->N = 1;
        this->max_value = max_value;
        while (this->N < n)
            this->N *= 2;
        this->data.resize(2 * N - 1, this->max_value);
    }
    // init
    void init(int n, ValueType max_value)
    {
        this->N = 1;
        this->max_value = max_value;
        while (this->N < n)
            this->N *= 2;
        this->data.resize(2 * N - 1, this->max_value);
    }
    // update k th element
    void update(int k, ValueType val)
    {
        k += N - 1;
        data[k] = val;
        while (k > 0)
        {
            k = (k - 1) / 2;
            data[k] = std::max(data[2 * k + 1], data[2 * k + 2]);
        }
    }
    // Max [a, b)
    ValueType max(int a, int b) { return max(a, b, 0, 0, N); }
    ValueType max(int a, int b, int k, int l, int r)
    {
        if (r <= a or b <= l)
            return max_value;
        if (a <= l and r <= b)
            return data[k];
        int med = (l + r) / 2;
        return std::max(max(a, b, 2 * k + 1, l, med), max(a, b, 2 * k + 2, med, r));
    }

  private:
    std::vector<ValueType> data;
    int N;
    ValueType max_value;
};
///////////////////////////////////////

int N;
vector<pii> HA;
const int MAX_N = 200100;
map<int, ll> dp;
int main()
{
    cin >> N;
    HA.resize(N);
    SegmentTreeMax<ll> seg;
    seg.init(MAX_N, 0);
    for (auto &val : HA)
    {
        cin >> val.first;
    }
    for (auto &val : HA)
    {
        cin >> val.second;
    }
    seg.update(HA[0].first, HA[0].second);
    for (int i = 1; i < N; i++)
    {
        ll val = seg.max(0, HA[i].first);
        seg.update(HA[i].first, val + HA[i].second);
    }
    cout << seg.max(0, MAX_N) << endl;
    return 0;
}


Measured memory_bytes: 5888
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a,b,c,k[2005],ans;
  cin>>a>>b>>c;
  for(int i=0;i<a;++i){
    cin>>k[i];
  }
  if(a==1){
    ans=k[0]-c;
  }
  else{
    int n=k[a-1]-c;
    if(n<0) n*=-1;
    int m=k[a-2]-k[a-1];
    if(m<0) m*=-1;
    ans=max(n,m);
  }
  if(ans<0) ans*=-1;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int;
            var num = 1;
            while (num <= N)
            {
                num *= 2;
            }
            return num / 2;
        }


        #region いつもの
#pragma warning disable
        private ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
    }
    static class Ext
    {
        public static Dictionary<TKey, int> GroupCount<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) => source.GroupBy(keySelector).ToDictionary(g => g.Key, g => g.Count());
        public static Dictionary<TKey, int> GroupCount<TKey>(this IEnumerable<TKey> source) => source.GroupCount(i => i);
    }
    public class ConsoleReader { private string[] ReadLineSplit() => textReader.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries); private string[] line = Array.Empty<string>(); private int linePosition; private TextReader textReader; public ConsoleReader(TextReader tr) { textReader = tr; } public int Int => int.Parse(String); public long Long => long.Parse(String); public double Double => double.Parse(String); public string String { get { if (linePosition >= line.Length) { linePosition = 0; line = ReadLineSplit(); } return line[linePosition++]; } } public class SplitLine { private string[] splited; public SplitLine(ConsoleReader cr) { splited = cr.ReadLineSplit(); cr.line = Array.Empty<string>(); } public int[] Int => String.Select(x => int.Parse(x)).ToArray(); public int[] Int0 => String.Select(x => int.Parse(x) - 1).ToArray(); public long[] Long => String.Select(x => long.Parse(x)).ToArray(); public double[] Double => String.Select(x => double.Parse(x)).ToArray(); public string[] String => splited; } public SplitLine Split => new SplitLine(this); public class RepeatReader : IEnumerable<ConsoleReader> { ConsoleReader cr; int count; public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; } public IEnumerator<ConsoleReader> GetEnumerator() => Enumerable.Repeat(cr, count).GetEnumerator(); System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerable<string> String => this.Select(cr => cr.String); public IEnumerable<int> Int => this.Select(cr => cr.Int); public IEnumerable<int> Int0 => this.Select(cr => cr.Int - 1); public IEnumerable<long> Long => this.Select(cr => cr.Long); public IEnumerable<double> Double => this.Select(cr => cr.Double); } public RepeatReader Repeat(int count) => new RepeatReader(this, count); }
    #endregion
}


Measured memory_bytes: 13140
#include <vector>
#include <iostream>
#include <string>

bool isIsolatedBlack(const std::vector<std::vector<int>> &target, int i, int j) {
  if (!target[j][i]) {
    return false;
  }
  if ((i != 0) && target[j][i-1]) {
    return false;
  }
  if ((j != 0) && target[j-1][i]) {
    return false;
  }
  if ((i != target[j].size() - 1) && target[j][i+1]) {
    return false;
  }
  if ((j != target.size() - 1) && target[j+1][i]) {
    return false;
  }
  return true;
}

bool isItPossibleToDraw(const std::vector<std::vector<int>> &target) {
  for (int j = 0; j < target.size(); ++j) {
    const auto &row = target[j];
    for (int i = 0; i < row.size(); ++i) {
      if (isIsolatedBlack(target, i, j)) {
        return false;
      }
    }
  }
  return true;
}

int main() {
  int h, w;
  std::cin >> h >> w;

  std::vector<std::vector<int>> target(h);
  for (auto &row : target) {
    row.resize(w);
  }

  for (int j = 0; j < h; ++j) {
    std::string row_string;
    std::cin >> row_string;
    auto &row = target[j];
    if (row.size() != row_string.size()) {
      std::cout << "wrong input" << std::endl;
      return -1;
    }
    for (int i = 0; i < row.size(); ++i) {
      if (row_string[i] == '.') {
        row[i] = 0;
      } else {
        row[i] = 1;
      }
    }
  }
  std::cout << (isItPossibleToDraw(target) ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define each(i, c) for (auto& (i) : (c))

using namespace std;
typedef long long int lli;
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }

int main() {
    int w, a, b;
    cin >> w >> a >> b;
    if (b+w < a) cout << a-(b+w) << endl;
    else if (a+w < b) cout << b-(a+w) << endl;
    else cout << 0 << endl;
    return 0;
}

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

int main(void) {
    int n,t,c,tt;
    int mincost = INT_MAX;
    cin >> n >> t;

    for(int i=0;i<n;i++) {
        cin >> c >> tt;
        if(tt <= t) {
            if(mincost > c ) {
                mincost = c;
            }
        }
    }
    
    if(mincost == INT_MAX) {
        cout << "TLE\n";
    } else {
    cout << mincost << endl;
    }

    return 0;
}


Measured memory_bytes: 256