akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
string s,p;
int m,n,j,k,l,sum,ans,r;
string fz(string h)
{
	char t,y;
	int len=h.size();
	for(int i=0; i<len/2; i++)
	{
		t=h[i];
		y=h[len-i-1];
		h[i]=y;
		h[len-i-1]=t;
	}
	return h;
}
int main()
{
	getline(cin,s);
	p=fz(s);
	l=p.size();
	for(int i=0; i<l; i++)
	{
		if(p[i]=='b')p[i]='d';
		else if(p[i]=='d')p[i]='b';
		else if(p[i]=='p')p[i]='q';
		else if(p[i]=='q')p[i]='p';
	}
	if(p==s)printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

class TSort{
public:
  int V;
  vector<unordered_set<int> > in,out;
  vector<int> tp;
  TSort():V(0){}
  TSort(int V):V(V),in(V),out(V){}
  
  void add_edge(int from,int to){
    assert(from >= 0 && to >= 0);
    assert(from < V && to < V);
    out[from].insert(to);
    in[to].insert(from);
  }

  vector<int> dfs(){
    vector<int> visited(V,0);
    
    function<void(int)> dfs = [&](int pos){
      if(visited[pos]++) return;
      for(int nx:out[pos]) dfs(nx);
      tp.push_back(pos);
    };
    
    tp.clear();
    for(int i=0;i<V;i++) dfs(i);
    reverse(tp.begin(),tp.end());
    return tp;
  }

  vector<int> bfs(){
    auto tmp = in;
    tp.clear();
    queue<int> Q;
    for(int i=0;i<V;i++)if(in[i].empty()) Q.push(i);
    
    while(!Q.empty()){
      int v = Q.front();Q.pop();
      tp.push_back(v);
      for(int nx:out[v]){
        if(in[nx].size() == 1) Q.push(nx);
        in[nx].erase(v);
      }     
    }
    for(int i=0;i<V;i++) if(!in.empty()) tp.clear(); // exist loop
    tmp = in;
    return tp;
  }
};


int main(){
  int n,m;
  cin>>n>>m;
  TSort A(n);
  
  for(int i=0,a,b;i<m;i++)cin>>a>>b,A.add_edge(a,b);
  
  A.bfs();
  for(int i=0;i<n;i++)cout<<A.tp[i]<<endl;
  return 0;
}



Measured memory_bytes: 10688
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

ll a[200000];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  ll n,m;cin>>n>>m;
  a[0]=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    a[i+1]+=a[i];
  }
  for(int i=0;i<=n;i++){
    a[i]%=m;
  }
  sort(a,a+n+1);
  set<ll> s;
  for(int i=0;i<=n;i++){
    s.insert(a[i]);
  }
  ll ans=0;
  for(auto x:s){
    ll u1=lower_bound(a,a+n+1,x)-a;
    ll u2=upper_bound(a,a+n+1,x)-a;
    ans+=((u2-u1)*(u2-u1-1))/2;
  }
  P(ans);


  return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> l(N*2);
  rep(i, N*2) cin >> l[i];
  sort(l.begin(), l.end());
  int ans=0;
  for(int i=0; i<N*2; i+=2)
    ans += l[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  long L1,L2,L3;
  L1=2,L2=1;
  for(int i=0;i<N-1;i++){
    L3=L1+L2;
    L1=L2;
    L2=L3;
  }
  if(N==1){
    cout<<1<<endl;
  }
  else{
  cout<<L3<<endl;
  }
}

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

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

    int a = atoi(S.substr(0,2).c_str());
    int b = atoi(S.substr(2,4).c_str());  
    if(a >= 1 && a<=12){
        if(b >= 13 || b == 0){
            cout << "MMYY" << endl;
        }else{
            cout << "AMBIGUOUS" << endl;
        }
        return 0;
    }else{
        if(b >= 13 || b == 0){
            cout << "NA" << endl;
        }else{
            cout << "YYMM" << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] l = new int[n];
    for(int i = 0; i < n; i++){
      l[i] = sc.nextInt();
    }
    int answer = 0;
    for(int i = 0; i < n - 2; i++){
      for(int j = i + 1; j < n - 1; j++){
        for(int k = j + 1; k < n; k++){
          if(l[i] == l[j] || l[j] == l[k] || l[i] == l[k] ){
            continue;
          }
          if(l[j] + l[k] > l[i] && l[i] + l[k] > l[j] && l[i] + l[j] > l[k] ){
            answer++;
          }
        }
      }
    }
    System.out.println(answer);
  }
}


Measured memory_bytes: 36444
N=io.read("n")
D=io.read("n")
X=io.read("n")
A={}
local total=0
for i=1,N do
  A[i]=io.read("n")
  local k=1
  while (1+A[i]*k<=D) do
    k=k+1
  end
  k=k-1
  total=total+k
end
print(N+total+X)


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)
#define inf 1e9+5
int fpow(int x, int y, int p = MOD) {x = x % p; int sum = 1; while (y) {if (y & 1)sum = sum * x; sum %= p; y = y >> 1; x = x * x; x %= p;} return sum;}
int fact[1000007] = {0};
void facto() {fact[0] = 1; fact[1] = 1; for (int i = 2; i < 100007; i++)fact[i] = (fact[i - 1] * i) % MOD;}
int ncr(int n, int r) {int res = 1; res = fact[n]; res = (res * (fpow(fact[r], MOD - 2))) % MOD; res = (res * (fpow(fact[n - r], MOD - 2))) % MOD; return res;}
int npr(int n, int r) {int res = 1; res = fact[n]; res = (res * (fpow(fact[n - r], MOD - 2))) % MOD; return res;}
int modmul(ll x, ll y) {return (x * y) % MOD;}
int modadd(int x, int y) {return (x + y) % MOD;}
int modsub(int x, int y) {return (x - y + MOD) % MOD;}

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int n;
	cin >> n;
	vi v(n), b(n);
	rep(i, 0, n - 1) cin >> v[i];
	rep(i, 1, n - 1) {
		if (v[i] > v[i - 1])
			v[i]--;
	}
	rep(i, 0, n - 1) b[i] = v[i];
	sort(all(b));
	if (b == v) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

	return 0;
}

Measured memory_bytes: 4764
# C - Snuke Festival

N = int(input())
A = list(int(x) for x in input().split())
B = list(int(x) for x in input().split())
C = list(int(x) for x in input().split())

B.sort()
C.sort()

def binarySearch(a, b):
    l = -1
    r = N
    while l+1<r:
        m = (l+r)//2
        if a[m]<=b:
            l = m
        else:
            r = m
    return l+1

BC = []
for i in range(N):
    tmp = binarySearch(C, B[i])
    BC.append((N - tmp))

BC = BC[::-1]
BC2 = [0] * (N+1)
for i in range(N):
    BC2[i+1] = BC2[i] + BC[i]
BC2 = BC2[::-1]

ans = 0
for i in range(N):
    b = binarySearch(B, A[i])
    ans += BC2[b]

print(ans)

Measured memory_bytes: 24676
import Control.Monad
import Data.List

type Item = (Int,Int)

readInts :: IO [Int]
readInts = fmap (map read . words) getLine

readItem :: IO Item
readItem = do 
  [x, y] <- readInts
  return (x, y)

unit :: Item -> Item -> Ordering
unit a b 
  | ua > ub   = LT
  | ua < ub   = GT
  | otherwise = EQ
  where
    ua = (fromIntegral $ fst a)/(fromIntegral $ snd a)
    ub = (fromIntegral $ fst b)/(fromIntegral $ snd b)

gks :: [Item] -> Int -> Double
gks ls wgt = iter ls wgt 0.0 where
  iter [] _ ac = ac
  iter _  0 ac = ac
  iter ((v, w):xs) wgt ac
    | wgt < w   = ac +  (fromIntegral v)/(fromIntegral w)*(fromIntegral wgt)
    | otherwise = iter xs (wgt-w) ac + fromIntegral v

solver :: [Item] -> Int -> Int
solver [] _ = 0
solver _  0 = 0
solver ((v, w):xs) weight
  | weight >= w && (fromIntegral v0) <  v1 = max v0 (solver xs weight) 
  | weight >= w && (fromIntegral v0) >= v1 = v0
  | otherwise = solver xs weight
  where
    v0 = solver xs (weight-w) + v
    v1 = gks xs weight

main :: IO ()
main = do
  [n,w] <- readInts
  ls <- replicateM n readItem
  let items = sortBy unit ls
  print (solver items w)
  


Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;  
using ll = long long;
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
// #define _GLIBCXX_DEBUG
template <class T> using V = vector<T>;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
// #define fi first
// #define se second
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int dy2[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx2[] = {1, 1, 0, -1, -1, -1, 0, 1};
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
 
/*--------------------------------------------------------------------------------
--------------------------------------------------------------------------------*/

class DisjointSet{
    public:
        vector<int> rank, p;
        
        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for(int i = 0; i < size; i++) makeSet(i);
        }

        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }

        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }

        void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x] == rank[y]){
                    rank[y]++;
                }
            }
        }

        int findSet(int x){
            if(x != p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main() {
	ll n, m;
	cin >> n >> m;
	DisjointSet uf(n);
	rep(i, 0, m){
		ll a, b;
		cin >> a >> b;
		a--; b--;
		uf.unite(a, b);
	}
	set<ll> st;
	rep(i, 0, n) st.insert(uf.findSet(i));
	cout << sz(st) - 1 << endl;
}

Measured memory_bytes: 7832
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n,m) for (int i=n; i<m; i++)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

void ret_ans(array<int,4> n,int i);

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

	string s;
	cin >> s;
    array<int,4> n;
    int ans;

    REP(i,4){
       n[i]=(int)(s[i]-'0');
    }
    
    for(int i=0; i < 1 << 3;i++){
        ans = n[0];
        REP(j,3){
            if ((i>>j & 1) == 1){
                ans += n[j+1];
            }
            else{
                ans -= n[j+1];
            }
        }
        if (ans==7){
            ret_ans(n,i);
            break;
        }
    }
    return 0;
}
 
void ret_ans(array<int,4> n, int bit){
    cout << n[0];
    REP(i,3){
        cout << ((bit>>i&1)==1 ? "+" : "-") << n[i+1];
    }
    cout << "=7" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ll> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    for(int i = 0;i < N;i++) {
        vec.at(i)--;
    }
    ll cnt = 0;
    map<ll,vector<int>> ma;
    ma[0].push_back(0);
    for(int i = 0;i < N;i++) {
        cnt += vec.at(i);
        cnt %= K;
        ma[cnt].push_back(i + 1);
    }
    ll ret = 0;
    for(auto x:ma) {
        for(int i = 0;i < x.second.size();i++) {
            auto itr = lower_bound(x.second.begin(),x.second.end(),x.second.at(i) + K);
            ll A = itr - x.second.begin();
            A--;
            ret += A - i;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 24320
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.linalg import spsolve

N = int(input())
A = 2 * np.array(list(map(int, input().split())))
r, c, v = [None] * 2 * N, [None] * 2 * N, [None] * 2 * N
for n in range(N):
  r[2 * n] = n
  r[2 * n + 1] = n
  c[2 * n] = n
  c[2 * n + 1] = n + 1 if n != N - 1 else 0
  v[2 * n] = 1
  v[2 * n + 1] = 1
C = csr_matrix((v, (r, c)), shape=(N, N))
a = list(map(int, spsolve(C, A)))
for aa in a:
  print(aa, end=' ')

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


void main() {
    long n;
    scan(n);

    long ans = 100000;

    while (n > 0) {
        ans = min(ans, abs(753 - n % 1000));
        n /= 10;
    }

    writeln(ans);
}



























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

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


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll d[100] = {};
ll f(ll n){
    ll &res = d[n];
    if(~res) return res;
    if(n == 0) return res = 2;
    if(n == 1) return res = 1;
    return res = f(n-1) + f(n-2);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    memset(d,-1,sizeof(d));
    print(f(N));


}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();
 
	public static void main(String[] args) {
 
		String S = in.nextLine();
		boolean b =
				S.equals("hi")
				|| S.equals("hihi")
				|| S.equals("hihihi")
				|| S.equals("hihihihi")
				|| S.equals("hihihihihi");
		System.out.println(b ? "Yes" : "No");

	}
 
	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}
 
}

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

int main() {
    string S;
    cin >> S;
    int count = 0;

    for (int i = 0; i < 3; i = i + 1) {
        if (S.at(i) == S.at(i + 1)) {
            cout << "Bad" << endl;
            count = 1;
            break;
        }
    }

    if (count != 1) {
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <map>
#include<vector>
#include<queue>
#include<bits/stdc++.h>
#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<x<<" "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+5;
void FAST(){ios::sync_with_stdio(false);cin.tie(0);}
const ll mod =  1e9+7;

int n, m, k;
struct node
{
    int id, w;
}a[N];
bool cmp(node x, node y)
{
    return x.w > y.w;
}
ll dp[2100][2100];
void solve()
{
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i].w);
        a[i].id = i;
    }
    sort(a, a+n, cmp);
    for(int i = 0;i  < n; ++i){
        for(int j = 0; i+j < n; ++j) {
            int k = i+j;
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]+(ll)a[k].w*abs(a[k].id-i));
            dp[i][j+1] = max(dp[i][j+1], dp[i][j]+(ll)a[k].w*abs(a[k].id-(n-1-j)));
        }
    }
    ll ans = 0;
    for(int i = 0; i <= n; ++i)
        ans = max(ans, dp[i][n-i]);
    printf("%lld\n", ans);
}


int main()
{
//    int _; scanf("%d", &_); while(_--)
//    while(~scanf("%d%d", &n, &d))
//    while(~scanf("%lld", &n))
    solve();
    return 0;
}


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

using namespace std;
typedef unsigned long long ll;

#define pf printf
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define REPSZ(i,v) REP(i,SZ(v))
#define pll pair <ll, ll>

const ll mxn = 2e5+5;
const ll mod = 1e9+7;
ll arr[mxn]; 
void print(vector <ll> &v){cout << v.size() << endl;for(int i = 0; i < v.size(); i++){pf("%lld ", v[i]);}pf("\n");}
void print(vector <pll> &v){ cout << v.size() << endl; for(int i = 0; i < v.size(); i++){pf("%lld %lld\n", v[i].first, v[i].second);}}
void print(set<ll> s){set <ll> :: iterator itr;for (itr = s.begin(); itr != s.end(); ++itr){cout << *itr << " ";}cout << endl;}
void print(double d){cout << fixed << setprecision(10) << d << endl;}

void from_file(void){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);}

/* ------------------main section-------------! */


void run() {
    fastio;
    ll n;
    cin >> n;
    REP(i,n)
    {
        cin >> arr[i];
    }
    ll tot = 0;
    REP(i,n-1)
    {
        if(arr[i] <= arr[i+1]) continue;
        tot += (arr[i] - arr[i+1]);
        arr[i+1] = arr[i];
    }
    cout << tot << endl;
}


int main() {
    #ifndef ONLINE_JUDGE
        from_file();
    #endif
    run();
    return 0;
}


Measured memory_bytes: 5140
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<ll> a(n*3);
    rep(i,n*3) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    ll id = 3*n-2;
    rep(i,n){
        ans += a[id];
        id -= 2;
        // debug(ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int N;
	int M;

	cin >> N;
	int T[N+1];
	for (int i = 1; i <= N; i++) {
		cin >> T[i];
	}
	cin >> M;

	int P[M+1];
	int X[M+1];

	for (int i = 1; i <= M; i++) {
		cin >> P[i];
		cin >> X[i];
	}

	for (int j = 1; j <= M; j++) {
		int ans = 0;
		for (int i = 1; i < N+1; i++) {
			if (i == P[j]) {
				ans += X[j];
			} else {
				ans += T[i];
			}
		}
		cout << ans << "\n";
		ans = 0;
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define deb(x) cout <<"\n"<< (#x) << " = " << (x) << "\n"
#define int long long int

void inputoutput()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
}

void dfs(int src , bool *vis , vector<int> v[])
{
	vis[src]=true;
	// cout<<src<<" ";

	for(auto it : v[src])
	{
		if(!vis[it])
			dfs(it,vis,v);
	}
}

int32_t main()
{
    inputoutput();


  int k;
  cin>>k;

  int total=0;

  for(int i=1 ; i<=1e6 ; ++i)
  {
    total=(total*10+7)%k;
    if(total==0)
    {
        cout<<i ;
        return 0;
    }
  }
  cout<<"-1";


    return 0;
}



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

#define MAX 100000

int dp[MAX+5][4];
int val[MAX+5][4];
int n;

void initialize()
{
    for(int i=0;i<=MAX;i++)
        for(int j=0;j<=3;j++)
            dp[i][j] = -1;
}

int vacation(int i, int j)
{
    if(i<=0) return 0;

  /*  if(i==1)
    {
        return val[i][j];
    }
*/
    if(dp[i][j]!=-1) return dp[i][j];

    int mx = INT_MIN;

    for(int k=1;k<=3;k++)
    {
        if(j==k) continue;

        mx = max(mx, vacation(i-1, k)+ val[i][j]);
    }


    dp[i][j] = mx;

    return mx;
}

int main()
{
    initialize();

    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=3;j++)
            cin>>val[i][j];
    }

    int retVal1 = vacation(n, 1);

    initialize();

    int retVal2 = vacation(n, 2);

    initialize();

    int retVal3 = vacation(n, 3);

    cout<<max({retVal1, retVal2, retVal3})<<endl;

    return 0;
}


Measured memory_bytes: 11136
l = list(input()) 
for i in range(8):
    p = ["+"if i&j else"-" for j in[1, 2, 4]]
    line = "".join([v+o for v,o in zip(l,p)])
    line += l[3]
    if eval(line) == 7:
        print(line + "=7")
        break

Measured memory_bytes: 38384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;

    cout << (a + b - 1) / b << endl;
    return 0;
}


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

int main(){
  ll n;
  cin >> n;
  vector<pair<ll,ll>> a(n);
  rep(i,n){
    cin >> a.at(i).second >> a.at(i).first;
  }
  sort(a.begin(),a.end());
  ll t = 0;
  rep(i,n){
    t += a.at(i).second;
    if( t > a.at(i).first ){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 3328
#include<iostream>

using namespace std;

#define HMAX 150
#define WMAX 150

int main(){

	int data[HMAX+1][WMAX+1];
	int h,w;
	int mh,mw;

	for(int i=1;i<=HMAX;i++){
		for(int j=1;j<=WMAX;j++){
			data[i][j]=i*i+j*j;
		}
	}

	while(1){
		cin>>h>>w;
		if(h==0&&w==0) break;
		mh=150,mw=150;
		for(int i=1;i<=HMAX;i++){
			for(int j=i+1;j<=WMAX;j++){
				if((data[h][w]<data[i][j]||(data[h][w]==data[i][j]&&h<i))&&data[i][j]<data[mh][mw]){
					mh=i,mw=j;
				}
			}
		}
		cout<<mh<<" "<<mw<<endl;
	}

}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
int main(void){
    ll n;cin>>n;
    vector<vector<ll>>dp(n+1,vector<ll>(3,0));
    vector<ll>v(3);
    rep(i,n){
        rep(j,3)cin>>v[j];
        rep(j,3){
            rep(k,3){
                if(j==k)continue;
                else dp[i+1][j]=max(dp[i+1][j],dp[i][k]+v[j]);
            }
        }
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}

Measured memory_bytes: 5760
#line 2 "cpplib/util/template.hpp"
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#include<bits/stdc++.h>
using namespace std;
struct __INIT__{__INIT__(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}__INIT__;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define endl ('\n')
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,...) for(auto i:range(__VA_ARGS__)) 
#define rrep(i,...) for(auto i:reversed(range(__VA_ARGS__)))
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
inline vector<long long> range(long long n){vector<long long>v(n);iota(v.begin(),v.end(),0LL);return v;}
inline vector<long long> range(long long a,long long b){vector<long long>v(b-a);iota(v.begin(),v.end(),a);return v;}
inline vector<long long> range(long long a,long long b,long long c){if((b-a+c-1)/c<=0)return vector<long long>();vector<long long>v((b-a+c-1)/c);for(int i=0;i<(int)v.size();++i)v[i]=i?v[i-1]+c:a;return v;}
template<typename T>inline T reversed(T v){reverse(v.begin(),v.end());return v;}
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
template<typename T,typename E>bool chmin(T& s,const E& t){bool res=s>t;s=min<T>(s,t);return res;}
template<typename T,typename E>bool chmax(T& s,const E& t){bool res=s<t;s=max<T>(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
template<typename T,typename ...Args>auto make_vector(T x,int arg,Args ...args){if constexpr(sizeof...(args)==0)return vector<T>(arg,x);else return vector(arg,make_vector<T>(x,args...));}
#line 2 "code.cpp"

int main(){
    lint a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,b*c,a*d,b*d})<<endl;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
using namespace std;
int gcd(int a,int b){
  if ( a%b ==0 ) {
    return (b);
  }
  else
  {
    return (gcd(b,a%b));
  }
}

int main() {
  int K;
  cin >> K;
  vector<int> A(100000);
  int sum=0;
  for (int i=1; i<K+1; i++) {
    for (int j=1; j<K+1; j++) {
      for (int k=1; k<K+1; k++) {
        A.at(i)=gcd(i,j);
        sum+=gcd(A.at(i),k);
      }
    }
  }
  cout << sum << endl;
        
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x , m; cin>>x>>m;
    unordered_map<int,bool>mark;
    for(int i = 0 ; i < m; ++i){
        int x; cin>>x;
        mark[x] = 1;
    }
    int ans = INT_MAX;
    int mn = INT_MAX;
    //vector<int>store;
    for(int i = -100; i <= 101; ++i){
        if(mark[i] == 0){
            if(ans > abs(x - i)){
                ans = abs(x - i);
                mn = i;
            }
            if(ans == abs(x - i)){
                ans = abs(x - i);
                mn = min(mn , i);
            }
        }
    }
    cout<<mn<<"\n";
}


Measured memory_bytes: 3620
from bisect import bisect_left, bisect_right

n = int(input())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))
ba = [bisect_left(a, bi) for bi in b]
bc = [bisect_right(c, bi) for bi in b]
cnt = 0
for i in range(n):
    cnt += ba[i] * (n - bc[i])
print(cnt)

Measured memory_bytes: 23488
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    int n; cin >> n;
    vector<float> v(n);
    for (int i=0; i<n; i++) cin >> v[i];
    sort(v.begin(), v.end());

    float val = v[0];
    for (int i=1; i<n; i++) {
        val = (val + v[i]) / 2;
    }
    cout << val << endl;
    return 0;
}



Measured memory_bytes: 888
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long ll;

const int kMaxN = 2e4 + 5;
ll n, k, a[kMaxN], b[kMaxN];

int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", a + i);
    k -= a[i];
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", b + i);
    k += b[i];
  }
  ll sum = 0;
  for (int i = 1; i <= n; ++i)
    if (b[i] > a[i])
      sum = sum + (b[i] - a[i] + (b[i] - a[i]) % 2) / 2;
  puts(sum <= k ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string.h>
 
using namespace std;
 
int main(){
   int num, a, b;
    
    scanf("%d %d %d", &num, &a, &b);
    char str[num+1];
    scanf("%s", str);
    
    for(int i = 0; i < strlen(str); i++){
        if(str[i] == 'a'){
            if(a > 0)
                a--;
            else if( b > 0)
                b--;
            else{
                printf("No\n");
                continue;
            }
            printf("Yes\n");
            
        }
        else if(str[i] == 'b'){
            if(b > 0)
                b--;
            else{
                printf("No\n");
                continue;
            }
            printf("Yes\n");
        }
        else
            printf("No\n");
    }
 
    return 0;
}

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



int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    
    rep(i,n) {
        cout << s[i] << t[i];
    }
    cout << endl;
    
    
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

const int mxN = 1e7;
int n, c[mxN + 1];

void solve() {
	cin >> n;
	rep(i, 1, n) {
		for (int j = 0; (j += i) <= n;) {
			++c[j];
		}
	}
	int ans = 0;
	rep(i, 1, n)
	ans += i * c[i];
	cout << ans;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();


	return 0;
}

Measured memory_bytes: 81644
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll H,W;
	cin >> H >> W;

	ll ans = INF*INF;
	ll a=0,b=0,c=0;

	for(int h = 0; h <= H; h++){
		if(W%2==0) a = h*W/2,b = h*W/2;
		else a = h*(W-1)/2,b = h*(W+1)/2;
		c = W*(H-h);

		ll s_max = max(max(a,b),c);
		ll s_min = min(min(a,b),c);
		if(s_max - s_min < ans){
			//cout << "max = " << s_max << " min = " << s_min << endl;
			ans = s_max - s_min;
		}
		// ans = s_max - s_min;

		a = h*W;
		if((H-h)%2==0) b = (H-h)/2 * W,c = b;
		else b = (H-h-1)/2 * W,c = (H-h+1)/2 * W;

		s_max = max(max(a,b),c);
		s_min = min(min(a,b),c);
		if(s_max - s_min < ans){
			//cout << "max = " << s_max << " min = " << s_min << endl;
			ans = s_max - s_min;
		} 
		//ans = s_max - s_min;
	}

	for(int w = 0; w <= W; w++){
		if(H%2==0) a = H/2*w, b = a;
		else a = (H-1)/2*w, b = (H+1)/2*w;
		c = H*(W-w);

		ll s_max = max(max(a,b),c);
		ll s_min = min(min(a,b),c);
		if(s_max - s_min < ans){
			//cout << "max = " << s_max << " min = " << s_min << endl;
			ans = s_max - s_min;
		} 
		//ans = s_max - s_min;

		a = w*H;
		if((W-w)%2==0) b = H*(W-w)/2 , c = b;
		else b = H*(W-w-1)/2, c = H*(W-w+1)/2;
		s_max = max(max(a,b),c);
		s_min = min(min(a,b),c);
		if(s_max - s_min < ans){
			//cout << "max = " << s_max << " min = " << s_min << endl;
			ans = s_max - s_min;
		} 
		//ans = s_max - s_min;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,rest;
  cin >> N >> A;
  rest = N-N/500*500;
  if (A-rest >= 0){
  cout << "Yes" << endl;
  }
  else if (N%500 == 0){
  cout << "Yes" << endl;
  }
  else {
  cout << "No" << endl;
  }
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m;
double l;
double p[1000];
double t[1000];
double v[1000];
double prob[2][101][51];
double sum[101][55];
double ans[101];

inline double Sum(int i, int j) { return sum[i][j + 1]; }

int main() {
  while (scanf("%d %d %lf", &n, &m, &l) > 0) {
    MEMSET(prob, 0);
    MEMSET(sum, 0);
    MEMSET(ans, 0);
    REP(i, n) {
      scanf("%lf %lf %lf", &p[i], &t[i], &v[i]);
      p[i] /= 100.0;
      prob[0][i][0] = 1;
      REP(j, m) {
        int prev = j & 1;
        int next = prev ^ 1;
        //MEMSET(prob[next][i], 0);
        FOREQ(k, 0, m) {
          prob[next][i][k] = (1.0 - p[i]) * prob[prev][i][k];
          assert(prob[next][i][k] >= 0.0);
          if (k != 0) {
            prob[next][i][k] += p[i] * prob[prev][i][k - 1];
          }
          assert(prob[next][i][k] >= 0.0);
        }
      }
      FOREQ(j, 0, m) {
        sum[i][j + 1] = sum[i][j] + prob[m & 1][i][j];
      }
    }


    REP(i, n) {
      if (v[i] == 0) { continue; }
      FOREQ(j, 0, m) {
        double time = l / v[i] + t[i] * j;
        if (isnan(time)) { continue; }
        double lans = 1.0;
        REP(k, n) {
          if (i == k || v[k] == 0) { continue; }
          double ntime = l / v[k];
          double lp = 1.0;
          FOREQ(cnt, 0, m) {
            if (ntime  - time > EPS) { break; }
            lp -= prob[m  & 1][k][cnt];
            assert(lp >= -EPS);
            ntime += t[k];
          }
          lans *= lp;
          if (lans == 0) { break; }
        }
        ans[i] += lans * prob[m & 1][i][j];
      }
    }
    REP(i, n) {
      printf("%.8f\n", ans[i]);
    }
  }
}

Measured memory_bytes: 1020
#!/bin/bash
read i j
p=`expr $i \+ 1`
if [ $i -eq $j ]; then
  echo `expr $i \* 2` ;
elif [ $p -gt $j ]; then
  echo `expr $i \* 2 - 1` ;
else
  echo `expr $j \* 2 - 1` ;
fi


Measured memory_bytes: 544
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
  	// ボール
	var strTmp = input[0].split(" ");
  	// 個数
  	var numTmp = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(numTmp[0], 10);
	var b = parseInt(numTmp[1], 10);
    // 3行目の文字列とボール名を比較して個数を計算する
  	if (input[2] == strTmp[0]) {
      console.log('%d %s', a-1, b);
    } else {
      console.log('%d %s', a, b-1);
    };
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import numpy as np
n, m, c = list(map(int, input().split()))
b = np.array(list(map(int, input().split())))
count = 0
for i in range(n):
    a = np.array(list(map(int, input().split())))
    result = sum(a*b) + c
    if result > 0:
        count += 1
print(count)

Measured memory_bytes: 14440
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;
  int ans=0;
  cin >> A>>B;
  N=A;
  
 while(N<=B){
     int d5=N%10;
     int d4=N/10%10;
     int d3=N/100%10;
     int d2=N/1000%10;
     int d1=N/10000;
     if(d5==d1&&d4==d2){
         ans++;
     }
    N=N+1;}
 cout<<ans;    
 
}

Measured memory_bytes: 3600
from fractions import gcd
a,b,c,d=map(int,input().split())
def lcm(n,m):
    return (n*m)//gcd(n,m)
cntb=b-(b//c)-(b//d)+(b//lcm(c,d))
cnta=a-1-(a-1)//c-((a-1)//d)+((a-1)//lcm(c,d))
ans=cntb-cnta
print(ans)

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

using namespace std;

const int MAXN = 100010;

int n;
int ans;
int qtdTwo;

int freq[MAXN];

int main()
{
	scanf("%d",&n);

	for(int i = 1 ; i <= n ; i++)
	{
		int v;
		scanf("%d",&v);

		freq[ v ]++;
	}

	for(int i = 0 ; i < MAXN ; i++)
	{
		while( freq[i] >= 3 )
		{
			ans++;
			freq[i] -= 2;
		}

		if( freq[i] == 2 ) qtdTwo++;
	}

	ans += ( qtdTwo + 1 )/2;

	printf("%d\n",n - 2*ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<ll> a(N), sum_raw(N), sum_opt(N);
	vector<int> minus;
	cin >> a[0];
	sum_raw[0]=a[0];
	sum_opt[0]=a[0];
	for(int i=1; i<N; ++i){
	    char op;
	    cin >> op >> a[i];
	    if(op=='+') sum_raw[i]=sum_raw[i-1]+a[i];
	    else{
	        sum_raw[i]=sum_raw[i-1]-a[i];
	        minus.push_back(i);
	    }
	    sum_opt[i]=sum_opt[i-1]+a[i];
	}
	ll ans=sum_raw[N-1];
	for(int i=0; i+1<minus.size(); ++i){
	    ans=max(ans, sum_raw[minus[i]]*2-sum_raw[minus[i+1]-1]+sum_opt[N-1]-sum_opt[minus[i+1]-1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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() {
    ll a,b,c;
    cin >> a >> b >> c;
    if((a == b && b == c)){
        if(a%2 == 0 && b%2 == 0 && c%2 == 0)cout << -1 << endl;
        else cout << 0 << endl;
    }else{
        rep(i,1e9){
            if(a%2 == 1 || b%2 == 1 || c%2 == 1){
                cout << i << endl;
                return 0;
            }
            ll ta = b/2 + c/2;
            ll tb = a/2 + c/2;
            ll tc = a/2 + b/2;
            a = ta;
            b = tb;
            c = tc;
        }
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int busa, busb, traina, trainb;
	cin >>busa >> busb;
	cin >> traina >> trainb;
	int bus;
	if (busa < busb)
	{
		bus = busa;
	}
	else
	{
		bus = busb;
	}
	int train;
	if (traina < trainb)
	{
		train = traina;
	}
	else
	{
		train = trainb;
	}
	cout << bus + train << endl;
	int z;
	cin >> z;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int m = scan.nextInt();
		
		int[] a = new int[n];
		double total = 0;
		
		for(int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
			total += a[i];
		}
		
		int ans = 0;
		
		for(int j = 0; j < n; j++) {
			if(a[j] >= total / (4*m)) {
				ans++;
			}
		}
		
		if(ans >= m) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}

}


Measured memory_bytes: 35744
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int v[n-1], c[n-1];
    for(int i=0;i<n;++i) cin >> v[i];
    for(int i=0;i<n;++i) cin >> c[i];
    int p[n-1];
    for(int i=0;i<n;++i) p[i]=v[i]-c[i];
    int sum=0;
    for(int i=0;i<n;++i) {
        if(p[i]>0) sum+=p[i];
    }
    cout << sum << endl;
}


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

int main() {
  
  string s;
  
  cin >> s;
  
  int count = 0;
  
  for (int i=0;i<3;i++) {
    if (s.at(i) == '1')
      count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 110
using namespace std;
const int INF = 1LL<<55;
int Max(int &a,int b){return a=max(a,b);}
int Min(int &a,int b){return a=min(a,b);}
struct dat{int cnt, num_door , dis;};
vector<int> G[N];
vector<int> rec;
vector<dat> A;

bool can_add_edge(int a,int b,int r){
  return A[a].cnt && A[b].cnt && A[a].dis - A[b].dis == r;
}

void add_edge(int a,int b){
  assert(A[a].cnt-- && A[b].cnt--);
  G[a].push_back(b);
  G[b].push_back(a);
  sort(G[a].begin(),G[a].end());
  sort(G[b].begin(),G[b].end());
}

void dfs(int idx,int num){
  if(idx >= (int)rec.size()) return;
  int pos = num;

  while(idx<(int)rec.size() && rec[idx]<0){
    for(int i=0;i<(int)A.size()-1;i++){
      if(!can_add_edge(i,pos,rec[idx])) continue;
      add_edge(i,pos);
      idx++;
      break;
    }
    while(pos && A[pos].cnt == 0) pos--;
  }
  if(idx >= (int)rec.size()) return;

  while(A[pos].cnt == 0) pos--;
  A.push_back((dat){rec[idx],rec[idx],A[pos].dis+1});
  add_edge(pos,num+1);
  dfs(idx+1,num+1);
}

signed main(){
  int q;
  cin>>q;
  while(q--){
    for(int i=0;i<N;i++) G[i].clear();    
    rec.clear();
    for(int a;cin>>a,a;)rec.push_back(a);

    A.clear();
    A.push_back((dat){rec[0],rec[0],0});
    dfs(1,0);

    for(int i=0;i<(int)A.size();i++){
      cout<<i+1;
      for(int a:G[i]) cout<<" "<<a+1;
      cout<<endl;
    }
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n; cin >> n;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];
  vector<ll> y = x;
  sort(ALL(y));
  rep(i, n) {
    if(x[i] <= y[n/2-1]) cout << y[n/2] << endl;
    else cout << y[n/2-1] << endl;
  }
}

Measured memory_bytes: 6372
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	
	int p, q, loop_start, loop_end;
	
	int a[20000], rest[20000];
	
	bool checker;
	
	cin >> p;
	
	while(true){
		
		if(cin.eof()){
			break;
		}
		
		cin >> q;
		
		//cout << p / q << ".";
		
		p = p % q;
		
		if(p == 0){
			printf("0\n");
			cin >> p;
			continue;
		}
		
		rest[0] = p;
		
		loop_start = 1;
		loop_end = 99;
		
		for(int i = 0; i < 100; i++){
			
			checker = false;
			
			p *= 10;
			
			for(int j = 1; j <= 10; j++){
				if(p < j * q){
					p -= (j - 1) * q;
					if(p == 0){
						checker = true;
						loop_start = -1;
						loop_end = i + 1;
					}
					a[i] = j - 1;
					break;
				}
			}
			
			rest[i + 1] = p;
			
			for(int j = 0; j <= i; j++){
				if(rest[j] == p){
					checker = true;
					loop_start = j;
					loop_end = i + 1;
					break;
				}
			}
			
			if(checker){
				break;
			}
			
		}
		
		for(int i = 0; i < loop_end; i++){
			cout << a[i];
		}
		
		cout << endl;
		
		if(loop_start >= 0){
			for(int i = 0; i < loop_end; i++){
				if(i >= loop_start){
					cout << '^';
				}else{
					cout << ' ';
				}
			}
			cout << endl;
		}
		
		
		cin >> p;
	}
	
	return 0;
}

Measured memory_bytes: 1172
import java.util.*;

public class Main{
	public static void main(String[] args){

		List<Double> listAl = new ArrayList<Double>();
		Scanner scan = new Scanner(System.in);
		double n = scan.nextDouble();
		while(n != 0){
			double[] sc = new double[(int) n];
			double sum = 0;
			for(int i = 0; i < n; i++){
				double s = scan.nextDouble();
				sc[i] = s;
				sum += s;
			}
			double m = sum / n;
			double a = 0;
			for(int i = 0; i < n; i++){
				a += Math.pow((sc[i] - m), 2);
			}
			double al = Math.sqrt(a / n);
			listAl.add(al);
			n = scan.nextDouble();
		}

		for(double a : listAl){
			System.out.println(a);
		}
	}
}

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


class person{
public:
	int num;
	double w;
	double h;
	double bmi;
	person(int n,double _w,double _h,double _bmi){
		num=n;w=_w;h=_h;bmi=_bmi;
	}
	double getBMIPoint(){
		if(h!=0)bmi=w/((h/100)*(h/100));
		if(bmi<22){
			return 22-bmi;
		}
		else {
			return bmi-22;
		}
	}
	void print(){
		cout<<num<<" "<<w<<" "<<h<<""<<bmi<<endl;
	}
};
int
main(){
	
	for(int d;cin>>d;){
		if(!d)break;
		person stable=person(0,0,0,100);
		for(int i=0;i<d;i++){
		//	stable.print();
			int num;
			double w,h;
			cin>>num>>h>>w;
			person p=person(num,w,h,0);
		//	p.print();
		//	cout<<p.getBMIPoint()<<endl;
			if(stable.getBMIPoint()>=p.getBMIPoint()){
					if(stable.getBMIPoint()==p.getBMIPoint()){
						if(stable.num<p.num)continue;
					}
					stable=p;
			}
			
		}
		cout<<stable.num<<endl;
	}
	return 0;
}

Measured memory_bytes: 0