akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import math


order = []

for _ in range(5):
    order.append(int(input()))

sorted_order = sorted(order, key=lambda x: (x - 1) % 10, reverse=True)

t = 0
for i, n in enumerate(sorted_order):
    if i == len(sorted_order) - 1:
        t += n
    else:
        t += math.ceil(n / 10) * 10

print(int(t))


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

int main()
{
	int n;
	cin >> n;
	long long sum = 0, min = 999999999, max = -999999999;
	int a;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		sum = sum + a;

		if (a < min)
			min = a;
		if (a > max)
			max = a;
	}
	cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3088
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dp[500][500];
int flag[500][500];
int sum[500];

int dfs(int l, int r) {
    if (r - l == 1) return 0;
    if(flag[l][r]) return dp[l][r];
    flag[l][r] = true;
    int tmp = INF2;
    REP(m, l + 1, r) {
        tmp = min(tmp, dfs(l, m)+dfs(m, r) + sum[r] - sum[l]);
        //cout << l << " " << m << " " << r << " " << dp[l][m] << " " << dp[m][r] << endl;
    }
    return dp[l][r] = tmp;
}


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[500];
    rep(i, N) cin >> a[i];
    rep(i, N) sum[i + 1] = sum[i] + a[i];
    cout << dfs(0, N) << endl;
    return 0;
    rep(i, N + 1) {
        rep(j, N + 1) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }



    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

const int MAX_N = (2e+5)+10;
vec fact(MAX_N+1,0),fact_inv(MAX_N+1,0);

ll fastpow(ll a, ll pw) {
	ll res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}
void makefact(ll n){//MODは素数かつnより大きい
    ll ans = 1;
    fact.at(0) = ans;
    fact_inv.at(0) = ans;
    reps(i,1,n+1){
        (ans *= i)%=MOD;
        fact.at(i) = ans;
        fact_inv.at(i) = fastpow(ans,MOD-2);
    }
    return;
}

ll nCm(ll n, ll m){
    ll res = fact[n];
    (res *= fact_inv[n - m])%=MOD;
    (res *= fact_inv[m])%=MOD;
    return res;
}

int main(){
    cin>>N>>K;
    vec a(N);
    rep(i,N) cin>>a[i];
    sort(ALL(a));
    makefact(150000);
    ll smi = 0, sma = 0;
    rep(i,N - K + 1){
        (smi += (a[i] + MOD) * nCm(N - 1 - i, K - 1))%=MOD;
    }
    reverse(ALL(a));
    rep(i,N - K + 1){
        (sma += (a[i] + MOD) * nCm(N - 1 - i, K - 1))%=MOD;
    }
    cout<<(sma - smi + MOD)%MOD<<endl;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main()
{
int N;
string S;
cin>>N;cin>>S;
vector<int>num(N);
for(int i=0;i<N;i++)
{
if(S[i]=='E'){num[i]=1;}
else{num[i]=0;}
}
vector<int>ruisekiwa(N+2);
ruisekiwa[0]=0;
for(int i=0;i<N+1;i++)
{ruisekiwa[i+1]=ruisekiwa[i]+num[i];}

vector<int>points(N);
for(int i=0;i<N;i++)
{points[i]=ruisekiwa[i]+(N-i-ruisekiwa[N]+ruisekiwa[i]);}
points[N-1]=ruisekiwa[N-1]+1;
sort(points.begin(),points.end());
cout<<N-points[N-1]<<endl;


}


Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	
	bool flg=1;
	for(int i=0; i<n; ++i){
		int a; cin >> a;
		if(a%2==0){
			if(!(a%3==0 || a%5==0)){
				flg=0;
				break;
			}
		}
	}

	cout << (flg ? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1172&lang=jp

#include <iostream>
#include <algorithm>
using namespace std;

int main() {
  const int M = 300000;
  bool prime[M];
  fill(prime, prime+M, true);
  prime[0] = prime[1] = false;
  for (int i=2; i<M; i++) {
    if (prime[i]) {
      int j = 2;
      while (i*j < M) {
	prime[i*j] = false;
	j++;
      }
    }
  }
  int n;
  while (scanf("%d", &n) != EOF && n) {
    int ans = 0;
    for (int i=n+1; i<=2*n; i++) {
      if (prime[i]) ans++;
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 1464
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

struct Node{
    int key;
    Node *right,*left,*parent;
};

Node *root,*NIL;

Node *find(Node *u, int k){
    while(u!=NIL&&k!=u->key){
        if(k<u->key)u=u->left;
        else u=u->right;
    }
    return u;
}

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;
    
    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->left;
        }else{
            x=x->right;
        }
    }
    z->parent=y;
    if(y==NIL){
        root=z;
    }else {
        if(z->key<y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
}

void inorder(Node *u){
    if(u==NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preoder(Node *u){
    if(u==NIL)return;
    printf(" %d",u->key);
    preoder(u->left);
    preoder(u->right);
}
int main(){
    int i,n,x;
    string com;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        cin>>com;
        if(com[0]=='f'){
            scanf("%d",&x);
            Node *t=find(root,x);
            if(t!=NIL)printf("yes\n");
            else printf("no\n");
        }else if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }else if(com=="print"){
            inorder(root);
            printf("\n");
            preoder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 26744
#include <iostream>
using namespace std;
int main(void){
    string s;
    getline(cin, s);  //1行読み込む
        for(int i = 0; i < s.size(); i++){
            char c = s[i];
            if ('A' <= c && c <= 'Z'){
                //c = tolower(c);
                c = c + 32;
            }
            else if('a' <= c && c <= 'z'){
                c = c - 32;
            }
            cout << c ;
    }
    cout << endl;
}


Measured memory_bytes: 3100
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	reds := make([][]int, N)
	blues := make([][]int, N)

	for i := 0; i < N; i++ {
		reds[i] = []int{ReadInt(), ReadInt()}
	}
	for i := 0; i < N; i++ {
		blues[i] = []int{ReadInt(), ReadInt()}
	}

	adjL = make([][]*Edge, 1+N+N+1)
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if reds[i][0] < blues[j][0] && reds[i][1] < blues[j][1] {
				AddEdge(i+1, j+1+N, 1)
			}
		}
	}
	for i := 0; i < N; i++ {
		AddEdge(0, i+1, 1)
	}
	for i := 0; i < N; i++ {
		AddEdge(i+1+N, 1+N+N, 1)
	}
	fmt.Println(MaxFlow(0, 1+N+N))
}

const Inf = 1 << 60

type Edge struct {
	To, Cap, Rev int
}

var adjL [][]*Edge

// 最大流 (最小カット) Ford-Fulkerson O(F|E|)
func MaxFlow(s, t int) int {
	flow := 0
	for {
		f := flowDfs(s, t, Inf, make([]bool, len(adjL)))
		if f == 0 {
			return flow
		}
		flow += f
	}
}

func AddEdge(from, to, cap int) {
	adjL[from] = append(adjL[from], &Edge{
		To:  to,
		Cap: cap,
		Rev: len(adjL[to]),
	})
	adjL[to] = append(adjL[to], &Edge{
		To:  from,
		Cap: 0,
		Rev: len(adjL[from]) - 1,
	})
}

func flowDfs(v, t, f int, used []bool) int {
	if v == t {
		return f
	}
	used[v] = true
	for _, edge := range adjL[v] {
		if !used[edge.To] && edge.Cap > 0 {
			d := flowDfs(edge.To, t, Min(f, edge.Cap), used)
			if d > 0 {
				edge.Cap -= d
				adjL[edge.To][edge.Rev].Cap += d
				return d
			}
		}
	}
	return 0
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

using namespace std;

using ll = long long;

const int MX = 57;

ll dp[MX][2];
int a[MX];

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    string s;
    cin >> s;
    int res = 9 * (s.size() - 1);
    int sm = 0;
    for (int i = 0; i < s.size(); i++) {
        bool can = false;
        if (s[i] >= '2') {
            can = true;
        }
        if (i != 0 && s[i] == '1') {
            can = true;
        }
        if (can) {
            res = max(res, sm + s[i] - '0' - 1 + 9 * (int(s.size()) - 1 - i));
        }
        sm += s[i] - '0';
    }
    res = max(res, sm);
    cout << res << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class B {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), a[] = in.readIntArray(n), ans = 0;
            Arrays.sort(a);
            for (int i = 0; i < n; ++i) {
                for (int j = i + 1; j < n; ++j) {
                    for (int k = j + 1; k < n; ++k) {
                        if (a[i] != a[j] && a[j] != a[k] && a[i] != a[k] && a[j] + a[i] > a[k]) {
                            ans++;
                        }
                    }
                }
            }
            out.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[(int) size];
            for (int i = 0; i < size; i++) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 33168
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))
#define PI 3.14159265358979


int main()
{
	int m,n;
	int k;
	int i,j,l;
	scanf("%d %d",&m,&n);
	scanf("%d",&k);
	char** list = mem(char*,m);
	int*** data = mem(int**,m);
	for(i = 0;i < m;i++)
	{
		list[i] = mem(char,n+1);
		data[i] = mem(int*,n);
		scanf("%s",list[i]);
		int count[2] = {0,0};
		for(j = 0;j < n;j++)
		{
			switch(list[i][j])
			{
				case 'J':
					count[0]++;
					break;
				case 'O':
					count[1]++;
					break;
			}
			data[i][j] = mem(int,2);
			if(i != 0)
			{
				data[i][j][0] = count[0] + data[i-1][j][0];
				data[i][j][1] = count[1] + data[i-1][j][1];
			}
			else
			{
				data[i][j][0] = count[0];
				data[i][j][1] = count[1];
			}
		}
	}
	for(i = 0;i < k;i++)
	{
		int a,b,c,d;
		scanf("%d %d %d %d",&a,&b,&c,&d);
		int jnum,onum;
		if(a != 1)
		{
			if(b != 1)
			{
				jnum = data[c-1][d-1][0]-data[a-2][d-1][0]-data[c-1][b-2][0]+data[a-2][b-2][0];
				onum = data[c-1][d-1][1]-data[a-2][d-1][1]-data[c-1][b-2][1]+data[a-2][b-2][1];
			}
			else
			{
				jnum = data[c-1][d-1][0]-data[a-2][d-1][0];
				onum = data[c-1][d-1][1]-data[a-2][d-1][1];
			}
		}
		else
		{
			if(b != 1)
			{
				jnum = data[c-1][d-1][0]-data[c-1][b-2][0];
				onum = data[c-1][d-1][1]-data[c-1][b-2][1];
			}
			else
			{
				jnum = data[c-1][d-1][0];
				onum = data[c-1][d-1][1];
			}
		}
		printf("%d %d %d\n",jnum,onum,(c-a+1)*(d-b+1)-jnum-onum);
	}
	return 0;
}

Measured memory_bytes: 20000
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  ll n; cin >> n;
  ll ans = 0;
  for (int i=floor(sqrt(n)); i>=1; i--) {
    if (n%i==0) {
      ans+=i;
      ans+=n/i;
      break;
    }
  }
  ans -= 2;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

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

    int ret = 1145141919;
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            if (1000 * i + 500 * j >= x) {
                ret = min(ret, a * i + b * j);
            }
        }
    }

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c;
    cin>>a>>b;
    c=(b-a)%2;
	if(a>0)
	{
		cout<<"Positive\n";
	}
	if(a<=0&&b>=0)
	{
		cout<<"Zero\n";
	}
	if(a<0&&b<0)
	{
		if(c==0)
		{
			cout<<"Negative\n";
		}
		else cout<<"Positive\n";
	}
    return 0;
}

Measured memory_bytes: 256
//Card Game

#include<stdio.h>
#include<string.h>

int main(){
    int n=0, i=0, j=0;
    char strA[100];
    char strB[100];
    int scrA=0, scrB=0;
    
    scanf("%d",&n);  //&がいる
    
    for(i=0; i<n; i++){
        j=0;
        scanf("%s",strA);  //&がいらない
        scanf("%s",strB);

        if(strcmp(strA, strB) == 0) {//strA == strB
            scrA++;
            scrB++;
        }
        else{
            while(1){
                if(strA[j] > strB[j]){
                    scrA+=3;
                    break;
                }else if(strA[j] < strB[j]){
                    scrB+=3;
                    break;
                }
//                if(strA[j]!='\0'||strA[j]!='\0') break;
                j++;
            }
        }
//    printf("%d %d\n", scrA, scrB);
    }
    
    printf("%d %d\n", scrA, scrB);
return 0;
}


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

ll mod = 1e9+7;
ll pow3[100100];

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  s = "0"+s;
  int n = s.size();
  int carry = 1;
  for (int i = n-1; i >= 0; i--) {
    s[i] = carry^s[i];
    carry = carry&(s[i]=='0');
  }
  //cout << s << endl;
  ll pow2 = 1;
  pow2 = pow3[0] = 1;
  for (int i = 0; i < n; i++)
    pow3[i+1] = pow3[i]*3%mod;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      (ans += pow3[n-1-i]*pow2%mod) %= mod;
      pow2 = pow2*2%mod;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
 
    int N,R;
    cin >> N >> R;

    int ans;
    if (N >= 10)
    {
        ans = R;
    }
    else
    {
        ans = R + 100*(10-N);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ad = {}

for i in range(26):
	ad[a[i]] = i

ans = ''
for i in range(len(s)):
	tmp = (ad[s[i]]+n)%26
	ans += a[tmp]

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

ll gcd(ll a,ll b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}

const int MOD = INF+7;
ll dp[105][10];
int main(){
    int n;
    ll x;cin >> n >> x ;
    vector<ll> v(n);
    rep(i,n){
        ll a; cin >> a;
        v[i] = abs( x - a );
    }
    sort(ALL(v));

    ll res = v[0];
    rep(i,n){
        res = gcd( res , v[i] );
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
void insertionSort(int *,int);
void print(int *,int);
int main(){
  int i,N;
  int A[1000];
  scanf("%d",&N);

  for(i=0;i<=N-1;i++){
    scanf("%d",&A[i]);
  }
print(A,N);
  insertionSort(A,N);
  return 0;
}

void print(int *A,int N){
  int i;
  for(i=0;i<=N-1;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}
void insertionSort(int *A, int N){
  int i,j,v;
  for(i=1;i<=N-1;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    print(A,N);
  }
}
  
  



Measured memory_bytes: 2100
a=int(input())
an=[int(i) for i in input().split()]
count=0
for i in an:
  if i%2==0:
    count+=1
  if i%4==0:
    count+=1
if a%2==1:
  a-=1
if count>=a:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector<ll> 
#define vv vector<v>
#define p pair<ll,ll>
#define mid (start+end)/2
#define fi first
#define se second
ll MOD=1e9+7;	
int main() {
	string s;
	cin>>s;
	int n=s.length();
	s="a"+s;
	vv dp(n+1,v(13,0));
	dp[0][0]=1;
	for (int i=1; i<=n; i++)
	{
		for (int j=0; j<=12; j++)
		{
			if (s[i]!='?')
			{
				dp[i][(j*10+s[i]-'0')%13]+=dp[i-1][j];
				dp[i][(j*10+s[i]-'0')%13]%=MOD;
			}
			else
			{
				for (int k=0; k<=9; k++)
				{
					dp[i][(j*10+k)%13]+=dp[i-1][j];
					dp[i][(j*10+k)%13]%=MOD;
				}
			}
		}
	}
	//cout<<dp[2][10]<<endl;
	cout<<dp[n][5]<<endl;

	return 0;
}

Measured memory_bytes: 13692
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll N;
ll a[200200];
int main(){
  cin >> N;
  rep(i,N){
    cin >> a[i];
  }
  sort(a,a+N);

  ll ans = 0;
  rep(i,N/2){
    if(i == 0){
      ans += abs(a[i]-a[N-1]) + abs(a[i]-a[N-2]);
    }
    else {
      ans += abs(a[i] - a[N-i-2]) + abs(a[i] - a[N-i]);
    }
    cerr << ans << endl;
  }
  cerr << endl;
  ll ans2 = 0;
  rep(i,N/2){
    if(i == 0){
      ans2 += abs(a[N-1]-a[0]) + abs(a[N-1]-a[1]);
    }
    else {
      ans2 += abs(a[N-i-1] - a[i-1]) + abs(a[N-i-1] - a[i+1]);
    }
    cerr << ans2 << endl;
  }
  cout << max(ans,ans2) << endl;

}


Measured memory_bytes: 1024
#include <stdio.h>

long long min(long long a,long long b){
  if(a < b){
    return a;
  }
  return b;
}

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

  if(min(N,M) == 1){
    if(N+M == 2){
      printf("1\n");
    }else{
      printf("%lld",N+M-3);
    }
  }else{
    printf("%lld\n",(N-2)*(M-2));
  }

  return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	// Code for C - Sum of gcd of Tuples (Easy)
	var k int
	fmt.Scanf("%d", &k)

	total := 0
	for a := 1; a <= k; a++ {
		for b := 1; b <= k; b++ {
			for c := 1; c <= k; c++ {
				total += GCD(GCD(a, b), c)
			}
		}
	}
	fmt.Printf("%d", total)
}

func GCD(a, b int) int {
	x := Min(a, b)
	y := Max(a, b)

	for {
		t := y % x
		if t == 0 {
			return x
		}
		y = x
		x = t
	}
}

func Max(x ...int) int {
	max := x[0]
	for _, v := range x {
		if v > max {
			max = v
		}
	}
	return max
}

func Min(x ...int) int {
	min := x[0]
	for _, v := range x {
		if v < min {
			min = v
		}
	}
	return min
}


Measured memory_bytes: 1852
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    string S; cin >> S;
    vector<string> vs = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

    int d = find(vs.begin(), vs.end(), S) - vs.begin();
    cout << (0 - d + 7) << endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		cs: Chars,
	}

	let mut count = [0; 26];
	for i in 0..cs.len() {
		let tmp = cs[i] as u8 - 'a' as u8;
		count[tmp as usize] += 1; 
	}
	for i in 0..26 {
		if count[i] == 0 {
			println!("{}", ('a' as u8 + i as u8) as char);
			return;
		}
	}
	println!("None");
}



Measured memory_bytes: 2476
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main () {
	int N;
	cin >> N;
	int T, A;
	cin >> T >> A;
	vector<int> H(N);
	double diff = 1e10;
	int idx = -1;
	for (int i=0; i<N; ++i) {
	 	cin >> H[i];
		double temp = fabs(A - (T - H[i]*0.006));
		if (diff > temp) {
			diff = temp;
			idx = i+1;
		}
	}
	
	cout << idx << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define vv(type)		vector<vector<type>>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define db(x) 			cout<<x<<" "
#define db1(x) 			cout<<x<<'\n'
#define db2(x,y) 		cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) 		cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define repA(i,a,n) 	for(int i=a;i<=(n);++i)
#define repD(i,a,n) 	for(int i=a;i>=(n);--i)
#define so(a) 			sort(a.begin(),a.end())
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// to find all local maximaa and minima in O(n)
//	 for (int i=1;i<=n;i++)
//        {
//            if (i==1 || i==n || (p[i-1]<p[i])!=(p[i]<p[i+1]))
//           ans.push_back(p[i]);
//        }
int dx[] = { -1, 1, -1, 0, 0, -1, 1, 1 };
int dy[] = { -1, -1, 1, -1, 1, 0, 0, 1 };
int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}
int modular_expo(int x, int y, int m)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans % m * x % m) % m;
		x = (x % m * x % m) % m;
		y /= 2;
	}
	return ans % m ;
}
int power(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x);
		x *= x;
		y /= 2;
	}
	return ans;
}
double dp[3001][3001];
double solve(std::vector<double> &p, int i, int x)
{
	if (x == 0) return 1;
	if (i == 0) return 0;
	if (dp[i][x] > -0.9)
		return dp[i][x];
	return dp[i][x] = p[i] * solve(p, i - 1, x - 1) + (1 - p[i]) * solve(p, i - 1, x);
}

void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	memset(dp, -1, sizeof(dp));
	vector<double> p(n + 1);
	repA(i, 1, n)
	cin >> p[i];
	cout << ps(solve(p, n, (n + 1) / 2), 10);
}

int32_t main()
{
	solve();
	return 0;
}


Measured memory_bytes: 74424
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int ans = -1;
    for(int i=1;i<=N;i++){
        int M = i * 1.08;
        if(N == M){
            ans = i;
            break;
        }
    }
    if(ans == -1){
        cout << ":(" << endl;
    }
    else{
        cout << ans << endl;
    }
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	string a,b;
	cin>>a>>b;
	int best=0;
	for(int i=0;i<a.size()-b.size()+1;i++){
		int k=0;
		int count=0;
		for(int j=i;k<b.size();j++){
			if(b[k++]==a[j]){
				count++;
			}
		}
		best=max(best,count);
	}
	printf("%d",b.size()-best);
	return 0;
}


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

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

    int k = 1;
    while(k * (k - 1) / 2 < n) {
        k += 1;
    }

    if(k * (k - 1) / 2 != n) {
        cout << "No" << endl;
        return 0;
    }

    const int m = n * 2 / k;
    vector<vector<int>> ans(k);
    vector<int> cnt(n);
    for(int i = 0; i < k; ++i) { // O(nsqrt(n)) ?
        for(int j = 0; j < i; ++j) {
            for(auto x : ans[j]) {
                if(cnt[x] != 2) {
                    ans[i].push_back(x);
                    cnt[x] += 1;
                    break;
                }
            }
        }

        for(int j = 0; j < n && (int)ans[i].size() != m; ++j) {
            if(cnt[j] == 0) {
                ans[i].push_back(j);
                cnt[j] += 1;
            }
        }
    }

    cout << "Yes\n" << k << endl;
    for(int i = 0; i < k; ++i) {
        cout << m << ' ';
        for(int j = 0; j < m; ++j) {
            cout << ans[i][j] + 1 << " \n"[j + 1 == m];
        }
    }
}


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

int main(){
    int n,dif;
    while(cin>>n){
if(n==0)break;
        dif=1000000;
        int a[1000];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
     sort(a,a+n);
for(int i=0;i<n-1;i++)
        if(max(a[i]-a[i+1], a[i+1]-a[i])<dif)dif=max(a[i]-a[i+1], a[i+1]-a[i]);

cout<<dif<<endl;
    }
    return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	vector<int> a(n + 1);
	for(int i = 0; i < n; ++i){
		a[i + 1] = a[i] + (s[i] == 'E' ? 1 : 0);
	}
	int answer = n;
	for(int i = 0; i < n; ++i){
		const int left = a[i] - a[0];
		const int right = a[n] - a[i + 1];
		answer = min(answer, (i - left) + right);
	}
	cout << answer << endl;
	return 0;
}



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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    set<long long>s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout<<s.size()<<endl;
    
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,r;
cin>>n>>r;
int ans;
if(n>=10){
    ans=r;
}
else{
    ans=r+100*(10-n);
}
cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

ll Solve(const vector<ll>& a) {
  int l = 0;
  int r = a.size() - 1;
  ll result = abs(a[r] - a[l]);
  while (r - l > 2) {
    result += abs(a[l] - a[r - 1]) + abs(a[l + 1] - a[r]);
    l++;
    r--;
  }
  if (r - l == 2) result += abs(a[l] - a[l + 1]);
  return result;
}

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  ll result = Solve(a);
  reverse(a.begin(), a.end());
  result = max(result, Solve(a));
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 1024
a = list(map(int,input().split()))
if a[1] == 0:
  print(a[0])
else:
  b = list(map(int,input().split()))
  min_num = a[0]
  min_p = a[0]
  m = 1
  ans = a[0]
  # そーとする
  # abs(a[0]-p1)がabs(a[0]-p2)より小さいならp1を保持。大きいならp2に更新。
  for i in set(b):
    if min_num >= abs(a[0]-i):
      min_p = i
      min_num = abs(a[0] - min_p)
  # 全て繰り返すとまずbのなかで一番近い値が出てくる。
      #下記をm回繰り返す
  # pn - mがset(b)にあるか確認
      #なければbreak,pn-1がans
  # pn + mがset(b)にあるか確認
      #なければbreak,pn+1がans
  while True:
    if (min_p - m) not in set(b):
      ans = min_p - m
      break
    elif (min_p + m) not in set(b):
      ans = min_p + m
      break
    m += 1
  print(ans)


Measured memory_bytes: 9220
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a >= 13){
            System.out.println(b);
        }else if(a >= 6 && a <= 12){
            System.out.println(b/2);
        }else{
            System.out.println(0);
        }
        
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define loop(i, n) for(int i = 0 ; i < n ; ++i)
#define LOOP(i, a, b) for(int i = a ; i < b ; ++i)
#define max3(a, b, c) max(a, max(b,c))
#define max4(a, b, c, d) max3(a, b, max(c, d))
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18
#define inf 1e9
#define MOD 1000000007 //check
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

long double dp[301][301][301];
bool dpb[301][301][301];
int n;
long double f;
string a;
long double expected(int zero, int one, int two)
{
	int three = n - zero - one - two;
	if(zero < 0 || one < 0 || two < 0 || three < 0) return 0;
	if(zero == n) return 0;
	long double &ans = dp[zero][one][two];
	if(dpb[zero][one][two]) return ans;
	dpb[zero][one][two] = 1;
	long double factor = 1-zero*f;
	ans = 1 + three*f*expected(zero, one, two+1) + two*f*expected(zero, one+1, two-1) + one*f*expected(zero+1, one-1, two);
	ans /= factor;
	return ans;
}
int main() {
	_69e27;
	memset(dpb, 0, sizeof(dpb));
	cin >> n;
	f = 1;
	long double temp = n;
	f /= temp;
	int arr[] = {0, 0, 0, 0};
	loop(i, n)
	{
		int in;
		cin >> in;
		++arr[in];
	}
	cout << fixed << setprecision(10) << expected(arr[0], arr[1], arr[2]);
	return 0;
}

Measured memory_bytes: 451072
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    // Here your code !
 int a,b,C;
 double S,L,h,c;
double Pi=acos(-1); 
 cin>>a>>b>>C;
 c=sqrt((a*a+b*b)-2*a*b*cos(C*Pi/180));
 L=a+b+c;
 S=0.5*a*b*sin(C*Pi/180);
 h=2*S/a;
 
 cout<<fixed<<setprecision(8);
 cout<<S<<' '<<L<<' '<<h<<endl;
 
}

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

class Solve {
private:
	std::string cipher;
	int length;
	std::priority_queue<std::string, std::vector<std::string>, std::greater<std::string>> greater;
	std::priority_queue<std::string> less;
	std::array<bool, 27> changed{};
	int ans_count{};
	std::string plainText;

	void rc(int index)
	{
		if (index == (int)cipher.size())
		{
			ans_count++;
			greater.push(plainText);
			less.push(plainText);
			if (ans_count > 10)
			{
				greater.pop();
				less.pop();
			}
			return;
		}
		if (cipher[index] == 'a' || changed[cipher[index] - 'a'])
		{
			plainText += cipher[index];
			rc(index + 1);
			plainText.pop_back();
		}
		if (!changed[cipher[index] - 'a' + 1])
		{
			changed[cipher[index] - 'a' + 1] = true;
			plainText += cipher[index] + 1;
			rc(index + 1);
			plainText.pop_back();
			changed[cipher[index] - 'a' + 1] = false;
		}
		return;
	}
public:
	bool is_last_query{};
	Solve()
	{
		std::cin >> cipher;
		if (cipher == "#")
		{
			is_last_query = true;
			return;
		}
		length = (int)cipher.size();
		changed.back() = true;
		rc(0);
		printf("%d\n", ans_count);
		if (ans_count <= 10)
		{
			while (!greater.empty())
			{
				std::cout << greater.top() << std::endl;
				greater.pop();
			}
		}
		else
		{
			std::vector<std::string> ans;
			while (less.size() > 5)
				less.pop();
			while (!less.empty())
			{
				ans.push_back(less.top());
				less.pop();
			}
			for (int i{4}; i >= 0; i--)
				std::cout << ans[i] << std::endl;
			while (greater.size() > 5) greater.pop();
			while (!greater.empty())
			{
				std::cout << greater.top() << std::endl;
				greater.pop();
			}
		}
	}
};

int main()
{
	while (!Solve().is_last_query);

	return 0;
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e2 + 10;
const int mod = 1e9 + 7;


map<int,int> mp;

int32_t main(){
	boost;
	int n;
	cin >> n;
	int a[n];

	set<int> s;
	priority_queue<pair<int,int>> q;
	int temp;
	for(int i = 0 ; i < n ; ++i){
		cin >> a[i];
		mp[a[i]]++;
		s.insert(a[i]);
	}

	for(auto i : s){
		q.push({mp[i] , i});
	}

	pair<int,int> hell = {0,0} , hav = {0,0}, hah = {0,0};
	while(true){

		if(q.top().first == 1) break;

		hell = q.top();
		q.pop();

		if(hell.first >= 3){
			q.push({hell.first - 2 , hell.second});
		}
		else if(q.size() > 2){

			hav = q.top();
			q.pop();
			if(hav.first + hell.first >= 3){
				if(hell.first == 2){
					q.push({hell.first-1 , hell.second});
					if(hav.first > 1){
						q.push({hav.first-1 , hav.second});
					}
				}
				else{
					q.push({hav.first-1, hav.second});
				}
			}
			else{

				hah = q.top();
				q.pop();
				q.push({hav.first , hav.second});
				if(hah.first > 1){
					q.push({hah.first-1 , hah.second});
				}
			}
		}
		else{
			break;
		}
	}

	cout << q.size();
	return 0;
}

Measured memory_bytes: 14196
defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.to_integer()
    |> get_mod()
    |> IO.puts()
  end
 
  def get_mod(mod) do
    cond do
      mod < 0 -> -mod
      mod == 0 -> 0
      true -> get_mod(mod - 1000)
    end
  end
end

Measured memory_bytes: 30736
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 20
#else
#define SIZE 6666
#endif

int N,S,A[SIZE];
// i番目まで見て、合計がjになる答え
int DP[SIZE][SIZE];
int MOD=998244353;

void solve() {
    cin>>N>>S;
    REP(i,N)cin>>A[i];
    DP[0][0]=2;
    DP[0][A[0]]=1;
    REP1(i,N-1)REP(j,S+1) {
        DP[i][j] += DP[i-1][j]*2;
        if (j>=A[i]) {
            DP[i][j] += DP[i-1][j-A[i]];
        }
        DP[i][j] %= MOD;
    }
    cout << DP[N-1][S] << endl;
}



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

int main(){

    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0; i<N; i++){
        cin >> a.at(i);
    }

    sort(a.begin(), a.end());
    
    int alice = 0, bob = 0;
    for (int i=N-1; i>=0; i = i-2){
        alice += a.at(i);
        if (i==0) break;
        bob += a.at(i-1);
    }

    int ans;
    ans = alice - bob;

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

Measured memory_bytes: 256
import math
a, b = map(int, input().split())
res = None
for i in range(1, 200000):
    if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
        res = i
        break
if res is not None:
    print(res)
else:
    print(-1)

Measured memory_bytes: 40748
//テ・ツ、ツァテ」ツ?催」ツ??・ツ崢崚ィツァツ津」ツつ? テ・ツ?・テ・ツ環崚・ツ、ツ堙ィツァツ津・ツスツ「テ」ツ?ョティツセツコテ」ツ?ァconvexCutテ」ツ?療」ツ?ヲテ」ツ??」ツ??
//テヲツ慊?ァツオツづァツ堋?」ツ?ォテゥツ敖「テァツゥツ催」ツ?古」ツ?づ」ツつ古」ツ?ー, テァツュツ氾」ツ?暗」ツ?ッ1. テ」ツ?ェテ」ツ?妥」ツつ古」ツ?ーテァツュツ氾」ツ?暗」ツ?ッ0???
//テヲツ?ェテ」ツ?療」ツ??」ツ?凝」ツつ?
#include <iostream>
#include <complex>
#include <vector>
using namespace std;

typedef complex<double> P;

#define INF P(999999, 999999)

const double EPS = 1e-8;

double cross(const P &a, const P &b){
  return imag(conj(a) * b);
}

double dot(const P &a, const P &b){
  return real(conj(a) * b);
}

struct L : public vector<P>{
  L(const P &a, const P &b){
    push_back(a);
    push_back(b);
  }
};

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b, c) > 0) return +1;
  if(cross(b, c) < 0) return -1;
  if(dot(b, c) < 0) return +2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

P crosspoint(const L &l, const L &m){
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if(abs(A) < EPS && abs(B) < EPS) return INF;
  return m[0] + B / A * (m[1] - m[0]);
}

vector<P> convexCut(const vector<P> p, const L &l){
  vector<P> q;

  for(int i = 0; i < p.size(); i++){
    P A = p[i];
    P B = p[(i + 1) % p.size()];

    if(ccw(l[0], l[1], A) != -1) q.push_back(A);
    if(ccw(l[0], l[1], A) * ccw(l[0], l[1], B) < 0)
      q.push_back(crosspoint(L(A, B), l));
  }

  return q;
}

double getArea(const vector<P> &v){
  int n = v.size();

  if(n < 3) return 0;

  double res = 0;
  for(int i = 0; i < n; i++){
    res += cross(v[i], v[(i + 1) % n]);
  }
  return abs(res) / 2.0;
}

void solve(int n, const vector<P> &v){
  vector<P> rem;

  rem.push_back(P(-1, -1));
  rem.push_back(P(10001, -1));
  rem.push_back(P(10001, 10001));
  rem.push_back(P(-1, 10001));

  for(int i = 0; i < n; i++){
    rem = convexCut(rem, L(v[i], v[(i + 1) % n]));
  }

  double area = getArea(rem);

  if(0 < area){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

int main(){
  int n;

  while(cin >> n, n){
    vector<P> v;

    for(int i = 0; i < n; i++){
      P p;
      cin >> p.real() >> p.imag();
      v.push_back(p);
    }

    solve(n, v);
  }
}

Measured memory_bytes: 1240
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main{
	public static void main(String[] args){
	int n =0;
	int x =0;
	Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		for(int i=1; i != n+1; i++){
			x = i;
			if(i%3 == 0){
				System.out.print(" "+i);
			}
			else{
				while(x != 0){
					if(x%10 == 3){
						System.out.print(" "+i);
						break;
					}
					else{
						x /= 10;
					}
				}
			}
			
		}
		System.out.println("");
	}
}

Measured memory_bytes: 28648
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func getScanner(fp io.Reader) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 500001), 500000)
	return sc
}

func getHugeScanner(fp io.Reader, size int) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, size), size)
	return sc
}

func getNextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func getNextInt(sc *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(sc))
	return i
}

func getNextInt64(sc *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(sc), 10, 64)
	return i
}

func getNextFloat64(sc *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(sc), 64)
	return i
}

var MOD int = 1000000007
var fact []int
var inv []int
var finv []int

func Init(fact, inv, finv []int) {
	fact[0] = 1
	fact[1] = 1
	inv[0] = 1
	inv[1] = 1
	finv[0] = 1
	finv[1] = 1

	for i := 2; i < len(fact); i++ {
		fact[i] = fact[i - 1] * i % MOD
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD
		finv[i] = finv[i - 1] * inv[i] % MOD
	}
}

func C(m, n int) int {
	if m < n {
		return 0
	}
	return fact[m] * (finv[n] * finv[m - n] % MOD) % MOD
}

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := getScanner(stdin)

	n := getNextInt(sc)
	k := getNextInt(sc)

	fact = make([]int, n + 1)
	inv = make([]int, n + 1)
	finv = make([]int, n + 1)

	Init(fact, inv, finv)

	for i := 1; i <= k; i++ {
		_, _ = fmt.Fprintf(stdout, "%v\n", C(k - 1, i - 1) * C(n - k + 1, i) % MOD)
	}
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main(){
    int st=200000,en=0;
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A') {
            
            st = min(st,i);
        } else if (S[i] == 'Z'){
            en = max(en,i);
        }
    }
    
    cout << en-st+1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <utility>
#include <cstdio>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#define INTINF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
#define MAX 27
#define NIL -1


struct Node {int parent, left, right; };
Node node[MAX];
int D[MAX];
int H[MAX];
int n;

void initNode(){
  for (size_t i = 0; i < n; i++) {
    node[i].parent = node[i].left = node[i].right = NIL;
    H[i]=0;
  }
}


void inputNode(){
  int id, l, r;
  for (size_t i = 0; i < n; i++) {
    std::cin >> id >> l >> r;
    node[id].left = l;
    node[id].right = r;
    if (l!=NIL) node[l].parent=id;
    if (r!=NIL) node[r].parent=id;
    }
}

void recDepth(int id, int depth){
    D[id]=depth;
    if (node[id].left!=NIL) {
      recDepth(node[id].left, depth+1);
    }
    if(node[id].right!=NIL) {
      recDepth(node[id].right, depth+1);
    }

}

void recHeight(int id, int idrec, int height){
  H[id] = max(H[id], height);
  if (node[idrec].left!=NIL) {
    recHeight(id, node[idrec].left, height+1);
  }
  if(node[idrec].right!=NIL) {
    recHeight(id, node[idrec].right, height+1);
  }
}



void printNode(int id) {
  int parent = node[id].parent;
  int sibiling = NIL;
  int depth = D[id];

  if (parent!=NIL && node[parent].left!=NIL && node[parent].right!=NIL) {
    if (node[parent].left==id) {
      sibiling = node[parent].right;
    }else{
      sibiling = node[parent].left;
    }
  }


  int degree = 0;
  degree += (node[id].left!=NIL) + (node[id].right!=NIL);

  recHeight(id,id,0);
  int height = H[id];

  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",id,parent,sibiling,degree,depth,height);

  if (parent==NIL) {
    std::cout << "root" << '\n';
  }else if(degree!=0){
    std::cout << "internal node" << '\n';
  }else{
    std::cout << "leaf" << '\n';
  }
}


int main(int argc, char const *argv[]) {
  std::cin >> n;
  initNode();
  inputNode();
  int root;
  for (size_t i = 0; i < n; i++) {
    if (node[i].parent==NIL) {
      root=i;
    }
  }
  recDepth(root, 0);
  for (size_t i = 0; i < n; i++) {
    printNode(i);
  }
  return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M,C;
    cin>>N>>M>>C;
    int B[M];
    rep(i,M){
        cin>>B[i];
    }

    int A[N][M];
    rep(i,N){
        rep(j,M){
            cin>>A[i][j];
        }
    }

    int ans=0;
    rep(i,N){
        int sum=C;
        rep(j,M){
            sum+=A[i][j]*B[j];
        }
        if(sum>0) ans++;
    }
    cout<<ans<<endl;
    



}


Measured memory_bytes: 3660
#include<cstdio>
using namespace std;
int main(){
	int n,k,ans=1;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		if(ans<<1<ans+k) ans<<=1;
		else ans+=k;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128