akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLine();
            Console.WriteLine((n[0] == '7' || n[1] == '7' || n[2] == '7') ? "Yes" : "No");
            ReadLine();
        }

        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static long ReadLineLongInt() => long.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
	vi arra (A);
	F0R(i, A) cin >> arra[i];
	vi arrb (B);
	F0R(i, B) cin >> arrb[i];
	vi arrc (C);
	F0R(i, C) cin >> arrc[i];

	sort(arra.begin(), arra.end());
	sort(arrb.begin(), arrb.end());
	sort(arrc.begin(), arrc.end()); reverse(arrc.begin(), arrc.end());

	int ai = A - X;
	int bi = B - Y;
	ll ASUM = 0;
	ll BSUM = 0;
	FOR(i, ai, A) ASUM += arra[i];
	FOR(i, bi, B) BSUM += arrb[i];
	ll best = ASUM + BSUM;
	ll CSUM = 0;
	F0R(c, C) {
		CSUM += arrc[c];
		if (ai < A && bi < B) {
			if (arra[ai] < arrb[bi]) {
				ASUM -= arra[ai++];
			} else {
				BSUM -= arrb[bi++];
			}
		} else if (ai < A) {
			ASUM -= arra[ai++];
		} else if (bi < B) {
			BSUM -= arrb[bi++];
		} else {
			break;
		}
		best = max(best, ASUM + BSUM + CSUM);
	}
	print(best);

}

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

int main() {
  char c;
  cin >> c;

  if ( (c == 'a') ||
       (c == 'e') ||
       (c == 'i') ||
       (c == 'o') ||
       (c == 'u') ) {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3620
n = int(input())
robots = []
for i in range(n):
    x, l = map(int, input().split())
    robots.append([x + l, x - l])
robots.sort()

r = - 10 ** 9 - 1
cnt = 0
for i in range(n):
    if r <= robots[i][1]:
        cnt += 1
        r = robots[i][0]
print(cnt)

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    vi l(N);
    Rep(i,N){
        Scd(l[i]);
    }

    sort(l.begin(),l.end());
    // reverse(l.begin(),l.end());

    vi dp(3333);
    vi dp2(4333);
    int ans = 0;

    Rep(i,N){
        Repe(j,3333,l[i]+1){
            ans += dp2[j];
        }
        Rep(j,3333){
            dp2[l[i]+j] += dp[j];
        }
        dp[l[i]]++;
    }

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

    return 0;
}




Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


back = []


def backtrack(n, ml, mh, tmp=[]):
    if n == 0:
        back.append(tmp)
        return

    for i in range(ml, mh + 1):
        backtrack(n - 1, i, mh, tmp + [i])


def main():
    A, B, N = inpl()
    if B == 1:
        print(0)
        exit()

    tmp = min(B - 1, N)
    print((A * tmp) // B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include<stdio.h>
#include<ctype.h>
#include<string.h>

int main(){
    char ptn[11], w[1001];
    scanf("%s", ptn);

    int i;
    for(i = 0; ptn[i] != '\0'; i++){
        ptn[i] = tolower(ptn[i]);
    }

    int cnt = 0;
    while(1){
        scanf("%s", w);
        if(strcmp(w, "END_OF_TEXT") == 0)break;

        int i;
        for(i = 0; w[i] != '\0'; i++){
            w[i] = tolower(w[i]);
        }

        if(strcmp(w, ptn) == 0)cnt++;
    }
    printf("%d\n", cnt);
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    string s;
    cin>>s;
    ll n=s.length();
    rep(i,0,n)
    {
        if (s[i]=='?')
        {
            cout<<'D';
        }
        else
        {
            cout<<s[i];
        }
        
    }
}


Measured memory_bytes: 3788
#include <iostream>
using ll = long long;
using namespace std;

int main() {
    string s,t;
    cin >> s >> t;
    int a = 1;
    for (int i = 0; i < s.length(); ++i) {
        for (int j = 0; j < s.length(); ++j) {
            if (s[(i+j)%s.length()] != t[j]) {a = 0; break;}
        }
        if (a == 1) {cout << "Yes"; return 0;}
        a = 1;
    }
    cout << "No";
    return 0;
}

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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d)cout<<"Yes"<<endl;
    else if(abs(a-b)<=d&&abs(b-c)<=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());//昇順ソート
#define usort(a) sort(a.rbegin(),a.rend());//降順ソート

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  string S; cin>>S;
  int cnt=0;
  rep(i,0,4) cnt+=(2==ctoi(S[i]));
  cout<<cnt;
}




// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int X;
    cin >>X;
    string ans;
    if(X == 3 || X==5 || X==7){
        ans = "YES";
    }else{
        ans = "NO";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
   string S,T;
   cin >> S >> T;
   int N = S.size();
   int ans =0;
   for (int i = 0; i < N; i++)
   {
      if(S[i]!=T[i]){ans++;}
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 3860
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;
ll dp[13][13][10];
ll solve(ll n,ll now,ll dig)
{
    if (n==now)
    {
        dp[n][now][dig]=1;
    }
    if (dp[n][now][dig]!=0)
        return dp[n][now][dig];
    if (dig>=1)
        dp[n][now][dig]+=solve(n,now+1,dig-1);
    dp[n][now][dig]+=solve(n,now+1,dig);
    if (dig<9)
        dp[n][now][dig]+=solve(n,now+1,dig+1);
    return dp[n][now][dig];
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    ll k;
    cin>>k;
    int x=1;
    ll sum=0;
    while (true)
    {
        for (int i=1;i<10;i++)
            sum+=solve(x,1,i);
        if (sum<k)
            x++;
        else
            break;
    }
    vi ans(x);
    for (int i=1;i<x;i++)
    {
        for (int j=1;j<10;j++)
            k-=solve(i,1,j);
    }
    int cur=1;
    sum=0;
    ll wsum=0;
    while (sum<k) {
        wsum = sum, sum += solve(x, 1, cur), cur++;
    }
    cur--;
    k-=wsum;
    ans[0]=cur;
    for (int i=1;i<x;i++)
    {
        sum=0;
        wsum=0;
        if (cur-1>=0)
            sum+=solve(x,i+1,cur-1);
        if (sum>=k)
        {
            ans[i]=cur-1;
            cur--;
            continue;
        }
        wsum=sum;
        sum+=solve(x,i+1,cur);
        if (sum>=k)
        {
            ans[i]=cur;
            k-=wsum;
            continue;
        }
        wsum=sum;
        ans[i]=cur+1;
        cur++;
        k-=sum;
    }

    for (int to:ans)
        cout<<to;









}


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

typedef long long ll;
ll N, D;
vector<vector<ll>> X;
ll R;

int main() {
  cin >> N >> D;
  X.resize(N);
  for (auto &x : X) x.resize(D);
  for (ll i = 0; i < N; ++i) {
    for (ll k = 0; k < D; ++k) cin >> X[i][k];
  }
  for (ll i = 0; i < N; ++i) {
    for (ll j = i + 1; j < N; ++j) {
      double d2 = 0;
      for (ll k = 0; k < D; ++k) {
        d2 += pow(X[i][k] - X[j][k], 2);
      }
      ll d = sqrt(d2);
      if (d2 == d * d) ++R;
    }
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

char s[110][110];
int tate[110],yoko[110];
int main(){
	ll h,w;
	scanf("%lld%lld",&h,&w);
	rep(i,0,h)scanf("%s",s[i]);
	rep(i,0,h){
		int cnt=0;
		rep(j,0,w)if(s[i][j]=='#')cnt++;
		yoko[i]=!!cnt;
	}
	rep(j,0,w){
		int cnt=0;
		rep(i,0,h)if(s[i][j]=='#')cnt++;
		tate[j]=!!cnt;
	}
	rep(i,0,h)if(yoko[i]){
		rep(j,0,w)if(tate[j])putchar(s[i][j]);
		puts("");
	}
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
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 H, W, result = 0;
	cin >> H >> W;

	ll h_mid = H / 2;
	if ((H%2) == 1) {
		ll w_mid = W / 2;
		if ((W%2) == 1) {
			result += h_mid * w_mid;
			result += (h_mid+1) * (w_mid+1);
		} else {
			result += h_mid * w_mid;
			result += (h_mid+1) * w_mid;
		}
	} else {
		result = h_mid * W;
	}

	if ((H == 1) || (W == 1)) result = 1;

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
require 'prime'

n = gets.chomp.to_i

if n == 1
  puts 0
  exit
end

prime_division = Prime.prime_division(n)
powers = prime_division.map(&:last).sort

def initialize_hash(powers)
  h = {}

  max = powers.last
  n = 1
  sum = 0
  while sum < max
    sum = n * (n + 1) / 2
    h[n] = sum
    n += 1
  end

  h
end

h = initialize_hash(powers)
h_values = h.values.sort.reverse

def calc_h(h, h_values, power)
  return h.key(power) if h.has_value?(power)

  greatest_value_less_than_power = h_values.find { |x| x < power }
  raise unless greatest_value_less_than_power

  h.key(greatest_value_less_than_power)
end

results = powers.map { |power| calc_h(h, h_values, power) }

puts results.sum


Measured memory_bytes: 14496
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int N,K,X,Y;
  cin>>N>>K>>X>>Y;
  cout<<min(N,K)*X+max(N-K,0)*Y;
return 0;}


Measured memory_bytes: 3612
(* Examples *)
(*
stdin.ReadLine()
printfn "%d"
printfn "%s"
*)

(* Library *)
module Library = ()

(* Standard Input *)
let readSplit elementFun=
  stdin.ReadLine().Split()
  |> Array.map elementFun

let read elementFun =
  stdin.ReadLine() |> elementFun

let readMap H =
  [|for i in 1..H -> stdin.ReadLine()|]
  |> Array.map(fun line ->
    line.ToCharArray()
  )
  |> array2D

(* Main *)
open Library

let str = read string
let length = str.Length
let mutable count = 0
[1..length / 2]
|> List.iter(fun i ->
  if str.[i - 1] <> str.[length - i] then count <- count + 1
)

count |> printfn "%d"

Measured memory_bytes: 14044
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >>n){
    int x[8],y[9]={4,1,4,1,2,1,2,1,0};
    long int m=100000,v=50000000;
    for(int i=0; i<8; i++){
      if(i>0) cin >>n;
      x[i] = n;
    }
    for(int i=0; i<8; i++){
      long int a=0,b=0;
      for(int j=0; j<8; j++){
	if(y[j]<x[j]) a+=x[j]-y[j];
	b = b*10+y[j];
      }
      if(a<m){m = a;v = b;}
      else if(a == m && b<v){v = b;}
      y[8] = y[0];
      for(int j=0; j<8; j++) y[j] = y[j+1];
    }
    for(int i=10000000; i>0; i/=10){
      cout <<(v/i)%10;
      if(i>1) cout <<" ";
      else cout <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
  int N; cin >> N;
  ll A[N];
  rep(i,N){int x; cin >> x; A[i]=x-i-1;}
  sort(A,A+N);
  ll a={N%2==0 ? (A[N/2]+A[N/2-1]) : A[N/2]*2};
  ll ans=0;
  rep(i,N){
    ans+=abs(A[i]*2-a);
  }
  cout << ans/2 << endl;

  return 0;
}


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

int main() {
	set<string> s;
	int N;

	cin >> N;
	for (int i = 0; i < N; i++) {
		string str;
		cin >> str;
		s.insert(str);
	}
	cout << s.size();
}

Measured memory_bytes: 19140
Q, H, S, D = map(int, input().split())
price = { 0.25: Q, 0.5: H, 1.0: S, 2.0: D }
N = int(input())
def f(n, l):
  if l == 0.25:
    return int(n / 0.25) * price[l]
  t = int(n / l)
  return min(f(n - l * t, l / 2) + t * price[l], f(n, l / 2))
print(int(f(N, 2.0)))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
vector<int> data;
int input;
for(int i = 0;i < 4;++i){
cin >> input;
data.push_back(input);
}
sort(data.begin(), data.end());
if(data[0] == data[1] && data[2] == data[3]){
cout << "yes" << endl;
}else{
cout << "no" << endl;
}
return 0;
}


Measured memory_bytes: 3240
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  int i,j,n;
  unsigned short *A,*B;
  int C[VMAX+1];

  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
  }
  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }
  for(j=0;j<n;j++){
    C[A[j+1]]++;
  }
  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

 for(i=1;i<=n-1;i++){
   printf("%d ",B[i]);
      }
 printf("%d\n",B[n]);
  return 0;
}




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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{

    ll n, ans = inf;
    cin >> n;
    vector<ll> v(n+2,0);
    for(ll i = 1; i <= n; i++) cin >> v[i];
    for(ll i = 1; i <= n; i++) v[i] = v[i]+v[i-1];
    for(ll i = 1; i < n; i++)
    {

        ll x = v[i];
        ll y = v[n]-v[i];
        ll dif = abs(x-y);
        ans = min(ans, dif);
    }
    cout << ans;
}


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;
using P = pair<int,int>;

const int m=100005;

int main(){
  int x;
  cin>>x;
  vector<bool> a(m,false);
  for(int i=2;i<x;i++){
    if(a[i]==false){
      int j=i;
      while(j<m){
        a[j]=true;
        j+=i;
      }
    }
  }
  rep(i,m){
    if(a[x+i]==false){
      cout<<x+i;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3636
import java.io.*;

class Main{
    public static void main(String[] args) throws Exception{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String num = br.readLine();

        int x = Integer.parseInt(num);
        int ans = x * x * x;
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 24432
#include <bits/stdc++.h>
#include <string> 
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mid 2019
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
 
 
int main()
{
    fastio;
   
        ll count=0,abs=0,sum=0,index=-1,c=0;
       ll n,m,i,j,d,a,b;
       cin>>n>>m;
       ll arr[n];
       ll ans[n];
       fr(i,0,n)
       {
           cin>>arr[i];
           ans[i]=1;
       }
       
       for(i=0;i<m;i++)
       {
           cin>>a>>b;
           if(arr[a-1]<arr[b-1])
           {
               ans[a-1]=0;
               if(ans[b-1]>0)
               ans[b-1]++;
           }
           else if(arr[a-1]==arr[b-1])
           {
               ans[a-1]=0;
               ans[b-1]=0;
           }
           else
           {
               ans[b-1]=0;
               if(ans[a-1]>0)
               ans[a-1]++;
           }
       }
       for(i=0;i<n;i++)
       {
          //cout<<ans[i]<<" ";
           if(ans[i]>0)
           count++;
       }
       //cout<<endl;
       cout<<count<<endl;
       
    
  

}

Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
vector<int>vec;
int ans;
int cha[105][105];
int main ()
{
        int N,l;
        cin>>N;
        for(int i=0;i<2*N;i++)
        {
                cin>>l;
                vec.push_back(l);
        }
        sort(vec.begin(),vec.end());
//        for(int i=0;i<vec.size();i++)
//        {
//                cout<<vec[i]<<" ";
//        }
//        cout<<endl;
        for(int i=2*N-1;i>=1;i-=2)
        {
                //cout<<ans<<endl;
                ans += min(vec[i],vec[i-1]);
        }
        cout<<ans<<endl;
//        for(int i=0;i<2*N;i++)
//        {
//                for(int j=0;j<2*N;j++)
//                {
//                        cha[i][j] = abs(vec[i] - vec[j]);
//                }
//        }
//        for(int i=0;i<2*N;i++)
//        {
//                for(int j=0;j<2*N;j++)
//                {
//                        cout<<cha[i][j]<<" ";
//                }
//                cout<<endl;
//        }


}


Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
#template input
import bisect

def IT():
    return int(input())
def IL():
    return [int(_) for _ in input().split()]
def SL():
    return [int(_) for _ in input().split()]
def ILS(n):
    return [int(input()) for _ in range(n)]
def SLS(n):
    return [input() for _ in range(n)]
def ILSS(n):
    return [[int(_) for _ in input().split()] for j in range(n)]

#template technique
def bit_full_search(ss):
    n = len(ss)
    for i in range(1 << n):
        s = ""
        for j in range(n + 1):
            if ((1 & i >> j) == 1):
                s += ss[j]
        print(s)

def bit_full_search2(A):
    #https://blog.rossywhite.com/2018/08/06/bit-search/
    value = []
    for i in range(1 << len(A)):
        output = []

        for j in range(len(A)):
            if ((i >> j) & 1) == 1:
                #output.append(A[j])
                output.append(A[j])
        value.append([format(i, 'b').zfill(16), sum(output)])
    return value


"""ここからメインコード"""
def main():
    n = IT()
    #それぞれ半分全列挙
    list1 = [(-2) **  i for i in range(16)]
    list2 = [(-2) ** (i + 16) for i in range(16)]

    list1 = bit_full_search2(list1)
    list1.sort(key=lambda x:x[1])
    list1_bin = [list1[i][0] for i in range(len(list1))]
    list1_val = [list1[i][1] for i in range(len(list1))]

    list2 = bit_full_search2(list2)
    list2.sort(key=lambda x:x[1])
    list2_bin = [list2[i][0] for i in range(len(list2))]
    list2_val = [list2[i][1] for i in range(len(list2))]
    ans = 0
    for i in range(len(list1_val)):
        j = bisect.bisect_left(list2_val, n - list1_val[i])
        if j < len(list2_val):
            if list1_val[i] + list2_val[j] == n:
                ans = list2_bin[j] +list1_bin[i]
                break
    print(int(ans))
main()



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

int main() {
    int N;
    cin >> N;
    int A[110][110];
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }

    for (int i = 1; i < N; i++) A[0][i] += A[0][i - 1];

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int sum = A[0][i];
        for (int j = i; j < N; j++) {
            sum += A[1][j];
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
h_array = [int(x) for x in input().split()]
ans = []
res = 0
all_res = 0
now = h_array[0]
for h in h_array[1:]:
    if h <= now:
        res += 1
    else:
        res = 0
    all_res = max(all_res, res)
    now = h
print(all_res)

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

int main(){
    int  A,B,C;
    cin>>A>>B>>C;
    if (A==B){if (B==C){cout<<"No"<<endl;}
        else{cout<<"Yes"<<endl;}
    }
    if (A==C){if (B!=A){cout<<"Yes"<<endl;}
    }
    if (C==B){if (B!=A){cout<<"Yes"<<endl;}
    }
    if (C!=B){if (B!=A){if(A!=C){cout<<"No"<<endl;}}
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    vl a(n);
    map<ll, int> cnt;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    priority_queue<int, vi, greater<int>> pq;
    for (auto &p : cnt) {
        pq.push(p.second);
    }
    vl ret(n, 0);
    ret[0] = n;
    for (int i = pq.size() - 1; i > 0; --i) {
        int mini = pq.top();
        pq.pop();
        ret[i] = mini;
        for (int j = 0; j < mini; ++j) {
            int mini2 = pq.top();
            pq.pop();
            pq.push(1 + mini2);
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << ret[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 24688
import sys

N = int(input())
A = list(map(int, input().split()))


ans = 0
for a in A:
    ans += abs(a)

c = 0
m = abs(A[0])
for a in A:
    if a < 0:
        c += 1
    elif a == 0:
        print(ans)
        sys.exit()

    if abs(a) < m:
        m = abs(a)

if c % 2 == 0:
    print(ans)
else:
    print(ans - 2 * m)


Measured memory_bytes: 85636
#include <iostream>
#include <string>
#include <algorithm>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    int a, p; std::cin >> a >> p;
    int temp = a * 3 + p;
    std::cout << (temp - temp % 2) / 2 << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<ctime>
#include<stack>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
inline void print(int x){
	if(x<0) putchar('-'),x=-x;
	if(x>9)
		print(x/10);
	putchar(x%10+'0');
	return ;
}
#define INF 0x3f3f3f3f
#define MAXN 1000000
char str[15];
int main(){
	scanf("%s",str+1);
	int len=strlen(str+1);
	if(str[1]=='A'){
		if(('A'<=str[2]&&str[2]<='Z')||('A'<=str[len]&&str[len]<='Z')){
			printf("WA\n");
			return 0;
		}
		int f=0;
		for(int i=3;i<len;i++){
			if(str[i]=='C'){
				f++;
				if(f==2){
					printf("WA\n");
					return 0;
				}
			}
			else if('A'<=str[i]&&str[i]<='Z'){
					printf("WA\n");
					return 0;
				}
		}
		if(!f) printf("WA\n");
		else printf("AC\n");
	}
	else
		printf("WA\n");
	return 0;
}

Measured memory_bytes: 256
def divisor(x):
    d = []
    for i in range(1, int(x**0.5)+1):
        if x%i == 0:
            d.append(i)
            if i!=(x//i): d.append(x//i)
    d.sort()
    return d

n, m = map(int, input().split())
d = divisor(m)
for i in range(len(d)-1, -1, -1):
    if d[i] <= m/n:
        print(d[i])
        break

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    int T, X;
    cin >> T >> X;

    cout << static_cast<double>(T) / X << endl;

    return 0;
}


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

class Main {

    public static void main( final String[] args ) {
		
		final Scanner stdin = new Scanner( System.in );
		
		while ( true ) {
			int n = stdin.nextInt();
			int m = stdin.nextInt();
			if ( n == 0 && m == 0 ) break;

			int[] table = new int[ m ];
			for ( int j = 0; j < n; j++ ) {
				for ( int i = 0; i < m; i++ ){
					final int val = stdin.nextInt();
					table[ i ] <<= 1;
					table[ i ] += val;
				}
			}
			int[] work = new int[ m ];
			
			int max = 0;
			int mask = (1 << n) - 1;

			for ( int i = 0; i < (1 << n); i++ ) {
				System.arraycopy( table, 0, work, 0, m );
				
				// よこ
				int rev = 0;
				for ( int j = 0; j < n; j++ ) {
					rev <<= 1;
					if ( ( ( 1 << j ) & i ) != 0 ) {
						rev++;
					}
				}
				for ( int k = 0; k < work.length; k++ ) {
					work[ k ] ^= rev;
				}
				int sum = 0;
				
				// たて
				for ( int val : work ) {
					int count = Integer.bitCount( val & mask );
					sum += Math.max( count, n - count );
				}
				if ( max < sum ) {
					max = sum;
				}
			}
			System.out.println( max );
		}	
    }    
}

Measured memory_bytes: 75464
#include <stdio.h>

int main() {
	int n, a, b;

	scanf("%d", &n);
	for (a = 1; a <= 9; a++)
		for (b = 1; b <= 9; b++)
			if (a * b == n) {
				printf("Yes\n");
				return 0;
			}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 128
import numpy as np


N = int(input().strip())
alist = list(map(int,input().strip().split()))

alist = np.array(alist)
alistp = np.abs(alist)
maxind = np.where(alistp==alistp.max())[0][0]

if alist[maxind]>0:
	positive = True
else:
	positive = False

count = 0
process = []
for i in range(N):
	if alist[i]*alist[maxind]<0:
		alist[i] = alist[i]+alist[maxind]
		count = count+1
		process.append([maxind,i])

if positive==True:
	for i in range(N-1):
		alist[i+1] = alist[i+1]+alist[i]
		count = count+1
		process.append([i,i+1])
else:
	for i in range(N-1,0,-1):
		alist[i-1] = alist[i-1]+alist[i]
		count = count+1
		process.append([i,i-1])

print(count)
for i in range(count):
	processi = process[i]
	print(processi[0]+1,processi[1]+1)


Measured memory_bytes: 12500
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<P> x(n);
    vector<int> ans(n*n, -1), cnt(n, 0), a(n);
    rep(i, n){
        cin >> x[i].first;
        x[i].second = i+1;
        a[i] = x[i].first;
        ans[x[i].first-1] = i+1;
    }
    sort(all(x));
    int p = 0;
    rep(i, n){
        int j = 0;
        while(j < x[i].second-1){
            if(ans[p] == -1){
                ans[p] = x[i].second;
                j++;
            }
            p++;
        }
    }
    rep(i, n){
        int j = 0;
        while(j < n-x[i].second){
            if(ans[p] == -1){
                ans[p] = x[i].second;
                j++;
            }
            p++;
        }
    }
    bool ok = true;
    rep(i, n*n){
        cnt[ans[i]-1]++;
        if(cnt[ans[i]-1] == ans[i] && i+1 != a[ans[i]-1])ok = false;
    }
    cout << (ok ? "Yes" : "No") << endl;
    if(ok){
        rep(i, n*n)cout << ans[i] << " ";
        cout << endl;
    }
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
//#define ll long long
#define mod 1000000007
#define NCONS 100001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;
ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

string str;
int arr[NCONS];
//int cnt[NCONS];

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> str;
    int rcnt = 0, lcnt = 0;
    int last_rptr = 0;
    
    for(int i = 0; i < str.size(); i++)
    {
        if(str[i] == 'R')
        {
            if(lcnt > 0)
            {
                arr[last_rptr] = rcnt;
                arr[last_rptr + 1] = lcnt;
                rcnt = lcnt = 0;
            }
            
            
            last_rptr = i;
            rcnt += 1;
        }
        else
        {
            lcnt += 1;
        }
    }
    
    arr[last_rptr] = rcnt;
    arr[last_rptr + 1] = lcnt;
    
    
    for(int i = 0; i < str.size(); i++)
    {
        if(arr[i] == 0) continue;
        auto temp_r = arr[i];
        auto temp = arr[i] + arr[i+1]; arr[i+1] = 0;
        arr[i] = arr[i+1] = temp / 2;
        
        if(temp % 2)
        {
            if(temp_r % 2)
            {
                arr[i] += 1;
            }
            else
            {
                arr[i+1] += 1;
            }
        }
        i += 1;
    }
    
    
    
    for(int i = 0; i < str.size(); i++)
        cout << arr[i] << " ";
    cout << endl;
    
  
  
    return 0;
}


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

using namespace std;

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

    vector<int> v(n);

    for (int &x: v)
        cin >> x;
    
    int ans = 0;
    sort(v.begin(), v.end());

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if(v[i] < v[j] and v[j] < v[k]) {
                    if(v[i] + v[j] > v[k] and v[i] + v[k] > v[j] and v[k] + v[j] > v[i])
                        ans++;
                }
            }
        }
    }

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


Measured memory_bytes: 3616
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int a[100004];
vector <int> l,r;
int main(){
	int ans=1e9;
	int n,k;
	cin>>n>>k;
	for (int i=0;i<n;i++){
		long long x;
		cin>>x;
		if (x<0) l.push_back(abs(x));
		else r.push_back(x);
	}
	reverse (l.begin(),l.end());
	for (int i=0;i<=l.size() && i<=k;i++){
		int a=0,b=0;
		if (i!=0) a=l[i-1];
		int fate=k-i;
		if (fate>r.size()) continue;
		if (fate!=0) b=r[fate-1];
		ans=min(ans,a+b+min(a,b));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1020
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in map(int,input().split()):
  d[i] += 1
c = dict()
for i in d:
  if d[i] >= 2:
    c[i] = d[i]
if len(c) == 0:
  print(0)
  exit()
f = max(c)
if c[f] < 4:
  del c[f]
if len(c) == 0:
  print(0)
  exit()
s = max(c)
print(f*s)

Measured memory_bytes: 24104
#include<stdio.h>
int main(void){
  int a;
  int i, j;
  int max = 0;
  int min;
  int s[100];
  scanf("%d", &a);
  for( i = 0; i < a; i++){
    scanf("%d", &s[i]);
  }
  min = s[0];
  for( i = 0; i < a; i++){
    if( s[i] > max){
      max = s[i];
    }
    if( s[i] < min){
      min = s[i];
    }
  }
  printf("%d\n", max - min);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	
	if (a + b == c || a + c == b || b + c == a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

// UnionFind
struct UnionFind {
    vector<int> par;
    vector<int> siz;

    UnionFind(int N) : par(N), siz(N, 1LL) {
        for(int i = 0; i < N; i++)
            par[i] = i;
    }
    int root(int x) {
        if(par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)
            return;
        if(siz[rx] < siz[ry])
            swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int size(int x) { return siz[root(x)]; }
};

int main() {
    int N, Q;
    cin >> N >> Q;
    UnionFind uf(N);
    rep(i, Q) {
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0) {
            uf.unite(u, v);
        } else {
            cout << (uf.same(u, v) ? 1 : 0) << endl;
        }
    }
}

Measured memory_bytes: 4752
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long height = sc.nextLong();
        long width = sc.nextLong();
        if(height == 1 || width == 1){
            System.out.println(1);
        }else if(height <= 2 || width <= 2){
            System.out.println(width*height/2);
        }else if(height%2 != 0 && width%2 != 0){
            System.out.println(width*height/2+1);
        }else{
            System.out.println(width*height/2);
        }
    }
}

Measured memory_bytes: 23892
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const int MOD = 1e9+7;

int main(){
    int N, M;
    while(cin >> N >> M,N|M){
        vector<int> score(M);
        vector<vector<int>> cood(M,vector<int>());
        for (int i = 0;i<M;i++){
            cin >> score[i];
            int k;cin >> k;
            for (int j = 0; j < k;j++){
                int a;
                cin >> a;
                a--;
                cood[i].push_back(a);
            }
        }
        
        vector<pair<int,int>> minscore(N),maxscore(N);
        for (int i = 0;i<N;i++){
            minscore[i].second = i+1;
            maxscore[i].second = i + 1;
        }
        for (int i = 0; i < M; i++)
        {
            for (auto c : cood[i])
            {
                if (cood[i].size() == 1)
                {
                    minscore[c].first += score[i];
                    maxscore[c].first += score[i];
                }
                else
                {
                    maxscore[c].first += score[i];
                }
            }
        }
            
        sort(minscore.begin(),minscore.end());
        sort(maxscore.rbegin(),maxscore.rend());
        int res = -1;
        for (int i = 0; i < N; i++)
        {
            int ma = maxscore[i].first;
            int mi = minscore[0].first;
            if (minscore[0].second == maxscore[i].second)
                mi = minscore[1].first;
            res = max(ma - mi + 1, res);
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3708
#include<cstdio>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
main()
{
    int n;scanf("%d",&n);
    int a[n];
    int ma=0;
    rep(i,n)cin>>a[i];
    rep(i,n)
    {
        ma=max(ma,a[i]);
        if(a[i]<ma-1){puts("No");return 0;}
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 640
# 自分の回答
n = int(input())
array = list(map(int, input().split()))

array.sort(reverse=True)

a_sum = 0
b_sum = 0

for i in range(n):
    if i % 2 == 0:
        a_sum += array[i]
    else:
        b_sum += array[i]

print(a_sum - b_sum)


Measured memory_bytes: 3060