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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	ll a, b;
	cin>>a>>b>>k;
	REP(i, k){
		if(i&1){
			if(b&1){
				--b;
			}
			b>>=1;
			a+=b;
		}
		else{
			if(a&1){
				--a;
			}
			a>>=1;
			b+=a;
		}
	}
	cout<<a<<' '<<b<<'\n';
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}







int main(){
    int N, L; std::cin >> N >> L;
    //dp[i][j] := i番目の兎までを見る。jまでしか進めない
    //但し i -> i&1して圧縮
    std::vector<std::vector<int>> dp(2, std::vector<int>(L, 0));
    for(int i(0); i < L; ++i) dp[0][i] = 1;
    std::vector<int> x(N), a(N);
    for(int i(0); i < N; ++i) std::cin >> x[i];
    for(int i(0); i < N; ++i) std::cin >> a[i];
    for(int i(0); i < N; ++i){
        int cur(i & 1), nxt(!cur);
        for(int j(x[i]); j < L; j += a[i]){
            if(!j) dp[nxt][j] = dp[cur][j];//x[0] = 0のとき
            else dp[nxt][j] += dp[cur][j-1];
            dp[nxt][j] %= MOD;
            if(!a[i]) break;
        }

        for(int j(x[i]); j < L-1; ++j){
            dp[nxt][j+1] = (dp[nxt][j+1] + dp[nxt][j]) % MOD;
        }
        std::fill(std::begin(dp[cur]), std::end(dp[cur]), 0);
    }
    std::cout << dp[N&1][L-1] << std::endl;
    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int A, B, K;

int main(){
    scanf("%d %d %*d %d", &A, &B, &K);
    printf("%d\n", (K&1) ? B-A : A-B);
    return 0;
}


Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [W,H,x,y] = nextIntArray()
    const area = W*H/2
    let pat = 0
    if(x == W/2 && y == H/2) pat = 1
    console.log(area, pat)

}
Main()

Measured memory_bytes: 30552
#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>
using namespace std;

int main() {
    vector<string> vec{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin >> s;
    auto it = find(vec.begin(), vec.end(), s);
    cout << 7 - distance(vec.begin(), it) << endl;
    return 0;
} 


Measured memory_bytes: 256
// Tenka1_Beginner2019_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll A, B, C;
    cin >> A >> B >> C;
    
    // calculation
    if ((A < C && C < B) || (B < C && C < A)) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

const ll mod = 1e9 + 7;

V<ll> fac, finv, inv;
void comb_init(int max) {
  fac.resize(max);
  finv.resize(max);
  inv.resize(max);
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < max; i++) {
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}
ll comb_cache(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

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

  comb_init(2020);
  for (int i = 1; i <= k; i++) {
    ll red = comb_cache(n - k + 1, i);
    ll blue = comb_cache(k - 1, i - 1);
    ll ans = red * blue % mod;
    printf("%ld\n", ans);
  }
}


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

#define ll long long
#define mod 1000000007
#define pii pair<ll,ll>

#define debug(a) { cout << #a << " = " << a << endl;}

void sep() {
    cout << "-------------BLOCK-----------------\n";
}

template<typename T>
void debugv(vector<T> arr) {
    for (auto t: arr)
        cout << t << " ";
    cout << "\n";
}

template<typename T>
void debugarr(T arr, int n) {
    for (int i=0;i<n;i++) cout << arr[i] << " ";
    cout << "\n";
}

const int maxn = 1e5+1;
ll arr[maxn], n, m, t, k;
unordered_map<ll,ll> u;

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

ll mpow(ll a, ll n) {
    ll r = 1;
    while (n-- > 0) {
        r = (r * a) %mod;
    }
    return r%mod;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>n;
    // inclusion exclusion
    ll ans = (mpow(10,n)%mod - mpow(9,n)%mod - mpow(9,n)%mod + mpow(8, n)%mod)%mod;
    ans = (ans+mod)%mod;
    cout << ans << endl;
}




Measured memory_bytes: 3636
N = int(input())
a = list(map(int, input().split()))
Alice = []
Bob = []
while a != []:
    get = max(a)
    Alice.append(get)
    a.remove(get)
    if a != []:
        get = max(a)
        Bob.append(get)
        a.remove(get)
print(sum(Alice) - sum(Bob))

Measured memory_bytes: 3060
import math

N = int(input())

A = N/1.08
B = (N+1)/1.08

if(A.is_integer()):
    print(math.floor(A))
else:
    if(B.is_integer()):
        print(":(")
    else:
        if(math.floor(A) == math.floor(B)):
            print(":(")
        else:
            print(math.floor(B))

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

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

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());

            int f = digsum(n);

            if (n % f == 0) {
                out.println("Yes");
            } else {
                out.println("No");
            }

        }

        int digsum(int n) {
            int res = 0;
            while (n > 0) {
                res += n % 10;
                n /= 10;
            }
            return res;
        }

    }
}



Measured memory_bytes: 21716
#include<stdio.h>
int main(){
	int r,c;
	int a[100][101];
	scanf("%d%d",&r,&c);
	int i,j;
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&a[i][j]);
		}
	}
	int sum=0;
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			sum+=a[i][j];
			printf("%d ",a[i][j]);
			if(j==c-1){
				printf("%d\n",sum);
				a[i][j+1]=sum;
			}
		}
		sum=0;
	}
	for(i=0;i<=c;i++){
		for(j=0;j<r;j++){
			sum+=a[j][i];
		}
		if(i==c){
			printf("%d\n",sum);
			continue;
		}
		
		printf("%d ",sum);
		sum=0;
	}
	return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i ++)
#define rep1(i, n) for (int i=1; i <= n; i ++)
#define _min(x, y) x = min(x, y)
#define _max(x, y) x = max(x, y)
using namespace std;

typedef pair<string, int> P;

int main() {
  int N; cin >> N;
  vector<P> playlist;
  rep(i, N) {
    string s;
    int t;
    cin >> s >> t;
    playlist.push_back(P(s, t));
  }

  string x;
  cin >> x;

  bool flag = false;
  int time_of_sleeping = 0;
  for(P song: playlist) {
    if (song.first == x) {
      flag = true;
    } else if (flag) {
      time_of_sleeping += song.second;
    }
  }
  cout << time_of_sleeping << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n, k, x_i; cin >> n >> k;
    int l=0;
    for (int i=0;i<n;i++){
        cin >> x_i;
        l += min(2*x_i,2*(k-x_i));
    }
    cout << l << endl; 
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

K = int(input())
A, B = map(int, input().split())

flag = False
for i in range(A, B + 1):
    if i % K == 0:
        flag = True
        break

print('OK' if flag else 'NG')



# def main():

# if __name__ == '__main__':
#     main()


Measured memory_bytes: 9584
#include <iostream>
#include <vector>
#include <tuple>

using vec = std::vector<int>;
using Graph = std::vector<vec>;
using edge = std::tuple<int, int, int>;

Graph calc_minimum_dists(Graph g)
{
    Graph min_dist = g;
    int N = g.size();
    for (int k = 0; k < N; k++)
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                min_dist[i][j] =
                    std::min(min_dist[i][j], min_dist[i][k] + min_dist[k][j]);

    return min_dist;
}

int calc_unuse_edge_count(
    Graph &d, std::vector<edge> &es
)
{
    int N = d.size();
    int unuse_edge_count = 0;
    for (auto e : es) {
        int a = std::get<0>(e);
        int b = std::get<1>(e);
        int c = std::get<2>(e);

        bool is_use_edge = false;
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                if (d[i][a] + c + d[b][j] == d[i][j])
                    is_use_edge = true;

        if (!is_use_edge)
            unuse_edge_count += 1;
    }
    return unuse_edge_count;
}

int main()
{
    int N, M;
    std::cin >> N >> M;
    Graph d(N, vec(N, 1e9));
    std::vector<edge> e;

    for (int i = 0; i < N; i++)
        d[i][i] = 0;

    for (int i = 0; i < M; i++) {
        int a, b, c;
        std::cin >> a >> b >> c;
        a--; b--;
        d[a][b] = d[b][a] = c;
        e.emplace_back(a, b, c);
    }

    Graph min_dist = calc_minimum_dists(d);
    std::cout << calc_unuse_edge_count(min_dist, e) << std::endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)



int main() {
	int i = 0,n, h = 0, p, ans = 0;
	double d ;
	cin >> n;
	vector<int>x(n);
	rep(i, n) {
		cin >> x.at(i);
		h += x.at(i);
	}
	p = h / n;
	if ((h % n *10)/n> 4) {
		p++;
	}
	rep(i, n) {
		d = (double)p - (double)x.at(i);
		ans += (int)d * (int)d;
	}
	cout << ans << endl;

	return 0;
}





Measured memory_bytes: 3612
N,M,Q=gets.chomp.split(" ").map(&:to_i)
AS=(1..M).to_a.repeated_combination(N).to_a
rets=Array.new(AS.length,0)
ret=0
Q.times do
    a,b,c,d=gets.chomp.split(" ").map(&:to_i)
    AS.each_with_index do |array,i|
        rets[i]+=d if array[b-1]-array[a-1]==c
        ret=rets[i] if ret<rets[i]
    end
end
puts ret


Measured memory_bytes: 28464
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
/*int main(){
    int n;
    cin >> n;
    int num = 0;
    vector<int> res;
    for (int i = 0; i < n; i++)
    {
        cin >> num;
        res.push_back(num);
    }
    int max_num = -2000000000;
    for (int i = 0; i < res.size()-1; i++)
    {
        for (int j = i+1; j < res.size(); j++)
        {
            max_num = max(max_num,res[j]-res[i]);
        }
    }
    cout << max_num <<endl;
    return 0;
}*/
int main(){
    int n;
    cin >> n;
    int num = 0;
    vector<int> res;
    for (int i = 0; i < n; i++)
    {
        cin >> num;
        res.push_back(num);
    }
    int max_num = -2000000000;
    int min_num = res[0];
    for (int j = 1; j < res.size(); j++){
        max_num = max(max_num, res[j]-min_num);
        min_num = min(min_num, res[j]);
    }
    cout << max_num << endl;
    return 0;
}



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

set<long long> prime(long long a){
    set<long long> p;
    for(long long k=2; k*k <= a;){
        if(a % k == 0){
            a /= k;
            p.insert(k);
        }else ++k;
    }
    if(a != 1) p.insert(a);

    return p;
}

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

    set<long long> ay = prime(a), by = prime(b);
    
    int ans = 0;
    auto itr = ay.begin();
    while(itr != ay.end()){
        if(by.find(*itr) != by.end()) ++ans;
        ++itr;
    }

    cout << ans + 1 << endl;
}


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

int main() {
  ll n, m;
  cin >> n >> m;
  if (n == 1 && m == 1) {
    cout << 1 << endl;
  } else if (n == 1) {
    cout << m - 2 << endl;
  } else if (m == 1) {
    cout << n - 2 << endl;
  } else {
    cout << (2 < n ? n - 2 : 0) * (2 < m ? m - 2 : 0) << endl;
  }
}


Measured memory_bytes: 256
#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 N;
  cin >> N;
  string s;
  cin >> s;

  int sumb[N+1];
  int sumw[N+1];
  sumb[0] = 0;
  sumw[0] = 0;
  for(int i=0;i<N;i++){
    if(s[i] == '#'){
      sumb[i+1] = sumb[i] + 1;
      sumw[i+1] = sumw[i];
    }
    else {
      sumb[i+1] = sumb[i];
      sumw[i+1] = sumw[i] + 1;
    }
  }

  int ans = 1000000000;
  for(int i=0;i<=N;i++){
    int tmp = 0;
    tmp += sumb[i] - sumb[0];
    tmp += sumw[N] - sumw[i];
    ans = min(ans, tmp);
  }

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


Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(m);
  for (int i = 0; i < m; i++){
    int k;
    cin >> k;
    v[i].resize(k);
    for (int j = 0; j < k; j++){
      cin >> v[i][j];
      v[i][j]--;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++)
    cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << n); i++){
    bool ok = true;
    for (int j = 0; j < m; j++){
      int c = 0;
      for (int id:v[j])
        if ((i >> id)&1)
          c++;
      if (c%2 != p[j])
        ok = false;
    }
    if (ok)
      ans++;
  }
  cout << ans << endl;
}


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

using namespace std;

struct Dsu {
    int n;
    vector<int> p;
    vector<int> r;
    
    Dsu(int _n) { n = _n; p.resize(n); r.resize(n); init(); }
    inline void init() {
        for (int i = 0; i < n; i++) {
            p[i] = i;
            r[i] = 1;
        }
    }
    inline int find(int x) {
        return p[x] == x ? x: p[x] = find(p[x]);
    }
    inline bool join(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (r[x] < r[y]) swap(x, y);
        p[y] = x; r[x] += r[y];
        return true;
    }
    inline bool check(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x){
        return r[find(x)];
    }
};

void solve() {
    int n,m,k;
    cin >> n >> m >> k;
    Dsu d(n);
    vector<set<int>> fr(n);
    for (int _ = 0; _ < m; _++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        d.join(x,y);
        fr[x].insert(y);
        fr[y].insert(x);
    }
    vector<int> res(n);
    for (int i = 0; i < n; i++) {
        res[i] = d.size(i) - fr[i].size() - 1;
    }
    for (int _ = 0; _ < k; _++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        if (fr[x].find(y) == fr[x].end() && d.check(x,y)) {
            res[x]--;
        }
        swap(x,y);
        if (fr[x].find(y) == fr[x].end() && d.check(x,y)) {
            res[x]--;
        }
    }
    for (auto& x: res) {
        cout << x << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a>0){
    cout << "Positive" << endl;
  }
  else if(a<=0&&0<=b){
    cout << "Zero" << endl;
  }
  else{
    if((b-a)%2) cout << "Positive" << endl;
    else cout << "Negative" << endl;
  }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const intll INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  string s; 
  cin >> s ; 
  
  rep(i,s.size()){
    if(s.at(i) == '?') cout <<'D' ;
    else               cout << s.at(i) ;
  }
  
  cout << endl ;
  
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion

int dp[2002][2002];
void solve()
{
    forn(i, 2002) forn(j, 2002) dp[i][j] = LLONG_MIN;
    int n; cin>>n;
    vector<int> a(n);
    forn(i, n) cin>>a[i];
    vector<pair<int,int>> v;
    forn(i, n) v.pb(mp(a[i], i));
    sort(v.rbegin(), v.rend());
    dp[0][0] = 0;
    forn(i, n) for(int j=0;i+j<n;++j)
    {
        int k = i+j;
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + v[k].f * abs(v[k].s - i));
        dp[i][j+1] = max(dp[i][j+1], dp[i][j] + v[k].f * abs(v[k].s - (n-1-j) ));
    }
    int ans = 0;
    for(int i=0;i<=n;++i) ans = max(ans, dp[i][n-i]);
    cout << ans << '\n';
}

signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    //cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


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

using namespace std;

int main(){
    string s1;
    while (cin >> s1){
        for (int n = 0; n < s1.size(); n++){
            if (s1[n] == '@'){
                for (int m = s1[n + 1]; m > '0'; m--){
                    cout << s1[n + 2];
                }
                n += 2;
            }
            else{
                cout << s1[n];
            }
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3048
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

int main(){
  int n;
  string c;
  string s="";
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> c;
    s+=c;
  }
  
  const char *ss = s.c_str();
  
  for(int i=0;i<=1000;i++){
    char tmp[5];
    sprintf(tmp,"%d",i);
    if(strstr(ss,tmp)==NULL){
      printf("%d\n",i);
      return 0;
    }
  }
}

Measured memory_bytes: 1228
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int a[300010];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,m;
    long long ans=0;
    cin>>n,m=n*3;
    for(int i=1;i<=m;i++) a[i]=gi();
    sort(a+1,a+1+m);
    for(int i=1;i<=n;i++) ans+=a[m-i-i+1];
    cout<<ans;
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'


void solve(){
    int n;
    cin>>n;
    vi a(n, 0);
    rep(i, n, 0)cin>>a[i];
    lli sum =0;
    for(int i = 1;i< n;i++){
        if(a[i] < a[i-1]){
            sum += a[i-1]-a[i];
            a[i] = a[i-1];
        }
    }
    cout<<sum<<endl;
    return ;
}


int main()
{
    fastio;
    int t;
    // cin>>t;
    t =1;
    while(t--)solve();

}

Measured memory_bytes: 3988
from collections import Counter
N = int(input())
Sl = [input() for _ in range(N)]
cSl = Counter(Sl).most_common()
pre = ""
maxl = []
for k, v in cSl:
    if pre != "" and pre != v:
        break
    maxl.append(k)
    pre = v
for e in sorted(maxl):
    print(e)

Measured memory_bytes: 45040
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 

ll m = 1e9+7;
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >>n;
	vector <ll> arr(63,0);
	for (int z=0;z<n;z++){
		ll temp;
		cin >> temp;
		for (int x=0;x<63;x++){
			if (temp & ll(1) << x){
				arr[x]++;
			}
		}
	}
	ll i = 1;
	ll ans = 0;
	for (int z=0;z<63;z++){
		ans += (((i*arr[z])%m)*(n-arr[z]))%m;
		ans %= m;
		i *= 2;
		i %= m;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
const int INF=2147483647;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
#define SIZE 13
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int N,M,X,flag,ans=INF;
int POW[SIZE],a[SIZE];
int b[SIZE][SIZE],c[SIZE];
int main(){
	POW[0] = 1;
	for(int i = 1; i <=SIZE; i++){
		POW[i] = POW[i-1]<<1;
	}
	N=read(),M=read(),X=read();
	for(int i = 0; i < N; i++){
		a[i]=read();
		for(int j = 0; j < M; j++) b[i][j]=read();
	}	
	for(int i = 0; i < POW[N]; i++){
		memset(c,0,sizeof(c)); 
		int sum = 0;
		for(int j = 0; j < N; j++){
			if(i & POW[j]){
				sum += a[j];
				for(int k = 0; k < M; k++)c[k] += b[j][k];
			}
		} 
		flag = 1;
		for(int j = 0; j < M; j++){
			if(c[j] < X){
				flag = 0;
				break;
			}
		}
		if(flag) ans = min(ans,sum);
	}
	if(ans == INF) printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
const int INF=1001001001;

int main(){
  int n;
  cin >> n;
  vector<int> hig(n);
  for(int i=0; i<n; ++i){
    cin >> hig.at(i);
  }
  vector<int> dp(n);
  dp.at(1) += abs(hig.at(0) - hig.at(1));
  for(int i=2; i<n; ++i){
    dp.at(i)=min(dp.at(i-2) +abs(hig.at(i-2) -hig.at(i)),dp.at(i-1) +abs(hig.at(i-1) -hig.at(i)));
  }
  cout << dp.at(n-1) << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	ll N, Z, W;
	cin >> N >> Z >> W;
	vector<ll> a(N);
	REP(i, N) cin >> a[i];
	if(N==1){
		cout << abs(a[0] - W) << endl;
	}else{
		cout << max(abs(a[N-1] - W), abs(a[N-1] - a[N-2])) << endl;
	}
    return 0;
}

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



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

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

    ll n;cin>>n;
    vector<ll> a(n);
    vector<ll> sum(n);

    for(ll i=0;i<n;i++){
        cin>>a[i];
    }

    ll c1=0;

    for(int i=0;i<n;i++){
        if(i==0) sum[i] = a[i];
        else sum[i]=sum[i-1]+a[i];

        if(i%2==0 && sum[i]<=0){
            c1 += abs(sum[i])+1;
            sum[i]=1;
        }
        else if(i%2==1 && sum[i]>=0){
            c1+= abs(sum[i])+1;
            sum[i]=-1;
        }

    }

    ll c2=0;

    for(int i=0;i<n;i++){
        if(i==0) sum[i] = a[i];
        else sum[i]=sum[i-1]+a[i];

        if(i%2==0 && sum[i]>=0){
            c2 += abs(sum[i])+1;
            sum[i]=-1;
        }
        else if(i%2==1 && sum[i]<=0){
            c2+= abs(sum[i])+1;
            sum[i]=1;
        }

    }

    cout<<min(c1,c2)<<endl;

}


Measured memory_bytes: 4772
N,K=map(int,input().split())
ans=0

n=N//K
ans+=n
if n>=2:
    ans+=n*(n-1)*3
    if n>=3:
        ans+=n*(n-1)*(n-2)
#print(ans)#1
if K%2==1:
    #n=N//K
    #ans+=nk
    #if nk>=2:
    #    ans+=nk*(nk-1)*3/2
    #    if nk>=3:
    #        ans+=nk*(nk-1)*(nk-2)
    #print(ans)
    print(int(ans))
else:
    #n=N//(K/2)
    #n=(N-K/2)//K
    n=(N+K/2)//K
    #print("n",n)#2
    ans+=n
#if n>=2:
#    ans+=n*(n-1)*3/2
#    if n>=3:
#        ans+=n*(n-1)*(n-2)
#print(int(ans))
    if n>=2:
        #ans+=n*(n-1)*3/2
        ans+=n*(n-1)*3
        if n>=3:
            ans+=n*(n-1)*(n-2)
    print(int(ans))


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

int main(){
	int n;
	cin >> n;
	map<string, int> mp;
	rep(i, n){
		string s;
		cin >> s;
		mp[s]++;
	}

	int m;
	cin >> m;
	rep(i, m){
		string t;
		cin >> t;
		mp[t]--;
	}

	int ans = 0;
	for(pair<string, int> p : mp){
		string key = p.first;
		int value = p.second;
		ans = max(ans, value);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHEEM
//ALLAH IS WATCHING ME
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cmath>
#include<iterator>
#include<cstdlib>
#define IOS   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test IOS long long t;cin >> t;while(t--)
#define ses   "\n"
#define whp   " "
#define mxi 200003
#define rep0(i,a,b) for(int i=a; i<b; i++)
#define rep1(i,a,b) for(int i=a; i<=b; i++)
#define rep0in(i,a,b) for(int i=a-1; i>=b; i--)
#define rep1in(i,a,b) for(int i=a; i>b; i--)
#define repv(i,a) for(auto i=a.begin(); i!=a.end();++i)
#define INF 0x3f3f3f3f
#define CLR(a,b) memset(a,b,sizeof(a));
#define PI acos(-1)
#define what_is(x) cout<<x<<ses;
//set <int, greater <int> > ::iterator it;
//vector<pair<int,int> >a;
//memset(arr,0,sizeof(hg));
//priority_queue <int, vector<int>, greater<int> > pq;
///  string single character erase-
///             s.erase(s.begin()+x); where s is st ring name
///               ans x is index;
///    transform(sl.begin(), sl.end(), sl.begin(), ::tolower);
///    transform(su.begin(), su.end(), su.begin(), ::toupper);
typedef long long v99;
typedef unsigned long long ull;
using namespace std;
v99 fx[4]= {1,-1,0,0};
v99 fy[4]= {0,0,1,-1};
v99 ox8[] = {0, 0, 1, 1, 1, -1, -1, -1};
v99 oy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
bool sort2val(const pair<int,int> &a,const pair<int,int> &b)
{
    if(a.second==b.second)return a.first<b.first;
    return a.second<b.second;
}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
/**
bool prime[1000020];vector<v99>prm;
void SieveOfEratosthenes(v99 n)
{
	memset(prime, true, sizeof(prime));
	for(v99 i=4;i<=n;i+=2)prime[i]=false;
	for (v99 p=3; p*p<=n; p++)
	{
		if (prime[p] == true)
		{
			/// Update all multiples of p
			for (v99 i=p*p; i<=n; i += 2*p)
				prime[i] = false;
		}
	}
	rep1(i,2,n)if(prime[i])prm.push_back(i);

}*/
v99 pw(v99 a, v99 b)
{
	v99 ans = 1;
	for(v99 i = 1; i <= b; ++i)
		ans = (ans * a);
	return ans;
}

template <class T> inline T bigmod(T n,T p,T m)
{
    if(p==0)return 1;
    else if(p%2==0)
    {
        v99 val=bigmod(n,p/2,m);
        return (T)((val*val)%m);
    }
    else return (T)(((v99)n*(v99)bigmod(n,p-1,m))%m);
}


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



int main()
{

    //freopen("data.out","w",stdout);
    //test
    //while(1)
    {
        v99 n;cin>>n;v99 visi[mxi];CLR(visi,0);
        rep1(i,1,100)
        {
            rep1(j,1,100)
            {
                rep1(k,1,100)
                {
                    v99 ans=(i+j)*(i+j);
                    ans+=(i+k)*(i+k);
                    ans+=(k+j)*(k+j);
                    ans/=2;
                    visi[ans]++;
                }
            }
        }
        rep1(i,1,n)cout<<visi[i]<<ses;
    }
    return 0;
}






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

using namespace std;

int findSumDigits(int N) {
	int sum = 0;
	while (N > 0) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}

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

	int total = 0;

	for (int i = 1; i <= N; i++) {
		int sum = findSumDigits(i);
		if (sum >= A&&B >= sum) {
			total += i;
		}
	}

	cout << total << endl;

	return 0;
}

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

int main() {
    using namespace std;

    string S;
    cin >> S;

    string alpha = "abcdeifghijklmnopqrstuvwsyz";

    for (int i=0; i<alpha.length(); i++) {
        char s = alpha[i];
        bool found = false;
        for (int j=0; j<S.length(); j++) {
            if (s == S[j]) {
                found = true;
                break;
            }
        }
        if (!found) {
            cout << s << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <map>

using namespace std;

int main(void){
    int n;
    map<int,int> dict;

    // input
    cin >> n;
    for (int i=0;i<n;i++){
        int v;
        cin >> v;
        dict[v] += 1;
    }
    cout << dict.size();
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a, b, c;
	scanf("%d %d %d",&a, &b, &c);
	
	if((a < c && c < b)||(a > c && c > b)){
	printf("Yes");
	}else{
	
	printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  vector<long long> L;
  L.push_back(2ll);
  L.push_back(1ll);
  cin >> N;
  for(int i = 2;i <= N;i++){
    L.push_back(L.at(i-1) + L.at(i-2));
  }
  cout << L.at(N);
}

Measured memory_bytes: 3632
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
ll MOD = 1000000007;

int main() {
  //
  int N;
  cin >> N;
  int ans = 0;
  rep(i, N) {
    int a;
    cin >> a;
    ans += a;
  }
  ans -= N;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*N
point=1
m,l=0,0#mは循環する町の数、lはそれまでの町の数
if K>N:
    for i in range(N):
        if B[point-1]==0:
            B[point-1]=i+1
            point=A[point-1]
        else:
            m=i+1-B[point-1]
            l=B[point-1]
            break
    if m!=0:
        m=(K-l)%m
    else:
        m=N
else:
    m=K
ans=1
for i in range(l+m):
    ans=A[ans-1]

print(ans)

Measured memory_bytes: 32280
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;

/*----------macros----------*/

//input, output================
#define fastio                          \
std::ios::sync_with_stdio(false);       \
std::cin.tie(nullptr);                  \
std::cout.tie(nullptr)

#define endl '\n'
#define fcout(a)                        \
cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF    = (ll)1e9 + 1;
constexpr ll INFll  = (ll)1e18 + 1;
constexpr ll MOD1   = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define snd second

//others================
#define sz(x)                           \
(int) x.size()

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

#define rall(x)                         \
(x).rbegin(), (x).rend()

#define rep(i, n)                       \
for(int i = 0; (i) < (n); ++(i))

#define reps(i, n)                      \
for(int i = 1; (i) <= (n); ++(i))

#define rrep(i, n)                      \
for(int i = n - 1; (i) >= 0 ; --(i))

#define repbit(bit, n)                  \
for(int bit = 0; (bit) < (1 << (n)); ++(bit))

#define ifbit(bit, i)                   \
if((bit) & (1 << (i)))

#define CtoI(c)                         \
int((c)) - int('0')

#define ItoC(c)                         \
char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b)
{ return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b)
{ return a > b && (a = b, true); }

// Vi  dx = {1, 0, -1, 0},
//     dy = {0, 1, 0, -1};

// Vi  dx2 = { 1,1,0,-1,-1,-1,0,1 },
//     dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
fastio;

    string s; cin >> s;
    if((s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) ||
       (s[0] == s[2] && s[0] != s[1] && s[1] == s[3]) ||
       (s[0] == s[3] && s[0] != s[1] && s[1] == s[2])){
           cout << "Yes" << endl;
           return 0;
       }

       cout << "No" << endl;

return 0;
}

Measured memory_bytes: 3564
import numpy as np

n, k, q = map(int, input().split())
a = np.array([int(input()) for i in range(q)])

players_score = np.full(n, k-q)

for item in a:
    players_score[item-1] += 1

for i in players_score:
    if i <= 0:
        print("No")
    else:
        print("Yes")

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int d, ans=0;
	vector<int> c, t, ld, at;
	vector< vector<int> >s;

	cin>> d;

	c.resize(26);
	rep(i, 26) cin>> c[i];
	s.resize(d);
	rep(i, d){
		s[i].resize(26);
		rep(j, 26) cin>> s[i][j];
	}
	t.resize(d);
	at.resize(d);
	rep(i, d){
		int tmp=1, ma=-1;
		rep(j, 26){
			if(ma<s[i][j]){
				tmp=j;
				ma=s[i][j];
			}
		}
		t[i]=tmp;
		cout<< t[i]+1 <<endl;
	}
	return 0;
	ld.resize(26);

	/*int m;
	vector<int> qd, qq;
	cin>> m;
	qd.resize(m);
	qq.resize(m);
	rep(i, m) cin>> qd[i] >> qq[i];*/
	
  	std::random_device seed_gen;
  	std::mt19937 engine(seed_gen());

	int ti = clock();
    while (clock() - ti < 189 * CLOCKS_PER_SEC / 100){
		//t[qd[k]-1]=qq[k]-1;
		ans=0;
		rep(i, 26) ld[i]=0;

		rep(i, d){
			ans+=s[i][t[i]];
			ld[t[i]]=i+1;
			rep(j, 26) ans-=(i-ld[j]+1)*c[j];
		}
		cout<< ans << endl;
	}
 
	return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll a[300005];
int main()
{
    int n;
    ll ans=0,ans1 = 0,ans2=0,ans3=0,fu = 0,zh = 0,lng = 0;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%lld",&a[i]);
        a[i] = a[i] - i - 1;
        if(a[i]>0) zh++;
        else if(a[i]<0) fu++;
        else lng++;
    }
    sort(a,a+n);
    if(abs(zh-fu)<=lng)
    {
        for(int i = 0; i < n; i++)
            ans = ans +abs(a[i]);
    }
    else if(zh > fu)
    {
        for(int i = 0; i < n; i++)
            ans = ans + abs(a[i]-a[fu+lng]);
    }
    else
    {
        for(int i = 0; i < n; i++)
            ans = ans + abs(a[i] - a[fu-1]);
    }
    int zho = (a[(n-1)/2]+a[n/2])/2;
    for(int i = 0; i < n; i++)
    {
        ans1 = ans1 + abs(a[i]-zho);
        ans2 = ans2 + abs(a[i]-zho-1);
        ans3 = ans3 + abs(a[i]-zho+1);
    }
    printf("%lld\n",min(ans,min(ans1,min(ans2,ans3))));
    return 0;
}


Measured memory_bytes: 1792
day=input()

if day=="MON":
	print("6")
elif day=="TUE":
	print("5")
elif day=="WED":
	print("4")
elif day=="THU":
	print("3")
elif day=="FRI":
	print("2")
elif day=="SAT":
	print("1")
elif day=="SUN":
	print("7")
else:
	print("0")

Measured memory_bytes: 3060
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *                # alpha = ascii_lowercase
from random import *                # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *                # d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter        # d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
10 9 3
10 1
6 7
8 2
2 5
8 4
7 3
10 9
6 4
5 8
2 6
7 5
3 1
'''

class DSU:

	def __init__(self,n):
		self.n = n
		self.par = list(range(self.n))
		self.size = [1 for i in range(self.n)]

	def find(self,i):
		while(i != self.par[i]):
			self.par[i] = self.par[self.par[i]]
			i = self.par[i]
		return i

	def unite(self,a,b):
		par_a = self.find(a)
		par_b = self.find(b)
		if(par_a == par_b):
			return False
		else:
			if(par_a <= par_b):
				self.par[par_b] = par_a
				self.size[par_a] += self.size[par_b]
				self.size[par_b] = 0
			else:
				self.par[par_a] = par_b
				self.size[par_b] += self.size[par_a]
				self.size[par_a] = 0
			return True

	def same(self,a,b):
		return self.par[a] == self.par[b]

	def size(self,a):
		return self.size[a]

N,M,K = map(int, stdin.readline().rstrip().split())
dsu = DSU(N)
directFriends = [0]*N
for i in range(M):
	a,b = map(int, stdin.readline().rstrip().split())
	a -= 1
	b -= 1
	dsu.unite(a,b)
	directFriends[a] += 1
	directFriends[b] += 1

enemiesInSameComponent = [0]*N
for i in range(K):
	a,b = map(int, stdin.readline().rstrip().split())
	a -= 1
	b -= 1
	if(dsu.find(a) == dsu.find(b)):
		enemiesInSameComponent[a] += 1
		enemiesInSameComponent[b] += 1


candidates = [0]*N
for i in range(N):
	tot = dsu.size[dsu.find(i)]
	candidates[i] = tot - directFriends[i] - enemiesInSameComponent[i] - 1


# print('PAR:',dsu.par)
# print('SIZE:',dsu.size)
# print()
# print(directFriends)
# print()
print(*candidates)



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

using namespace std;

typedef long long ll;

int main() {
    int X;
    cin >> X;

    if (X <= 599) { cout << 8 << endl; }
    else if (X <= 799)  { cout << 7 << endl; }
    else if (X <= 999)  { cout << 6 << endl; }
    else if (X <= 1199) { cout << 5 << endl; }
    else if (X <= 1399) { cout << 4 << endl; }
    else if (X <= 1599) { cout << 3 << endl; }
    else if (X <= 1799) { cout << 2 << endl; }
    else { cout << 1 << endl; }
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(ReadLine());
        int[] A = ReadLine().Split(' ').Select(int.Parse).ToArray();
        int[] ans = new int[N];
        for(int i = 0; i < N; i++)
        {
            ans[A[i] - 1] = i + 1;
        }
        for(int i = 0; i < N; i++)
        {
            Write(ans[i]);
            if(i < N - 1)
            {
                Write(" ");
            }
        }
    }
}

Measured memory_bytes: 26332
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const double EPS = 1e-12;

i64 tp(i64 n) {
    i64 ret = 1;
    for (i64 i = 0; i < n; i++) ret *= 2;
    return ret;
}

int main(void) {
    i64 n, k, m, s = 0;
    scanf("%lld%lld", &n, &k);
    for (i64 i = 1; i <= n; i++) {
        i64 x = i, c = 0;
        while (k > x) {
            x *= 2;
            c++;
        }
        //printf("%lld\n", c);
        if (i == 1) m = n * tp(c);
        s += m / (n * tp(c));
    }
    printf("%0.16lf\n", (double)s / m);
}


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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int r = 0, b = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'R') r++;
    else b++;
  }
  cout << (r > b ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3624
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict


def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            lower_divisors.append(i)
            n=n//i
  #          if i != n // i:
  #              upper_divisors.append(n//i)
        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return lower_divisors + nokori # upper_divisors[::-1]

def main():
    n=int(input())
 #   n=2**40
    yaku=make_divisors(n)
    memo = defaultdict(int)
    for i in range(len(yaku)):
        memo[yaku[i]]+=1
    ans=0
    for b in memo.values():
        if b<=2:
            ans+=1
        elif b>=3 and b<=5:
            ans+=2
        elif b>=6 and b<=9:
            ans+=3
        elif b >= 10 and b <= 14:
            ans += 4
        elif b >= 15 and b <= 20:
            ans += 5
        elif b >= 21 and b <= 27:
            ans += 6
        elif b >= 28 and b <= 35:
            ans += 7
        elif b >= 36 and b <= 44:
            ans += 8
        elif b>=45:
            ans+=9


    if n==1:
        print(0)
    else:
        print(ans)


 #   print(memo)
 #   print(yaku)








if __name__ == "__main__":

    main()

Measured memory_bytes: 72900