akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
long long n,tot,ans;
using namespace std;
int main()
    {
        cin>>n;
        while(n>0)
        {
            ans+=n%10;
            n/=10;
        }
        if(ans!=1) cout<<ans<<endl;
        else cout<<"10"<<endl;
        return 0;
    }


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int cmp(const void *a,const void *b){
	return *(int *)a-*(int *)b;
}

int main(){
	int n;
	scanf("%d",&n);
	int b,res=0,a[100000];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	qsort(a,n,sizeof(a[0]),cmp);
	int cnt=1;
	for(int i=1;i<n;i++){
		if(a[i]!=a[i-1]){
			if(cnt%2!=0){
				res++;
			}
			cnt=1;
		}
		else{
			cnt++;
		}
	}
	if(cnt%2!=0){
		res++;
	}
	printf("%d",res);
}

Measured memory_bytes: 892
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

tonum = lambda c: ord(c) - 97
tochr = lambda num: chr(num + 97)

def to26(n):
	ans = deque()
	while n:
		n -= 1
		n, dig = divmod(n, 26)
		ans.appendleft(dig)
	return ans

def main():
	n = int(rl())
	ans = [tochr(x) for x in to26(n)]
	print("".join(x for x in ans))
	stdout.close()

if __name__ == "__main__":
	main()


Measured memory_bytes: 65476
N = int(input())
AList = list(map(int,input().split()))
BList = list(map(int,input().split()))
CList = list(map(int,input().split()))
AList.sort()
BList.sort()
CList.sort()
#Bより真に小さいAの数
Bx  = []
#Bxの累積和
Bx2 = []
#Cより真に小さいBの数
Cx = []

bnum = 0
for b in BList:
    while bnum < N and AList[bnum] < b:
        bnum += 1
    Bx.append(bnum)

for i in range(N):
    if i != 0:
        Bx2.append(Bx2[i-1]+Bx[i])
    else:
        Bx2.append(Bx[i])

cnum = 0
for c in CList:
    while cnum < N and BList[cnum] < c:
        cnum += 1
    Cx.append(cnum)

ans = 0
for sc in Cx:
    if sc > 0:
        ans += Bx2[sc-1]
print(ans)


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

int main() {
    string s;
    ll k;
    cin >> s >> k;
    int n = s.size();
    for (int i = 0; i < n - 1; ++i) {
        if (s[i] == 'a') continue;
        int dist = 'z' - s[i] + 1;
        if (dist <= k) {
            s[i] = 'a';
            k -= dist;
        }
    }
    ll c = s[n - 1] + k % 26;
    if (c > (int)'z') s[n - 1] = (char)(c - 26);
    else s[n - 1] = (char)c;
    cout << s << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int do_win(char a, char b, int point)
{
    if ((a == 'r' && b == 's') || (a == 's' && b == 'p') || (a == 'p' && b == 'r'))
    {
        return point;
    }
    return 0;
}

int main()
{
    int n, k, R, S, P, ans = 0;
    string t;
    cin >> n >> k >> R >> S >> P >> t;
    vector<int> point = {R, S, P};
    vector<char> my = {'r', 's', 'p'};
    for (int lane = 0; lane < k; lane++)
    {
        int size = (n - lane - 1) / k + 1;
        vector<vector<int>> dp(size + 1, vector<int>(3, 0));
        for (int gen = 0; gen < size; gen++)
        {
            for (int j = 0; j < 3; j++)
            { //0:r 1:s 2:p
                dp[gen + 1][j] += do_win(my[j], t[lane + gen * k], point[j]) + max(dp[gen][(j + 1) % 3], dp[gen][(j + 2) % 3]);
            }
        }
        ans += max({dp[size][0], dp[size][1], dp[size][2]});
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) {
        cin >> A[i];
        A[i] -= i + 1;
    }

    ASC(A);
    ll sum1 = 0, sum2 = 0;
    REP(i,0,N/2) {
        sum1 += A[i];
        sum2 += A[N-i-1];
    }
    PR(sum2-sum1);

    return 0;
}

/*



*/

Measured memory_bytes: 4796
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

int popcount(int n) {
    return __builtin_popcount(n);
}

int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    vector<int>init_a(n);
    rep(i,n) {
        cin >> a[i];
        init_a[i] = a[i];
    }
    sort(a.rbegin(),a.rend());
    int m1 = a[n/2-1];
    int m2 = a[n/2];
    a = init_a;
    rep(i,n) {
        if(m1>a[i]) cout << m1 << endl;
        else cout << m2 << endl;
    }
}

Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi a(n),b(n);
  ll sumA = 0, sumB = 0;
  rep(i,n){
    cin >> a[i];
    sumA += a[i];
  }
  rep(i,n){
    cin >> b[i];
    sumB += b[i];
  }
  ll cnt = 0;
  rep(i,n){
    if(a[i] < b[i]) cnt += ceil((b[i]-a[i])/2.0);
  }
  if(cnt <= sumB-sumA) cout << "Yes";
  else cout << "No";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3692
card_n = int(input())
A = 0
B = 0
for i in range(card_n):
    Acard, Bcard = input().split()
    if Acard == Bcard:
        A += 1
        B += 1
    else:
        for a, b in zip(Acard, Bcard):
            if ord(a) > ord(b):
                A += 3
                break
            elif ord(a) < ord(b):
                B += 3
                break
            elif a == Acard[-1] or b == Bcard[-1]:
                if len(Acard) > len(Bcard):
                    A += 3
                else:
                    B += 3
print(A, B)                


Measured memory_bytes: 5596
N = gets.to_i

ans = 0
if N < 10
    ans = N
elsif N < 100
    ans = 9
elsif N < 1000
    ans = 9 + N - 100 + 1
elsif N < 10000
    ans = 909
elsif N < 100000
    ans = 909 + N - 10000 + 1
else
    ans = 90909
end

puts ans


Measured memory_bytes: 1788
#include<stdio.h>
#include <iostream>
int map[1002][1002];
int dat[1002][1002];
int x[1000001], y[1000001];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
	int mx, my;
	scanf("%d%d", &mx, &my);
	for (int i = 0; i < mx + 2; i++)for (int j = 0; j < my + 2; j++)map[i][j] = 1000000000, dat[i][j] = 0;
	for (int i = 0; i < mx; i++)for (int j = 0; j < my; j++)scanf("%d", &map[i + 1][j + 1]);
	for (int i = 1; i <= mx; i++)for (int j = 1; j <= my; j++)x[map[i][j]] = i, y[map[i][j]] = j;
	int c = 0;
	for (int i = 1; i <= mx*my; i++)
	{
		int r = 0;
		for (int j = 0; j < 4; j++)
		{
			int a = x[i] + dx[j], b = y[i] + dy[j];
			if (map[a][b] < i)
			{
				if (r == 0)r = dat[a][b];
				else if (r != dat[a][b])r = -1;
			}
		}
		if (r == 0)dat[x[i]][y[i]] = i;
		else dat[x[i]][y[i]] = r;
		if (r == -1)c++;
	}
	printf("%d\n", c);
}

Measured memory_bytes: 18800
#include <iostream>

using namespace std;

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

    int ret = 0;
    for (int i = 0; i <= a; i++) {
        int sum_i = i * 500;
        if (sum_i > x)   break;

        for (int j = 0; j <= b; j++) {
            int sum_ij = i * 500 + j * 100;
            if (sum_ij > x)   break;

            for (int k = 0; k <= c; k++) {
                int sum_ijk = i * 500 + j * 100 + k * 50;
                if (sum_ijk == x)   ret++;
                else if (sum_ijk > x)   break;
            }
        }
    }

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

Measured memory_bytes: 256
n,m = map(int,input().split())
s = [0] * m
k = [0] * m
for i in range(m):
    s[i] = list(map(int,input().split()))
    k[i] = s[0]
    s[i] = s[i][1:]
p = list(map(int,input().split()))

ans = 0
b = '0' + str(n) + 'b'
for i in range(1 << n):
    sw = format(i,b)
    if all(sum(sw[g-1] == '1' for g in s[j])%2 == p[j] for j in range(m)):
        ans += 1
print(ans)


Measured memory_bytes: 9160
#include <cstdio>

using namespace std;

int binarySearch(int A[], int n, int key)
{
    int left = 0;
    int right = n;
    while (left < right) {
        int mid = (left + right) / 2;
        if (A[mid] == key) return 1;
        if (A[mid] < key) {
            left = mid + 1;
        }
        else {
            right = mid;
        }
    }

    return 0;
}

int main()
{
    int n, q, A[1000000], key, sum = 0;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &key);
        if (binarySearch(A, n, key)) {
            sum++;
        }
    }

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

    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int N;
vector<vector<pair<int, lint>>> roads;
vector<lint> ans;

void dfs(int now, int back, lint sum){
    ans[now] = sum % 2;
    for(auto i: roads[now]){
        int to = i.first;
        lint cost = i.second;
        if(to != back){
            dfs(to, now, sum + cost);
        }
    }
}

int main(){
    cin >> N;
    roads.resize(N);
    for(int i = 0; i < N - 1; i++){
        int u, v;
        lint w;
        cin >> u >> v >> w;
        u--, v--;
        roads[u].push_back({v, w});
        roads[v].push_back({u, w});
    }
    ans.resize(N);
    dfs(0, -1, 0);
    for(lint i: ans){
        cout << i << endl;
    }
}

Measured memory_bytes: 9984
n = int(input())
a = list(map(int, input().split()))
MX = 100005
cnt = [0]*MX
for i in a:
    cnt[i] += 1
tot = 0
for i in range(1, MX):
    tot += cnt[i] * i
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    tot += (c - b) * cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(tot)


Measured memory_bytes: 21024
#include<stdio.h>
#include<string.h>
int main(){
    int n,m,a[1000],c[1000],ans=0;
    memset(c,0,sizeof(c));
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
    }
    for(int i=0;i<m;i++){
        int b;
        scanf("%d",&b);
        for(int j=0;j<n;j++){
            if(a[j]<=b){
                c[j]++;
                break;
            }
        }
    }
    for(int i=1;i<n;i++){
        if(c[i]>c[ans]) ans=i;
    }
    printf("%d\n",ans+1);
    return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
template<class T>void sort(vec<T> &v){sort(v.begin(),v.end());}
template<class T>void rsort(vec<T> &v){sort(v.rbegin(),v.rend());}
const ll mod = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,k; cin >> a >> b >> c >> k;
    if(k<a)cout << k << endl;
    else if(a<=k && k < a+b)cout << a << endl;
    else cout << 2*a+b-k << endl;
}

Measured memory_bytes: 3652
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        int i=1;
        for(int n=0;n<N;n++){
        if(i*2>=i+K){
            i=i+K;
        }else{
            i=i*2;
        }
        if(n==N-1){
            System.out.println(i);
        }
        }
        
     
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());

        // 主処理
        long result = (n / (a + b) * a) + Math.min(a, n % (a + b));

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 24020
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

VE to[100010];
int n;
VE dist;
// d->デフォルト引数(今の距離)
// p->親
void dfs(int v, int d = 0, int p = -1) {
	dist[v] = d;
	for (int u : to[v]) {
		if (u == p)continue;
		dfs(u, d + 1, v);
	}
}
VE calcdist(int s) {
	dist = VE(n);
	dfs(s);
	return dist;
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	// 頂点数
	cin >> n;
	int s, t; cin >> s >> t;
	s--; t--;
	rep(i, n - 1) {
		int a, b; cin >> a >> b; a--; b--;
		to[a].push_back(b); to[b].push_back(a);
	}
	// sから(高橋君から)の距離
	VE dists = calcdist(s);
	// tから(青木君から)の距離
	VE distt = calcdist(t);
	int M = 0;
	rep(i, n) {
		if (dists[i] < distt[i]) {
			chmax(M, distt[i]);
		}
	}
	cout << M - 1 << endl;
	return 0;
}


Measured memory_bytes: 12144
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = 0;

		n = Integer.parseInt(sc.nextLine());

		String arys[] = sc.nextLine().split(" ");
		int[] ary = Stream.of(arys).mapToInt(Integer::parseInt).toArray();

		int count = 0;

		for (int i = 0; i < n; i++) {
			while (ary[i] % 2 == 0) {
				ary[i] /= 2;
				count++;
			}
		}
		System.out.println(count);

		sc.close();

	}
}


Measured memory_bytes: 30144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/arc065_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  vector<string> ss = {"dream", "dreamer", "erase", "eraser"};
  rep(i, ss.size()) { reverse(ss[i].begin(), ss[i].end()); }

  int i = 0;
  while (i < S.size()) {
    bool ok = false;
    for (auto s : ss) {
      if (i + s.size() > S.size()) continue;
      string test = S.substr(i, s.size());
      if (s == test) {
        i += s.size();
        ok = true;
        break;
      }
    }
    if (!ok) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll > 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
#define s(v) v.size()
#define e(v) v.empty()

using namespace std;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
// bool sortbysec(const pll &a, const pll &b){return (a.second < b.second);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n, k;
        cin>>n>>k;
        vl vec(MAX);
        rep(i,n)    cin>>vec[i];
        vl dp(MAX);
        rep(i, k+1){
            dp[i] = abs(vec[0]-vec[i]);
            // cout<<dp[i]<<endl;
        }
        foi(i, k+1, n){
            ll mn = MOD;
            rep1(j, k+1){
                mn = min(mn, dp[i-j]+abs(vec[i]-vec[i-j]));
            }
            dp[i]=mn;
        }
        // rep(i, n)   cout<<dp[i]<<endl;
        cout<<dp[n-1];
    }
}

Measured memory_bytes: 15872
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<double> p(N);
	for (int i = 0; i < N; i++) cin >> p[i];

	vector<double> dp(N + 1);
	dp[0] = 1;
	for (int i = 0; i < N; i++) {
		for (int front = N; front >= 0; front--) {
			dp[front] = dp[front] * (1 - p[i]);
			if (front != 0) dp[front] += dp[front - 1] * p[i];
		}
		DMP(dp);
	}

	cout << fixed << setprecision(10);
	cout << accumulate(dp.begin() + (N + 1) / 2, dp.end(), 0.0) << "\n";

	return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int M, K; cin >> M >> K;


	int Max = (1ll << M);
	dump(Max);

	if (M == 0 or M == 1) {
		if (M == 0) {
			if (K == 0) {
				cout << "0 0" << endl;
			}
			else {
				cout << -1 << endl;
			}
		}
		else {
			if (K == 0) {
				cout << "0 0 1 1" << endl;
			}
			else {
				cout << -1 << endl;
			}
		}
		return 0;
	}

	if (K < Max) {
		deque<int>x;
		x.push_back(K);
		rep(i, 0, Max) {
			if (i == K)continue;
			x.push_front(i);
			x.push_back(i);
		}
		x.push_back(K);
		
		rep(i, 0, x.size()) {
			cout << x[i] << (i == x.size() - 1 ? '\n' : ' ');
		}
	}
	else {
		cout << -1 << endl;
	}

	/*int L = (1ll << (M + 1));
	int l = (1ll << M);
	vector<int>A(L + 1);

	rep(i, 0, l) {
		A[i + 1] = i;
	}
	rep(i, 0, l) {
		A[i + l + 1] = i;
	}

	dump(A);
	vector<int>X(A);
	rep(i, 1, X.size()) {
		X[i] ^= X[i - 1];
	}
	dump(X);*/



	return 0;
}


Measured memory_bytes: 3968
import itertools
N,K = map(int,input().split())
D = list(map(int,input().split()))
A = []
for i in range(10):
    if i not in D:
        A.append(i)
cmin = 100000
k = len(str(N))
for i in range(k,6):
    for x in itertools.product(A,repeat=i):
        cnt = 0
        for j in range(i):
            cnt += x[j]*10**(i-1-j)
        if cnt>=N:
            cmin = min(cmin,cnt)
print(cmin)

Measured memory_bytes: 41836
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>

using namespace std;



int main() {
    int M, N;
    cin >> N >> M ;
    vector<int> p(M);
    vector<string> S(M);

    for(int i=0; i<M; i++){
        cin >> p[i] >> S[i];
    }

    vector<bool> solved(N, false);
    vector<int> wa(N,0);

    int ac=0, penalty=0;

    for(int i=0; i<M; i++){
        int question = p[i]-1;
        string result = S[i];

        if(!solved[question] and result=="AC"){
            ac++;
            penalty+=wa[question];
            solved[question]=true;
        }else if(!solved[question] and result=="WA"){
            wa[question]++;
        }
    }

    cout << ac << " " <<penalty << endl;

    return 0;
}

Measured memory_bytes: 6528
import java.util.LinkedList;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String input;
		LinkedList<String> output = new LinkedList<String>();
		double[] p = new double[6];//0a 1b 2c 3d 4e 5f
		double a, b, c, d, e, f;
		while (in.hasNext()) {
			for (int i = 0; i < p.length; i++) {
				p[i] = in.nextDouble();
			}
			a = p[0];
			b = p[1];
			c = p[2];
			d = p[3];
			e = p[4];
			f = p[5];
			double y = (c * d - a * f) / (b * d - a * e);
			double x = (c * e - b * f) / (a * e - b * d);
			if (x == -0.0) {
				x = 0.0;
			}
			if (y == 0.0) {
				y = 0.0;
			}
			output.add(String.format("%.3f %.3f", x, y));
		}
		for (int i = 0; i < output.size(); i++) {
			System.out.println(output.get(i));
		}
	}
}

Measured memory_bytes: 28460
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  string s;
  cin >> s;
  for (i64 i = 0; i < s.size() - 1; i++)
    if (s[i] == s[i + 1])
    {
      cout << "Bad" << endl;
      return 0;
    }
  cout << "Good" << endl;
  return 0;
}


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

int main()
 {
    int n;
    while(cin>>n,n)
    {
        int d[99]={0},c=0;
        while(n>0)
         {
            d[c++]=n%8;
            n/=8;
        }
        while(c--)
        cout<<"01235789"[d[c]];
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

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

    int n;
    while (cin >> n)
    {
        vector<int> ans;
        for (int i = 1; i <= n; i <<= 1)
        {
            if (i & n)
            {
                ans.push_back(i);
            }
        }
        for (int i = 0; i < ans.size(); ++i)
        {
            if (i)
                cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define IO() freopen("palindrome.in","rw",stdin)
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e7+9, M = (1<<31), OO = 0x3f3f3f3f;
int memo[N][4],arr[N][3];
int n;
int solve(int idx=0,int pre=3)
{
  if(idx==n) return 0;
  int &ret=memo[idx][pre];
  if(~ret) return ret;
  ret=0;
  int a=0,b=0,c=0;
  if(pre!=0) a=solve(idx+1,0)+arr[idx][0];
  if(pre!=1) b=solve(idx+1,1)+arr[idx][1];
  if(pre!=2) c=solve(idx+1,2)+arr[idx][2];
  return ret+=max(a,max(b,c));
}
int main()
{
  memset(memo,-1,sizeof memo);
  scanf("%d",&n);
  for(int i=0;i<n;++i) scanf("%d%d%d",&arr[i][0],&arr[i][1],&arr[i][2]);
  printf("%d\n",solve());
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

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

namespace ABC123
{
    class Program
    {
        static void Main(string[] args)
        {
            FiveAntennas(); // 25min 掛けたが解けず
            // FiveDishes(); // 35min

            //FiveTransportation();
        }

        public static void FiveTransportation()
        {
            long n = ReadLong();
            long[] time = new long[5];
            for (int i = 0; i < 5; i++)
            {
                time[i] = ReadLong();
            }

            long min = time.Min();

            long ans = (long)Math.Ceiling(n * 1.0m / min) + 4;

            Console.WriteLine(ans);
        }

        public static void FiveDishes()
        {
            int[] dishes = new int[5];
            for(int i = 0; i < 5; i++)
            {
                dishes[i] = ReadInt();
            }

            dishes = dishes.OrderByDescending(i => i % 10 == 0 ? 10 : i % 10).ToArray();

            int ans = 0;
            for(int i = 0; i < 4; i++)
            {
                ans += (int)Math.Ceiling(dishes[i] / 10m) * 10;
            }

            ans += dishes[4];

            Console.WriteLine(ans);
        }

        public static void FiveAntennas()
        {
            int[] antennas = new int[5];
            for(int i = 0; i < 5; i++)
            {
                antennas[i] = ReadInt();
            }

            int k = ReadInt();

            string ans = "Yay!";
            if (antennas[0] + k < antennas[4])
            {
                ans = ":(";
            }

            Console.WriteLine(ans);
        }

        public static int[] ReadBinaryString()
        {
            return Console.ReadLine().Select(c => int.Parse(c.ToString())).ToArray();
        }

        public static bool[] ReadBoolArray()
        {
            return Console.ReadLine().Select(c => c == '1').ToArray();
        }

        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
    }
}


Measured memory_bytes: 13140
function main(input) {
  const s = input.trim();
  let chunk = "";
  const result = [];
  for (let i = 0; i < s.length; i++) {
    const char = s[i];
    if (i === s.length - 1 || (chunk[chunk.length-1] === "L" && char === "R")) {
      if (i === s.length - 1) chunk += char;
      const arr = Array(chunk.length).fill(0);
      const rCnt = chunk.replace(/L/g, "").length;
      const lCnt = chunk.length - rCnt;
      if (chunk.length%2 === 0) {
        arr[rCnt-1] = chunk.length/2;
        arr[rCnt] = chunk.length/2;
        result.push(...arr); 
      } else {
        arr[rCnt-1] = rCnt%2 === 0 ? Math.floor(chunk.length/2) : Math.ceil(chunk.length/2);
        arr[rCnt] = chunk.length - arr[rCnt-1];
        result.push(...arr);
      }
      chunk = "";
    }
    chunk += char;
  }
  console.log(result.join(" ");
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 41036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(5e5 + 5);
#define REP(i, n) for (int i = 0; i < n; i++)

ll n, cum[MAX_N]{}, dif[MAX_N]{};
map<ll, ll> arts;

int main() {
    cin >> n;
    REP(i,n){
        ll a, b;
        cin >> a >> b;
        arts[a] += b;
    }
    n = arts.size();
    ll cnt = 1, pre=(*arts.begin()).first;
    for(auto itr : arts){
        dif[cnt] = itr.first - pre;
        cum[cnt] = itr.second - dif[cnt];
        cum[cnt] += cum[cnt-1];
        pre = itr.first;
        cnt++;
    }
    ll ma=-LLINF, ans = 0;
    for(int i = n; i>0; i--){
        ma = max(ma, cum[i]);
        ans = max(ans, ma-cum[i-1]+dif[i]);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 42168
#include <iostream>
//#include <algorithm>
//#include <vector>
//#include <unordered_map>
//#include <map>
//#include <queue>
//#include <cstring>

//#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


#define MOD		1000000007
#define ll		long long int
#define pll		pair<ll, ll>
#define pb		push_back
#define endl	"\n"
#define f 		first
#define s 		second
#define fastio 	ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(v)  (v).begin(), (v).end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

ll power(ll x, ll y) { ll ans = 1; x %= MOD; while (y) {if (y & 1)ans = (x * ans) % MOD; x = (x * x) % MOD; y >>= 1;} return ans;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};



void solve() {
    int n;
    cin >> n;
    bool flag = false;
    int cnt = 0;
    while(n--) {
        int x;
        int y;
        cin >> x >> y;
        if(x == y) {
            cnt++;
        } else {
            cnt = 0;
        }
        if(cnt == 3) {
            flag = true;
        }
    }

    if(flag) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

int main() {
    fastio;
    solve();
}


Measured memory_bytes: 3640
import java.util.Scanner;
import java.io.PrintWriter;
 
public class Main {
    static Scanner scan = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args){
        while(true){
            int n = si();
            if(n==0) break;
            int[] list = new int[n];
            long[] map = new long[n];
            int res = -1;
            for (int i = 0; i < n; i++) {
                int m = si();
                map[i]=1L<<i;
                for (int j = 0 ;j < m ; j++)
                    list[i] |= 1<<(si()-1);
            }
            for (int i = 0; i < 30; i++) {
                long tmp = 0;
                for (int j = 0; j < n; j++)
                    if((list[j]>>i)%2==1) tmp |= map[j];
                for (int j = 0; j < n; j++)
                    if((list[j]>>i)%2==1) map[j]=tmp;
                if(tmp==(1L<<n)-1){
                    res = i+1;
                    break;
                }
            }
            out.println(res);
        }
        out.flush();
    }
    static int si(){
        return Integer.parseInt(scan.next());
    }
}

Measured memory_bytes: 70984
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;


int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio
    ll t, i, j, n, x, sum=0;
    cin>>n;
    ll a[n+9], mx=0, ans=0;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    mx=a[0];
    for(i=1; i<n; i++)
    {
        mx=max(a[i], mx);
        ans+=mx-a[i];
    }
    cout<<ans;
}





Measured memory_bytes: 5216
#!/usr/bin/env python

wab = [int(i) for i in input().split()]

w = wab[0]
a = wab[1]
b = wab[2]

if (a <= b+w) and (b <= a+w):
    print(0)
else:
    if a < b:
        print(abs(a-b+w))
    elif b < a:
        print(abs(a-b-w))
    else:
        print(w)

Measured memory_bytes: 3064
a = int(input())
b = [0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100]
c = [0,7,14,21,28,35,42,49,56,63,70,77,84,91,98]
d = 0

for i in range(len(b)):
	for j in range(len(c)):
		if b[i] + c[j] == a:
			print("Yes")
			d = 1
			break
	if d == 1:
		break
if d == 0:
	print("No")

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#define PI 3.1415926535

int main(void)
{
	double a, b, c, C, S, L, h;
	scanf("%lf %lf %lf",&a,&b,&C);
	C = C*PI / 180;
	S = a*b*sin(C) / 2;
	c = sqrt( a*a + b*b - 2*a*b*cos(C) );
	L = a + b + c;
	h = 2*S / a;
	printf("%f\n%f\n%f\n",S,L,h);
	return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp1, tmp2;
    string S[3];
    bool flag=true;
    
    cin >> S[0] >> S[1] >>S[2];
    S[0][0] -= 32;
    S[1][0] -= 32;
    S[2][0] -= 32; 
    cout << S[0][0] << S[1][0] << S[2][0] <<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
n, m = map(int, input().split())

V = [set() for _ in range(n)] # 隣接リスト
for a, b in [[*map(lambda x: int(x)-1, input().split())] for _ in range(m)]:
    V[a].add(b)
    V[b].add(a)

from collections import deque
G = [-1] * n # グループ色分け
for s in range(n): # BFS
    dq = deque([s])
    while dq:
        p = dq.popleft()
        if G[p] >= 0: continue
        G[p] = s # 色付け
        for c in V[p]:
            dq.append(c)

C = dict() # グループメンバ数集計
for g in G:
    if not g in C: C[g] = 0
    C[g] += 1

print(max(C.values())) # 最大メンバ数


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

namespace ABC063_C_Bugged
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			List<int> removeTenSList = new List<int>(n);
			int tenSum = 0;
			int removeTenSum = 0;
			for (int i = 0; i < n; i++)
			{
				int value = int.Parse(Console.ReadLine());
				if (value % 10 == 0) tenSum += value;
				else
				{
					removeTenSum += value;
					removeTenSList.Add(value);
				}
			}
			removeTenSList.Sort();
			
			//こうすることで、確実に10の倍数でない最大値になる
			if (removeTenSum % 10 == 0)
			{
				/*10の倍数を除いた合計が0の場合、リストには何も入っていないため配列外エラー
				 よって10の倍数の合計も0にして、成績の最大値を0にする*/
				if (removeTenSum != 0) removeTenSum -= removeTenSList[0];
				else tenSum = 0;
			}
			
			Console.WriteLine(removeTenSum + tenSum);
		}
	}
}


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

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int[] X = new int[3];
		
		X[0] = keyboard.nextInt();
		X[1] = keyboard.nextInt();
		X[2] = keyboard.nextInt();
		
		Arrays.sort(X);
		
		System.out.println(X[0]+ X[1]);
		keyboard.close();	
	}
}


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

using namespace std;
#define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

int main(){
  long long n;
  const long long max_n = 2*1e5;
  // long long a[max_n + 1];
  vector<long long> a(max_n + 1, 0);
  vector<long long> count(max_n + 1, 0);

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

  // map<long long, long long> count;
  // for(long long i = 0; i < n; i++){
  //   count[a[i]] = 0;
  // }
  // for(long long i = 0; i < n; i++){
  //   count[a[i]] ++;
  // }

  long long sum = 0;
  for(long long i = 0; i < n + 1; i++){
    sum += count[i] * (count[i] - 1) / 2;
  }

  for(long long k = 0; k < n; k++){
    // cout << sum - count[a[k]] * (count[a[k]] - 1) / 2 + (count[a[k]] - 1) * (count[a[k]] - 2) / 2 << endl;
    cout << sum - (count[a[k]] - 1) << endl;
  }


  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var r = int.Parse(inputs[0]);
        var D = int.Parse(inputs[1]);
        var x2000 = int.Parse(inputs[2]);
        var bef = x2000;
        for (int i = 1; i <= 10; i++)
        {
            // x_i+1 = r * x_i - D
            var x = r * bef - D;
            Console.WriteLine(x);
            bef = x;
        }
    }

}



Measured memory_bytes: 11092
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n][3] = {0};
    for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    int dp[n][3] ={0};
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

Measured memory_bytes: 6008
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		int k = Integer.parseInt(sa[2]);
		int[][] v = new int[h + 1][w + 1];
		for (int i = 0; i < k; i++) {
			sa = br.readLine().split(" ");
			int r = Integer.parseInt(sa[0]);
			int c = Integer.parseInt(sa[1]);
			v[r][c] = Integer.parseInt(sa[2]);
		}
		br.close();

		long[][][] dp = new long[h + 1][w + 1][4];
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				long ue = max(dp[i - 1][j]);
				dp[i][j][0] = Math.max(ue, dp[i][j - 1][0]);
				dp[i][j][1] = dp[i][j - 1][1];
				dp[i][j][2] = dp[i][j - 1][2];
				dp[i][j][3] = dp[i][j - 1][3];
				if (v[i][j] > 0) {
					dp[i][j][1] = Math.max(dp[i][j][1], ue + v[i][j]);
					dp[i][j][1] = Math.max(dp[i][j][1], dp[i][j - 1][0] + v[i][j]);
					dp[i][j][2] = Math.max(dp[i][j][2], dp[i][j - 1][1] + v[i][j]);
					dp[i][j][3] = Math.max(dp[i][j][3], dp[i][j - 1][2] + v[i][j]);
				}
			}
		}
		System.out.println(max(dp[h][w]));
	}

	static long max(long[] a) {
		long ret = 0;
		for (int i = 0; i < a.length; i++) {
			ret = Math.max(ret, a[i]);
		}
		return ret;
	}
}


Measured memory_bytes: 702224
# -*- coding: utf-8 -*-


def main():
    n, d = map(int, input().split())
    x = d * 2 + 1
    ans = int(n / x)
    if n % x == 0:
        print(ans)
    else:
        print(ans + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
struct sort1 : public binary_function<pair<string, long long>, pair<string, long long>, bool>
{
	bool operator()(pair<string, long long> p1, pair<string, long long> p2)
	{
		int l1 = p1.first.size();
		int l2 = p2.first.size();

		return (l1 < l2 ? true : l1 == l2 ? p1.first < p2.first : false);
	}
}; //by.SQUARE1001
int main(){
  typedef pair<string, int> P;
  int n,count=0,cnt=0;
  cin >> n;
  vector<P> p(n);
  for(int i=0; i<n; i++){
    cin >> p[i].first >> p[i].second;
    //cout << p[i].first << " " << p[i].second << endl;
    /*if(i>0){
      count++;
      for(int j=0; j<count; j++){
        if(p[i].first == p[j].first){
          p[j].second += p[i].second;
          p[i].first = "ZZZZZ";
          p[i].second = 10000;
          cnt++;
        }
      }
    }*/
  }
  //for(int i=0; i<n; i++) cout << p[i].first << " " << p[i].second << endl;
  sort(p.begin(), p.end(), sort1());
  int sum = p[0].second;
  for(int i=1; i<n; i++){
    if(p[i-1].first != p[i].first){
      cout << p[i-1].first << " " << sum << endl;
      sum = 0;
    }
    sum += p[i].second;
  }
  cout << p[n-1].first << " " << sum << endl;
  return 0;
}


/*
int match(string x, int y, int z){
  for(int i=0; i<y; i++){
    if(x == p[i].first){
      z += p[i].second;
      p[i].first = "ZZZZZZZZZZ";
      p[i].second = 100000000;
    }
  }
  return x,z;
}*/



Measured memory_bytes: 3588