akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int n, m, p;
vector<string> name;
vector<vector<int> > d;
map<string, string> variable;
bool error;

vector<int> solve(const string& s, int a, int b)
{
    int brackets = 0;
    for(int i=b-1; i>=a; --i){
        if(s[i] == '(')
            ++ brackets;
        else if(s[i] == ')')
            -- brackets;
        else if(brackets == 0 && (s[i] == '+' || s[i] == '-')){
            vector<int> x = solve(s, a, i);
            vector<int> y = solve(s, i+1, b);
            if(x != y)
                error = true;
            return x;
        }
    }

    for(int i=b-1; i>=a; --i){
        if(s[i] == '(')
            ++ brackets;
        else if(s[i] == ')')
            -- brackets;
        else if(brackets == 0 && (s[i] == '*' || s[i] == '/')){
            vector<int> x = solve(s, a, i);
            vector<int> y = solve(s, i+1, b);
            if(s[i] == '*'){
                for(int j=0; j<n; ++j)
                    x[j] += y[j];
            }else{
                for(int j=0; j<n; ++j)
                    x[j] -= y[j];
            }
            return x;
        }
    }

    if(s[a] == '(')
        return solve(s, a+1, b-1);

    string t = s.substr(a, b-a);
    return d[find(name.begin(), name.end(), variable[t]) - name.begin()];
}

int main()
{
    for(;;){
        cin >> n >> m >> p;
        if(n == 0)
            return 0;

        name.resize(m);
        d.assign(m, vector<int>(n));
        for(int i=0; i<m; ++i){
            cin >> name[i];
            for(int j=0; j<n; ++j)
                cin >> d[i][j];
        }

        string formula;
        cin >> formula;

        variable.clear();
        for(int i=0; i<p; ++i){
            string s, t;
            cin >> s >> t;
            variable[s] = t;
        }

        error = false;
        vector<int> ret = solve(formula, 0, formula.size());
        if(error)
            cout << "error" << endl;
        else{
            int j = -1;
            for(int i=0; i<m; ++i){
                if(ret == d[i])
                    j = i;
            }
            if(j == -1)
                cout << "undefined" << endl;
            else
                cout << name[j] << endl;
        }
    }
}

Measured memory_bytes: 0
import Base.readline
function readline(T)
    map(x->parse(T, x), split(readline()))
end

cnt = fill(false, 4)
for i in 1:3
    for v in readline(Int)
        cnt[v] $= true
    end
end

if sum(cnt) == 2
    println("YES")
else
    println("NO")
end

Measured memory_bytes: 111576
#include <iostream>

using namespace std;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  string ans;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == 'B') {
      if (ans.length() > 0) {
        ans.pop_back();
      }
    } else {
      ans.push_back(s[i]);
    }
  }


  cout << ans << "\n";
  return 0;
}

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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ) {
    cout << "vowel" << endl;
  }
  else
    cout << "consonant" << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long long n, k, q, i, j, l, cnt = 0, x;

    cin >> n;

    cout << pow(n, 3) << endl;

    return 0;
}


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

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

ans = []

for i in range(N) :
    ss = -ss + 2*A[i]
    ans.append(ss)

print('{} '.format(ans[-1]), end='')
ans.pop()

for a in ans :
    print('{} '.format(a), end='')
print('')

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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    string S; cin >> S;
    ll K; cin >> K;

    ll t = 0;
    ll ans = 1;

    for (int i = 0; i < 100; ++i) {
        if (S[i] - '0' > 1) {
            t = i + 1;
            ans = S[i] - '0';
            break;
        }
    }

    if (t <= K) {
        cout << ans << endl;
    } else {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>


int main(){

  int n, i, x;

  scanf("%d", &n);
  
  for(i=1;i<=n;i++){
    x=i;
    if(i%3==0){
      printf(" %d", i);
    }else{
      while(x>0){
	if(x%10==3){
	  printf(" %d", i);
	  break;
	}
	x/=10;
      }
    }
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <algorithm>
using namespace std;

int partition(int A[], int p, int r) {
    int x = A[r];
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[r]);
    return i + 1;
}

int main(void) {
    int n, i, idx, A[150000];
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);

    idx = partition(A, 0, n - 1);

    for (i = 0; i < n; i++) {
        if (i) printf(" ");
        if (i == idx) printf("[");
        printf("%d", A[i]);
        if (i == idx) printf("]");
    }
    printf("\n");

    return 0;
}

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

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define piii    pair<int, pair<int, int>>
                                   
int main() {
        int i, j;
        string s;
        cin >> s;
        cout << s[0] << (int)s.size() - 2 << s.back() << endl;
        return 0;
}



Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	vi co(100);
	loop(i,1,n+1){
		int t=i;
		loop(j,2,101)while(t%j==0){
			t/=j;
			co[j]++;
		}
	}
	vvi dp(101,vi(100));
	dp[0][1]=1;
	rep(i,100)rep(j,100)rep(k,co[i]+1)if(dp[i][j]){
		dp[i+1][min(90ll,j*(k+1))]+=dp[i][j];
	}
	cout<<dp[100][75]<<endl;
}






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

int main(){
    int n, d, ans=0;
    cin >> n >> d;
    vector<vector<int>> vec(n, vector<int>(d));
    for(int i=0; i<n; i++){
        for (int j=0; j<d; j++){
            cin >> vec[i][j];
        }
    }
    for(int i=0; i<n; i++){
        for(int j=1+i; j<n; j++){
            int norm=0;
            for(int k=0; k<d; k++){
                int diff = abs(vec[i][k] - vec[j][k]);
                norm += diff * diff;
            }
            bool flg=false;
            for(int k=0; k<=norm; k++){
                if(k*k == norm) flg=true;
            }
            if(flg) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	int n,a,b,c;cin>>n>>a>>b>>c;
	cout<<n-(a+b-c)<<endl;
}


Measured memory_bytes: 3124
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,s = map(int,read().split())

def f(b,n):
    r = 0
    while n:
        r += n%b
        n//= b
    return r

M = 4*10**5

ans = -1
for i in range(2,M):
    if f(i,n) == s:
        print(i)
        break
else:
    for x in range(M,0,-1):
        if (n-s)%x==0:
            b = (n-s)//x + 1
            #print(b)
            if x < b and 0 <= s-x < b:
                print(b)
                break
    else:
        if n==s:
            print(n+1)
        else:
            print(-1)
    
    
    
    
    
    

Measured memory_bytes: 73464
<?php

while ($stdin = fgets(STDIN)) {
    $line[] = trim($stdin);
}
foreach ($line as $key => $value) {
    $data[] = explode(' ', $value);
}

foreach ($data as &$line) {
    $line = array_map(function($val) { return (int)$val; }, $line);
}

$N = $data[0][0];

$n11 = floor($N / 11);
$mod = $N % 11;

if ($mod === 0) {
    $ans = $n11 * 2;
} else if (1 <= $mod && $mod <= 6) {
    $ans = $n11 * 2 + 1;
} else {
    $ans = $n11 * 2 + 2;
}

printf("%d", $ans);


Measured memory_bytes: 4604
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    int n, k;
    cin >> n >> k;
    --k;

    string s;
    cin >> s;

    if (s[k] >= 'A' && s[k] <= 'Z')
        s[k] = s[k] - 'A' + 'a';

    cout << s << endl;

    return 0;
}

int main()
{
     solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

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

int main() {
  int n, m, _sum=0;
  cin >> n;
  vector<int> t(n);
  rep(i, n) {
    cin >> t[i];
    _sum += t[i];
  }

  cin >> m;
  rep(i, m) {
    int p, x;
    cin >> p >> x;
    cout << _sum - (t[p-1] - x) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int x = inp.nextInt();
        int a = inp.nextInt();
        int b = inp.nextInt();
        int xa = Math.abs(x - a);
        int xb = Math.abs(x - b);
        if (xa < xb) System.out.println("A");
        else System.out.println("B");
    }
}

Measured memory_bytes: 23252
N, M = map(int, input().split())
H = list(map(int, input().split()))
G = dict()
for i in range(1, N+1):
    G[i] = [0]

for _ in range(M):
    A, B = map(int, input().split())
    G[A] += [B]
    G[B] += [A]

cnt = 0
for i in range(1, N+1):
    flag = False
    if len(G[i]) > 1:
        for j in G[i]:
            if j == 0:
                continue
            if H[i-1] <= H[j-1]:
                flag = False
                break
            else:
                flag = True
    else:
        flag = True
    if flag:
        cnt += 1

print(cnt)

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

/**
 * startからすべての頂点への最小距離を求める O(|E| log |V|)
 * 負辺はないものとする
 */
std::vector<int> dijkstra(int start, std::vector<std::vector<std::pair<int, int>>> graph) {
    const unsigned long num_node = graph.size();

    //[(最短距離, node番号)]のque(距離が近い順にとりだす)
    std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>> que;
    que.push({0, start});

    std::vector<int> prev(num_node, -1);            // 経路復元用
    std::vector<int> distance(num_node, INT_MAX);   // startからの距離
    distance[start] = 0;

    while (not que.empty()) {
        int now_dist, from;
        std::tie(now_dist, from) = que.top();
        que.pop();

        if (distance.at(from) < now_dist) {
            continue;
        }
        for (const std::pair<int, int> &p : graph.at(from)) {
            int to = p.first;
            int dist = p.second;
            int new_dist = now_dist + dist;

            if (new_dist < distance.at(to)) {
                prev.at(to) = from;
                distance.at(to) = new_dist;
                que.push({new_dist, to});
            }
        }
    }

    return distance;
}

using namespace std;

int main(void) {
    int V, E, r;
    cin >> V >> E >> r;

    vector<vector<pair<int, int>>> graph(V);
    for (int i = 0; i < E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        graph[s].emplace_back(make_pair(t, d));
    }

    auto distance = dijkstra(r, graph);
    for (int i = 0; i < distance.size(); ++i) {
        if (distance[i] == INT_MAX) {
            cout << "INF" << endl;
        }
        else {
            cout << distance[i] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 20572
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

  int n; cin >> n;
  int cnt=1;
  while(cnt*(cnt+1)/2 < n) {
    cnt++;
  }

  for(int i=cnt; i>=0; i--) {
    if (n > i) {
      cout << i << '\n';
      n -= i;
    } else {
      cout << n << '\n';
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;

const int N = 1e6 + 69;

int n,x,y,m;

int A[N];

string s,t,u;

map<int,int>fix;

int main(){

    cin>>n;
    for(int i=1;i<=n;i++){
            cin>>A[i];
        if(fix[A[i]]==1){
            cout<<"NO"<<endl;
            return 0;
        }
        fix[A[i]]=1;
    }
    cout<<"YES"<<endl;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  int cr = count(s.begin(), s.end(), 'R');
  int cb = count(s.begin(), s.end(), 'B');
  puts(cr > cb ? "Yes" : "No");
}


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

int a[15],lef[15],rig[15];
bool flag;

bool solve(){
	for(int i=0; i<1024; i++){
		memset(lef,0,sizeof(lef));
		memset(rig,0,sizeof(rig));
		int lc=0,rc=0,j;
		int cnt = 0;
		for(cnt=0,j=i; cnt<10; cnt++,j>>=1){
			if(j&1) lef[lc++] = a[cnt];
			else rig[rc++] = a[cnt];
		}
		flag = true;
		for(int j=1; j<lc; j++)
			if(lef[j]<lef[j-1]){
				flag = false;
				break;
			}

		for(int j=1; j<rc; j++)
			if(rig[j]<rig[j-1]){
				flag=false;
				break;
			}

		if(flag) return true;
	}
	return false;
}

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		for(int i=0; i<10; i++)
			scanf("%d",&a[i]);
		if(solve()) printf("YES\n");
		else printf("NO\n");
	}

}

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

int main(){
  int C[3][3];
  for(int i = 0; i < 3; ++i){
    for(int j = 0; j < 3; ++j) cin >> C[i][j];
  }
  bool info = true;
  int check[3];
  for(int i = 0; i < 2; ++i){
    for(int j = 0; j < 3; ++j) check[j] = C[j][i] - C[j][i+1];
    if(check[0] != check[1] || check[0] != check[2]) info = false;
    for(int j = 0; j < 3; ++j) check[j] = C[j][2] - C[j][0];
    if(check[0] != check[1] || check[0] != check[2]) info = false;
  }
  for(int i = 0; i < 2; ++i){
    for(int j = 0; j < 3; ++j) check[j] = C[i][j] - C[i+1][j];
    if(check[0] != check[1] || check[0] != check[2]) info = false;
    for(int j = 0; j < 3; ++j) check[j] = C[2][j] - C[0][j];
    if(check[0] != check[1] || check[0] != check[2]) info = false;
  }
  if(info) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<tuple>
using namespace std;
struct State { int x[8][8]; };
int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 };
int F[8][8], n; vector<tuple<int,int,int>>vec;
int solve(State S, int pos, int rec, int px, int py, int cnts) {
	if (pos == vec.size() - 1 && cnts == n*n) { return 1; }
	int cnt = 0;
	for (int i = 0; i < 4; i++) {
		int cx = px + dx[i], cy = py + dy[i];
		if (cx < 0 || cy < 0 || cx >= n || cy >= n || S.x[cx][cy] == 1)continue;
		if (F[cx][cy] + rec > get<2>(vec[pos]))continue;
		State T = S; T.x[cx][cy] = 1;
		if (F[cx][cy] + rec == get<2>(vec[pos])) {
			cnt += solve(T, pos + 1, 0, get<0>(vec[pos + 1]), get<1>(vec[pos + 1]), cnts + 1);
		}
		else {
			cnt += solve(T, pos, rec + F[cx][cy], cx, cy, cnts + 1);
		}
	}
	return cnt;
}
int main() {
	while (true) {
		cin >> n; if (n == 0)break; vec.clear();
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cin >> F[i][j];
				if (F[i][j] < 0)vec.push_back(make_tuple(i, j, -F[i][j]));
			}
		}
		State ST; vec.push_back(make_tuple(-1, -1, -1));
		for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { ST.x[i][j] = 0; if (F[i][j] < 0)ST.x[i][j] = 1; } }
		int sum = solve(ST, 0, 0, get<0>(vec[0]), get<1>(vec[0]), vec.size() - 1);
		if (sum >= 1)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);

using namespace std;
ll mod = 1e9 + 7;



ll solve(ll x) {
	ll val;

	while (x) {
		val = x % 10;
		x /= 10;
	}
	//cout << val << endl;
	return val;
}

ll x;
ll arr[50][50];

int main() {
    MohamedMotaz;

	 
	cin >> x;
	ll cnt = 0;

	for (int i = 1; i <= x; i++) {
		arr[solve(i)][i % 10]++;
	}
	for (int i = 1; i < 11; i++) {
		for (int j = 1; j < 11; j++) {
			cnt += arr[i][j] * arr[j][i];
		}
	}
	cout << cnt;
}



















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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))

int main() {
     vector<ll>v;
     for (ll i = 0; i < 5; i++) {
        ll x;
        cin >> x;
        v.push_back(x);
     }

     for (ll i = 0; i < 5; i++) {
        if(v[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
     }

    return 0;
}



Measured memory_bytes: 3548
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		int[] lx = new int[n];
		int[] ly = new int[n];
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			lx[i] = x[i];
			ly[i] = y[i];
		}
		Arrays.sort(lx);
		Arrays.sort(ly);

		Long ans = 1L * (lx[n-1]-lx[0]) * (ly[n-1]-ly[0]);

		for(int xi = 0; xi < n; xi++) {
			for(int xj = 0; xj < n; xj++) {
				for(int yi = 0; yi < n; yi++) {
					for(int yj = 0; yj < n; yj++) {
						int num = 0;
						Long lX = (long) lx[xi],rX = (long) lx[xj];
						Long upY = (long) ly[yi], underY = (long) ly[yj];

						for(int i = 0; i < n; i++) {
							if(lX <= x[i] && x[i] <= rX && underY <= y[i] && y[i] <= upY) {
								num++;
							}
						}

						if(num >= k) {
							ans = Math.min(ans, 1L * (rX - lX) * (upY - underY));
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
}

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

const int m=200005;

int main(){
  int n;
  string x;
  cin >> n >> x;
  vi ans(m,-1);
  ans[0]=0;
  vi now(24);
  now[0]++;
  int cnt=1;
  for(int i=1;i<=200001;i++){
    ans[i]=ans[i%cnt]+1;
    now[0]++;
    cnt++;
    rep(j,23){
      if(now[j]==2){
        cnt-=1;
        now[j]=0;
        now[j+1]++;
      }
    }
  }
  
  int n1=0;
  rep(i,n) if(x[i]=='1') n1++;
  vi dig_plus(m),dig_minus(m);
  ll k=0,l=0;
  ll two=1;
  rep(i,n){
    dig_plus[n-1-i]=two;
    k+=two*(x[n-1-i]-'0');k%=(n1+1);
    two*=2;two%=(n1+1);
  }
  if(n1>2){
  two=1;
  rep(i,n){
    dig_minus[n-1-i]=two;
    l+=two*(x[n-1-i]-'0');l%=(n1-1);
    two*=2;two%=(n1-1);
  }
  }
  rep(i,n){
    if(x[i]=='0'){
      //n1+1型
      ll y=k+dig_plus[i];
      cout << ans[y%(n1+1)]+1<< "\n";
    }else{
      //n1-1型
      if(n1<=1){cout << 0 << "\n";continue;}
      ll y=l-dig_minus[i]+(n1-1);
      cout << ans[y%(n1-1)]+1 << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 5964
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int>S(N);
  for (int i=0;i<N;i++){
    cin>>S[i];
  }
  int sum=0;
  for (int i=0;i<N;i++){
    sum+=S[i];
  }
  int ans=0;
  int tmp;
  for (int i=0;i<N;i++){
    ans+=S[i];
    if(ans >=sum/2){
      tmp=i;
      break; 
    }
  }
  cout<<min(abs(sum-ans-ans),abs(sum-ans+S[tmp]-ans+S[tmp]))<<endl;
 
}

Measured memory_bytes: 256
import sys
def main():
    S = input()
    for i in range(len(S)):
        if i % 2 != 0:
            if S[i] == "L" or S[i] == "U" or S[i] == "D":
                continue
            else:
                print("No")
                exit()
        else:
            if S[i] == "R" or S[i] == "U" or S[i] == "D":
                continue
            else:
                print("No")
                exit()
    print("Yes")

if __name__ == "__main__":
    main()

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p.at(i);
    }
    int count = 0;
    for(int i = 1; i < n-1; i++){
        if(p.at(i-1) > p.at(i) && p.at(i) > p.at(i+1)){
            count++;
        } else if(p.at(i-1) < p.at(i) && p.at(i) < p.at(i+1)){
            count++;
        }
    }
    cout << count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main()
{
    int n,ans=0;
    cin >> n;
    long long int a[n];
    for(int i=0;i<n;i++){
    	cin >> a[i];
    }
    for(int i=0;i<n;i++){
    	while(1){
    		if(a[i]%2==0){
    		    a[i]=a[i]/2;
    		    ans++;
    	    }
    	    else{
    		    break;
    	    }
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main()
{
    long long a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    if((b-a)%2==1)cout<<"IMPOSSIBLE";
    else
    {
        long long k=(b-a)/2;
        cout<<b-k<<endl;
    }
}


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

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define pb push_back
using vi  = vector<int>;

vi mp; // a : mp[0], b : mp[1], c : mp[2], d : mp[3]
vector<function<int(int,int)>> ops;

typedef string::const_iterator State;
int letter(State &begin){
  int res = mp[*begin - 'a'];
  ++begin;
  return res;
}
int hashf(State &begin){
  if(*begin == '['){
    ++begin; // '['
    
    int optype;
    if(*begin == '+') optype = 0;
    else if(*begin == '*') optype = 1;
    else if(*begin == '^') optype = 2;
    else assert(false);
    ++begin; // operator
    
    int lop = hashf(begin), rop = hashf(begin);

    ++begin; // ']' 
    
    return ops[optype](lop,rop);
  }else{
    return letter(begin);
  }
}

int main(){
  string s;
  mp.resize(4);
  ops.push_back([](int a, int b){ return a|b; });
  ops.push_back([](int a, int b){ return a&b; });
  ops.push_back([](int a, int b){ return a^b; });
  while(cin >> s, s != "."){
    string p; cin >> p;
    rep(i,4) mp[i] = p[i] - '0';
    State begin = s.begin();
    int ans = hashf(begin);
    int cnt = 0;
    rep(a,10) rep(b,10) rep(c,10) rep(d,10){
      mp[0] = a; mp[1] = b; mp[2] = c; mp[3] = d;
      begin = s.begin();
      if(ans == hashf(begin)) cnt++;
    }
    cout << ans << " " << cnt << endl;
  }
}


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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int a, b;
	cin >> a >> b;
	int c = b - a;
	cout << (c * (c + 1) / 2 - b) << endl;
	return 0;
}



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

int main() {
	int n;
	cin >> n;
	int ans = 0;
	rep(i,n) {
		int a;
		cin >> a;
		if (i%2==0 && a%2==1) ans++;
	}

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


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

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

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

	int d[N+1];
	int sum=0;
	for (int i = 0; i < N+1; ++i)
	{
		d[i] = abs(A[i+1]-A[i]);
		sum += d[i];
	}

	for (int i = 0; i < N; ++i)
	{
		cout << sum - d[i] - d[i+1] + abs(A[i+2]-A[i]) << endl;
	}


	return 0;
}

Measured memory_bytes: 2048
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let ans = if (a * b) % 2 == 0 { "Even" } else { "Odd" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Maxn 4000007
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    int n;
    cin>>n;
    int cnt = n/500;
    cnt*=1000;
    n%=500;
    cnt+=(n/5)*5;
    cout<<cnt;
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 256
from collections import deque

n, q = map(int, input().split())
queue = deque([])
for i in range(n):
    a = input().split()
    queue.append([a[0], int(a[1])])

time = 0

while queue:
    b = queue.popleft()
    if b[1] <= q:
        time += b[1]
        print(b[0] + ' ' + str(time))
    else:
        b[1] -= q
        time += q
        queue.append(b)

Measured memory_bytes: 15828
#include <stdio.h>
#include <stdlib.h>
#define int long long

int max(int a, int b){
	return a >= b ? a : b;
}

signed main(){
	int L, N, i;
	scanf("%lld%lld", &L, &N);
	int *X = (int *)malloc(sizeof(int) * (N + 2));
	int *Y = (int *)malloc(sizeof(int) * (N + 2));
	int *SX = (int *)malloc(sizeof(int) * (N + 2));
	int *SY = (int *)malloc(sizeof(int) * (N + 2));
	for(i = 1; i <= N; i++){
		scanf("%lld", &X[i]);
		Y[i] = L - X[i];
	}
	SX[0] = 0;
	for(i = 1; i <= N; i++){
		SX[i] = SX[i - 1] + X[i];
	}
	SY[N + 1] = 0;
	for(i = N; i >= 1; i--){
		SY[i] = SY[i + 1] + Y[i];
	}
	int l, r, now, ans;
	ans = max(X[N], Y[1]);
	for(i = 1; i < N; i++){
//		printf("i = %lld\n", i);
		l = i;
		r = N - i;
//		k = min(l, r);
//		now = 2 * SX[k]
		if(l < r){
			now = 2 * SX[i];
			now += 2 * (SY[i + 1] - SY[i + 1 + l + 1]) - Y[i + 1];
			ans = max(ans, now);
//			printf("now1 = %lld\n", now);
			now = 2 * SX[i] - X[i];
			now += 2 * (SY[i + 1] - SY[i + 1 + l]);
			ans = max(ans, now);
		}
		if(l > r){
			now = 2 * SY[i + 1];
//			printf("now = %lld\n", now);
//			printf("test:%lld\n", 2 * (SX[i] - SX[i - r - 1]));
			now += 2 * (SX[i] - SX[i - r - 1]) - X[i];
			ans = max(ans, now);
//			printf("now2 = %lld\n", now);
			now = 2 * SY[i + 1] - Y[i + 1];
			now += 2 * (SX[i] - SX[i - r]);
			ans = max(ans, now);

		}
		if(l == r){
			now = 2 * SX[i];
			now += 2 * SY[i + 1] - Y[i + 1];
			ans = max(ans, now);
//			printf("now3 = %lld\n", now);
			now = 2 * SY[i + 1];
			now += 2 * SX[i] - X[i];
			ans = max(ans, now);
//			printf("now4 = %lld\n", now);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6400
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

pair<ll,ll> q[100005];

void solve()
{
    IN(n);
    rep(i, n)
    {
        IN(x, l);
        q[i] = make_pair(x+l,x-l);
    }
    sort(q, q+n);
    ll last = q[0].first;
    ll count = 1;
    reps(i, 1, n)
    {
        if (q[i].second >= last)
        {
            ++count;
            last = q[i].first;
        }
    }
    cout << count << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
    int x, y, z, tmp;
    scanf("%d %d %d", &x, &y, &z);

    //xとyをswap
    tmp = x;
    x = y;
    y = tmp;

    //xとzをswap
    tmp = x;
    x = z;
    z = tmp;

    printf("%d %d %d", x, y, z);
    return 0;
}

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

int ans;

int main(){
    cin >> ans;
    while(1){
        if(ans % 10 == (ans%100-ans%10)/10 && ans % 10 == (ans-ans%100)/100){
            cout << ans << endl;
            return 0;
        }
        ++ans;
    }
}

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

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

    set<string> S;

    rep(i,n) {
        string s;
        cin >> s;
        S.insert(s);
    }

    cout << S.size() << endl;
    return 0;
}


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

int isprime(int);

int main(){
  int A[10000];
  int n, i, j, flag, count = 0;

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

  for(i = 0; i < n; i++){
    count += isprime(A[i]);
  }

  printf("%d\n",  count);

  return 0;
}

int isprime(int x){
  int i;
  if(x == 2) return 1;

  if(x < 2 || x % 2 == 0) return 0;

  i = 3;
  while (i <= sqrt(x)){
    if(x % i == 0) return 0;
    i = i + 2;
  }

  return 1;
}



Measured memory_bytes: 2140
num = int(input())
S = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
H = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
C = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
D = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
for i in range(num):
  t = input().rstrip().split(' ')
  a = int(t[1])
  b = str(t[0])
  if b == "S" and a in S:
      S.remove(a)
  elif b == "H" and a in H:
      H.remove(a)
  elif b == "C" and a in C:
      C.remove(a)
  elif b == "D" and a in D:
      D.remove(a)
lengthS = len(S)
lengthH = len(H)
lengthC = len(C)
lengthD = len(D)
S.sort()
H.sort()
C.sort()
D.sort()
for j in range(lengthS):
  ans = ""
  ans += "S" + " " + str(S[j])
  print(ans)
for k in range(lengthH):
  ans = ""
  ans += "H" + " " + str(H[k])
  print(ans)
for l in range(lengthC):
  ans = ""
  ans += "C" + " " + str(C[l])
  print(ans)
for m in range(lengthD):
  ans = ""
  ans += "D" + " " + str(D[m])
  print(ans)


Measured memory_bytes: 5620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
ll dp[2020];
int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int now = 0;
    dp[0] = 1;
    ll ans = 0;
    ll f = 1;
    for(auto x:s){
        now += f * (x - '0');
        now %= 2019;
        ans += dp[now];
        dp[now]++;
        f = f * 10 % 2019;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3736
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N,M,K,ans,r,a;

pair<LL, LL>bc;
vector<pair<LL, LL>>BC;
int main() {

	cin >> N ;
	LL W[100];
	a = 0;
	for (LL i = 0; i < N; i++) {
		cin >> W[i];
		a += W[i];
	}
	ans = 100000000;
	for (LL i = 0; i < N-1; i++) {
		r += W[i];
		a -= W[i];
		ans = min(ans,abs(a-r));
	}
	cout << ans << endl;
	return 0;

}


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

const long long inf = 1000000000000000037;
const int maxn = 1003;
const int maxm = 2003;

int n, m;
int a[maxm], b[maxm], c[maxm];
long long d[maxn], d_old[maxn];

signed main () {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= m; ++i) 
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
	for (int i = 1; i <= n; ++i)
		d[i] = -inf;
	d[1] = 0;
	for (int j = 0; j < n - 1; ++j) {
		for (int i = 1; i <= m; ++i) {
			if (d[a[i]] != -inf)
				d[b[i]] = max(d[b[i]], d[a[i]] + c[i]);
		}
	}
	memcpy(d_old, d, sizeof(d));
	for (int j = 0; j < n - 1; ++j) {
		for (int i = 1; i <= m; ++i) {
			if (d[a[i]] != -inf)
				d[b[i]] = max(d[b[i]], d[a[i]] + c[i]);
		}
	}
	if (d_old[n] == d[n])
		cout << d[n] << '\n';
	else
		cout << "inf\n";
}


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

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

using namespace std;

int m, x[20], y[20], ct=0;
double tilt[20][20];

int dfs (int j, int used, vector<double> vec){
	// printf("dfs j: %d\n", j);
	
	int ret=0;
	used += 1<<j;
	
	int k=j+1;
	for (; k<m; k++){
		if ((used>>k) & 1){
			continue;
		}
		used += 1<<k;
		vec.push_back(tilt[j][k]);
		
		// printf("used: %x, tilt[%d][%d] = %f\n", used, j, k, tilt[j][k]);
		// printf("j: %d, k: %d\n", j, k);
		
		// 一番下までたどりついた
		if (used>=(1<<m)-1){
			// ct++;
			// printf("%d ---------------------\n", ct);
			// printf("j: %d, k: %d, used: %x, count: %d\n", j, k, used, ct);
			
			sort(vec.begin(), vec.end());

			int count=1, ret=0;
			double prev=vec[0];
			
			for (int i=1; i<vec.size(); i++){
				if (vec[i]!=prev){
					ret += count*(count-1)/2;
					count = 0;
					prev = vec[i];				
				}
				count++;
			}
			ret += count*(count-1)/2;
			
			/*
			if (ret>=12){
				printf("ret: %d\nvec = {", ret);
				REP(i,vec.size()){
					printf("%f, ", vec[i]);
				}
				printf("}\n");
			}
			//*/
			return ret;
			
		}
	
		int j2 = j+1;
		for (; j2<m; j2++){
			if (!((used>>j2) & 1)){
				break;
			}
		}
		ret = max(ret, dfs(j2, used, vec));

		used -= 1<<k;
		vec.pop_back();
	}
	
	return ret;
	
}

int main(){
	vector<double> vec;
	cin >> m;
	for (int i=0; i<m; i++){
		cin >> x[i] >> y[i];	
		// printf("x[%d]: %d\n", i, x[i]);
	}
	
	REP(j,m){
		for (int k=j+1; k<m; k++){
			if (y[j]-y[k]==0){
				tilt[j][k] = 3000;
			}else{
				tilt[j][k] = (double)(x[j]-x[k])/(double)(y[j]-y[k]);
			}
			// printf("tilt[%d][%d] = %f\n", j, k, tilt[j][k]);
		}
	}
	
	cout << dfs(0, 0, vec) << endl;
	
	return 0;
	
}


Measured memory_bytes: 3172
n=int(input())
a=map(int,input().split())
p=[(x,i) for i,x in enumerate(a)]
p.sort(reverse=True)

ans=0
dp=[[0]*(n+1) for i in range(n+1)]
for i in range(n+1):
  for j in range(n+1):
    if i+j==n:
      ans=max(ans,dp[i][j])
      break
    act,ind=p[i+j]
    dp[i+1][j]=max(dp[i+1][j],
                   dp[i][j]+act*abs(ind-i))
    dp[i][j+1]=max(dp[i][j+1],
                   dp[i][j]+act*abs(n-1-j-ind))

print(ans)

Measured memory_bytes: 100296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();

		int []  h= new int [1000000];
		int count=0;
		for(int i = 0; i < n; i++) {
			h[i] = scan.nextInt();
			if(h[i] >= k) {
				count++;
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 64460
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<climits>
#include<set>
#define ll long long
using namespace std;
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) {
		cout << "bust" << endl;
	}
	else {
		cout<<"win"<<endl;
	}

}

Measured memory_bytes: 256
/* Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define debug(x) cout << #x << " " << x <<endl;
#define set_bits __builtin_popcount
typedef long long ll;
typedef unsigned long long ull;
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod)
{ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
ll combination(ll n, ll r, ll m, ll* fact) {ll val1 = fact[n]; ll val2 = mminvprime(fact[r], m); ll val3 = mminvprime(fact[n - r], m); return ((val1 * val2) % m * val3) % m;}
/*--------------------------------------------------------------------------------------------------------------------------*/
ll helper(int *ans, int index, int end, int n, int m, int k, string *arr)
{
	// debug(index);
	if (index == end)
	{
		int count_of_black = 0;
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				if (arr[i][j] == '#' && ans[i] == 0 && ans[j + n] == 0)
					count_of_black++;
			}
		}
		if (count_of_black == k)
			return 1;
		else
			return 0;
	}
	ans[index] = 1;
	ll ans1 = helper(ans, index + 1, end, n, m, k, arr);
	ans[index] = 0;
	ll ans2 = helper(ans, index + 1, end, n, m, k, arr);
	return ans1 + ans2;
}
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	int n;
	cin >> n;
	ll arr[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(arr, arr + n, revsort);
	ll ans = 0;
	ll value = arr[0];
	int index = 0;
	int counter = 0;
	for (int i = 1; i < n; i++)
	{
		ans += value;
		counter += 1;
		if (index == 0 || counter == 2)
		{
			index++;
			value = arr[index];
			counter = 0;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    vector<char> s(3);
    int count = 0;
    for (int i = 0; i < 3; i++)
    {
        cin >> s.at(i);
    }
    for (int i = 0; i < 3; i++) {
        if (s.at(i) =='a')
            count += 1;
        else if (s.at(i) =='b')
            count += 20;
        else if (s.at(i) =='c')
            count += 100;
        else
            count = 0;
    }
    if (count == 121)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793)
#define mod 1000000007

int main() {
	int n,m;
	cin >> n;
	map<string, int>ans;
	int now = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		ans[s]++;
	}
	cin >> m;
	for (int j = 0; j < m; j++) {
		string t;
		cin >> t;
		ans[t]--;
	}
	int MAX = 0;
	for (auto p : ans) {
		MAX = max(p.second, MAX);
	}
	cout << MAX << endl;
	return 0;
}

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

int main(){
  
  int n,m;
  cin >> n >> m;
  vector<int> a(100); 
  vector<int> b(100,0);
  for(int i=1; i<=100; i++) {
    cin >> a[i];
  }
  
  for(int i=1; i<=100; i++) {
    for(int j=1; j<=n; j++){
  		if(a[i] == j) b[j]++;
    }
  }
  for(int i=1; i<=n; i++) cout << b[i]<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    const long long mod = 1000000007;
    long long n, k;
    cin >> n >> k;
    vector< int > a(n);
    for (long long i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
        for (long long j = i + 1; j < n; j++) {
            if (a[i] < a[j]) {
                ans += ((k * (k - 1)) / 2) % mod;
            } else if (a[i] > a[j]) {
                ans += ((k * (k + 1)) / 2) % mod;
            } else {
                ;
            }
        }
    }
    cout << ans % mod << endl;
    return 0;
}

Measured memory_bytes: 256
from math import sin, cos, pi

a,b,h,m=map(int,input().split())
tax=a*cos(pi/2 - (h/12+m/60/12)*2*pi)
tay=a*sin(pi/2 - (h/12+m/60/12)*2*pi)
tbx=b*cos(pi/2 - (m/60)*2*pi)
tby=b*sin(pi/2 - (m/60)*2*pi)

print( ((tax - tbx)**2 + (tay - tby)**2) ** .5)

Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int n, k; cin>>n>>k;
    vector<int> p(n);
    For(i, 0, n){
        cin>>p[i];
    }
    sort(all(p));
    int ans = 0;
    For(i, 0, k){
        ans += p[i];
    }
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3664