akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
    int A[3][3];
    int N;
    int B[10];
    int bin[3][3];
    int flg=0;
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            scanf("%d",&A[i][j]);
            bin[i][j] = 0;
        }
    }
    scanf("%d",&N);
    for(int i = 0 ; i < N ; i++){
        scanf("%d",&B[i]);
        for(int j = 0 ; j < 3 ; j++){
           for(int k = 0 ; k < 3 ; k++){
                if(A[j][k] == B[i]){
                    bin[j][k]++;
                }
            }
        }
    }
    for(int i = 0 ; i < 3 ; i++){
        if(bin[i][0] > 0 && bin[i][1] > 0 && bin[i][2] > 0){
            flg++;
        }else if(bin[0][i] > 0 && bin[1][i] >0 && bin[2][i] > 0 ){
            flg++;
        }
    }
    if(bin[0][0] > 0 && bin[1][1] > 0 && bin[2][2] > 0 ){
        flg++;
    }else if(bin[0][2] > 0 && bin[1][1] > 0 && bin[2][0] > 0 ){
        flg++;
    }
    if(flg == 0){
        printf("No");
    }else{
        printf("Yes");
    }
    return 0;
}

Measured memory_bytes: 128
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        int len = int.Parse(ReadLine());
        string a = ReadLine();
        string b = ReadLine();
        string c = ReadLine();
        int[] count = new int[len];

        for(int i = 0; i < len; i++)
        {
            if (a[i] == b[i]) count[i]++;
            if (b[i] == c[i]) count[i]++;
            if (c[i] == a[i]) count[i]++;

            switch (count[i])
            {
                case 3:
                    count[i] = 0;
                    break;
                case 1:
                    count[i] = 1;
                    break;
                case 0:
                    count[i] = 2;
                    break;
            }
        }

        WriteLine(count.Sum());

        Console.ReadKey();
    }
}

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

    /// <summary>
    /// <see cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="ts"></param>
    public static void WriteToConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        Console.WriteLine(stringBuilder.ToString());
    }
}

Measured memory_bytes: 13268
<?php
	fscanf(STDIN, "%s",$N);

	$cnt = 1;
	$buf = substr($N, 0, 1);
	for ($i = 1; $i < 4; $i++){
		if ($buf === substr($N, $i, 1)){
			$cnt++;
		}else{
			$cnt = 1;
			$buf = substr($N, $i, 1);
		}

		if ($cnt === 3){
			echo "Yes\n";
			return;
		}


	}

	echo "No\n";

?>

Measured memory_bytes: 3700
a,b,c=map(int,input().split())
l=sorted([a,b,c])
a,b,c=l[0],l[1],l[2]
if (c-a)%2==0 and (c-b)%2==0:
  print((c-a)//2+(c-b)//2)
elif (c-a)%2==1 and (c-b)%2==1:
  a+=1
  b+=1
  print((c-a)//2+(c-b)//2+1)
else:
  if (c-a)%2==1:
    c+=1
    b+=1
    print((c-a)//2+(c-b)//2+1)
  else:
    c+=1
    a+=1
    print((c-a)//2+(c-b)//2+1)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;

        static void SolveA()
        {
            var o = ReadAndParseIntArr();
            int a = o[0];
            int b = o[1];
            int c = o[2];
            int d = o[3];

            var sw = new int[101];
            for(int i=a;i<b;++i)
            {
                sw[i]++;
            }
            for(int i=c;i<d;++i)
            {
                sw[i]++;
            }
            int ans = 0;
            for(int i=0;i<sw.Length;++i)
            {
                if( sw[i] == 2)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13140
N = int(input())
U = [list(input().split()) for i in range(N)]

for i in range(N):
    U[i][1] = - int(U[i][1])
    U[i].append(i + 1)

U = sorted(U, key = lambda x:(x[0], x[1]))

for i in U:
    print(i[2])


Measured memory_bytes: 3060
$_=<>;($a,$b)=glob<>;s#F+#push@{$`=~y/T//&1},length$&#ge;$a-=/^1/&&shift@0;$s=$_?b:a,map$$s>0?$$s-=$_:($$s+=$_),sort{$b-$a}@$_ for 0,1;print$a|$b?No:Yes

Measured memory_bytes: 1152
from collections import deque
import math
import copy
#https://qiita.com/ophhdn/items/fb10c932d44b18d12656

def max_dist(input_maze,startx,starty,mazex,mazey):
    input_maze[starty][startx]=0
    que=deque([[starty,startx]])
#    print(que)
    while que:
#        print(que,input_maze)
        y,x=que.popleft()
        for i,j in [(1,0),(0,1),(-1,0),(0,-1)]:
            nexty,nextx=y+i,x+j
            if (nexty>=0) & (nextx>=0) & (nextx<mazex) & (nexty<mazey):
                dist=input_maze[nexty][nextx]
                if dist!=-1:
                    if (dist>input_maze[y][x]+1) & (dist > 0):
                        input_maze[nexty][nextx]=input_maze[y][x]+1
                        que.append([nexty,nextx])
#    print(que)
#    print(max(list(map(lambda x: max(x),copy_maze))))
    return max(list(map(lambda x: max(x),copy_maze)))

h,w =list(map(int,input().split()))
maze=[list(input()) for l in range(h)]

# Maze preprocess
for y in range(h):
    for x in range(w):
        if maze[y][x]=='.':
            maze[y][x]=math.inf
        elif maze[y][x] == '#':
            maze[y][x]=int(-1)

results = []

for y in range(h):
    for x in range(w):
        if maze[y][x]==math.inf:
            copy_maze = copy.deepcopy(maze)
            max_dist_result = max_dist(copy_maze,x,y,w,h)
            results.append(int(max_dist_result))
            #print(max_dist_result)

print(max(results))



Measured memory_bytes: 77268
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);



int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    vector<ll> m;
    vector<ll> s;
    bool f = true;
    bool t = true;


    rep(i, n) {
        cin >> v[i];
        if (v[i] > 0)f = false;
        if (v[i] < 0)t = false;
        if (v[i] >= 0)s.push_back(v[i]);
        if (v[i] < 0)m.push_back(v[i]);
    }
    //vector<ll> c;
    //sort(c.begin(),c.end());
    sort(v.begin(), v.end());
    sort(s.begin(), s.end());
    sort(m.begin(), m.end());
    vector<pair<ll, ll>> ans;


    if(n==2){
        cout<<v[1]-v[0]<<endl;
        cout<<v[1]<<" "<<v[0]<<endl;
        return 0;
    }


    if (f) {//負のみ


      ll mi=v[0];
        ll ma=v[n-1];
        int p;
        int pl=0;int ne=0;
        rep(i,n){
            if(v[i]<0){
                p=i;
                ne++;
            }else{
                pl++;
            }
        }

        p++;

        if((n-ne-pl)==n){
            cout<<0<<endl;
            rep(i,n-1){
                cout<<0<<" "<<0<<endl;
            }
            return 0;
        }

        if(n==2){
            cout<<v[1]-v[0]<<endl;
            cout<<v[1]<<" "<<v[0]<<endl;
            return 0;
        }
        p=min(n-1,p);
        for(int i=1;i<p;i++){
            ans.push_back({ma,v[i]});
            ma-=v[i];
        }
        for(int i=p;i<n-1;i++){
            ans.push_back({mi,v[i]});
            mi-=v[i];
        }
        ans.push_back({ma,mi});
        cout<<ma-mi<<endl;

        rep(i,ans.size()){
            cout<<ans[i].first<<" "<<ans[i].second<<endl;
        }


    }else if(t){//正のみ

            ll lass=s[0];
            for(int i=2;i<s.size();i++){
                ans.push_back({lass,s[i]});
                lass-=s[i];
            }
           // cout<<lass<<endl;


            ans.push_back({s[1],lass});
            cout<<s[1]-lass<<endl;
            rep(i,ans.size()){
                cout<<ans[i].first<<" "<<ans[i].second<<endl;
            }
     }else{

        ll las=m[0];
        for(int i=0;i<s.size()-1;i++){
            ans.push_back({las,s[i]});
            las-=s[i];
        }

        ll las2=s[s.size()-1];
        for(int j=1;j<m.size();j++){
            ans.push_back({las2,m[j]});
            las2-=m[j];
        }


        ans.push_back({las2,las});
        cout<<las2-las<<endl;
        rep(i,ans.size()){
            cout<<ans[i].first<<" "<<ans[i].second<<endl;
        }


    }










    return 0;
}


Measured memory_bytes: 5872
#include <iostream>
#include <vector>
#include <map>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  int n;
  cin >> n;
  vector<int> v(n, 0);
  vector<int> v2(n, 0);
  ll ans = 0;
  rep(i, n){
    cin >> v[i];
    ans += v[i];
  }
  rep(i, n){
    cin >> v2[i];
  }
  ans += v2[n-1];
  ll res = ans;
  for(int i=n-1; i>0; i--){
    // cout << v[i] << ' ' << v2[i-1] << endl;
    ans -= v[i];
    ans += v2[i-1];
    res = max(res, ans);
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;


typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll x;
    cin>>x;
    ll a = 100;
    ll ans = 0;
    while(a < x){
        a *= 1.01;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
    int s;
    scanf("%d", &s);

    int a, b;
    a = s / 100;
    b = s % 100;
    int c, d;
    c = 1 <= a && a <= 12;
    d = 1 <= b && b <= 12;
    if (c && d) {
        printf("AMBIGUOUS\n");
    } else if (c && !d) {
        printf("MMYY\n");
    } else if (!c && d) {
        printf("YYMM\n");
    } else {
        printf("NA\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    int a;
    int ans = 0;
    vector<int> ss;
    for (int i = 1; i <= N; i++) {
        cin >> a;
        if (i == a) {
            ss.push_back(a);
        }
    }

    for (int i = 0; i < ss.size(); i++) {
        if (i + 1 != ss.size() && ss[i] + 1 != ss[i + 1]) {
            ans++;
        } else if (i + 1 != ss.size() && ss[i] + 1 == ss[i + 1]) {
            ans++;
            i++;
        } else {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <string>
//#define DEBUG
using namespace std;

int main(){
    int a, b, c, d, e, k;
    cin >>a >> b >> c >> d >> e >> k;

    if(b - a  <= k &&  c - a <= k &&  d - a <= k  && e - a <= k &&  c-b <= k && d-b <= k &&  e-d <= k &&  d-c <= k &&  e-c <= k && e -d <= k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
    
    
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vector<P> v;
    rep1(i, N){
        Rep1(j, i+1, N){
            if(N%2){
                if(i+j != N && i != j) v.push_back(make_pair(i, j));
            }else{
                if(i+j != N+1 && i != j) v.push_back(make_pair(i, j));
            }
        }
    }
    cout << v.size() << endl;
    rep(i, v.size()){
        cout << v[i].first << " " << v[i].second << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7856
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<limits>
#include<stack>
#include<array>
#include<stdio.h>
#include<cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;

int INF = std::numeric_limits<int>::max();
ll LLINF = 1e15;
int NINF = std::numeric_limits<int>::min();
int MOD = 1e9+7;

int col[] = {0,-1,0,1,1,1,-1,-1};
int row[] = {-1,0,1,0,1,-1,1,-1};

//knight moves
int cc[] = {1,2,2,1,-1,-1,-2,-2};
int rr[] = {-2,-1,1,2,-2,2,1,-1};

int main()
{
    //cout << LLINF ;
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n,m;
    cin >> n >> m;

    vvll dp(n+1,vll(m+1,0));
    dp[1][1] = 1;

    for(int i = 1 ; i <= n; ++i)
        for(int j = 1 ; j <= m ; ++j)
        {
            char c;
            cin >> c;
            if(c == '#')
                dp[i][j] = -1;
        }

    for(int i = 1; i <= n ; ++i)
        for(int j = 1 ; j <= m; ++j)
            if(dp[i][j] == 0)
            {
                dp[i][j] =  (((dp[i-1][j] != -1?dp[i-1][j]:0)%MOD) + ((dp[i][j-1] != -1?dp[i][j-1]:0)%MOD) )%MOD;
            }
    cout << dp[n][m] ;

    return 0;
}

Measured memory_bytes: 11104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define F first
#define S second
#define fi(a, b) for(ll i=(a);i<=b;i++)
#define fj(a, b) for(ll j=(a);j<=b;j++)
#define fid(a, b) for(ll i=(a);i>=b;i--)
#define fjd(a, b) for(ll i=(a);i>=b;j--)

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    os << "]";
	return os;
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class T> ostream& operator<<(ostream &os, multiset<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, unordered_map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}

// Kevin Mathew T
// Birla Institute of Technology, Mesra
// LinkedIn - https://www.linkedin.com/in/KevinMathewT/
// GitHub - https://github.com/KevinMathewT
// CodeForces - https://codeforces.com/profile/KevinMathew
// CodeChef - https://www.codechef.com/users/KevinMathew
// HackerRank - https://www.hackerrank.com/KevinMathew

const ll N = 1, M = 1e9 + 7;
ll a, b, x;

void solve(){
	cin >> a >> b >> x;
	ll out = 0;
	if(a == 0) out++, a++;

	out += (b / x) - ((a - 1) / x);
	cout << out << "\n";
}

int main(){
	// freopen("input.txt", "r", stdin);		//Comment
	// freopen("output.txt", "w", stdout);		//this out.
	ios::sync_with_stdio(false);			//Not
	cin.tie(NULL);							//this.
	cout.tie(0);							//or this.

	// ll T;
	// cin >> T;
	// while(T--)
		solve();

	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main()
{
    int N,M;
    cin >> N >> M;

    int ac[N] = {0};
    int pena[N] = {0};

    rep(i,M){
        int p;
        string s;

        cin >> p >> s;

        --p;

        if(ac[p]) continue;

        if(s == "AC") ac[p] = 1;

        else pena[p]++;
    }

    int AC = 0;
    int WA = 0;

    rep(i,N){
        AC+=ac[i];
        if(ac[i]) WA+=pena[i];
    }

    cout << AC << " " << WA << endl;

    return 0;
}

Measured memory_bytes: 1024
n, a, b = map(int, input().split())
cnt = 0
for i in range(1, n+1):
    s = list(str(i))
    t = 0
    for j in range(len(s)):
        t += int(s[j])
    if a<=t and t<=b:
        cnt += i
print(cnt)
    

Measured memory_bytes: 3064
#include<stdio.h>

int main(void) {
	char b;
	scanf("%c", &b);
	switch (b) {

	case'A':
		printf("T");
		break;

	case'C':
		printf("G");
		break;

	case'G':
		printf("C");
		break;

	case'T':
		printf("A");
		break;
	default:
		break;
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
using namespace std;

int main()
{
    long long n;
    while(~scanf("%lld", &n))
    {
        if(n%2)
            printf("%lld\n", n*2);
        else
            printf("%lld\n", n);
    }
    return 0;
}


Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e18) + 1;
const int mod = 479001599;
const int maxn = 5e5 + 111;
        
using namespace std;          

string s;

void solve(){
	cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7')
    	cout << "Yes";
  	else
  		cout << "No";                                                                         
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>

int main(int argc, char *argv[])
{
    size_t N = 0;
    size_t Res = 0;
    std::cin >> N;
    for (size_t i = 0; i <= N; ++i)
        if ((i % 3 != 0) && (i % 5 != 0))
            Res += i;
    std::cout << Res << std::endl;;
}


Measured memory_bytes: 3168
import java.util.Scanner;
public class Main {
	int time = 60;
	final static int numPerson = 3;
	
	static int[] calcTime(int[] after, int[] before) {
		int[] ans = new int[3];
		
		for(int r = 0; r < ans.length; r++) {
			ans[r] = after[r] - before[r];
		}
		int secCheck = 0, minCheck = 0;
		if(ans[2] < 0) {
			ans[2] += 60;
			secCheck = -1;
		}
		ans[1] += secCheck;
		if(ans[1] < 0) {
			ans[1] += 60;
			minCheck = -1;
		}
		ans[0] += minCheck;
		
		return(ans);
	}
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[][] ans = new int[numPerson][];
		for(int k = 0; k < numPerson; k++) {
			int[] before = new int[3];
			int[] after = new int[3];
			for(int r = 0; r < 2; r++) {
				for(int c = 0; c < 3; c++) {
					if(r == 0) before[c] = stdIn.nextInt();
					else       after[c]  = stdIn.nextInt();
				}
			}
			ans[k] = calcTime(after, before);
		}
		for(int r = 0; r < numPerson; r++) {
			for(int c = 0; c < 3; c++) {
				System.out.print(ans[r][c]);
				System.out.print((c == 2) ? '\n' : ' ');
			}
		}
	}
	
}

Measured memory_bytes: 17176
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
using namespace std;

int N;
long long W;
int w[100];
long long v[100];
long long dp[101][100001];

int main(){
    int value_sum = 0;
    cin >> N >> W;
    for(int i = 0; i < N; i++){
        cin >> w[i] >> v[i];
        value_sum += v[i];
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j <= value_sum; j++){
            dp[i][j] = INT_MAX;
        }
    }
    dp[0][0] = 0;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= value_sum; j++){
            dp[i][j] = dp[i - 1][j];
            if(j - v[i-1] >= 0){
                dp[i][j] = min(dp[i-1][j], dp[i - 1][j - v[i-1]] + w[i-1]);
            }
        }
    }

    /*for(int i = 0; i <= N; i++){
        for(int j = 0; j <= value_sum; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/
    int ans = 0;
    for(int i = 0; i <= value_sum; i++){
        if(dp[N][i] <= W){
            //cout << i << " " << " " << dp[N][i] << endl;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S,T;
    cin >> S >> T;
    int a=S.size();
    int ans=0;
    for (int i=0;i<a;i++) {
        if (S.at(i) != T.at(i)) {
            ans++;
        }
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 3860
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
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();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  
  ll A[N];
  vector<pair<ll,ll>> L;
  REP(i,N){
    cin>>A[i];
    L.PB(MP(A[i],i));
  }
  SORT(L);
  REVERSE(L);
  
  ll DP[N+1][N+1];
  REP(i,N+1){
    REP(j,N+1){
      DP[i][j]=0;
    }
  }
  
  for(int i=0; i<N; ++i){
    for(int j=0; i+j<N; ++j){
      chmax(DP[i+1][j],DP[i][j]+L[i+j].first*(L[i+j].second-i));
      chmax(DP[i][j+1],DP[i][j]+L[i+j].first*(N-1-j-L[i+j].second));
    }
  }
  
  REP(i,N+1) chmax(ans,DP[i][N-i]);
  co(ans);
  return 0;
}

Measured memory_bytes: 34940
N = int(input())
A = [int(i) for i in input().split()]

A.sort()

check = [0]*A[-1]

ans = 0
for i in range(N):
    elem = A[i]
    if check[elem-1]==0:
        if i < N-1:
            if elem != A[i+1]:
                ans += 1 
        if i==N-1:
            ans += 1
    
    now = elem
    while now <= A[-1]:
        check[now-1] = 1
        now += elem
        
print(ans)

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

int main() {
  int n, m, x;
  std::cin >> n >> m >> x;
  std::vector<int> a(m);
  for (auto &i : a) {
    std::cin >> i;
  }

  std::cout << std::min(std::count_if(a.cbegin(), a.cend(), [&](auto i){return i < x;}), std::count_if(a.cbegin(), a.cend(), [&](auto i){
    return x < i;})) << std::endl;
  return 0;
}


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

namespace abc161
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var a = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            int ans = 0;
            for (int i = 0; i < a.Length; i++)
            {
                ans += a[i];
            }
            int Judge = nm[0] >= ans ? nm[0] - ans : -1;
            Console.WriteLine(Judge);
        }
    }
}


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

int main() {
  string s; cin >> s;
  int cnt = 0;
  int ans = 0;
  
  rep(i,s.size()){
    if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C')
      cnt++;
    else{
      ans = max(ans,cnt);
      cnt=0;
    }
  }
  ans = max(ans,cnt);
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define long long long
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;


signed main()
{
  int N, K;
  scanf("%d%d", &N, &K);

  for (int i=0; i < (1<<N); ++i) {
    if (__builtin_popcount(i) != K) continue;
    printf("%d:", i);
    for (int j=0; j<N; ++j) {
      if ((i>>j) & 1) printf(" %d", j);
    }
    puts("");
  }
}




Measured memory_bytes: 3208
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#include <string>
using namespace std;

//宣言
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//数値
#define MOD 1000000007
#define INF (1<<20)
const double EPS = 1e-10;
const double PI = acos(-1.0);

//操作
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) FOR(i,0,n)
#define REPB(i,n) for(int i=n;i>=0;--i)
#define SORT(A) sort(A,A+sizeof(A)/sizeof(A[0]))
#define VSORT(A) sort(A.begin(),A.end())
#define EXIST(s,e) (s.find(e)!=s.end())
#define PB push_back
#define MP make_pair
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);

//DEBUG
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int MAX = 2007;
const int MOD = 1000000007;

void solve() {
    int a, b;
    cin >> a >> b;
    if (b % 2) {cout << "No";}
    else if (b >= 2*a && b <= 4*a) {cout << "Yes";}
    else {cout << "No";}
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve(); cout << endl;}
    solve();
}


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

int main(){
    set<string> ss;
    int n; cin >> n;
    rep(i, n) {string s; cin >> s; ss.insert(s);}
    cout << ss.size() << endl;

    return 0;
}

Measured memory_bytes: 19256
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> d(n);
  for(int &i:d)
    cin >> i;

  vector<int> num(110,0);
  for (int i : d)
  {
    num.at(i)++;
  }
  int res = 0;
  for (int i : num)
  {
    if(i>0){
      res++;
    }
  }
  cout << res << endl;
  return 0;
}

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

int main() {
    int k, x;
    cin >> k >> x;
    
    for (int i = x - k + 1; i < x + k; i++) {
        cout << i << " ";
    }
    
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

	int n;
	cin >> n;
	vi v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	sort(all(v));
	ld res = (ld) (1.0 * v[0] + 1.0 * v[1]) / 2;
	for(int i = 2; i < n; i++){
		res = (res + 1.0 * v[i]) / 2;
	}
	cout << fixed << setprecision(10) << res;
}

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

public class Main {

	static void exec(MyScanner in, PrintWriter out) {
		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();
		int E = in.nextInt();
		Integer[] ary = {A, B, C, D, E};
		Arrays.sort(ary, (a, b) -> {
			int ra = a % 10;
			int rb = b % 10;
			if (ra == rb) {
				return 0;
			}
			if (ra == 0) {
				return -1;
			}
			if (rb == 0) {
				return 1;
			}
			if (ra > rb) {
				return -1;
			}
			return 1;
		});
		int sum = 0;
		for (int i = 0; i < ary.length - 1; i += 1) {
			if (ary[i] < 10) {
				sum += 10;
			} else if (ary[i] % 10 == 0) {
				sum += ary[i];
			} else {
				sum += (ary[i] / 10 + 1) * 10;
			}
		}
		out.println(sum + ary[ary.length - 1]);
	}

	public static void main(String[] args) {
		PrintWriter w = new PrintWriter(System.out);
		exec(new MyScanner(System.in), w);
		w.flush();
	}

	static class MyScanner {
		static final int BUFFER_SIZE = 1024;
		private final InputStream in;
		private final byte[] buffer = new byte[BUFFER_SIZE];
		private int point;
		private int readLength;
		MyScanner(InputStream in) {
			this.in = in;
		}
		private int readByte() {
			if (point < readLength) {
				int result = buffer[point];
				point += 1;
				return result;
			}
			try {
				readLength = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (readLength == -1) {
				return -1;
			}
			point = 1;
			return buffer[0];
		}
		static boolean isPrintableCharExceptSpace(int c) {
			return 33 <= c && c <= 126;
		}
		String next() {
			StringBuilder b = new StringBuilder();
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			do {
				b.appendCodePoint(c);
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return b.toString();
		}
		long nextLong() {
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long result = 0L;
			do {
				if (!('0' <= c && c <= '9')) {
					throw new InputMismatchException();
				}
				result = result * 10L + (c - '0');
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return minus ? -result : result;
		}
		int nextInt() {
			long n = nextLong();
			if (Integer.MIN_VALUE <= n && n <= Integer.MAX_VALUE) {
				return (int) n;
			}
			throw new InputMismatchException();
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}


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

//#include <conio.h>
using namespace std;


struct P
{
    //string r;
    int x;
    long long y,z;

   /* bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
              return y>a.y;
    }*/
};


vector<P> v[5];
//bitset<4001000> b;
int a,c,i,b,k,n,d,m;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[5][5];

int o[255];
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,-1,1,-1,1},dz[10]={0,0,0,0,1,-1};

int e[5][5];

long long x,y,mod=1000000007;
long long z;
int j[200];
P u[110000];
//stack<int> s;
//queue<long long> q;
queue<int> q;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//list<int> l;
string r;

//deque<int> de;

bool as(P a,P b)
{
    return max(a.y,-a.y)<max(b.y,-b.y);
}


int main()
{
    cin>>r;
    for(int t=0;t<r.size();t++)
    {
        o[r[t]]++;
        if(o[r[t]]==2)
        {
            for(int h=r[t]+1;h<='z';h++)
                if(!o[h])
            {
                r[t]=h;
                goto asd;
            }
            puts("-1");
            return 0;
            asd:;
            for(int h=0;h<=t;h++)
                printf("%c",r[t]);
            return 0;
        }
    }


    if(r.size()<26)
    {
        cout<<r;
            for(int h='a';h<='z';h++)
                if(!o[h])
            {
                printf("%c",h);
                return 0;
            }
    }


    memset(o,0,sizeof(o));
    d=-1;
    for(int t=0;t<r.size();t++)
    {
        o[r[t]]++;
        for(int h=r[t]+1;h<='z';h++)
            if(!o[h])
            {
                d=t;
                break;
            }
    }

    if(d<0)
    {
        puts("-1");
        return 0;
    }


    memset(o,0,sizeof(o));
    for(int t=0;t<d;o[r[t]]++,t++)
        printf("%c",r[t]);
    for(int h=r[d]+1;;h++)
        if(!o[h])
    {
        printf("%c",h);
        return 0;
    }
}



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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<lint> a(3); 
    REP(i,3) cin>>a[i];
    lint n; cin>>n;
    sort(all(a),greater<int>());
    lint ans = 0;
    REP(i,3001){
        REP(j,3001){
            int ball = a[0]*i + a[1]*j;
            if(ball>n) continue;
            if((n-ball)%a[2] == 0) ans++;
            else continue;
        }
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
//#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
    ll n,m;cin>>n>>m;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n);
    ll l=0,r=200001;
    ll mid;
    while(r-l>1){
        mid=(r+l)/2;
        ll sum=0;
        rep(i,0,n-1){
            ll k=lower_bound(a,a+n,mid-a[i])-a;
            sum+=(n-k);
        }
        if(sum<=m){
            r=mid;
        }else{
            l=mid;
        }
    }
    ll s[n+1];s[n]=0;
    for(ll i=n-1;i>=0;i--){
        s[i]=s[i+1]+a[i];
    }
    ll ans=0;
    ll sum=0;
    rep(i,0,n-1){
        ll k=lower_bound(a,a+n,r-a[i])-a;
        sum+=(n-k);
        ans+=(a[i]*(n-k)+s[k]);
    }
    ans+=((m-sum)*l);
    cout<<ans<<endl;
    
    return 0;
}






Measured memory_bytes: 1792
aI, aO, _, aJ, aL, _, _ = map(int, input().split())

ans = 0

# JILを作る
if aI * aJ * aL > 0:
    tmp = 3
    tmp += 2 * ((aI - 1) // 2)
    tmp += 2 * ((aL - 1) // 2)
    tmp += 2 * ((aJ - 1) // 2)
    tmp += aO
    ans = max(ans, tmp)

# JILを作らない
tmp = 0
tmp += 2 * (aI // 2)
tmp += 2 * (aL // 2)
tmp += 2 * (aJ // 2)
tmp += aO
ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
	#include <cstdio>
	#include <algorithm>
	#include <string>
	#include <cstring>
	#include <cctype>
	#include <cmath>
	#include <stack>
	#include <queue>
	#include <vector>
	#include <set>
	#include <map>
	#include <list>
	#include <stdio.h>
	#include <string.h>
	#include <cstdlib>
	#include <math.h>
	#include <bitset>
	#include <iterator>
	#include <iomanip>
	#include <sstream>
	#include <numeric>
	#include <cassert>
	using namespace std;
	int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
	long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
	long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
	#define INF 2000000000
	#define MOD 1000000007
	#define sym cout<<"---------"<<endl;
	#define ll long long
	#define mk make_pair
	#define en endl
	#define RE return 0
	#define int ll
	#define P pair<int,int>

	int n,m; 
	void solve(int m){
		int ans=-1;
		for(int i=1; i*i<=m; i++){
			if(m%i==0){
				if(i*n<=m) ans=max(ans,i);
				if((m/i)*n<=m) ans=max(ans,m/i);
			}
		}
		if(ans==-1) cout<<1<<en;
		else cout<<ans<<en;
	}

	signed main(){
		cin>>n>>m;
		solve(m);
	}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <climits>
#include <iomanip>

using namespace std;

const int N = 2e6 + 9;
const int INF = 2e9 + 2;
const int mod = 1e9 + 7;
const int K = 25;
const int P = 51;
const long long LONG_INF = LONG_MAX;
const int SZ = (1 << 18) - 1;

#define eb emplace_back
#define sz(s) (int)(s.size())
#define mkp make_pair
#define all(s) s.begin(), s.end()

#define ll long long

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

	string s;
	cin >> s;

	vector <int> a(n);
	for (int i = 0; i < n; ++ i)
		a[i] = s[i] - '0' - 1;
	bool ok = false;
	for (int i = 0; i < n; ++ i)
		if (a[i] == 1)
			ok = true;
	
	if (ok)
		for (int i = 0; i < n; ++ i)
			a[i] %= 2;
	int ans = 0;

	for (int i = 0; i < n; ++ i)
		if (((n - 1) & i) == i)
			ans ^= a[i];
	cout << ans << '\n';
}

signed main() {
	ios_base::sync_with_stdio(false);
	solve();
	return 0;
}


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

bool check (string s){
  int n = s.length();
  if (n%2==1){
    return false;
  }
  else {
    return (s.substr(0,n/2-1)==s.substr(n/2));
  }
}

int sort (int n, int a[]){
  int index;
  for (int i=0; i<n-1; i++){
    int min = a[i], num;
    for (int j=i; j<n-1; j++){
      if (a[j+1]<min){
        min = a[j+1];
        num = j+1;
      }
    }
    index = a[i];
    a[i] = min;
    a[num] = index;
  }
}

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

  int a[n];
  int b[100010];
  for (int i=0; i<=100000; i++){
    b[i] = 0;
  }
  for (int i=0; i<n; i++){
    cin >> a[i];
    b[a[i]]++;
  }

  int index, max=0;
  for (int i=1; i<100000; i++){
    index = b[i-1] + b[i] + b[i+1];
    if (index>max){
      max = index;
    }
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 1024
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N = int(input())
    s = [input().strip() for i in range(N)]

    count = np.zeros((N, ord("z") - ord("a") + 1), dtype=int)

    for i in range(N):
        for c in s[i]:
            count[i][ord(c) - ord("a")] += 1
    
    for i in range(1, N):
        count[i] = np.minimum(count[i], count[i-1])
    
    for i in range(len(count[-1])):
        print(chr(ord("a") + i) * count[-1][i], end="")
    print()

if __name__ == "__main__":
    main()

Measured memory_bytes: 12472
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int N, M;
	cin >> N >> M;
    vector<int> P(M), Y(M);
    vector<vector<int>> yd(N+1);
    rep(i,M) {
        cin >> P[i] >> Y[i];
        yd[P[i]].push_back(Y[i]);
    }
    rep(i,N) sort(yd[i+1].begin(), yd[i+1].end());
    rep(i,M) {
        printf("%012lld\n", ll(P[i])*1000000 + int(lower_bound(yd[P[i]].begin(),yd[P[i]].end(), Y[i]) - yd[P[i]].begin()) +1);
    }
	return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int a, b;
    cin >> a >> b;
    bool f = (a * b) % 2 == 0;
    cout << (f ? "Even" : "Odd") << endl;
}

Measured memory_bytes: 256