akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

pair<int, int> getmax(map<int, int> o) {
    int cmax = 0;
    int vmax = 0;
    for (auto it = o.begin(); it != o.end(); it++) {
        if (cmax < it->second) {
            cmax = it->second;
            vmax = it->first;
        }
    }
    return make_pair(cmax, vmax);
}

template<typename A, typename B>
std::pair<B,A> flip_pair(const std::pair<A,B> &p)
{
    return std::pair<B,A>(p.second, p.first);
}

template<typename A, typename B>
std::multimap<B,A> flip_map(const std::map<A,B> &src)
{
    std::multimap<B,A> dst;
    std::transform(src.begin(), src.end(), std::inserter(dst, dst.begin()),
                   flip_pair<A,B>);
    return dst;
}

ll solve() {
    int N;
    cin >> N;
    
    map<int, int> o, e;
    REP(i, N) {
        int v;
        cin >> v;
        if (i%2) {
            o[v]++;
        } else {
            e[v]++;
        }
    }
    
    auto fo = flip_map<int, int>(o);
    auto fe = flip_map<int, int>(e);
    auto ito = fo.rbegin();
    auto ite = fe.rbegin();
    
    if (ito->second != ite->second) return (N+1)/2 - ito->first + N/2 - ite->first;
    
    int okeep = (N+1)/2 - ito->first;
    int ekeep = N/2 - ite->first;
    ito++;
    ite++;
    
    if (ito == fo.rend() && ite == fe.rend()) return N/2;
    else if (ito == fo.rend()) return N/2 - ite->first + okeep;
    else if (ite == fe.rend()) return (N+1)/2 - ito->first + ekeep;
    
    return min((N+1)/2 - ito->first + ekeep, N/2 - ite->first + okeep);
}

int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 9600
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;
#define MAX_N 500000
struct goods {
	ll val, siz;
};


bool cmp(const goods& a, const goods& b)
{
	return a.siz < b.siz;
}


goods g[MAX_N + 1];
ll cs[MAX_N + 1];
int main() {
	ll S;
	ll ANS;
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> g[i].siz >> g[i].val;
	}

	/*
	for (int i = 1; i <= N-1; i++) {
		for (int j = i + 1; j <= N; j++) {
			if (g[i].siz > g[j].siz) {
				goods temp;
				temp = g[i];
				g[i] = g[j];
				g[j] = temp;
			}
		}
	}
	*/

	sort(g + 1, g + N + 1, cmp);

	S = g[1].val + g[N].val;
	ANS = S - (g[N].siz - g[1].siz);
	cs[0] = 0;
	for (int i = 1; i <= N; i++) {
		cs[i] = cs[i - 1] + g[i].val;
	}
	ll MIN = 0xffffffffffff;
	for (int i = 1; i <= N; i++) {
		if (cs[i - 1] - g[i].siz < MIN)
			MIN = cs[i - 1] - g[i].siz;
		ANS = max(ANS, cs[i] - g[i].siz - MIN);
	}
	cout << ANS << endl;
	return 0;
}


Measured memory_bytes: 14876
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n % 2 == 0) {
			System.out.println(n);
		} else {
			System.out.println(n * 2);
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define TOAD
#define int ll
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS() 
#else
#define bug(...)
#define IOS() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
const ll inf = 1ll<<60;
const int iinf=2147483647;
const ll mod = 998244353;
const ll maxn=300005;

signed main (){
  IOS();
  int n,a,b,c,d; cin>>n>>a>>b>>c>>d;
  string str; cin>>str;
  if (c<d){
    bool rock=false;
    FOR(i,b-1,d){
      if (rock&&str[i]=='#'){
        cout<<"No\n";
        return 0;
      }
      if (str[i]=='#'){
        rock=true;
      }
      else rock=false;
    }
    str[d-1]='#';
    rock=false;
    FOR(i,a-1, c){
      if (rock&&str[i]=='#'){
        cout<<"No\n";
        return 0;
      }
      if (str[i]=='#'){
        rock=true;
      }
      else rock=false;
    }
    cout<<"Yes\n";
  }
  else {
    bool rock=false;
    int mid=-1;
    FOR(i,b-1,d){
      if (rock&&str[i]=='#'){
        cout<<"No\n";
        return 0;
      }
      if (str[i]=='#'){
        rock=true;
      }
      else {
        rock=false;
        if (i<n-1&&str[i-1]=='.'&&str[i+1]=='.'){
          str[i]='#';
          mid=str[i];
          break;
        }
      }
    }
    if (mid==-1){
      mid=d;
      str[d-1]='#';
    }
    rock=false;
    FOR(i,a-1, c){
      if (rock&&str[i]=='#'){
        cout<<"No\n";
        return 0;
      }
      if (str[i]=='#'){
        rock=true;
      }
      else rock=false;
    }
    rock=false;
    FOR(i,mid,d ){
      if (rock&&str[i]=='#'){
        cout<<"No\n";
        return 0;
      }
      if (str[i]=='#'){
        rock=true;
      }
      else rock=false;
    }
    cout<<"Yes\n";
  }

 }

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	long long x;
	cin>>x;
	
	long long ans = 0;
	
	ans += (x/11)*2;
	x%=11;
	if(x>6)ans+=2;
	else if(x>0)ans++;
	
	cout<<ans<<endl;
	
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include <cmath>
#define PI 3.14159265359879323846
using namespace std;
int main(){
cout.precision(30);//浮動小数点の有効桁数指定
long double a,b,x;
std::cin >> a>>b>>x;
long double h=atan((2/a)*(b-(x/(a*a))));
if(a*tan(atan((2/a)*(b-(x/(a*a)))))>b){
  h=atan((a*b*b)/(2*x));
}
std::cout << h*180.000000000000/PI << '\n';

return 0;
}


Measured memory_bytes: 512
#include<vector>
#include<iostream>
#include<cstdlib>
using namespace std;
int func(vector<int>& h){
  int n=h.size();
  vector<int> dp(n,-1);
  dp[n-1]=0;
  for(int i=n-2;i>=0;--i){
  	dp[i] = dp[i+1] + abs(h[i+1]-h[i]);
    if(i+2<=n-1)dp[i] = min(dp[i],dp[i+2] + abs(h[i+2] -h[i]));
  }
  return dp[0];
}
int main(){
  int n;cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;++i)cin>>h[i];
  //vector<int> memo(n,-1);
  cout<<func(h);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N,C,D[30][30],c[500][500];
    std::cin >> N>>C;
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            cin >>D[i][j];
        }
    }
    long long SUM[3][30];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >>c[i][j];
            c[i][j]--;
            for (int k = 0; k < C; k++) {
                SUM[(i+j)%3][k]+=D[c[i][j]][k];
            }
        }
    }

    long long res=9223372036854775807;
    for (int i = 0; i < C; i++) {
        for (int j =0; j < C; j++) {
            for (int k = 0; k < C; k++) {
                if(i!=j && j!=k && i!=k){
                    res=min(res,SUM[0][i]+SUM[1][j]+SUM[2][k]);
                }
            }
        }
    }
    std::cout << res << std::endl;
}




Measured memory_bytes: 2176
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <climits>
#include <utility>
#include <deque>
using namespace std;

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

	cout << (k == 1 ? 0 : n - k) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int n = b - a;
        long x = n * (n+1) / 2 - b;
        System.out.println(x);
    }
}

Measured memory_bytes: 21716
# Your code here!

list = gets.to_s

if (list[0].to_i == list[1].to_i and list[1].to_i == list[2].to_i) or (list[1].to_i == list[2].to_i and list[2].to_i == list[3].to_i)
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int k;
    cin >> k;
    vi a{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k - 1] << endl;
}


Measured memory_bytes: 256
def b_buildings_are_colorful(N, K, A):
    import itertools
    # 注目するビルの番号(左端を除くK-1個)の組
    attention_building = itertools.combinations(range(1, N), K - 1)
    ans = float('inf')
    for comb in attention_building:
        raised_a = A[:]  # 左から注目しているビルが見えるように高さを調節したあとのビルの高さ
        max_height = A[0]  # 高さを調整するとき、そのビルより左にあるビルより高くしなければならない
        for k in range(1, N):
            if k in comb:
                # 左からk番のビルは注目しているものだった。
                # 左から見えるように、高さを調整する
                if raised_a[k] <= max_height:
                    raised_a[k] = max_height + 1
            max_height = max(max_height, raised_a[k])

        cost = 0
        for k in range(N):
            cost += raised_a[k] - A[k]
        ans = min(ans, cost)
    return ans

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(b_buildings_are_colorful(N, K, A))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;

signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	cout << n * (n - 1) / 2;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int k;cin>>k;
      string s;cin>>s;string temp="";
      int l=s.length();
      if(l<=k) cout<<s;
      else 
      {
        for(int i=0;i<k;i++)
        {
          temp+=s[i];
        }
        temp+="...";
        cout<<temp;
      }
      return 0;
    }

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,h,w,a,b,ans=0;
  cin >> n >> h >> w;
  for(int i=0; i<n; i++) {
    cin >> a >> b;
    if(a>=h&&b>=w) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main()
{
    int n;
    string s, s1, s2;
    cin >> n >> s;
    s1 = s.substr(0, n / 2);
    s2 = s.substr(n / 2);
    if (s1.compare(s2) == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };

int N = 1e3 + 7;


int main() {
	fastIO;
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
	}

	int moves = 1;
	n -= k;
	while(n > 0) {
		n -= (k-1);
		moves++;
	}

	cout << moves;






}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll dp[101][100005];
ll dpsum[101][100005];
ll n, k;
ll a[105];

int main() {
    //cout.precision(10);
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    dp[0][0] = 1;
    for(int i = 0; i <= k; i++){
        dpsum[0][i] = 1;
    }
    for(int child = 1; child <= n; child++){
        dp[child][0] = 1;
        dpsum[child][0] = 1;
        for(int candy = 1; candy <= k; candy++){
            int mini = max((ll)1, candy - a[child]);
            dp[child][candy] = dpsum[child - 1][candy] - dpsum[child - 1][mini - 1];
            if(candy - a[child] < 1){
                dp[child][candy] += dpsum[child - 1][mini - 1];
            }
            dp[child][candy] = (dp[child][candy] + mod) % mod;
            dpsum[child][candy] = (dpsum[child][candy - 1] + dp[child][candy]) % mod;
        }
    }
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= k; j++){
            //cout << dp[i][j] << " " ;
        }
        //cout << endl;
    }
    cout << dp[n][k] << endl;
    return 0;
}


Measured memory_bytes: 158080
#include<bits/stdc++.h>
#define inf 100000000000
#define int long long int
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int n;
    cin>>n;
    int ans=0;
    ans+=1000*(n/500);
    n%=500;
    ans+=(n/5)*5;
    cout<<ans;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	var x, a, b int
	fmt.Fscanf(reader, "%d %d %d\n", &x, &a, &b)
	fx, fa, fb := float64(x), float64(a), float64(b)
	if math.Abs(fx-fa) < math.Abs(fx-fb) {
		fmt.Fprintf(writer, "%s\n", "A")
		return
	}
	fmt.Fprintf(writer, "%s\n", "B")
}


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

int main() {
	long long N;
	cin>>N;
	long long ans;
	if(N%2==0) {
		ans = (N - 1)*(N/2);
	}
	else {
		ans = N * (N-1)/2;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
for i in range(n):
    data = list(input())
    for a in range(len(data)):
        if a>=6:
            if data[a-6] == "H" and data[a-5]=="o" and data[a-4]=="s" and data[a-3]=="h" and data[a-2]=="i" and data[a-1]=="n" and data[a]=="o" :
                data[a] = "a"
    new = "".join(data)
    print(new)
                    


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

using namespace std;

int h, w;
vector<string> strs;
string str;

void solve()
{
  cin >> h >> w;
  strs.resize(h);
  for(auto&& i : strs) {
    cin >> i;
    str += i;
  }
  bool cans = (h * w) % 2;
  int use2 = h % 2 * (w / 2) + w % 2 * (h / 2);
  for(char i = 'a'; i <= 'z'; i++) {
    int cnt = count(str.begin(), str.end(), i);
    if(cnt % 2) {
      if(cans) {
        cans = false;
        cnt--;
      } else {
        cout << "No\n";
        return;
      }
    }
    if(cnt % 4) {
      if(cnt % 2) {
        cout << "No\n";
        return;
      }
      if (use2) {
        use2--;
      } else {
        cout << "No\n";
        return;
      }
    }
  }
  cout << "Yes\n";
}

int main()
{
  solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>

using namespace std;

int gomipeople[30];


    int main(){
       int people;
       for(int i=0;i<28;i++){
        cin>>people;
        gomipeople[people]=1;
       }
      
       for(int i=1;i<31;i++){
        if(gomipeople[i]==0){
             cout<<i<<endl;
        }
       }
     return 0;
    }

Measured memory_bytes: 1160
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    H = int(input())
    ans = 0
    i = 0
    while(H >= 1):
        ans += 2**i
        H /= 2
        i += 1

    print(ans)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 77568
// https://atcoder.jp/contests/abc047/tasks/arc063_b
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, t;
    cin >> n >> m;
    vector<int> v(n);
    int minv = INF;
    REP(i, n) {
        cin >> t;
        minv = min(minv, t);
        v[i] = t - minv;
    }
    sort(ALLR(v));
    // 差分が一番大きいものを数える
    int ans = 0;
    REP(i, n) {
        if (v[i] != v[0])
            break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

#define fcout(n) std::cout << std::fixed << std::setprecision((n))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::pair<int,int> PII;

typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector<PII> VPII;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

std::string S;
int main() {
    std::cin >> S;
    int x = 0;
    for(auto c: S) {
        if(c == '+') {
            ++x;
        } else {
            --x;
        }
    }
    std::cout << x << std::endl;
}

Measured memory_bytes: 256
from collections import defaultdict
def main():
    n, m = map(int, input().split(" "))
    d = defaultdict(lambda:"")
    dp = defaultdict(lambda:0)
    cnt_p=0
    cnt_ca=0
    for i in range(m):
        p,s = input().split(" ")
        if d[p] == "":
            if s == "AC":
                d[p] = 1
                cnt_ca += 1
                cnt_p += dp[p]
            else:
                dp[p] += 1
    print(f"{cnt_ca} {cnt_p}")


if __name__ == "__main__":
    main()

Measured memory_bytes: 27524
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

ll gcd(ll x, ll y) { return (x == 0) ? y : gcd(y % x, x); }

int main() {
  string s, t;

  cin >> s >> t;

  ll ans = 0;
  if (s[0] == t[0]) ans++;
  if (s[1] == t[1]) ans++;
  if (s[2] == t[2]) ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];

            List<Tuple<long, long>> p = new List<Tuple<long, long>>();

            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            
            for(var i = 0; i < M; i++)
            {
                var bcin = Console.ReadLine().Split().Select(int.Parse).ToArray();
                p.Add(new Tuple<long, long>(bcin[1], bcin[0]));
            }
            for(var i = 0; i < N; i++)
            {
                p.Add(new Tuple<long, long>(a[i], 1));
            }
            long ans = 0;

            p.Sort();
            p.Reverse();

            long cnt = 0;
            for(var i = 0; i < p.Count; i++)
            {
                if (cnt + p[i].Item2 >= N)
                {
                    ans += (N - cnt) * p[i].Item1;
                    break;
                }
                ans += p[i].Item2 * p[i].Item1;
                cnt += p[i].Item2;
            }

            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
    


    public class Calculation
    {

    }

    public class Graph
    {

    }
}
    

Measured memory_bytes: 34992
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		double d = (double) (a+b)/2;
		double ans = Math.ceil(d);
		System.out.println((int) ans);
	}
}

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

int main()
{
    int a,b,ab,na,nb;
    while(~scanf("%d%d%d%d%d",&a,&b,&ab,&na,&nb))
    {
        int m1,m2,m3;
        m1=na*a+nb*b;
        m3=2*ab*max(na,nb);
        if(na>nb)   m2=ab*(nb)*2+(na-nb)*a;
        else    m2=ab*(na)*2+(nb-na)*b;
        printf("%d",min(min(m1,m3),m2));
    }
    return 0;
}


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

int* BubbleSort(int num, int *val) {
  int *id;
  id = new int[num];

  for (int i = 0; i < num; i++) {
    id[i] = i;
  }

  for (int i = 0; i < num; i++) {
    for (int j = num - 1; j >= i + 1; j--) {
      if (val[id[j]] < val[id[j - 1]]) {
        int tmp;
        tmp = id[j];
        id[j] = id[j - 1];
        id[j - 1] = tmp;
      }
    }
  }

  return id;
}

int* SelectionSort(int num, int *val) {
  int *id;
  id = new int[num];

  for (int i = 0; i < num; i++) {
    id[i] = i;
  }

  for (int i = 0; i < num; i++) {
    int mini = i;
    for (int j = i; j < num; j++) {
      if (val[id[j]] < val[id[mini]]) {
        mini = j;
      }
    }
    if (mini != i) {
      int tmp;
      tmp = id[i];
      id[i] = id[mini];
      id[mini] = tmp;
    }
  }

  return id;
}

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

  char *s;
  int *v;
  s = new char[num];
  v = new int[num];
  for (int i = 0; i < num; i++) {
    char tmp[2];
    cin >> tmp;
    s[i] = tmp[0];
    v[i] = tmp[1] - '0';
  }

  int *id_BB = BubbleSort(num, v);
  int *id_SS = SelectionSort(num, v);

  int flag = 0;
  for (int i = 0; i < num - 1; i++) {
    cout << s[id_BB[i]] << v[id_BB[i]] << " ";
    if (v[id_BB[i]] == v[id_BB[i + 1]]) {
      if (id_BB[i] > id_BB[i + 1]) {
        flag = 1;
      }
    }
  }
  cout << s[id_BB[num - 1]] << v[id_BB[num - 1]] << endl;
  if (flag) {
    cout << "Not stable" << endl;
  }
  else {
    cout << "Stable" << endl;
  }

  flag = 0;
  for (int i = 0; i < num - 1; i++) {
    cout << s[id_SS[i]] << v[id_SS[i]] << " ";
    if (v[id_SS[i]] == v[id_SS[i + 1]]) {
      if (id_SS[i] > id_SS[i + 1]) {
        flag = 1;
      }
    }
  }
  cout << s[id_SS[num - 1]] << v[id_SS[num - 1]] << endl;
  if (flag) {
    cout << "Not stable" << endl;
  }
  else {
    cout << "Stable" << endl;
  }
}


Measured memory_bytes: 3136
import math
s = input()
l =list(s+"A")
count = [0]*(len(l))
start = -1
for i in range(len(l)-1):
  if l[i] == "R" and l[i+1] == "L":
    doko = i
  elif l[i] == "L" and l[i+1] != "L":
    count[doko] = math.ceil((doko-start)/2)+math.floor((i-doko)/2)
    count[doko+1] = math.floor((doko-start)/2)+math.ceil((i-doko)/2)
    start = i
for i in range(len(l)-1):
  print(count[i],end = " ")

Measured memory_bytes: 5744
import math
import sys


def merge(a, left, mid, right):
    count = 0

    a1 = a[left:mid] + [math.inf]
    a2 = a[mid:right] + [math.inf]

    i = j = 0
    for k in range(left, right):
        if a1[i] <= a2[j]:
            a[k] = a1[i]
            i += 1
        else:
            a[k] = a2[j]
            j += 1
        count += 1

    return count


def merge_sort(a, left, right):
    if left + 1 >= right:
        return 0

    count = 0
    mid = (left + right) // 2
    count += merge_sort(a, left, mid)
    count += merge_sort(a, mid, right)
    count += merge(a, left, mid, right)
    return count


n = int(sys.stdin.readline())
a = [int(v) for v in sys.stdin.readline().split()]
count = merge_sort(a, 0, len(a))

print(' '.join(map(str, a)))
print(count)



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

int main(){
	int r,c;
	cin >> r >> c;
	int sum = 0;
	int data[r*c];
	int max = 0;
	for(int i = 0; i < r * c; i++){
		cin >> data[i];
		sum += data[i];
		cout << data[i] << " ";
		if( i%c == c-1 ){
			cout << sum << endl;
			max += sum;
			sum = 0;
		}
	}
	for(int i = 0; i < c; i++){
		for(int k = i+c; k < r*c; k+=c){
			data[i] += data[k];
		}
		cout << data[i] << " ";
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

//typedef pair<int, int> P;

vector<int>a, b,am,bm;


signed main() {
	int N; cin >> N;
	a.resize(N); b.resize(N);
	am.resize(N); bm.resize(N);
	REP(i, N)cin >> a[i];
	REP(i, N)cin >> b[i];
	int ans = 0;
	REP(k, 50) {
		int T = 1LL << k;
		//print(T);
		REP(i, N) {
			am[i] = a[i] % (2 * T);
			bm[i] = b[i] % (2 * T);
		}
		//bm[N] = INF;
		VSORT(bm);
		
		int cnt = 0;
		REP(i, N) {
			auto itr = lb(bm, T - am[i]);
			int it = itr - bm.begin();
			itr = lb(bm, 2 * T - am[i]);
			int it2 = itr - bm.begin();
			itr = lb(bm, 3 * T - am[i]);
			int it3 = itr - bm.begin();
			cnt += N - it3;
			cnt += it2 - it;
		}
		if (cnt % 2 == 1) {
			ans += (1LL << k);
		}
	}
	print(ans);
}


Measured memory_bytes: 6528
#include<stdio.h>
#include<stdlib.h>
int partition(int*,int,int);
void swap(int*,int,int);
void printArray(int*,int,int);
int main(void)
{
  int i;//counter
  int n;//length of array
  int par;//partition number
  int *arr;
  scanf("%d",&n);
  arr=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++) scanf("%d",&arr[i]);
  par=partition(arr,0,n-1);
  printArray(arr,n,par);
  return 0;
}
int partition(int *arr,int p,int r)
{
  int i;//counter
  int parlast;//last index of first half part
  int sep=arr[r];//separate number
  parlast=p-1;
  for(i=p;i<r;i++)
    {
      if(arr[i]<=sep)
	{
	  parlast++;
	  swap(arr,parlast,i);
	}
    }
  swap(arr,parlast+1,r);
  return parlast+1;
}
void swap(int *arr,int x,int y)
{
  int temp;
  temp=arr[x];
  arr[x]=arr[y];
  arr[y]=temp;
}
void printArray(int *arr,int n,int par)
{
  int i;//counter
  for(i=0;i<n;i++)
    {
      if(i>0) printf(" ");
      if(i==par) printf("[%d]",arr[i]);
      else printf("%d",arr[i]);
    }
  printf("\n");
}



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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, h;
    cin >> a >> b >> h;
    h /= 2;
    cout << (a + b) * h << endl;

    return 0;
}


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

int main() {
  int N, D;
  cin >> N >> D;
 
  double x = N / ((2 * D) + 1);
  double y = N % ((2 * D) + 1);
  if(N <= D) {
    cout << 1 << endl;
  }
    else if(y != 0 && y <= 2 * D){
      cout << x + 1 << endl;
    }
  else {
    cout << x << endl;
  }
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int dp[1001][9];

int main(){
  int total_days;
  while(~scanf("%d",&total_days)){
    string must_attend_persons;
    cin >> must_attend_persons;

    must_attend_persons = "J" + must_attend_persons;

    memset(dp,0,sizeof(dp));

    //J:=0 O:=1 I:=2
    dp[0][(1<<0)] = 1;

    map<char,int> name2idx;
    name2idx['J'] = 0;
    name2idx['O'] = 1;
    name2idx['I'] = 2;

    for(int day=1;day<=total_days;day++){
      //J:=0 O:=1 I:=2
      for(int prev_attendance=0;prev_attendance<=(1<<3)-1;prev_attendance++){
	for(int next_attendance=0;next_attendance<=(1<<3)-1;next_attendance++){
	  if(__builtin_popcount(prev_attendance & next_attendance) == 0) continue;
	  if(!(next_attendance & (1<<name2idx[must_attend_persons[day]]))) continue;
	  
	  dp[day][next_attendance]
	    += dp[day-1][prev_attendance];
	  dp[day][next_attendance] %= 10007;
	}
      }
    }
    
    int res = 0;
    for(int attendance=0;attendance<=(1<<3)-1;attendance++){
      res += dp[total_days][attendance];
      res %= 10007;
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1284
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>
#include<stack>
#include<math.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<=(n);i++)
#define LL long long int
#define MOD 1000000007
 
 
using namespace std;
 
LL lcm(LL n, LL m)
{
	LL u;
	LL ansl = 0;
	for(u=m; u>=m; u++){
		if(u%n == 0){
			if(u%m == 0){
				ansl = u;
				break;
			}
		}
	}
	return ansl;
}
 

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

    vector<pair<LL,int>> a(n);
    rep(i,n){
        cin >>a[i].first;
        a[i].second=i;
    }
    sort(a.begin(),a.end(), greater<>());
    vector<vector<LL>> dp(n+1,vector<LL>(n+1,0));
    LL l,r,i,ans=0;

 //   rep(i,n){
//        cout<<a[i].first<<" "<<a[i].second<<endl;
 //   }


    for(int x=0;x<(n);x++){
        for(int y=0;y<(n);y++){

//            cout<<" "<< x<<" "<<y<<" "<<dp[x][y]<<"    ";

            if(x+y==0)continue;
            i=a[x+y-1].second;
            if(x!=0){
                l=dp[x-1][y]+(a[x+y-1].first) *(i-x+1);
                
            }
            else{
                l=0;
            }
            if(y!=0){
                r=dp[x][y-1]+(a[x+y-1].first) *((n-y)-i);
                
            }
            else{
                r=0;
            }
            dp[x][y]=max(r,l);
//            ans=max(ans,dp[x][y]);
//            cout <<r<<","<<l<<" l "<<dp[x][y]<<endl;

        }
    }
    rep(i,n){
        ans=max(ans,dp[i][n-i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 34672
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N;
	cin >> N;
	VLL PQ(N, 0);   //PQ[n] := S[n]一番最後の文字のp[*]-q[*]
	VLL PQMin(N, 1e9);   //PQMin[n] := S[n]単体で見た時のp[*]-q[*]min
	for (LL n = 0; n < N; n++) {
		string S;
		cin >> S;
		LL pq = 0;
		for (LL m = 0; m < S.size(); m++) {
			if (S[m] == '(')pq++;
			else pq--;
			PQMin[n] = min(PQMin[n], pq);
		}
		PQ[n] = pq;
	}
	LL pqsum = 0;
	for (LL n = 0; n < N; n++) {
		pqsum += PQ[n];
	}
	VLL order(N);
	if (pqsum != 0) {
		cout << "No\n";
		return 0;
	};
	for (LL n = 0; n < N; n++)order[n] = n;
	sort(order.begin(), order.end(), [&](LL a, LL b) {
		LL am = max(-PQMin[a], -PQ[a] - PQMin[b]);
		LL bm = max(-PQMin[b], -PQ[b] - PQMin[a]);
		return am < bm;
	});
	LL counter = 0;
	LL n = 0;
	for (; n < N; n++) {
		if (counter + PQMin[order[n]] < 0)break;
		counter += PQ[order[n]];
	}
	if (n != N)cout << "No\n";
	else cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

void is_prime_cal(ll n, vector<bool> &is_prime) {
  // nまでの素数を生成
  // vector<bool> is_prime(n + 1, true);
  vector<bool> tmp(n + 1, true);
  is_prime = tmp;
  for (ll i = 0; i <= n; i++) {
    if (!is_prime.at(i)) continue;
    if (i == 0 || i == 1) is_prime.at(i) = false;
    if (is_prime.at(i)) {
      for (ll j = 2; j * i <= n; j++) {
        is_prime.at(j * i) = false;
      }
    }
  }
}

void prime_gen(ll n, vector<ll> &prime) {
  // nまでの素数を生成
  vector<bool> is_prime(n + 1, true);
  for (ll i = 0; i <= n; i++) {
    if (!is_prime.at(i)) continue;
    if (i == 0 || i == 1) is_prime.at(i) = false;
    if (is_prime.at(i)) {
      for (ll j = 2; j * i <= n; j++) {
        is_prime.at(j * i) = false;
      }
    }
  }
  REP(i, n + 1) {
    if (is_prime[i]) prime.push_back(i);
  }
}

void factorization(ll n, vector<ll> prime, set<ll> &f) {
  // 準備:is_prime_genでis_primeを生成しておく
  // factor[i].first = i番目の素数
  // factor[i].second = 指数
  for (auto &p : prime) {
    if (p > sqrt(n)) break;
    if (n % p == 0) f.insert(p);
    while (n % p == 0) n /= p;
    if (n == 1) break;
  }
  if (n != 1) {
    f.insert(n);
  }
}

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }

  ll g = a[0];
  REP(i, n) { g = gcd(g, a[i]); }
  if (g != 1) {
    cout << "not coprime" << endl;
    return 0;
  }

  set<ll> fac;
  vector<ll> prime;
  // is_prime_cal(sqrt(*max_element(ALL(a))), is_prime);
  prime_gen(sqrt(*max_element(ALL(a))), prime);
  bool fp = true;
  REP(i, n) {
    set<ll> f;
    factorization(a[i], prime, f);
    for (auto x : f) {
      if (fac.count(x)) {
        fp = false;
        break;
      }
      fac.insert(x);
    }
    if (!fp) break;
  }

  if (fp)
    cout << "pairwise coprime" << endl;
  else
    cout << "setwise coprime\n";

  return 0;
}


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

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
ll k,a[200005];
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n>>k;ll sum1 = 0;
		for(ll i=0;i<n;i++)cin>>a[i];
		sort(a,a+n);
		for(ll i=0;i<k;i++)sum1+=a[i];
		cout<<sum1<<endl;





}

int main(){
	fastio;randomINIT;

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

    
}

Measured memory_bytes: 5976
#include <iostream>

int main(){
 int N;
 std::cin>>N;
 int* A=new int[N+1];
 for(int i=0;i<N+1;i++){
  std::cin>>A[i];
 }
 long long* ub=new long long[N+1];
 ub[N]=A[N];
 for(int i=N-1;i>=0;i--){
  ub[i]+=ub[i+1]+A[i];
 }
 
 long long* node=new long long[N+1];
 node[0]=1;
 long long ans=0;
 int flag=0;
 for(int i=0;i<N;i++){
  //std::cout<<node[i]<<" "<<A[i]<<std::endl;
  if(node[i]>A[i]){
   if((node[i]-A[i])*2<ub[i+1]){
    node[i+1]=(node[i]-A[i])*2;
   }else{
    node[i+1]=ub[i+1];
   }
  }else{
   ans=-1;
   flag=1;
   break;
  }
 }
 if(node[N]!=A[N]){
  ans=-1;
  flag=1;
 }

 if(flag==0){
  for(int i=N;i>=0;i--){
   ans+=node[i];
  }
 }
 std::cout<<ans<<std::endl;
}

Measured memory_bytes: 5600
import numpy as np
import math

def main():
    a, b = map(int, input().split())

    # print(a/0.08)

    a_ans = np.array([i for i in range(math.ceil(a/0.08), int((a+1)/0.08))])
    b_ans = np.array([j for j in range(math.ceil(b/0.1), int((b+1)/0.1))])

    # print(a_ans)
    # print(b_ans)
    #
    # print(a_ans * 0.08)
    # print(b_ans * 0.1)

    ans = set(a_ans) & set(b_ans)

    # print(ans)

    if ans == set():
        print(-1)
    else:
        print(min(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 20904
#include <iostream>
#include <iomanip>
#include <fstream>

#include <cmath>
#include <string>

#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int dp[100005];
vector<int> child[100005];

void dfs(int src) {
	if (dp[src] != -1) return;

	dp[src] = 0;

	for (int i = 0; i < child[src].size(); i++) {
		dfs(child[src][i]);
		dp[src] = max(dp[src], dp[child[src][i]] + 1);
	}
}

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

	int n, m;
	cin >> n >> m;
	int u, v;
	while(m--) {
		cin >> u >> v;
		child[u].push_back(v);
	}

	for (int i = 0; i < 100005; i++) dp[i] = -1;
	for (int i = 1; i < n+1; i++) dfs(i);

	int ans = 0;
	for (int i = 1; i < n+1; i++) ans = max(ans, dp[i]);
	cout << ans << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

#define fast_io() ios_base::sync_with_stdio(false);

const int MAX_N = 2e5 + 10;

set<int> multiples[MAX_N];


int main()
{
	int N, K;
	cin >> N >> K;
	for(int i = 1; i <= K; i++)
	{
		for(int j = i; j <= N; j += i)
		{
			multiples[i].insert(j);
		}
	}
	ll ans;
	if(K % 2 == 1)
	{
		ans = multiples[K].size();
		ans *= ans * ans;
	}
	else
	{
		K /= 2;
		ll even = multiples[K].size() / 2;
		ll odd = multiples[K].size() - even;
		ans = even*even*even + odd*odd*odd;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 91776
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n; cin >> n;
  int ans = 0;

for(int i = 0; i < n; i++){
  int a;cin >> a;
  int j = 0;
  bool ok = false;
  while(true){
    if(j % a == a - 1){
      ok = true;
      ans += a-1;
      break;
    }
    j++;
  }
}
cout << ans << endl;
//7
//994 518 941 851 647 2 581
}

Measured memory_bytes: 256
#include <stdio.h>

int main() 
{
	int N=0,b=0,c=0;
	int  a[100];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d",&a[i]);
	}
	
	for (int i = 0; i < N; i++) {
		if (b <= a[i])
			b = a[i];
	}
	
	c = a[0];

	for (int i = 0; i < N; i++) {
		if (c >= a[i])
			c = a[i];
	}

	printf("%d\n", b - c);

	return 0;
}

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



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

  int A, B, C;
  cin >> A >> B >> C;
  cout << C << ' ' << A << ' ' << B << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include<list>
#include<string>
using namespace std;

int main() {
	int h, w,cnt;
	cin >> h >> w;
	string *arry = new string[h],*ret = new string[h];
	for (int i = 0; i < h; i++) {
		cin >> arry[i];
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (arry[i][j] == '#')	ret[i] += "#";
			else if (arry[i][j] == '.') {
				cnt = 0;
				for (int s = -1; s <= 1; s++) {
					for (int t = -1; t <= 1; t++) {
						if (!(s == 0 && t == 0) && i + s >= 0 && i + s < h && j + t >= 0 && j + t < w) {
							if (arry[i + s][j + t] == '#') {
								cnt++;
							}
						}
					}
				}
				ret[i] += to_string(cnt);
			}
		}
	}
	for (int i = 0; i < h; i++) {
		cout << ret[i] << endl;
	}

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[10];
  int a=0,b=0,i;

  scanf("%s",s);

  for(i=0;i<10;i++){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
      a += 1;
    }else{
    a = 0;
    }
    if(a > b)
      b = a;
    if(s[i]==NULL)
      break;
  }
  printf("%d",b);

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<string>
int d;
using namespace std;
int main()
{ 
	int i;
	int x[3000],y[3000];
	
		for(i=0;i<3000;i++)
	
		{
			cin>>x[i]>>y[i];
			if(x[i]==0&&y[i]==0)
				break;
		}
		for(int k=0;k<i;k++)
		{
		    if(x[k]>y[k])
			cout<<y[k]<<" "<<x[k]<<endl;
		else
			cout<<x[k]<<" "<<y[k]<<endl;
		}
	
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define mod1 998244353 
#define inf 1000000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'




int main()
{
    fastio;
    #ifdef APNA_IO
        start_routine();
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);    
    #endif

    db w,h,x,y;cin>>w>>h>>x>>y;
    db a=w*h;
    a/=2.0;

    cout<<stp<<a<<" ";

    if(x==(w/2.0) && y==(h/2.0))
        cout<<1;
    else
        cout<<0;

    #ifdef APNA_IO
        end_routine();  
    #endif
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define double long double
using namespace std;
typedef pair<int, int>P;
void pyes() { cout << "Yay!" << endl; }
void pno() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
//繰り返し二乗法
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
//xCy
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int f(int x) {
	int ans = 1;
	for (int i = 1; i <= x; i++) {
		ans *= i;
		ans %= mod;
	}
	return ans;
}
struct edge { int to, cost; };
signed main() {
	int x;
	cin >> x;
	for (int i = 1; i <= x; i++) {
		if (i * 108 / 100 == x) {
			cout << i << endl;
			ggr
		}
	}
	pno();
	ggr
}


Measured memory_bytes: 256