akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  ll n, m, k;
  cin >> n >> m >> k;
  arrll(a,n);
  arrll(b,m);
  vecll s(n+1), t(m+1);
  rep(i,n){
    s[i+1] = s[i] + a[i];
  }

  rep(i,m){
    t[i+1] = t[i] + b[i];
  }

  ll ans=0;
  rep(i,n+1){
    if(k-s[i]>=0){
      auto tmp = upper_bound(all(t), k-s[i]);

      ll num = i + tmp - t.begin() - 1;
      //prt2(i, num);
      chmax(ans, num);
    }
  }

  prt(ans);

}


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

using namespace std;
#define sz(x) (int)((x).size())
#define forn(i,n) for (int i=0; i < n; i++)
#define forse(i,s,e) for (int i=s; i < e; i++)
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

double PI=3.141592653589793;


void solve(){
	int a,b;
	cin >> a >> b;
	cout << a*b;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	forse(c,1,T+1){
	//	cout << "Case #" << cid << ": ";
		solve();
	}
}


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

using namespace std;

using ll = long long;
using ld = long double;

void Dfs(const int p, const int cur, const ll d, vector<int> &color,
         const vector<vector<pair<int, ll>>> &adj) {
    color[cur] = d % 2;

    for (const auto &e : adj[cur]) {
        if (e.first != p) {
            Dfs(cur, e.first, d + e.second, color, adj);
        }
    }
}

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

    int n;
    cin >> n;

    vector<vector<pair<int, ll>>> adj(n);
    for (int i = 0; i + 1 < n; ++i) {
        ll u, v, w;
        cin >> u >> v >> w;
        adj[u - 1].emplace_back(v - 1, w);
        adj[v - 1].emplace_back(u - 1, w);
    }

    vector<int> color(n, -1);
    Dfs(-1, 0, 0, color, adj);

    for (int v = 0; v < n; ++v)
        cout << color[v] << "\n";

    return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string s;
    cin >> s;
    if(c < d) {
        bool ok = true;
        rep2(i,b+1,d-1) {
            if(s[i] == '#' && s[i+1] == '#'){
                ok = false;
                break;
            }
        }
        rep2(i,a+1,c-1) {
            if(s[i] == '#' && s[i+1] == '#'){
                ok = false;
                break;
            }
        }
        cout << (ok ? "Yes" : "No") << endl;
    } else {
        bool ok = true;
        bool ex = false;
        rep2(i,b+1,d-1) {
            if(s[i] == '#' && s[i+1] == '#') {
                ok = false;
                break;
            }
        }
        rep2(i,max(b-1,0),min(d,n-2)) {
            if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.'){
                ex = true;
                break;
            }
        }
        if(!ex) {
            cout << "No" << endl;
            return 0;
        }
        rep2(i,a+1,c-1) {
            if(s[i] == '#' && s[i+1] == '#'){
                ok = false;
                break;
            }
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 592
# @author 

import sys

class BEasyLinearProgramming:
    def solve(self, tc=0):
        a, b, c, k = [int(_) for _ in input().split()]
        print(min(a - max(0, k - a - b), k))


solver = BEasyLinearProgramming()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 9196
#ifdef __APPLE__
    # include <iostream>
    # include <cmath>
    # include <algorithm>
    # include <stdio.h>
    # include <cstdint>
    # include <cstring>
    # include <string>
    # include <cstdlib>
    # include <vector>
    # include <bitset>
    # include <map>
    # include <queue>
    # include <ctime>
    # include <stack>
    # include <set>
    # include <list>
    # include <random>
    # include <deque>
    # include <functional>
    # include <iomanip>
    # include <sstream>
    # include <fstream>
    # include <complex>
    # include <numeric>
    # include <immintrin.h>
    # include <cassert>
    # include <array>
    # include <tuple>
    # include <unordered_map>
    # include <unordered_set>
    # include <thread>
#else
    # include <bits/stdc++.h>
#endif

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

const int max_n = 100+10, inf = 1000111222;

int a[max_n];

int main() {
//    freopen("barik.in", "r", stdin);
//    freopen("barik.out", "w", stdout);

    int n;
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans=0;
    for (int i=1;i<=n;i+=2){
        if (a[i]%2==1){
            ans++;
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 3524
#include <stdio.h>
#include <math.h>

typedef struct node
{
    double x, y;
} POINT;

void kock(int, POINT, POINT);

int main()
{

    int n;
    POINT p1 = {0, 0}, p2 = {100, 0};
    scanf("%d", &n);

    printf("%.8f %.8f\n", p1.x, p1.y);
    kock(n, p1, p2);
    printf("%.8f %.8f\n", p2.x, p2.y);
    printf("\n");
    return 0;
}
void kock(int n, POINT p1, POINT p2)
{

    POINT s, t, u;
    if (n == 0)
        return;

    double th = 60 * M_PI / 180;

    //p1,p2からs,t,u を計算する
    s.x = (2 * p1.x + 1 * p2.x) / 3;
    s.y = (2 * p1.y + 1 * p2.y) / 3;
    t.x = (1 * p1.x + 2 * p2.x) / 3;
    t.y = (1 * p1.y + 2 * p2.y) / 3;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    kock(n - 1, p1, s);
    printf("%.8f %.8f\n", s.x, s.y); //s

    kock(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y); //u

    kock(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y); //t

    kock(n - 1, t, p2);
}



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

typedef long long ll;

int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<int>> a(h,vector<int>(w));
    int i,j;
    for(i = 0;i < h;++i){
        for(j = 0;j < w;++j){
            cin >> a.at(i).at(j);
        }
    }
    int x = 0,y = 0;
    int n_x,n_y;
    int end_x,end_y = h-1;
    int ans = 0;
    if((h-1)%2 == 0){
        end_x = w-1;
    }else{
        end_x = 0;
    }
    vector<vector<int>> ans_v;
    while(!(x == end_x && y == end_y)){
        if((y%2 == 0 && x == w-1) || (y%2 == 1 && x == 0)){
            n_x = x;
            n_y = y+1;
        }else if(y%2 == 0){
            n_y = y;
            n_x = x+1;
        }else{
            n_y = y;
            n_x = x-1;
        }
        if(a.at(y).at(x)%2){
            ++ans;
            vector<int> v = {y+1,x+1,n_y+1,n_x+1};
            ans_v.push_back(v);
            --a.at(y).at(x);
            ++a.at(n_y).at(n_x);
        }
        x = n_x;
        y = n_y;
    }
    cout << ans << endl;
    for(i = 0;i < ans;++i){
        cout << ans_v.at(i).at(0) << " " << ans_v.at(i).at(1) << " " << ans_v.at(i).at(2) << " " << ans_v.at(i).at(3) << endl;
    }
    return 0;
}

Measured memory_bytes: 11312
import sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N=II()
P=[II() for _ in range(N)]
P.sort()
print(sum(P) - (int(P[-1]/2)))

Measured memory_bytes: 5312
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main()
{
    int N;
    cin >> N;
    
    int t[110000], x[110000], y[110000];
    t[0] = x[0] = y[0] = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> t[i + 1] >> x[i + 1] >> y[i+ 1];
    }
    
    bool can = true;

    for (int i = 0; i < N; i++)
    {
        int dt = t[i+1] - t[i];
        int dis = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if(dis > dt) can = false;
        if((dis%2) != (dt%2)) can = false;
    }
    
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

ct1 = 0
ct2 = 0

for i in range(0, X):
    if i in A:
        ct1 += 1

for i in range(X, N+1):
    if i in A:
        ct2 += 1

print(min(ct1, ct2))


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

typedef long long LL;

const LL INF=1e9;

LL s;

void into(){
  scanf("%lld",&s);
}

LL x[2],y[2];

void Get_ans(){
  x[0]=min((LL)(sqrt(s)+0.5),INF);
  y[1]=min(s/x[0]+1,INF);
  x[1]=1;
  y[0]=x[0]*y[1]-s;
}

void work(){
  Get_ans();
}

void outo(){
  printf("%lld %lld %lld %lld %lld %lld\n",x[0],y[0],x[1],y[1],0,0);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << max(0, C - A + B) << endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        h: usize,
        w: usize,
        a: [chars; h],
    }

    let mut tbl = vec![vec![None; w]; h];
    let mut q = std::collections::VecDeque::new();

    for i in 0..h {
        for j in 0..w {
            if a[i][j] == '#' {
                q.push_back((i, j, 0));
            }
        }
    }

    while let Some((i, j, dep)) = q.pop_front() {
        if tbl[i][j].is_some() {
            continue;
        }

        tbl[i][j] = Some(dep);

        for &(di, dj) in [(1, 0), (-1, 0), (0, 1), (0, -1)].iter() {
            let ci = i as i64 + di;
            let cj = j as i64 + dj;

            if !(ci >= 0 && ci < h as _ && cj >= 0 && cj < w as _) {
                continue;
            }

            let ci = ci as usize;
            let cj = cj as usize;

            q.push_back((ci, cj, dep + 1));
        }
    }

    // dbg!(&tbl);

    let mut ans = 0;

    for row in tbl {
        for cell in row {
            if let Some(d) = cell {
                ans = std::cmp::max(ans, d);
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 114676
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> H(N);
  rep(i, N) {
    cin >> H[i];
  }

  if (N <= K) {
    cout << 0 << "\n";
    return 0;
  }

  ll ans = 0;
  sort(all(H));
  rep(i, N - K) {
    ans += H[i];
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {
	var n,t,cost,time int
	fmt.Scan(&n,&t)
	
	minCost := 1001
  	for i := 0; i < n; i++ {
  		fmt.Scan(&cost)
  		fmt.Scan(&time)
  		if time <= t && cost < minCost {
  			minCost = cost
  		}
  	}
  	if minCost == 1001 {
  		fmt.Println("TLE")
  	} else {
  		fmt.Println(minCost)
  	}
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main(){
  int alph[3]={0};
  char S[3];
  scanf("%s", S);
  
  for(int i=0;i<=2;i++){
    if(S[i]=='a'){alph[0]=alph[0]+1;}
    else if(S[i]=='b'){alph[1]=alph[1]+1;}
    else if(S[i]=='c'){alph[2]=alph[2]+1;}
  }
  if(alph[0]==1 && alph[1]==1 && alph[2]==1){
    printf("Yes\n");
  }
  else printf("No\n");
  //printf("%s\n", S);
  return 0;
}

Measured memory_bytes: 128
s = input()
d = True
f = '' # Front
b = '' # Back
q = int(input())
for _ in range(q):
    a = input().split()
    if a[0] == '1':
        d = not d
    else:
        if a[1] == '1':
            if d:
                f = ''.join([a[2], f])
            else:
                b = ''.join([b, a[2]])
        else:
            if d:
                b = ''.join([b, a[2]])
            else:
                f = ''.join([a[2], f])

if not d:
    print(''.join([b[::-1], s[::-1], f[::-1]]))
else:
    print(''.join([f, s, b]))


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


int main() {

  int64_t n;
  cin>>n;

  int64_t div=n;
  int64_t rem=0;
  string s;
  while(1){

    rem=(div-1)%26;
    div=(div-1)/26;
    

    char c;
//    if(rem==0)
//      c='z';
//    else
      c=(char)(0x61+rem);

    s.push_back(c);

    if(div==0)
      break;
      
  }

  reverse(s.begin(),s.end());

  cout<<s<<endl;

  return 0;
}
//27  = 26+1 = 1(27/26)1(27%26) aa
//701 = 26*26+25 26(26*26/26)25(701%26)zy
//702 =  26*26+26 26(26*26/26) 26(702%26)zz
//703 =  26*26+26+1 aaa
//18277 = 26^3+26^2+25 zzy 



Measured memory_bytes: 3632
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;

int n,a,b;
string s;

int main(){
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0,a+b-n)<<endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> S(N);
    for (auto& s : S) {
        cin >> s;
    }
    vector<vector<int>> dp(N + 1, vector<int>(10101, 0));
    dp[0][0] = 1;
    rep(i, 0, N) rep(j, 0, 10101) {
        rep(k, i + 1, N + 1) {
            if (j + S[k - 1] >= 10101) {
                continue;
            }
            dp[k][j + S[k - 1]] |= dp[i][j];
        }
    }
    rrep(i, 10101, 0) {
        if (i % 10 && dp[N][i]) {
            cout << i << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int mod = int(1e+9) + 7;


int main() {
  int n;
  cin >> n;
  map<int, int> m;
  rep(i, n) {
    int p;
    cin >> p;
    auto itr = m.find(p-1);
    if (itr == m.end()) {
      m.insert(make_pair(p, 1));
    } else {
      m.insert(make_pair(p, itr->second + 1));
    }
  }

  int num = 0;
  for (auto& v : m) {
    chmax(num, v.second);
  }

  cout << n - num << endl;

  return 0;
}


Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.Linq;

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

        static void ABC071_B()
        {
            var S = Console.ReadLine();
            var list = new int[123];
            foreach (var s in S)
                list[s] = 1;

            for (var i = 97; i < list.Length; i++)
            {
                if (list[i] == 0)
                {
                    Console.WriteLine((char)i);
                    return;
                }
            }
            Console.WriteLine("None");
        }
    }
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

// int main() {
//   // std::cout << std::fixed << std::setprecision(10);

//   ll N, M, Q;
//   scanf("%lld %lld %lld", &N, &M, &Q);

//   ll prev_a = -1;
//   for (ll n = 2; n <= N; n++) {
//     for (ll m = 1; m <= M; m++) {
//     }
//   }
// }

void recursive_comb(int *indexes, int s, int rest,
                    std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s + 1;
    recursive_comb(indexes, s - 1, rest - 1, f);
    recursive_comb(indexes, s, rest - 1, f);
  }
}

void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

ll N, M, Q;

ll q_list[55][4];

ll ans = 0;

int main() {
  scanf("%lld %lld %lld", &N, &M, &Q);

  for (ll i = 0; i < Q; i++) {
    ll a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

    q_list[i][0] = a;
    q_list[i][1] = b;
    q_list[i][2] = c;
    q_list[i][3] = d;
  }

  foreach_comb(M, N, [](int *indexes) {
    // for (ll i = 0; i < N; i++) {
    //   cout << indexes[i] << ",";
    // }
    // cout << endl;

    ll tmp_ans = 0;
    for (ll j = 0; j < Q; j++) {
      ll a = q_list[j][0];
      ll b = q_list[j][1];
      ll c = q_list[j][2];
      ll d = q_list[j][3];

      // cout << "a:" << a << endl;
      // cout << "b:" << b << endl;

      ll value = indexes[b - 1] - indexes[a - 1];

      // cout << "value:" << value << endl;

      if (c == value) {
        tmp_ans += d;
        // cout << "+d:" << d << endl;
      }
    }
    // cout << "tmp_ans:" << tmp_ans << endl;

    ans = max(ans, tmp_ans);
    // cout << "" << endl;
  });

  cout << ans << endl;
}

Measured memory_bytes: 3680
/*
[ ( ^ _ ^ ) ]
*/

// problem: atc/dp_q

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;

    class BIT {
        int n;
        long[] f;

        public BIT(int n) {
            this.n = n;
            f = new long[n+1];
        }

        public void update(int i, long v) {
            while(i<=n) {
                f[i] = Math.max(f[i], v);
                i += i & (-i);
            }
        }

        public long get(int i) {
            long rs = 0;
            while(i>0) {
                rs = Math.max(rs, f[i]);
                i -= i & (-i);
            }
            return rs;
        }
    }


    void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int[] h = new int[n];
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            h[i] = in.nextInt();
        }
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
        }
        BIT bit = new BIT(n);
        long rs = 0;
        for(int i=0; i<n; i++) {
            long x = bit.get(h[i]-1);
            x += a[i];
            rs = Math.max(rs, x);
            bit.update(h[i], x);
        }
        out.println(rs);
    }
    

    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 63500
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int32_t A[1000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		in >> A[i];
	}
	int count = 0;
	int max = 0;
	for (size_t i = 0; i < N; i++)
	{
		if (max <= A[i])
		{
			count += A[i] - max;
		}
		max = A[i];
	}
	out << count << endl;

	return 0;
}
#endif


Measured memory_bytes: 888
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	READV(H);
	READV(W);
	ll odd=(H+1)/2;
	ll even=H-odd;
	ll ans=1;
	if(H>1 && W>1)
	{
		ans=((W+1)/2)*odd+(W-((W+1)/2))*even;
	}
	cout<<ans<<endl; 

//-----------------------------------------------------------------------------------------------------------//


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

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

using namespace std;

int main(){
  int d,n,ret=1,i;
  cin >> d >> n;
  for(i=0;i<d;i++)ret*=100;
  //cout << ret << endl;
  if(n==100)ret*=101;
  else ret*=n;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

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

    rep(i,n+1){
        rep(j,m+1){
            int black=0;
            black+=i*m+j*n;
            black-=i*j*2;
            if(black==k){
                couty;
                return 0;
            }
        }
    }
    coutn;

}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define zapp ios::sync_with_stdio(false);cin.tie(0)
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll inv(ll x) {return power(x, MOD - 2);}
const int MAXN = 1e5 + 5;
//const bool is_in = container.find(element) != container.end();
int main()
{
	zapp;
	ll n;
	cin >> n;
	set<string> st;
	while (n--)
	{
		string s;
		cin >> s;
		st.in(s);
	}
	cout << st.size();

	return 0;
}

Measured memory_bytes: 19200
#include <bits/stdc++.h>
#define mem(a,b) memset(a, b, sizeof(a))
using namespace std;
typedef  long long ll;
const ll maxn = 1e5+5;

ll max3(ll a, ll b, ll c){
    ll Max = a;
    Max = max(b, Max);
    Max = max(c, Max);
    return Max;
}
ll min3(ll a, ll b, ll c){
    ll Min = a;
    Min = min(b, Min);
    Min = min(c, Min);
    return Min;
}
ll h, w;
ll solve(ll x, ll y){
    ll ans = maxn;
    ll sa, sb, sc;
    for(ll i = 1; i < y; i++){
        sa = x * i;
        sb = x * floor((y-i)/2.0);
        sc = x * ceil((y-i)/2.0);
        ans = min(max3(sa, sb, sc) - min3(sa, sb, sc), ans);
    }
    for(ll i = 1; i < y; i++){
        sa = x * i;
        sb = (y-i) * floor(x/2.0);
        sc = (y-i) * ceil(x/2.0);
        ans = min(max3(sa, sb, sc) - min3(sa, sb, sc), ans);
    }
    return ans;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin >> h >> w;
    if(h%3==0 || w%3==0) {cout << "0" << endl;return 0;}
    ll ans = maxn;
    ans = min(solve(h,w),ans);
    ans = min(solve(w,h),ans);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//AtCoder Beginner Contest 130
//A	Rounding
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		sc.close();

		if (X < A) {
			System.out.println(0);
		} else {
			System.out.println(10);
		}
	}
}


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

int main()
{
    long long n,k,a[200000],j;
    long long  m,x=0,y,z=1,d,i;
    cin>>m>>d;
    set<long long>s;
    for(i=2; i<=m; i++)
    {
        for(j=2; j<=9; j++)
        {
            z=1;
            for(k=2;k<=9;k++)
            {
                if(j*k==i && j*k<=d && z==1)
                {
                    x++;
                    if(((j*10)+k)>d)
                    {
                        x--;
                    }
                }
            }

        }
    }
    cout<<x;
}


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

int main(){
    int h,w,n,sr,sc;
    string s,t;
    cin>>h>>w>>n>>sr>>sc>>s>>t;
    int pl=sc-1,pr=sc-1,pu=sr-1,pd=sr-1;
    int ql=sc-1,qr=sc-1,qu=sr-1,qd=sr-1;
    for(int i=0;i<n;i++){
        if(s[i]=='L'){
            pl--;
            qr--;
            if(pl<0 && qr<0){
                cout<<"NO"<<endl;
                exit(0);
            }
        }
        else if(s[i]=='R'){
            pr++;
            ql++;
            if(pr>=w && ql>=w){
                cout<<"NO"<<endl;
                exit(0);
            }
        }
        else if(s[i]=='U'){
            pu--;
            qd--;
            if(pu<0 && qd<0){
                cout<<"NO"<<endl;
                exit(0);
            }
        }
        else{
            pd++;
            qu++;
            if(pd>=h && qu>=h){
                cout<<"NO"<<endl;
                exit(0);
            }
        }
        if(t[i]=='L'){
            pr=max(pr-1,pl);
            ql=max(ql-1,0);
        }
        else if(t[i]=='R'){
            pl=min(pl+1,pr);
            qr=min(qr+1,w-1);
        }
        else if(t[i]=='U'){
            pd=max(pd-1,pu);
            qu=max(qu-1,0);
        }
        else{
            pu=min(pu+1,pd);
            qd=min(qd+1,h-1);
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 776
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
char a;
bool h[14],s[14],c[14],d[14];
for(int i=1;i<=13;i++)
{
s[i]=h[i]=c[i]=d[i]=false;
}
int aa;
for(int i=0;i<n;i++)
{
cin>>a>>aa;
if(a=='S')s[aa]=true;
else if(a=='H')h[aa]=true;
else if(a=='C')c[aa]=true;
else d[aa]=true;
}
for(int i=1;i<=13;i++)if(!s[i])cout<<"S"<<" "<<i<<endl;
for(int i=1;i<=13;i++)if(!h[i])cout<<"H"<<" "<<i<<endl;
for(int i=1;i<=13;i++)if(!c[i])cout<<"C"<<" "<<i<<endl;
for(int i=1;i<=13;i++)if(!d[i])cout<<"D"<<" "<<i<<endl;
return 0;
}

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

ll n, a, b, c, d;
map<ll, ll> dp;
ll rec(ll num){
    if(dp[num] > 0) return dp[num];
    if(num == 0) return 0;
    if(num == 1) return dp[1] = d;
    ll ret = num*d;
    if(INF/num<d) ret = INF;

    ret = min(ret, d*(num%2) + a + rec(num/2));
    if(num%2 != 0) ret = min(ret, d*(2-num%2) + a + rec((num+(2-num%2))/2));

    ret = min(ret, d*(num%3) + b + rec(num/3));
    if(num%3 != 0) ret = min(ret, d*(3-num%3) + b + rec((num+(3-num%3))/3));

    ret = min(ret, d*(num%5) + c + rec(num/5));
    if(num%5 != 0) ret = min(ret, d*(5-num%5) + c + rec((num+(5-num%5))/5));
    
    return dp[num] = ret;
}

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

    int t;
    cin >> t;

    while(t--){
        cin >> n >> a >> b >> c >> d;
        dp.clear();
        cout << rec(n) << endl;
    }

    return 0;
}

Measured memory_bytes: 4384
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    ans = h[0];
    for(int i = 1; i < n; i++){
        ans += (max(0, h[i] - h[i - 1]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from math import trunc
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin
import math

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()

a = 1
c = 1
b = 1
for i in range(n):
    a *= 9
    a = a%mod
    b *= 10
    b = b%mod
    c *= 8
    c = c%mod

print((c + b - a - a)%mod)



Measured memory_bytes: 69912
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0;i < n;i++){
			a[i] = sc.nextLong();
		}
		long ans = 0;
		for(int  i = 0;i < n;i++){
			while(a[i] != 0){
				if(a[i] % 2 == 0){
					a[i] = a[i]/2;
					ans++;
				}else{
					break;
				}
			}
		}
		System.out.println(ans);



	}
	static long sum(long n){
		long l =  String.valueOf(n).length();
		long s = 0l;
		for(int i = 0;i < l;i++){
			s +=  (long)(n/Math.pow(10, l-1-i));
			n -= (long)Math.pow(10, l-1-i) *(long)(n/Math.pow(10, l-1-i));
		}

		return s;


	}

}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



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

using namespace std;

int solve(int N, const vector<int>& xs)
{
    multiset<int> cs;

    for (auto x : xs)
    {
        auto it = cs.upper_bound(-x);
//cout << "=== x = " << x << ", end?" << (it == cs.end()) << endl;
        if (it != cs.end())
        {
//cout << "x = " << x << ", it = " << *it << endl;
            cs.erase(it);
//cout << "size = " << cs.size() << endl;
        }

        cs.insert(-x);
    }

    return cs.size();
}

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

    int N;
    cin >> N;

    vector<int> xs(N);

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

    auto ans = solve(N, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 5376
s = input().split()
X=int(s[0])
K=int(s[1])
D=int(s[2])
q, mod = divmod(X, D)
if q < 0:
  q = -q
if 2*mod < D:
   if K < q:
      if X > 0:
         m = X - D*K
      else:
         m = X + D*K
   else:
       restmovement = (K-q)%2
       if restmovement==0:
          m = mod
       else:
          m = D - mod
else:
   if X > 0:
      if K < q+1:
         m = X - D*K
      else:
         restmovement = (K - q - 1)%2
         if restmovement==0:
                    m = D - mod
         else:
                    m = mod
   else:
       if K < q-1:
          m=X - D*K
       else:
          restmovement = (K+1-q)%2
          if restmovement==0:
                m = D-mod
          else:
                m = mod
if m < 0:
   print(-m)
else:
   print(m)

Measured memory_bytes: 9244
#include<bits/stdc++.h>
using namespace std;
#define Maxn 200005
#define MOD 1000000007
int n,a[Maxn];
long long ans,s[Maxn];
int main(){
	cin >> n;
	for(int i = 1;i <= n;i++)
		cin >> a[i];
	s[n] = a[n] % MOD;
	for(int i = n - 1;i >= 1;i--)
		s[i] = (a[i] + s[i + 1]) % MOD;
	for(int i = 1;i < n;i++)
		ans = (ans + a[i] * s[i + 1] % MOD) % MOD;
	cout << ans << endl;
	return 0; 
}


Measured memory_bytes: 5920
using System;
using System.Collections;
using System.Collections.Generic;

namespace ABC128 {
  class ProblemB {
    static void Main(string[] args) {
      int n = Input.num;
      Tuple<string, int, int>[] score = new Tuple<string, int, int>[n];
      
      for (int i = 0; i < n; i++) {
        string[] str = Input.strs;
        score[i] = Tuple.Create(str[0], int.Parse(str[1]), i + 1);
      }
      Comparer comp = new Comparer();
      Array.Sort(score, comp);
      for (int i = 0; i < n; i++) {
        System.Console.WriteLine(score[i].Item3);
      }
    }
  }
  public class Comparer : System.Collections.IComparer {
    //xがyより小さいときはマイナスの数、大きいときはプラスの数、同じときは0を返す
    public int Compare(object x, object y) {
        Tuple<string, int, int> z = (Tuple<string, int, int>)x, w = (Tuple<string, int, int>)y;
        int cmp = z.Item1.CompareTo(w.Item1);
        if (cmp == 0) {
          return -1 * z.Item2.CompareTo(w.Item2);
        } else {
          return cmp;
        }
        
    }
  }
  public class Input {
    public static string str => System.Console.ReadLine();
    public static string[] strs => str.Split(' ');
    public static char[] charArr => str.ToCharArray();
    public static int num => int.Parse(str);
    public static int[] nums => Array.ConvertAll(strs, int.Parse);
    public static long numL => long.Parse(str);
    public static long[] numLs => Array.ConvertAll(strs, long.Parse);
  }
}

Measured memory_bytes: 11360
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
map<pair<string,string>,int>H;
string s;
void dfs(int x,int N,string s1,string s2){
    if(x==N){
        H[{s1,s2}]++;
        return;
    }
    dfs(x+1,N,s1+s[x],s2);
    dfs(x+1,N,s1,s2+s[x]);
}
LL an=0;
void dfs2(int x,int N,string s1,string s2){
    if(x<N){
        an+=H[{s1,s2}];
        return;
    }
    dfs2(x-1,N,s1+s[x],s2);
    dfs2(x-1,N,s1,s2+s[x]);
}
int main(){
    int N; R(N);
    R(s);
    dfs(0,N,"","");
    dfs2(2*N-1,N,"","");
    W(an);
    return 0;
}


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

using namespace std;

#define ull unsigned long long
#define ll long long
#define int long long
#define ld long double

#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define MX LLONG_MAX
#define MN LLONG_MIN

const ll mod=1e9+7;
const ll N=1e5+5;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

int32_t main()                  
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    for(ll i=1;i<4;i++)
    {
        if(s[i]==s[i-1])
        {
            cout<<"Bad";
            return 0;
        }
    }
    cout<<"Good";
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    s = input()
    L = len(s)
    ans = ''
    for i in range(0,L,2):
        ans += s[i]
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188