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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  long long kotae=0;
  if(a<=b)kotae=a*c;
  else kotae=b*c+(a-b)*d;
  cout<<kotae<<endl;
  return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll a, b;
    cin >> a >> b;
    if(abs(a - b) <= 1)
        cout << "Brown" << en;
    else
        cout << "Alice" << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;



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

        Reader.init( System.in ); // connect Reader to an input stream
        int X = Reader.nextInt();
        int A = Reader.nextInt();
        int B = Reader.nextInt();
        System.out.println((X-A)%B);
    }
    }






class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;
    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );

        tokenizer = new StringTokenizer("");
    }

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

    /** get next word */
    static String next() throws IOException {

        while ( ! tokenizer.hasMoreTokens() ) {

            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {

        return Integer.parseInt( next() );

    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }

    static long nextLong() {
        return Long.parseLong(nextToken());
    }
}

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

int N;
int main() {
  cin >> N;
  int a, c = 0;
  for ( int i = 0; i < N; i++) {
    cin >> a;
    while ( a % 2 == 0) {
      c++;
      a /= 2;
     }
    }
  cout << c;
}

Measured memory_bytes: 888
#include <stdio.h>

int main (void)
{
  int yen;
  int happy=0;
  
  scanf("%d", &yen);
   
  while (yen >= 500) {
    yen = yen - 500;
    happy += 1000;
  }
  
  while (yen >= 5) {
   yen = yen - 5;
   happy += 5;
  }
  
  printf("%d\n",happy);
  
  return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
int main()
{
	long long a,b;
	char c;
		scanf("%lld",&a);
		scanf(" %c ",&c);
		scanf("%lld",&b);
		if(c=='-')
		{
			printf("%lld\n",a-b);
		}
		else
		{
			printf("%lld\n",a+b);
		}
	return 0;
}

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

typedef long long ll;
const int MAX_N = 100030;    // Change as necessary
const ll  MODD = 1000000009; //

int A[MAX_N];

vector<int> adj[MAX_N];

int ans,K;
int f(int v){
  int max_d = 0;
  for(auto& x : adj[v]){
    int D = 1+f(x);
    max_d = max(D,max_d);
  }
  
  if(v && max_d == K-1 && A[v] != 0){
    ans++;
    return -1;
  }
  return max_d;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n >> K;
  for(int i=0;i<n;i++) { cin >> A[i]; A[i]--; }
  
  ans = (A[0] != 0);
  
  for(int i=1;i<n;i++) adj[A[i]].push_back(i);
  f(0);
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    enum Color {
        gray = 399,
        brown = 799,
        green = 1199,
        aqua = 1599,
        blue = 1999,
        yellow = 2399,
        orange = 2799,
        red = 3199,
        freedom = 4800
    };
    Color All[] = {gray, brown, green, aqua, blue, yellow, orange,
        red, freedom};
    int N; cin >> N;
    vector<int> A(N);
    map<Color, int> MAP;
    rep(i,N) {
        cin >> A.at(i);
        auto c = lower_bound(begin(All), end(All), A[i]);
        MAP[*c]++;
    }
    /*
    auto mi = min_element(begin(MAP), end(MAP), [](auto& a, auto& b){
        return a.second < b.second;
    });
    auto ma = max_element(begin(MAP), end(MAP), [](auto& a, auto& b){
        return a.second < b.second;
    });
    */
    int mi, ma;
    if (MAP.count(Color::freedom) > 0) {
        int num = MAP.size() - 1;
        int free = MAP[Color::freedom];
        ma = num + free;
        mi = num; 
        if (mi == 0) mi = 1;
    } else {
        mi = ma = MAP.size();
    }
    cout << mi << " " << ma << endl;
}

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

vvii adj(MAXN);
int ans[MAXN];
int nxt[MAXN];
set<int> mx[MAXN];

void dfs(int u, int p) {
  for (auto &[v, idx] : adj[u]) {
    if (v == p)
      continue;
    int &c = ans[idx];
    if (c == 0) {
      c = max(nxt[u], nxt[v]);
      mx[u].emplace(c);
      mx[v].emplace(c);
      while (mx[u].count(nxt[u]))
        ++nxt[u];
      while (mx[v].count(nxt[v]))
        ++nxt[v];
      dfs(v, u);
    }
  }
}

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;

  vector<int> d(n);
  nxt[0] = 1;
  for (int i = 1; i < n; ++i) {
    nxt[i] = 1;
    int u, v;
    cin >> u >> v;
    --u, --v;
    ++d[u], ++d[v];
    adj[u].eb(v, i - 1);
    adj[v].eb(u, i - 1);
  }

  cout << *max_element(all(d)) << endl;
  dfs(1, -1);
  for (int i = 1; i < n; ++i)
    cout << ans[i - 1] << endl;
}

signed main() {
  // freopen(".in", "r", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 34136
def is_triangle(x, y, z):
    x, y, z = sorted([x, y, z])
    return x**2 + y**2 == z**2

num = int(input())
for i in range(num):
    x, y, z = map(int, input().split())
    triangle = is_triangle(x, y, z)
    if triangle:
        print('YES')
    else:
        print('NO')
        

Measured memory_bytes: 7672
#include<bits/stdc++.h>
#include<atcoder/all>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
using namespace atcoder;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;

void solve() {
  ll N, M;
  cin >> N >> M;
  dsu dsu(N);
  rep(_, M) {
    ll a,b;
    cin>>a>>b;
    a--,b--;
    dsu.merge(a, b);
  }
  set<ll> s;
  rep(i, N) {
    s.insert(dsu.leader(i));
  }
  cout<<(s.size()-1)<<endl;
}

int main() {
  //ll T;
  //cin >> T;
  //rep(_,T)
    solve();
  return 0;
}


Measured memory_bytes: 7508
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d,e;
  while(cin>>d>>e,d){
    double ans=10000;
    for(int i=0;i<d;i++)
      ans=min(ans,abs(e-sqrt(i*i+(d-i)*(d-i))));
    cout<<ans<<endl;
  }
  return 0;
}

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

int main() {
	int n,m;
	cin >>n>>m;
	int matrix[n][m] = {};
	int vector[m] = {};
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> matrix[i][j];
		}
	}
	for(int i=0; i<m; i++){
		cin >> vector[i];
	}
	for(int i=0; i<n; i++){
		int product;
		for(int j=0; j<m; j++){
			product += matrix[i][j]*vector[j];
		}
		cout << product << endl;
		product = 0;
	}
	return 0;
}


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

using namespace std;

typedef pair<int, int> pii;

vector<pii> ans;


int main() {
    int N;
    cin >> N;
    int S = N;
    if (N % 2 == 0) {
        S ++;
    }
    for (int i = 1; i <= N; i++) {
        int half = S - i;
        for (int to = i + 1; to <= N; to++) {
            if (to != half) {
                ans.push_back(pii(i, to));
            }
        }
    }
    cout << ans.size() << endl;
    for (pii i : ans) {
        cout << i.first << " " << i.second << endl;
    }

}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

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

    vector<vector<int>> v(n + 1, vector<int>());
    int a, b;
    REP(i, n - 1) {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    vector<int> w(n + 1, 0);
    int p, x;
    REP(i, q) {
        cin >> p >> x;
        w[p] += x;
    }

    function<void(int, int)> rec = [&](int pointer, int parent) {
        for (auto x : v[pointer]) {
            if (x == parent) continue;
            w[x] += w[pointer];
            rec(x, pointer);
        }
    };

    rec(1, -1);

    REP1(i, n) {
        cout << w[i];
        if (i != n) cout << " ";
    }
    cout << endl;
}

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

int main(){
	int n = 0;
	cin >> n;
	int* p = new int[n];
	int num_to_swap=0;
	for(int i=0;i<n;i++){
		cin >> p[i];
		if(p[i] != (i+1)){
			num_to_swap++;
		}
	}
	if(num_to_swap <= 2){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
#define P pair<int,int>
int N;
struct edge{int to,cost;};
vector<edge> G[100010];
ll D[100010];
void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P>> Q;
  rep(i,N) D[i]=1000000000000000000;
  D[s]=0;
  Q.push(P(0,s));
  while(!Q.empty()){
    P p=Q.top();
    Q.pop();
    int x=p.second;
    if(D[x]<p.first) continue;
    rep(i,G[x].size()){
      edge e=G[x][i];
      if(D[e.to]>D[x]+e.cost){
        D[e.to]=D[x]+e.cost;
        Q.push(P(D[e.to],e.to));
      }
    }
  }
}
int main(){
  int M,S,T;
  ll Z=1000000000000000;
  cin>>N>>M>>S>>T;
  int U[M],V[M],A[M],B[M];
  rep(i,M) cin>>U[i]>>V[i]>>A[i]>>B[i];
  rep(i,M){
    edge e1={V[i]-1,A[i]};
    edge e2={U[i]-1,A[i]};
    G[U[i]-1].push_back(e1);
    G[V[i]-1].push_back(e2);
  }
  dijkstra(S-1);
  ll X[N];
  rep(i,N) X[i]=D[i];
  rep(i,N) G[i].clear();
  rep(i,M){
    edge e1={V[i]-1,B[i]};
    edge e2={U[i]-1,B[i]};
    G[U[i]-1].push_back(e1);
    G[V[i]-1].push_back(e2);
  }
  dijkstra(T-1);
  ll ans[N];
  ans[N-1]=Z-X[N-1]-D[N-1];
  rep(i,N-1) ans[N-2-i]=max(ans[N-1-i],Z-X[N-2-i]-D[N-2-i]);
  rep(i,N) cout<<ans[i]<<endl;
}

Measured memory_bytes: 11860
from collections import defaultdict
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    A = list(map(int,input().split()))
    d = defaultdict(int)
    for x in A:
        d[x] += 1
    A = list(set(A))
    A.sort(reverse = True)
    l = len(A)
    
    def exp(x):
        l = len(str(bin(x))[2:])
        return 2**l

    ans = 0
    for i in range(l):
        a = A[i]
        if exp(a)//2 == a:
            ans += int(d[a]//2)
        else:
            m = min(d[a],d[exp(a)-a])
            ans += m
            d[a] -= m
            d[exp(a)-a] -= m
            
    print(ans)
    
if __name__ == "__main__":
    main()


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,i,j,ans=0,d2=0,d4=0,d14=0,d24=0,a[26]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101};
	cin>>n;
	vector<int> g;
	for (i=0;a[i]<=n;i++){
		int r=0,t=a[i];
		while ((int)n/t>0){
			r+=n/t;
			t*=a[i];
		}
		g.push_back(r);
	}
	for (i=0;i<g.size();i++){
		if (g[i]>=74){
			ans++;
		}
		if (g[i]>=2){
			d2++;
		}
		if (g[i]>=4){
			d4++;
		}
		if (g[i]>=14){
			d14++;
		}
		if (g[i]>=24){
			d24++;
		}
	} 
	ans+=d24*(d2-1)+d14*(d4-1)+d4*(d4-1)/2*(d2-2);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;

int main()
{
    long long n;
    long long answer = 0;
    vector<long long> b(2000000, 0);
    cin >> n;
    for (size_t i = 0; i < n; i++)
    {
        long long a;
        cin >> a;
        b[a]++;
    }
    for (long long i = 1; i < 2000000; i++)
    {
        if (b[i] == 0)
        {
            continue;
        }
        if (b[i] == 1) {
            answer++;
        }
        for (long long j = 0; j * i < 1000010; j++)
        {
            b[j * i] = 0;
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 18188
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];


void dfs(int v) {
	visited[v] = true;
	for (int v2 = 0; v2 < n; ++v2) {
		if (graph[v][v2] == false) continue;
		if (visited[v2] == true) continue;
		dfs(v2);
	}
}


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

	for (int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}

	int ans = 0;

	for (int i = 0; i < m; ++i) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

		for (int j = 0; j < n; ++j) visited[j] = false;

		dfs(0);

		bool bridge = false;
		for (int j = 0; j < n; ++j) if (visited[j] == false) bridge = true;
		if (bridge) ans += 1;

		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}

	cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    //const int MOD = 1000000007;
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int n = cin.NextInt();
        long[] a = new long[n];

        HashSet<long> set = new HashSet<long>();
        for (int i = 0; i < n; i++)
        {
            a[i] = cin.NextLong();
            set.Add(a[i]);
        }

        int numOfKinds = set.Count();
        if (a.All(e => e == 0L))
        {
            Console.WriteLine("Yes");
            return;
        }
        if (numOfKinds == 2 && a.Where(e => e == 0L).Count() == n / 3)
        {
            Console.WriteLine("Yes");
            return;
        }
        if (numOfKinds == 3 
            && a.Where(e => e == set.ElementAt(0)).Count() == n / 3 && a.Where(e => e == set.ElementAt(1)).Count() == n / 3
            && (set.ElementAt(0) ^ set.ElementAt(1)) == set.ElementAt(2))
        {
            Console.WriteLine("Yes");
            return;
        }
        Console.WriteLine("No");
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 29024
def resolve():
    N = int(input())
    A = list(map(int, input().split(" ")))
    res = 0
    for a in A:
        while True:
            if a % 2 != 0:
                break
            res += 1
            a = a // 2
    print(res)

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 40432
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007
#define MEM_SIZE = 1e5+5;

template<typename T> void DEBUG(T e){std::cout <<"DEBUG>>"<< e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }


 
 
void solve(void)
{
  int N;
  cin>>N;
  vector<vector<int> > DP(N,vector<int>(3,0));

  
  cin>>DP[0][0]>>DP[0][1]>>DP[0][2];

  for (int i = 1; i < N; i++)
  {
    vector<int> INPUT(3);
    cin>>INPUT[0]>>INPUT[1]>>INPUT[2];
    for (int r = 0; r < 3; r++)
    {
      for (int p = 0; p < 3; p++)
      {
        if(r != p)
        {
          DP[i][r] = max(DP[i][r],DP[i-1][p] + INPUT[r]);
        }
      }
    }
  }
  int ANS = 0;
  for (int i = 0; i < 3; i++)
  {
    ANS = max(DP[N-1][i],ANS);
  }
  cout<<ANS;
  
  
  return;
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(8);
  solve();

 
  return 0;
}

Measured memory_bytes: 5760
n = int(input())
cnt = 0

def handstand(a, b):
  cnt_ = 0
  if a == b:
    cnt_ += 1
  k = 0
  while (a+1) * (10 ** (k+1)) + b-10 <= n:
    cnt_ += (10 ** k)
    k += 1
  cnt_ += max(0, (n - (a * (10 ** (k+1)) + b) + 10) // 10)
  return cnt_  

if n < 10:
  print(n)
  exit()
for i in range(1, 10):
  for j in range(1, 10):
    cnt += handstand(i, j) * handstand(j, i)
print(cnt)


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define Max(x,y) ((x>y)?x:y)
int comp(const void *p,const void *q){
	return *(int *)q- *(int *)p;
}
int d[15][2005],dn[15],dp[15][2005];
int main(){
	int i,j,k,n,kk,x,y;
	scanf("%d%d",&n,&kk);
	memset(d,0,sizeof(d));
	for(i=1;i<11;i++)dn[i]=1;
	memset(dp,0,sizeof(dp));
	for(i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		d[y][dn[y]]=x;
		dn[y]++;
	}
	for(i=1;i<11;i++)qsort(d[i]+1,dn[i],sizeof(int),comp);
	for(i=1;i<11;i++)for(j=1;j<dn[i];j++)
		d[i][j]+=2*j-2+d[i][j-1];
	for(i=1;i<11;i++){
		for(j=1;j<=kk;j++){
			//printf("%d-%d:",i,j);
			for(k=1;k<dn[i];k++){
				if(j>=k)dp[i][j]=Max(dp[i][j],Max(dp[i-1][j],dp[i-1][j-k]+d[i][k]));
				//else dp[i][j]=Max(dp[i][j],dp[i-1][j]);
				//printf("%2d ",dp[i][j]);
			}
			dp[i][j]=Max(dp[i][j],dp[i-1][j]);
			//printf("%2d ",dp[i][j]);
		}
		//printf("\n");
	}
	printf("%d\n",dp[10][kk]);
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void)
{
        int n,i,tmp,index,j,a[100],al=0,bo=0,s;
        scanf("%d",&n);
        for(i=0;i<n;i++){
                scanf("%d",&a[i]);
        }
        for(i=0;i<n;i++){
                index=i;
                for(j=i;j<n;j++){
                   if(a[j]>a[index])
                           index=j;
                }
                tmp=a[i];
                a[i]=a[index];
                a[index]=tmp;
        }
        for(i=0;i<n;i++){
                if(i%2==0){
                        al=al+a[i];
                }
else if(i%2!=0){
                bo=bo+a[i];
                }
        }
s=al-bo;
printf("%d\n",s);

return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	
	static String s;
	static int cur;
	
	static boolean isdigit(char c) {
		if(c=='0' || c=='1' ||c=='2' ||c=='3' ||c=='4' ||c=='5' ||c=='6' ||c=='7' ||c=='8' ||c=='9') {
			return true;
		}
		return false;
	}
	
	static int digit() {
		assert(isdigit(s.charAt(cur)));
		int n=s.charAt(cur)-'0';
		cur++;
		return n;
	}
	
	static int number() {
		int n=digit();
		while(cur<s.length() && isdigit(s.charAt(cur))) {
			n=n*10+digit();
		}
		return n;
	}
	
	static int term() {
		int a=factor();
		while(cur<s.length() && (s.charAt(cur)=='*' || s.charAt(cur)=='/')) {
			char op=s.charAt(cur++);
			int b=factor();
			if(op=='*') {
				a*=b;
			}
			else {
				a/=b;
			}
		}
		return a;
	}
	
	static int expression() {
		int a=term();
		while(cur<s.length() && (s.charAt(cur)=='+' || s.charAt(cur)=='-')) {
			char op=s.charAt(cur++);
			int b=term();
			if(op=='+') {
				a+=b;
			}
			else {
				a-=b;
			}
		}
		return a;
	}
	
	static int factor() {
		if(s.charAt(cur)!='(') {
			return number();
		}
		cur++;
		int n=expression();
		assert(s.charAt(cur)==')');
		cur++;
		return n;
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n=sc.nextInt();
			for(int i=0; i<n; i++) {
				cur=0;
				s=sc.next();
				s=s.substring(0, s.length()-1);
				System.out.println(expression());
			}
			
			
		}
	}
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,j,k,n,x,y,ans=0;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            x=__gcd(i,j);
            for(k=1;k<=n;k++)
            {
                y=__gcd(x,k);
                ans+=y;
            }
        }
    }
    cout << ans;
    return 0;
}


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

int main(){
    ll x; cin >> x;
    for(ll a = -200; a <= 200; a++){
        for(ll b = -200; b <= 200; b++){
            if(a*a*a*a*a - b*b*b*b*b == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

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

int main() {
	int i,j,d[4];

	scanf("%d %d %d %d", &d[0], &d[1], &d[2], &d[3]);

	/*for(i=0;i<2;i++)
		for (j = 2; j > 0; j--)
		{
			if (d[j] < d[j - 1])
			{
				int r;
				r = d[j];
				d[j] = d[j - 1];
				d[j - 1] = r;

			}
		}*/
	if (d[3] >= abs(d[2] - d[0]))
		printf("Yes\n");
	else
	{
		if ((d[3] >= abs(d[1] - d[2])) && (d[3] >= abs(d[1] - d[0]))
			)printf("Yes\n");

		else
			printf("No\n");

	}


	return 0;
}

Measured memory_bytes: 128
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var [q,h,s,d] = nexts(4);
  var n = next();
  if(q*2 < h)h = q*2;
  if(h*2 < s)s = h*2;
  if(s*2 < d)d = s*2;
  return BigInt(n/2|0)*BigInt(d) + BigInt((n&1)*s);
}

Measured memory_bytes: 29480
<?php
fscanf(STDIN, "%d %d", $N, $M);
$r = [];
$g = array_fill(1, $N, null);
$ans = 0;
$cnt = 0;
for ($i = 0; $i < $M; $i++) {
    fscanf(STDIN, "%d %d", $A, $B);
    $r[$A][$B] = 1;
    $r[$B][$A] = 1;
}
$memo = [];
for ($i = 1; $i <= $N; $i++) {
    if (is_null($g[$i])) {
        $cnt++;
        $g[$i] = $cnt;
    } else {
        continue;
    }
    $stack = [];
    $memo = [];
    $t = $i;
    while(true) {
        if (!isset($r[$t])) break;
        foreach ($r[$t] as $k => $dummy) {
            if (!isset($memo[$k])) {
                $memo[$k] = 1;
                $stack[] = $k;
                $g[$k] = $cnt;
            }
        }
        if ($stack) {
            $t = array_pop($stack);
        } else {
            break;
        }
    }
}
printf("%d", max(array_count_values($g)));


Measured memory_bytes: 114496
eneNum, spNum = map(int, input().split())
eneHp = map(int, input().split())
eneHpList = list(eneHp)

# TLE
#count = 0
#for i in range(spNum):
#    if len(eneHpList) > 0:
#        maxEneHp = max(eneHpList)
#        eneHpList.remove(maxEneHp)

# new method
eneHpList.sort()
eneHpList.reverse()
del eneHpList[0:min([spNum, len(eneHpList)])]
count = sum(eneHpList)

print("{}".format(count))

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n,m,x,y;
	std::cin >> n >> m >> x >> y;
	std::vector<int> xx(n),yy(m);
	for (int i = 0; i < n; i++) {
		std::cin >> xx[i];
	}
	for (int i = 0; i < m; i++) {
		std::cin >> yy[i];
	}
	sort(xx.begin(), xx.end());
	reverse(xx.begin(),xx.end());
	sort(yy.begin(), yy.end());

	std::vector<int> v;
	for (int i = xx[0] + 1; i <= yy[0]; i++) {
		if (x < i && i <= y) {
			std::cout << "No War" << '\n';
			return 0;
		}
	}

	std::cout << "War" << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9+7 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
void solve(){
    ll n , k ;
    cin >> n >> k ;
    cout << min(n%k,(k-(n%k)));
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;

    //cin >> t ;
    while(t--){
        solve( );
    }
}


Measured memory_bytes: 256
L,R = map(int, input().split())
if R-L >= 2019:
  print(0)
else:
  t = 2019
  for i in range(L,R):
    for j in range(i+1,R+1):
        m = (i*j)%2019
        t = min(m,t)
  print(t)


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 1111
#define MOD 1000000007
const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int a[N] ;

int main() {
  int n ;
  ll ans = 1LL ;
  scanf("%d", &n) ;

  for(int i = 2 ;i<=n ;i++) {
    int temp = i ;

    for(int j = 2 ;j *j <=temp; j++){
      while(!(temp%j)){
        temp/=j ;
        a[j]++ ;
      }
    }
    if(temp>1)a[temp]++ ;
  }

  for(int i = 2 ; i <=n ;i++){
    ans=(ans*(a[i]+1))%MOD ;
  }

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

    


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int a,b;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>a>>b;
    if(a>b){
        for(int i=1;i<=a;i++){
            cout<<b;
        }
        cout<<endl;
    }
    else{
        for(int i=1;i<=b;i++){
            cout<<a;
        }
        cout<<endl;
    }
}

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

using namespace std;

int n;
vector<long long>vec;

void input(){
    for(int i=0;i<n;i++){
        long long a;
        cin>>a;

        vec.push_back(a);
    }
}

long long dp[3003][3003];
bool vis[3003][3003];
long long rec(int L, int R){

    if(vis[L][R]==true)return dp[L][R];

    if(L==R)return vec[L];

    long long a = vec[L] - rec(L+1,R);

    long long b = vec[R] -  rec(L,R-1);

    vis[L][R]=true;
    return dp[L][R] = max(a,b);
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(vis,false,sizeof vis);

    cin>>n;

    input();

    cout<<rec(0,n-1)<<"\n";
}


Measured memory_bytes: 78720
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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 (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n, l; cin >> n >> l;
    vint apples(n, l);
    rep(i, n) apples[i] += i;
    int d = INT_MAX, sum = accumulate(all(apples), 0), ans;
    rep(i, n) {
        int s = accumulate(apples.begin(), apples.begin() + i, 0);
        s += accumulate(apples.begin() + i + 1, apples.end(), 0);
        if(abs(s - sum) < d) {
            ans = s;
            d = abs(s - sum);
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	//freopen("Curtain","r",stdin);
	//freopen("Curtain","r",stdin);
	cin>>a>>b;
	if(2*b>=a)
	{
		cout<<0;
	}
	else 
	cout<<a-2*b;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner x = new Scanner(System.in);
		int h = x.nextInt();
		int w = x.nextInt();
		StringBuilder sb1 = new StringBuilder();
		while(h != 0 || w != 0){
		for(int i = 1 ; i <= h ; i++){
			if(i%2 != 0){
				for(int n = 1 ; n <= w ; n++){
					if(n%2 != 0 ){
						sb1.append("#");
					}else{
						sb1.append(".");
					}
				}
			}
			if(i%2 == 0){
				for(int n = 1 ; n <= w ; n++){
				if(n%2 == 0 ){
					sb1.append("#");
				}else{
					sb1.append(".");
				}
				}
			}
			sb1.append("\n");
		}
		sb1.append("\n");
		h = x.nextInt();
		w = x.nextInt();
		}
		System.out.print(sb1);
	}

}

Measured memory_bytes: 21196
#include <bits/stdc++.h>
using namespace std ;
using V_2 = vector<vector<int>> ;
using Gragh = vector<vector<char>> ;
using P = pair<int,int> ;
using ll = long long ;

int main(){
  ll a , b , c , d ;
  ll ans[4] ;
  cin >> a >> b >> c >> d ;
  ans[0] = a * c ;
  ans[1] = a * d ;
  ans[2] = b * c ;
  ans[3] = b * d ;
  sort(ans,ans+4) ;
  cout << ans[3] << endl ;
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll n;
	cin>>n;
	n--;
	vector<ll> v;
	while(n >= 0){
		v.push_back(n % 26);
		n = n/26 - 1;
	}
	reverse(v.begin(),v.end());
	string s = "";
	REP(i,0,v.size()){
		s.push_back('a' + v[i]);
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3632
XN = input().split()
X = int(XN[0])
N = int(XN[1])
if N == 0:
    print(X)
else:
    p = input().split()
    A = [None]*N
    for i in range(N):
        A[i] = abs(int(p[i])-X)
    if 0 not in A:
        print(X)
    else:
        j = 1
        while A.count(j) == 2:
            j += 1
        if A.count(j) == 0:
            print(X-j)
        else:
            if str(X-j) in p:
                print(X+j)
            else:
                print(X-j)

Measured memory_bytes: 9224
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			String S = sc.next();
			char[] s = S.toCharArray();
			
			long r = 0;
			long g = 0;
			long b = 0;
			
			for(int i=0;i<n;i++) {
				if(s[i]=='R') {
					r++;
				}else if(s[i]=='G') {
					g++;
				}else {
					b++;
				}
			}
			
			long res = r*g*b;
			
			for(int i=0;i<n;i++) {
				for(int j=i+1;j<n;j++) {
					int k = j+(j-i);
					
					if(k<n&&s[i]!=s[j]&&s[j]!=s[k]&&s[i]!=s[k]) {
						res--;
					}
				}
			}
			
			if(res<=0) {
				System.out.println("0");
			}else {
				System.out.println(res);
			}
			
		}	
	}

Measured memory_bytes: 35892
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+5;
struct node{
	int x,step,mod;
};
bool mark[M][3];
vector<int>Edge[M];
int ans;

bool bfs(int st, int ed){
	queue<node>Q;
	while(!Q.empty()) Q.pop();
	Q.push((node)<%st,0,0%>);
	while(!Q.empty()){
		node now=Q.front(); Q.pop();
		for(int i=0,_i=Edge[now.x].size(); i<_i; i++){
			int u=Edge[now.x][i],v=(now.mod+1)%3;
			if(mark[u][v]) continue;
			mark[u][v]=1;
			if(u==ed && v==0){
				ans=(now.step+1)/3;
				return 1;
			}
			Q.push((node)<%u,now.step+1,v%>);
		}
	}
	return 0;
}

int main(){
	int n,m,st,ed;
	scanf("%d %d",&n,&m);
	for(int i=1,x,y; i<=m; i++){
		scanf("%d %d",&x,&y);
		Edge[x].push_back(y);
	}
	scanf("%d %d",&st,&ed);
	if(bfs(st,ed)) printf("%d\n",ans);
	else puts("-1");
	return 0;
}

Measured memory_bytes: 6016
#include<iostream>
using namespace std;
int main()
{
	int n,value=0;
	cin>>n;
	int a[n];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	 } 
	 for(int i=1;i<=n;i++)
	 {
	 	if(i%2!=0 && a[i]%2!=0 )
	 	{
	 		value++;
		 }
	 }
	 cout<<value<<"\n";
	 return 0;
	 
	
 } 

Measured memory_bytes: 3164
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[10001],dp[100][100];

int main(){
  vi vec;
  cin >> n >> m;
  rep(i,0,n){
    cin >> l;
    vec.pb(l);
  }
  sort(all(vec),greater<int>());
  ll ans = 0;
  rep(i,0,m){
    ans += vec[i];
  }
  print(ans);
  return 0;
}

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

#define ll long long
#define ull unsigned long long

#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >

#define vi vector < int >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define pvi vector < pii >
#define pvll vector < pll >

#define pb push_back

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;

int a[10005];

void precal()
{
    for(int i = 1; ; i++){
        if((i * i) > 10000) break;

        for(int j = 1; ; j++){
            if(((i * i) + (j * j) + (i * j)) > 10000) break;

            for(int k = 1; ; k++){
                int tmp = (i * i) + (j * j) + (k * k) + (i * j) + (i * k) + (j * k);

                if(tmp > 10000) break;

                a[tmp]++;
            }
        }
    }
}

int main()
{
    fast;

    int n;

    cin >> n;

    precal();

    for(int i = 1; i <= n; i++) cout << a[i] << endl;

    return 0;
}



Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int m,d,sum = 0;
        
        m = sc.nextInt();
        d = sc.nextInt();
        
        for(int i = 4; i <= m; i++){
            for(int j = 22; j <= d; j++){
                int d10 = (int)j / 10;
                int d1 = (int)j % 10;
                if((d10 >= 2) && (d1 >= 2) && (i == d10 * d1)) sum++;
            }
        }
        
        System.out.println(sum);
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=600005;
const int mod = 1000000007;

int N, K;

struct SegmentTree {
private:
    int n;
    vector<int> node;

public:
    SegmentTree(vector<int> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1,0);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }

    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = max(node[2*x+1], node[2*x+2]);
        }
    }

    int getmax(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];

        int vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};
int main() {
  int N,K;
  cin>>N>>K;
  SegmentTree seg(vector<int>(INF,0));
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    int l=max(0,a-K);
    int r=min(INF,a+K+1);
    int v=seg.getmax(l,r);//cout<<l<<" "<<r<<endl;
    seg.update(a,v+1);//cout<<v<<endl;
  }
  cout<<seg.getmax(0,INF)<<endl;
  return 0;
}

Measured memory_bytes: 13800
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import Data.Bits
import Data.List
import Control.Monad

update :: MP.Map Char Int -> B.ByteString -> MP.Map Char Int
update m bs 
    | h  `elem` "MARCH" = MP.adjust (+1) h m
    | otherwise = m
    where
        h = B.head bs

enum :: Int -> Int -> [Int]
enum n l
    | l == 0 = []
    | otherwise = (n .&. 1) : enum (shiftR n 1) (l - 1)

solve :: [Int] -> Int
solve es = sum $ map (\i -> comb es (enum i 5)) [0..31]
    where
        comb :: [Int] -> [Int] -> Int
        comb es ens 
            | (length $ elemIndices 1 ens) /= 3 = 0
            | otherwise = foldl' step 1 $ zip es ens
                where
                    step acc (v, b)
                        | b == 1 = acc * v
                        | otherwise = acc

main = do
    n <- readLn :: IO Int
    names <- replicateM n B.getLine
    let m = foldl' (\m i -> MP.insert i 0 m) MP.empty "MARCH"
    let es = MP.elems $ foldl' update m names
    print $ solve es

Measured memory_bytes: 21372
#include<stdio.h>
#define N 100000
#define Q 50000

int main(){
  int s,t,S[N],T[Q],i,l,m,r,count=0,n;

  scanf("%d",&s);
  
  for(i=0;i<s;i++)scanf("%d",&S[i]);
  
  scanf("%d",&t);
  
  for(i=0;i<t;i++)scanf("%d",&T[i]);
  
  l=0;
  r=s-1;
  
  for(i=0;i<t;i++){
    l=0;
    r=s;
    while(1){
      m=(l+r)/2;
      if(T[i]==S[m]){
	count++;
	break;
      }
      if(T[i]<S[m])r=m;
      if(S[m]<T[i])l=m+1;
      if(r==l)break;
    }
  }
  printf("%d\n",count);
  return 0; 
}

Measured memory_bytes: 1184
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,k = map(int, input().split())
    ans = 0
    mn = mx = 0
    for i in range(n+1):
        j = n-i
        mn += i
        mx += j
        if i+1 >= k:
            ans += mx-mn+1
    print(ans%(10**9+7))

if __name__=="__main__":
    main()


Measured memory_bytes: 68696
#include <stdio.h>
int t,p[101],ans;
int main() {
	for(int i=0;i<3;i++) {
		scanf("%d",&t);
		p[t]=1;
	}
	for(int i=1;i<101;i++)
		if(p[i]) ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

typedef struct point{
	int x;
	int y;
}POINT;

int main(void){
	POINT s, t,difference;
	int i;

	scanf("%d %d %d %d", &s.x, &s.y,&t.x,&t.y);

	difference.x = t.x - s.x;
	difference.y = t.y - s.y;

	printf("L");
	for (i = 0; i < difference.y + 1; i++){
		printf("U");
	}
	for (i = 0; i < difference.x + 1; i++){
		printf("R");
	}
	for (i = 0; i < difference.y + 1; i++){
		printf("D");
	}
	for (i = 0; i < difference.x; i++){
		printf("L");
	}

	
	for (i = 0; i <difference.y; i++){
		printf("U");
	}

	for (i = 0; i < difference.x + 1; i++){
		printf("R");
	}

	for (i = 0; i < difference.y + 1; i++){
		printf("D");
	}

	for (i = 0; i < difference.x + 1; i++){
		printf("L");
	}

	printf("U");

	
	printf("\n");

	return 0;
}


Measured memory_bytes: 128
n = gets.to_i
array = gets.split(" ").map{|p| p.to_i}

count = 0
for i in 0..n-3
  subarray = array.slice(i..i+2)
  if (subarray[1] != subarray.max) && (subarray[1] != subarray.min)
    count += 1
  end
end

p count

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
typedef pair<int, int> pa;
vector<pa> g[N];
int f[N];
void dfs(int fa, int u, int w) {
    f[u] = w;
    for(auto e : g[u]) {
        if(e.first == fa) continue;
        dfs(u, e.first, w^(e.second&1));
    }
}
int main() {
    int n;
    cin >> n;
    for(int i = 1, u, v, w; i < n; i++) {
        cin >> u >> v >> w;
        g[u].push_back(pa(v, w));
        g[v].push_back(pa(u, w));
    }
    dfs(-1, 1, 0);
    for(int i = 1; i <= n; i++) {
        cout << f[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 13056