akhauriyash/Code-Regression huggingface dataset:
/*I wanna be the very best, like no one ever was...*/

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif


int main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
  
    int n;
    cin>>n;
    int arr[n];
    rep(i,0,n)cin>>arr[i];
    ll res = POSITIVE_INFINITY;
    for(int i =1;i<=100;i++){
        ll ans = 0;
        for(int j = 0;j<n;j++){
            ans+=(arr[j]-i)*(arr[j]-i);
        }
        // see(i,ans);
        res = min(res, ans);

    }
    cout<<res;
 
 
    
 
    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
if S.find(T) != -1:
    min = 0
else:
    min = float('inf')
    r = len(S) - len(T)
    for i in range(r+1):
        t = 0
        for j, v in enumerate(T):
            t += int(S[i+j] != v)
        if min > t:
            min = t

print(min)


Measured memory_bytes: 73448
#include<iostream>
using namespace std;
int main(){
	
	int b1, b2, b3;
	cin >> b1 >> b2 >> b3;

	if((b1 == 1 && b2 == 1)||b3 == 1){
		cout << "Open" << endl;
	}else{
		cout << "Close" << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
/*
    Author : DemonStar
*/

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx2,tune=native")

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pi pair<int, int>
#define pl pair<long long, long long>
#define pld pair<long double, long double>
#define endl '\n'
#define loop(i, n) for (ll i = 0; i < n; i++)
#define rep(i, begin, end) for (__typeof(begin) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(x) x.begin(), x.end()
#define vl vector<ll>
#define vi vector<int>
#define ml map<ll, ll>
#define vpl vector<pair<ll, ll>>
const ll mod = 1e9 + 7;

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t)
{
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t)
{
    for (auto &i : t)
        os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (T &t : v)
        is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v)
{
    for (pair<T1, T2> &t : v)
        is >> t.first >> t.second;
    return is;
}

int main()
{
    fast;
    int n, k;
    cin >> n >> k;
    vi v(n);
    cin >> v;
    vi dp(n + 1, 1e9);
    dp[0] = 0;
    rep(i, 1, n)
    {
        rep(j, 1, k + 1) if (i >= j) dp[i] = min(dp[i], dp[i - j] + abs(v[i] - v[i - j]));
    }
    cout << dp[n - 1] << endl;

#ifdef LOCAL
    cerr
        << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[3],b[3],c[3];
	for(int i=0;i<3;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	int tmp=0;
	for(int i=0;i<2;i++){
		if(a[i]-b[i]==a[i+1]-b[i+1]){
			tmp++;
		}
		if(b[i]-c[i]==b[i+1]-c[i+1]){
			tmp++;
		}
		if(a[i+1]-a[i]==b[i+1]-b[i]){
			tmp++;
		}
		if(b[i+1]-b[i]==c[i+1]-c[i]){
			tmp++;
		}
	}
	if(a[0]+c[2]==a[2]+c[0]){
		tmp++;
	}
	if(tmp==9){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(int i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  int N;cin >> N;
  int v[N][3];
  REP(i,N) cin >> v[i][0] >> v[i][1] >> v[i][2];
  //dp[i+1][j]:i日目にjという行動をした時の幸福度最大
  ll dp[N+1][3];
  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[0][2] = 0;
  REP(i,N){
    dp[i+1][0] = max(dp[i][1]+v[i][0],dp[i][2]+v[i][0]);
    dp[i+1][1] = max(dp[i][0]+v[i][1],dp[i][2]+v[i][1]);
    dp[i+1][2] = max(dp[i][0]+v[i][2],dp[i][1]+v[i][2]);
  }
  cout << max(max(dp[N][0],dp[N][1]),dp[N][2]) << endl;
  return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>

int main(void)
{
  char s[100];
  int i,j;

  scanf("%s",s);

  for(i=0;s[i]!=0;i++){
    if(s[i]=='B' &&i!=0){
      for(j=i-1;s[j+2]!=0;j++)
        s[j]=s[j+2];
        s[j]=0;
        i-=2;
    }
    else if(s[i]=='B' &&i==0){
      for(j=0;s[j]!=0;j++)
        s[j]=s[j+1];
        s[j]=0;
        i--;
    }
  }

  printf("%s\n",s);

  return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;

#define INT_MAX 2147483647

int main( void ){

	int n;
	vector<int> vi;

	cin >> n;

	for( int i = 0; i < n; i++ ){
		int tmp;
		cin >> tmp;
		vi.push_back(tmp);
	}
	int ans = 0;
	bool flg = true;
	while(flg){
		for( int i = 0; i < vi.size(); i++ ){
			vi[i] /= 2;
			if(vi[i]%2 != 0) flg = false;	
		}
		if(flg) ans++;
	}
	if(ans) ans++;
	cout << ans << endl;


	return 0;

}



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

int main(void)
{
    long N;
    cin >> N;
    vector<long> H(N);
    
    for(long i = 0; i < N; i++) cin >> H[i];

    string flag = "Yes";
    long ind = -1;
    long max = -1;
    decltype(H)::iterator top = H.begin();
    for(long i = N-1; i > 0; i--){
        if (ind == -1 || i == ind){
            ind = max_element(top, top+i-1) - top;
            max = H[ind];
        }
        if (max - H[i] > 1){
            flag = "No";
            break;
        }
    }

    cout << flag << endl;
    
    return 0;
}

Measured memory_bytes: 1024
function main(arg) {
	var s = arg.trim();
  	var weather = ['Sunny', 'Cloudy', 'Rainy'];
  	s = weather.indexOf(s);
  	if (s === 0 || s === 1) {
    	s++
    } else {
    	s = 0
    }
  	var out = weather[s];
	console.log(out)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
n = int(input())
btn = [0]
for i in range(n):
  btn.append(int(input()))
see = [0 for i in range(n+1)]
  
now = 1
cnt = 0

see[now] = 1
while True:
  now = btn[now]
  cnt += 1
  
  if now == 2:
    print(cnt)
    break
  
  if see[now] == 1:
    print(-1)
    break
  
  see[now] = 1
  

Measured memory_bytes: 13668
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)

const double EPS = 1e-10;

int main() {
	int n;
	ll m, a, b;
	
	while(cin >> n, n) {
		 vector<vector<ll> > table(n*2+1, vector<ll>(2));

		 REP(i, n) {
			 cin >> m >> a >> b;
			 table[2*i][0] = a;
			 table[2*i][1] = m;
			 table[2*i+1][0] = b;
			 table[2*i+1][1] = -m;
		 }
		 table[2*n][0] = -1;

		 sort(ALL(table));

		 ll sum = 0;
		 bool flag = true;

		 REP(i, 2*n) {
			 sum += table[i][1];
			 if(sum > 150 && table[i][0] != table[i+1][0]) {
				 cout << "NG" << endl;
				 flag = false;
				 break;
			 }
		 }

		 if(flag) {
			 cout << "OK" << endl;
		 }
	}
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N + 10, 0), D(N + 10, 0);
  for (auto&& e : A) {
    cin >> e;
    C[e]++;
  }
  for (auto&& e : B) {
    cin >> e;
    D[e]++;
  }
  for (int i = 0; i < N + 10; i++) {
    if (C[i] + D[i] > N) {
      cout << "No" << '\n';
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    C[i + 1] += C[i], D[i + 1] += D[i];
  }
  int d = 0;
  for (int i = 0; i < N; i++) {
    d = max(d, D[i + 1] - C[i]);
  }
  cout << "Yes" << '\n';
  for (int i = 0; i < N; i++) {
    cout << B[(i + d) % N] << (i == N - 1 ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 6368
#include<stdio.h>
#define M(a,b) a>b?a:b
int n,t[25],i,o,f;
int main()
{
	for(;scanf("%d",&n),n;)
	{
		for(i=0;i<n;i++)
			scanf("%d",&t[i]);
		for(o=32,i=f=0;o;i%=n)
		{
			if(++f%2)
				printf("%d\n",o=o-(o-1)%5);
			else
			{
				printf("%d\n",o=M(0,o-t[i]));
				i++;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
long long i,j,n,m,c,d,a[200000],b,e,k;
int main(){
  for(cin>>n>>k;i<n;i++)cin>>a[i],c+=a[i];
  sort(a,a+n,greater<int>());
  for(i=0;i<k;i++)c-=a[i];
  cout<<c;
}

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

int main() {
  pair<pair<string,int>,int>p[1000];
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string s;
    int t;
    cin>>s>>t;
    p[i]=make_pair(make_pair(s,-t),i+1);
  }
  sort(p,p+n);
  for(int i=0;i<n;i++){
    cout<<p[i].second<< endl;
  }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toDouble() }
    val theta = (360.0 * h / 12.0 + 30.0 * m / 60.0) - 360.0 * m / 60.0
    val c = sqrt(pow(a) + pow(b) - 2 * a * b * cos(theta))
    println(c)
}

fun sqrt(v: Double) = Math.sqrt(v)
fun pow(v: Double) = Math.pow(v, 2.0)
fun cos(v: Double) = Math.cos(v / 180.0 * Math.PI)

Measured memory_bytes: 36608
from sys import stdin
def isPrime(x):
    if x == 2: return 1
    elif x % 2 == 0: return 0
    return pow(2, x - 1, x) == 1
n = int(stdin.readline())
cnt = 0
for i in range(0, n):
    cnt += isPrime(int(stdin.readline()))
print(cnt)

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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int r; cin >> r;

  cout << 3 * r * r << endl;
  
  return (0);
}

Measured memory_bytes: 3700
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int cnt = 0;

        if (Math.abs(A - B) >= 2) {
            System.out.println(Math.max(A,B) * 2 - 1);
        } else if (Math.abs(A - B) == 1) {
            System.out.println(A+B);
        }else if(Math.abs(A-B)==0){
            System.out.println(A+B);
        }

    }


}


Measured memory_bytes: 21712
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

class Main{
	static Scanner s;

	public static void main(String args[]){
		// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		s = new Scanner(System.in);
		try{
			while(true){
				int n = s.nextInt();
				int k = s.nextInt();
				if(n + k == 0) return;

				System.out.println(solve(n, k));
			}
		}catch(Exception e){
			System.err.println(e);
		}
	}

	static String solve(int n, int k){
		int supply_array[] = new int[k];
		int demand_matrix[][] = new int[n][k];

		for(int i = 0; i < k; i++){
			supply_array[i] = s.nextInt();
		}
		//print(supply_array);

		for(int i = 0; i < n; i++){
			for(int j = 0; j < k; j++){
				demand_matrix[i][j] = s.nextInt();
			}
		}
		//print(demand_matrix);

		for(int i = 0; i < k; i++){
			int demand_sum = 0;
			for(int j = 0; j < n; j++){
				demand_sum += demand_matrix[j][i];
			}
			//System.out.println("demand: " + demand_sum + "\t supply: " + supply_array[i]);
			if(demand_sum > supply_array[i]) return "No";
		}
		return "Yes";
	}

	static void print(int a[]){
		for(int i = 0; i < a.length; i++){
			System.out.print(a[i] + "\t");
		}
		System.out.println();
	}

	static void print(int m[][]){
		for(int i = 0; i < m.length; i++){
			for(int j = 0; j < m[i].length; j++){
				System.out.print(m[i][j] + "\t");
			}
			System.out.println();
		}
	}
}

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

int main() {

	
	int m, d;
	cin >> m >> d;

	if ( d < 22 ) {
		cout << "0" << endl;
		return 0;
	}

	int ans = 0;

	int d1 = d % 10;
	int d10 = d / 10;


	for (int k = 1;k <= m;k++) {
		for (int i = 2;i < d10;i++) {
			for (int j = 2;j < 10;j++) {
				if ( k == i * j) {
					ans++;
				}
			}
		}

		if (d1 >= 2) {
			for (int i = 2; i <= d1;i++) {
				if ( k == d10 * i) {
					ans++;
				}
			}
		}
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <string.h>
#include <map>
#include <iomanip>
#include <time.h>
using namespace std;
typedef long long ll;

// 対象：モノイド（結合律・単位元の存在）

int n, dat[262200];

ll gcd(ll a, ll b) {
    if (a < b) {
        ll tmp = a;
        a = b;  b = tmp;
    }
    if (!b) return a;
    ll r = a % b;
    while (r != 0) {
        a = b;  b = r;
        r = a % b;
    }
    return b;
}

void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    for (int i = 0; i < 2 * n - 1; i++) dat[i] = 0;
}

// k番目の値をaに変更
void update(int k, int a) {
    k += n - 1;
    dat[k] = a;
    while (k > 0) {
        k = (k - 1) / 2;
        dat[k] = gcd(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}

// [a, b)の最小値を求める．
int query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return 0;
    
    if (a <= l && r <= b) return dat[k];
    else {
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return gcd(vl, vr);
    }
}

int main() {
    int m, a[100010];
    cin >> m;

    init(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        update(i, a[i]);
    }

    int mx = 0;
    for (int i = 0; i < m; i++) {
        update(i, a[i + int(pow(-1, i % 2))]);
        mx = max(mx, query(0, n, 0, 0, n));
        update(i, a[i]);

    }
    cout << mx << endl;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>

int main()
{
    int a,b,c;
    char op;

    while(1)
    {
        std::cin >> a >> op >> b;

        if(op =='?'){
            break;
        }
        
        if(op =='+'){
            c=a+b;
        }
        else if(op == '-')
        {
            c=a-b;
        }
        else if(op == '*')
        {
            c=a*b;
        }
        else if(op == '/')
        {
            c=a/b;
        }
        
        std::cout << c << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

int main() {
    string s;
    cin >> s;
    int left=0,right=s.size()-1;
    ll ans=0;
    bool jg=true;
    while(left<right){
        if(s[left]==s[right]){
            left++;
            right--;
        }
        else if(s[right]=='x'){
            ans++;
            right--;
        }
        else if(s[left]=='x'){
            ans++;
            left++;
        }
        else {
            jg=false;
            break;
        }
    }
    cout << (jg?ans:-1) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int x, y;
	int pair[13];
	pair[1] = 1;
	pair[3] = 1;
	pair[5] = 1;
	pair[7] = 1;
	pair[8] = 1;
	pair[10] = 1;
	pair[12] = 1;
	pair[4] = 4;
	pair[6] = 4;
	pair[9] = 4;
	pair[11] = 4;
	pair[2] = 2;
	cin >> x >> y;
	if (pair[x] == pair[y])puts("Yes");
	else puts("No");
	return 0;
}

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

int main(){
  long int k,n,ans=0,num=0,max=0;
  cin >> k >> n;
  
  vector<int>a(n);
  rep(i,n){
    cin >> a[i];        
    if(i > 0 && max < a[i]-a[i-1]){
      num = i; max = a[i]-a[i-1];      
    }
  }
  
  if(max < k+a[0]-a[n-1]) num = 0;
  
  for(int j = num+1; j < n; j++)
    ans += a[j]-a[j-1];
  for(int k = 1; k < num; k++)
    ans += a[k]-a[k-1];
  
  if(num > 0){
    ans += (k+a[0]-a[n-1]);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	int a[1000];
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a, a + n);
	int sum  = 0;
	for(int i = 0; i < k; ++i) {
		sum += a[i];
	}
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 3612
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    one = A.count(1)
    two = A.count(2)
    three = A.count(3)
    
    # dp[i][j][k] : i:3個,j:2個,k:1個
    dp = [[[0.0] * (N+1) for _ in range(N+1)] for _ in range(N+1)]
    for c3 in range(N+1):
        for c2 in range(N+1):
            for c1 in range(N+1):
                if (c3 + c2 + c1) <= N:
                    # すしが1個以上ある状態
                    nozero = float(c3+c2+c1)
                    if nozero == 0.0:
                        continue
                    dp[c3][c2][c1] = float(N) / nozero
                    # dp[c3-1][c2+1][c1] : 3個の皿を一個食べると2個の皿になる
                    # なので[c2+1]
                    if c3-1 >= 0:
                        dp[c3][c2][c1] += dp[c3 - 1][c2+1][c1] * float(c3) / nozero
                    if c2-1 >= 0:
                        dp[c3][c2][c1] += dp[c3][c2 - 1][c1+1] * float(c2) / nozero
                    if c1-1 >= 0:
                        dp[c3][c2][c1] += dp[c3][c2][c1 - 1] * float(c1) / nozero

    print(dp[three][two][one])


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 295560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define Graph vector<vector<ll>>
#define INF (ll)(1ll<<60)
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;}

int main(){
	ll d,g;//d 点数の種類 g 目標展
	cin>>d>>g;
	vector<ll> p(d),c(d);//p 同じ得点の問題の数 c ボーナス
	rep(i,d)  cin>>p[i]>>c[i];

	ll ans=INF;
	ll score,num;

	rep(i,(1<<d)){//全部解く問題について、bit全探索
		score=0;num=0;

		vector<bool> selected(d,false);//jを全部解くならselected[j]=true
		rep(j,d){
			if((i>>j)&1){//jの問題は全部解く
				score+=(p[j]*100*(j+1)+c[j]);
				num+=p[j];
				selected[j]=true;
			}
		}

		for(int j=d-1;j>=0;j--){//全部解く問題を選び終わったら、後は、点数の高い順に貪欲に問題を解く(ただし、1問は残さなければならない<-全部解くのは許されない)
			if(selected[j]) continue;

			for(int k=0;k<p[j]-1;k++){
				if(score>=g) break;
				
				score+=(100*(j+1));
				num++;
			}
			if(score>=g) break;
		}

		if(score>=g) ans=min(ans,num);//scoreがg以上で達成されていればminをとる
	}

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

Measured memory_bytes: 256
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.util.*;
import java.io.*;

public class Main {
	double[] x, y;
	double EPS = 1e-8;
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if(n == 0) break;
			
			x = new double[n];
			y = new double[n];
			for(int i=0;i<n;i++) {
				x[i] = sc.nextDouble(); y[i] = sc.nextDouble();
			}
			int max = 1;
			for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) {
				if(2.0  < d(i, j) - EPS ) continue;
				double[][] c = c(i, j);
				for(double[] a: c) {
					int cnt = 0;
					for(int k=0;k<n;k++)  if(1.0 + EPS > d(a, k)){
						cnt++;
					}
					max = max(max, cnt);
				}
					
			}
			System.out.println(max);
		}
	}
	
	double d(double[] c, int i) {
		return sqrt( (x[i] - c[0]) * (x[i] - c[0]) + (y[i] - c[1]) * (y[i] - c[1]) );
	}
	
	double d(int i, int j) {
		return sqrt( (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) );
	}
	
	double[][] c(int i, int j) {
		double[][] ret = new double[2][2];
		double cx = (x[i]+x[j]) / 2, cy = (y[i]+y[j]) / 2;
		double nx = y[i] - y[j], ny = x[j] - x[i], norm = sqrt(nx*nx+ny*ny);
		nx /= norm; ny /= norm;
		double dc = (x[j]-cx)*(x[j]-cx)+(y[j]-cy)*(y[j]-cy), d = sqrt( 1.0 - dc );
		nx *= d; ny *= d;
		ret[0][0] = nx + cx; ret[0][1] = ny + cy;
		ret[1][0] = -1.0 * nx + cx; ret[1][1] = -1.0 * ny + cy;
		debug(nx, ny, cx, cy, ret);
		return ret;
	}

	void debug(Object... os) {
	//	System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

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

  int count = 0;
  for (int i = 0; i < N.size(); i++) {
    if (N.at(1) == N.at(i) && N.at(2) == N.at(i)) {
      count++;
    }
      
  }
    if (count >= 3 ) {
      cout << "Yes" << endl;
    }
  else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    a = in_nl()
    b = in_nl()

    count = sum(b) - sum(a)

    x, y = 0, 0
    for i in range(N):
        if a[i] == b[i]:
            continue
        elif a[i] > b[i]:
            y += a[i] - b[i]
        else:
            t = b[i] - a[i]
            if t % 2 == 0:
                x += t // 2
            else:
                x += t // 2 + 1
                y += 1

    if count < 0:
        ans = 'No'
    else:
        if count < x or count < y:
            ans = 'No'
        else:
            if y + 2 * (count - x) == count:
                ans = 'Yes'
            else:
                ans = 'No'

    # print(count)
    #print(x, y)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10588
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::collections::HashMap;

fn main() {
    let n: usize = read();
    let sv: Vec<String> = read_col(n);

    let mut hm = HashMap::new();

    let mut max = 0;

    for s in sv {
        let b = hm.get(&s) == None;
        let mut tmp = 0;
        if !b {
            tmp = *(hm.get(&s).unwrap());
        }
        hm.insert(s, tmp + 1);

        if tmp + 1 > max {
            max = tmp + 1;
        }
    }

    let mut v: Vec<String> = vec![];

    for (key, val) in hm.iter() {
        if *val == max {
            v.push((*key).clone());
        }
    }

    v.sort();

    for a in v {
        println!("{}", a);
    }
}


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

int main() {
	int n, k;
    cin >> n >> k;
    vector<pair<int, int>> lr(n);
    for (int i = 0; i < k; ++i) {
        cin >> lr[i].first >> lr[i].second;
        lr[i].second++;
    }

    const ll mod = 998244353;
    vector<ll> dp(n, 0);
    dp[0] = 1;
    dp[1] = -1;
    for (int i = 0; i < n; ++i) {
        if(i - 1 >= 0) {
            dp[i] += dp[i - 1];
            dp[i] %= mod;
        }
        for (int j = 0; j < k; ++j) {
            int l = lr[j].first, r = lr[j].second;
            if(i + l < n) {
                dp[i + l] += dp[i];
                dp[i + l] %= mod;
            }
            if(i + r < n) {
                dp[i + r] -= dp[i];
                dp[i + r] = (dp[i + r] + mod) % mod;
            }
        }
    }
    cout << dp[n - 1] << endl;
}


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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int x ;
  cin >> x ;
  
  if(x==3 || x==5 || x==7){
    cout <<"YES"<<endl ;
  }
  else{
    cout <<"NO"<<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

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

int main() {
	int A, B, C, D, N;
	cin >> N;
	D = N%10;
	C = N/10%10;
	B = N/100%10;
	A = N/1000;
	while(1){
		if(A+B+C+D==7){
			cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
			break;
		}
		else if(A+B+C-D==7){
			cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
			break;
		}
		else if(A+B-C+D==7){
			cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
			break;		
		}
		else if(A+B-C-D==7){
			cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
			break;		
		}
		else if(A-B+C+D==7){
			cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
			break;		
		}
		else if(A-B+C-D==7){
			cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
			break;			
		}
		else if(A-B-C+D==7){
			cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
			break;			
		}
		else if(A-B-C-D==7){
			cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
			break;			
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define MN 100000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
long long tot,per;
int n,a[MN+5];
int main()
{
	n=read();per=1LL*(n+1)*n/2;
	for(int i=1;i<=n;++i) a[i]=read(),tot+=a[i];
	if(tot%per) return 0*puts("NO");
	for(int i=1;i<=n;++i)
	{
		long long x=a[i%n+1]-a[i]-(tot/per);
		if(x>0||(-x)%n) return 0*puts("NO");
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define ms(a,v) memset(a,v,sizeof a)
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n, m; cin>>n>>m;
	priority_queue<ld> q;
	ll ans=0; ld d;
	while(n--){
		cin>>d;
		q.push(d);
	}
	while(m--){
		d=q.top(); q.pop();
		d/=2.000;
		q.push(d);
	}
	while(!q.empty()){
		ans += (ll)q.top();
		q.pop();
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2420
def examA():
    X = I()
    if X==3 or X==5 or X==7:
        ans = "YES"
    else:
        ans = "NO"
    print(ans)
    return



import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()


Measured memory_bytes: 38384
//shara's here
//私は大きな男の子
//SPEEEEEEEEEED IS KEEEEEEEEEEY
#include <bits/stdc++.h>
using namespace std;
//fold
typedef double w;
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
#if defined(BANYANYA)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
//endfold
int main(){
	ll n; cin>>n;
	vector<ll>v(n);
	vector<ll>d(n);
	vector<ll>t(n);
	for(ll i=0;i<n;i++)cin>>v[i];
	d=v;
	t=v;
	sort(d.begin(),d.end());
	if(v==d){cout<<"YES"<<endl; return 0;}
	bool ok=false;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			swap(v[i],v[j]);
			if(v==d){ok=true; break;}
			else v=t;
			}
		if(ok)break;
		
		}
	if(ok){cout<<"YES"<<endl;}
	else cout<<"NO"<<endl;
return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int i,j,n,prime[60000]={0};
  for(i=2;i<60000;i++){
    if(prime[i]==0){
      for(j=i+i;j<60000;j+=i){
	prime[j]=1;
      }
    }
  }
  while(scanf("%d",&n)!=EOF){
  for(i=n-1;prime[i]!=0;i--);
  for(j=n+1;prime[j]!=0;j++);
  printf("%d %d\n",i,j);
  }
  return 0;
}

Measured memory_bytes: 836
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        boolean even = true;
        boolean zeroExit = false;
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
            if (a[i] < 0) {
                even = !even;
            }
            if (a[i] == 0) {
                zeroExit = true;
            }
        }

        long result = 0;
        if (even || zeroExit) {
            for (int i = 0; i < n; i++) {
                result += Math.abs(a[i]);
            }
        } else {
            int min = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                result += Math.abs(a[i]);
                min = Math.min(min, Math.abs(a[i]));
            }
            result -= min * 2;
        }

        System.out.println(result);
    }
}


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

const int MOD = 1000000007;
long long int n, k, a[3000];

int main(){
  cin >> n >> k;
  rep(i, n){
    cin >> a[i];
  }
  long long int b[n][2]; //0:subete 1:mae
  rep(i, n){b[i][1] = b[i][0] = 0;}
  rep(i, n){
    rep(j, n){
      if(a[j] < a[i]){
        b[i][0]++;
      }
      if(a[j] < a[i] && j > i){
        b[i][1]++;
      }
    }
  }
  rep(i, n){cerr << b[i][0] <<" "<< b[i][1]<<endl;}
  //-をなるべく使わない（modこわれる）
  long long int res = 0;
  rep(i, n){
    long long int sum1 = k * b[i][1];
    sum1 %= MOD;
    long long int sum2 = k * (k - 1);
    sum2 /= 2;
    sum2 %= MOD;
    sum2 *= b[i][0];
    res += sum1 + sum2;
    res %= MOD;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
// abc126_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> rank;

    UnionFind(int N) : par(N), rank(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {par[i] = i; rank[i] = 0;}
    }

    int find(int x) { // データxが属する木の根を再帰で得る：find(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = find(x); //xの根をrx
        int ry = find(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま

        if(rank[rx] < rank[ry]) { // root が rx の木の方が root が ry の木よりも低い
            par[rx] = ry; // root ry に rx の木をつなぐ
        } else {
            par[ry] = rx; // root rx に ry の木をつなぐ
            if(rank[rx] == rank[ry]) ++rank[rx]; // 同じ高さだったならばまとめたことによって高さ +1
        }
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }
};

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    int u, v, w;

    auto uf = UnionFind(2 * N);
    REP(i, N-1){
        cin >> u >> v >> w; u--;v--;

        if (w % 2 == 0){
            uf.unite(u, v);
            uf.unite(u + N, v + N);
        } else {
            uf.unite(u, v + N);
            uf.unite(u + N, v);
        }
    }

    u = 0;
    print(1);
    REPN(v, 1, N){
        if (uf.same(u, v) || uf.same(u+N, v+N)){
            print(1);
        } else {
            print(0);
        }
    }

    return 0;
}


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

#define show(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for (decltype(n) i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n % 2 == 0) {
        for (int i = n - 1; i >= 0; i -= 2) {
            cout << a[i] << " ";
        }
        for (int i = 0; i < n; i += 2) {
            cout << a[i] << " ";
        }
    } else {
        for (int i = n - 1; i >= 0; i -= 2) {
            cout << a[i] << " ";
        }
        for (int i = 1; i < n; i += 2) {
            cout << a[i] << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmpArray = br.readLine().split(" ");
		
		int input[] = new int[3];
		input[0] = Integer.parseInt(tmpArray[0]);
		input[1] = Integer.parseInt(tmpArray[1]);
		input[2] = Integer.parseInt(tmpArray[2]);
		
		Arrays.sort(input);
		
		int k = Integer.parseInt(br.readLine());
		int result = 0;

		for(int i = 0; i < k; i++){
			input[2] *= 2;
		}
		
		for(int i = 0; i < 3; i++){
			result += input[i];
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 23252
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val s = IntArray(N)
    (1..N).forEach {
        val a = readLine()!!.toInt()
        s[it - 1] = a
    }

    s.sort()

    val sum = s.sum()
    if (sum % 10 != 0) {
        println(sum)
    } else {
        val num = s.find {
            it % 10 != 0
        }
        if (num == null) {
            println(0)
        } else {
            println(sum - num)
        }
    }
}

Measured memory_bytes: 32192
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] a =S.toCharArray();
		
		for(int i=0;i<S.length();i++) {
			a[i]='x';
		}
		System.out.println(a);

	}
}


Measured memory_bytes: 24916
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

double distanceAB(double xa, double ya, double xb, double yb);
//void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u)
{
	int v;
	color[u] = GRAY;
	d[u] = ++tt;
	rep(v, n)
	{
		if (M[u][v] == 0) continue;
		if (color[v] == WHITE)
		{
			dfs_visit(v);
		}
	}
	color[u] = BLACK;
	f[u] = ++tt;
}

void dfs()
{
	int u;
	
	for (u=0; u<n; u++) color[u] = WHITE;
	tt = 0;
	
	for (u=0; u<n; u++)
	{
		if (color[u] == WHITE) dfs_visit(u);
	}
	
	for (u=0; u<n; u++)
	{
		printf("%d %d %d\n", u + 1, d[u], f[u]);
	}
}


int main()
{
	int u, v, k, i, j;
	
	scanf("%d", &n);
	rep(i, n) rep(j, n) M[i][j] = 0;
	
	rep(i, n)
	{
		scanf("%d %d", &u, &k);
		u--;
		rep(j, k)
		{
			scanf("%d", &v);
			v--;
			M[u][v] = 1;
		}
	}
	
	dfs();
	
	return 0;
}

/*
void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}
*/


double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define ll long long
#define li long int
#define ld long double
#define pl pair<long long, long long>
#define pi pair<int, int>
#define ppl pair<pl, ll>
#define ppi pair<int, pi>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LLFOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define MOD 1000000007
#define M2 998244353
//std::cout <<setprecision(30) << av << endl;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
       string in;
       cin >> in;
       if(in=="ABC"){
            cout << "ARC\n";

       }else{
        cout << "ABC\n";
       }
    }
}


Measured memory_bytes: 3652
#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
#include <climits>
#include <bitset>

#include <stack>
#include <queue>
// #include <deque>
#include <set>
#include <map>
#include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;


typedef long long ll;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;
typedef pair<int,long long> pil;
typedef pair<long long,int> pli;
typedef vector<vector<long long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef priority_queue<int, vector<int>, greater<int> > minq;
typedef priority_queue<int> maxq;
// to initialize PQs with a vector, do 
// minq(v.begin(),v.end()) or maxq(v.begin(),v.end())
// or minq(a,a+10) for arrays

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/
int numsubordinates[200001];

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

    int n; cin>>n; cin.ignore();

    for (int i = 2; i<=n; ++i) {
        int a; cin>>a;
        ++numsubordinates[a];
    }

    for (int i = 1; i<=n; ++i) {
        cout<<numsubordinates[i]<<el;
    }

}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vecl = vector<ll>;
using Graph = vector<vector<int>>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<Pi> c;
  REP(i, M) {
    int f, s;
    cin >> f >> s;
    if (N > 1 && f == 1 && s == 0) {
      cout << -1 << endl;
      return 0;
    }
    c.push_back(make_pair(f - 1, s));
  }
  sort(c.begin(), c.end());

  vector<int> ans(N, -1);
  REP(j, M) {
    if (ans.at(c[j].first) != -1 && ans.at(c[j].first) != c[j].second) {
      cout << -1 << endl;
      return 0;
    } else {
      ans.at(c[j].first) = c[j].second;
    }
  }

  REP(k, N) {
    if (ans[k] == -1) {
      ans[k] = N > 1 && k == 0 ? 1 : 0;
    }
    cout << ans[k];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import collections
N = int(input())
a = list(map(int,input().split()))
cnt = collections.Counter(a)
ans = 0
aset = sorted(set(a))
for i in aset:
    if cnt[i] < i:
        ans += cnt[i]
    elif cnt[i] > i:
        ans += cnt[i] - i
print(ans)

Measured memory_bytes: 20592
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int a, b, c;
    vector<int> ABC(101, 0);
    cin >> a >> b >> c;
    ABC[a] = 1;
    ABC[b] = 1;
    ABC[c] = 1;
    
    int ans = 0;
    rep(i, 101) ans += ABC[i];
    cout << ans << endl;
    return 0;
}

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

int sum[100010];

int main() {
	int q; cin >> q;
	memset(sum, 0, sizeof(sum));
	for (int i = 1; i < 100000; i += 2) {
		bool flag1 = true, flag2 = true;
		for (int j = 2; j <= (int)sqrt(i); j ++)
			if (i % j == 0) { flag1 = false; break; }
		if (i == 1) flag1 = false;
		int tmp = (i + 1) / 2;
		for (int j = 2; j <= (int)sqrt(tmp); j ++) 
			if (tmp % j == 0) { flag2 = false; break; }
		if (tmp == 1) flag2 = false;
		if (flag1 && flag2) sum[i] += sum[i-2] + 1;
		else sum[i] = sum[i-2];
	}
	for (int i = 0; i < q; i ++) {
		int l, r, st, ed; cin >> l >> r;
		if (l == 1) st = 0;
		else st = sum[l-2];
		ed = sum[r];
		cout << ed - st << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1024
m,d = map(int, input().split())
count = 0
if d < 22:
    print(0)
else:
    for i in range(1,m+1):
        for j in range(22,d+1):
            ju = int(str(j)[-2])
            ichi = int(str(j)[-1])
            if i == ju * ichi and ichi >= 2 and ju >= 2:
                count += 1
    print(count)


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

class LowestCommonAncestor{
public:
    int n;
    int LOG_N;
    vector<int> depth;
    vector<vector<int>> g;
    vector<vector<int>> ancestor;

    void dfs(int s, int p){
        for(auto& u : g[s]){
            if(u==p) continue;
            depth[u] = depth[s] + 1;
            ancestor[u][0] = s;
            dfs(u, s);
        }
    }

    int lca(int u, int v){
        if(depth[u]>depth[v]) swap(u, v);
        for(int i=0;i<LOG_N;++i){
            if((depth[v]-depth[u]) >> i & 1){
                v = ancestor[v][i];
                assert(v!=-1);
            }
        }
        if(u == v) return u;
        for(int i=LOG_N-1;0<=i;--i){
            if(ancestor[u][i]!=ancestor[v][i]){
                u = ancestor[u][i];
                v = ancestor[v][i];
            }
        }
        return ancestor[u][0];
    }

    LowestCommonAncestor() : n(0), LOG_N(0){}

    explicit LowestCommonAncestor(vector<vector<int>> &g, int s=0) : g(g){
        n = g.size();
        LOG_N = 0;
        while((1<<LOG_N)<n) ++LOG_N;
        depth.resize(n, 0);
        ancestor.resize(n, vector<int>(LOG_N, -1));
        dfs(s, -1);
        for(int i=1;i<LOG_N;++i){
            for(int j=0;j<n;++j){
                if(ancestor[j][i-1]!=-1) ancestor[j][i] = ancestor[ancestor[j][i-1]][i-1];
            }
        }
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int N;
    cin>>N;
    vector<vector<int>> G(N);
    for(int i=0;i<N;++i){
        int ki;
        cin>>ki;
        for(int j=0;j<ki;++j){
            int c;
            cin>>c;
            G[i].push_back(c);
        }
    }
    auto solver = LowestCommonAncestor(G);
    int Q;
    cin>>Q;
    while(Q--){
        int u, v;
        cin>>u>>v;
        cout<<solver.lca(u, v)<<'\n';
    }
}


Measured memory_bytes: 27576