akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int X, Y, Z;
signed main() {
    cin >> X >> Y >> Z;
    swap(X, Y);
    swap(X, Z);
    cout << X << " " << Y << " " << Z << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
const long long int MOD = 998244353;
#define pb push_back
#define mp make_pair
#define fill(a)  memset(a, 0, sizeof (a))
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 2e5+5;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector< iii > viii;

ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// bool isl = binary_search(x.begin(), x.end(), 5);
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 1e7;
int binsearch(int lo, int hi){
    while(lo<hi){
        int mid=(lo+hi)/2;
        if((mid))   // check(mid)
            hi=mid;
        else
            lo=mid+1;
    }
    return lo;
}
int power(int x,int y){
    int res=1;
    while(y>0){
      if(y&1) res=((res*x));

      y/=2;
      x=((x*x));
    }
    return res;
}

int main(){
    FAST  
    int x;
    cin>>x;
    for(int i=1;i<=2000;i++){
        if(i==x){
            cout<< 10 - i/200; break;
        }
    }
    return 0;
}


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

 using namespace std;
 typedef long long ll;

 int main() {
   int N;
   cin >> N;
   vector<int> a(N + 1);
   for (int i = 1; i <= N; i++) cin >> a.at(i);

   int ans = 0;

   for (int i = 1; i <= N; i++) {
     if (a.at(a.at(i)) == i) ans++;
   }

   cout << ans / 2 << endl;
 }


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 100000;

#define FILENAME ""
               
int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //	freopen(FILENAME ".in", "r", stdin);
    //	freopen(FILENAME ".out", "w", stdout);
   	ll n, k;
   	cin >> n >> k;
   	ll ans = n - 2;
   	ll temp = n - 3;
   	while (temp > 0) {
   		ans += max(temp, (ll) 0);
   		temp--; 	
	}
	if (k > ans) {
		cout << -1;
		re 0;		 	
	}
	ll need = ans - k;
	vector <pair<ll, ll>> answ;
	answ.pb(mp(1, 2));
	for (int i = 3; i <= n; i++) {
		answ.pb(mp(2, i));
	}	
	for (int i = 3; i <= n; i++) {
	 	for (int j = i + 1; j <= n; j++) {
	 	 	if (need > 0) {
	 	 	 	answ.pb(mp(i, j));
	 	 	 	need--;
	 	 	}
	 	 	else {
	 	 	 	break;
	 	 	}
		}
	}
	for (int i = 3; i <= n; i++) {
	 	if (need > 0) {
	 	 	answ.pb(mp(1, i));
	 	 	--need;
	 	}
	 	else {
	 	 	break;
	 	}
	}
	cout << answ.size() << endl;
	for (int i = 0; i < answ.size(); i++) {
	 	cout << answ[i].fi << " " << answ[i].se << endl;
	}
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
int main(){
  string s,t;
  cin >> s;
  cin >> t;
  int count=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!=t.at(i))count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3912
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
typedef mp::cpp_int BigInt;
typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b) {
        std::swap(a, b);
    }
    
    return b ? gcd(b, a % b) : a;
}

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

BigInt gcdBigInt(BigInt a, BigInt b)
{
    if (a < b) {
        std::swap(a, b);
    }
    
    return b ? gcdBigInt(b, a % b) : a;
}

BigInt lcmBigInt(BigInt a, BigInt b)
{
    return a * b / gcdBigInt(a, b);
}

const ll MOD = 1000000007; // 1e9 + 7

ll modinv(ll a, ll modVal) {
    ll b = modVal, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; std::swap(a, b);
        u -= t * v; std::swap(u, v);
    }
    u %= modVal; 
    if (u < 0) u += modVal;
    return u;
}

ll solve(const std::vector<ll> a)
{
    const ll n = a.size();
    ll m = a[0];
    std::vector<ll> lcmArray;
/*
    for (int i = 1; i < n; i++) {
        ll last_m = m;
        m = lcm(m, a[i]);
        if ((m / last_m < 1)||(m % last_m != 0)) {
            lcmArray.push_back(last_m);
            m = a[i];
        }
    }
    lcmArray.push_back(m);

    BigInt mBigInt = lcmArray[0];
    for (int i = 1; i < lcmArray.size(); i++) {
        mBigInt = lcmBigInt(mBigInt, lcmArray[i]);
    }
    */

    BigInt mBigInt = a[0];
    for (int i = 1; i < n; i++) {
        mBigInt = lcmBigInt(mBigInt, a[i]);
    }


    m = static_cast<ll>(mBigInt % MOD);

    ll sum = 0;
    for (int i = 0; i < n; i++) {
        //sum += static_cast<ll>((mBigInt / a[i]) % MOD);
        sum += m * modinv(a[i], MOD);
        sum %= MOD;
    }

    return sum;
}

int main(int argc, char *argv[])
{
    ll n;
    std::vector<ll> a;

    std::cin >> n;

    a.resize(n);

    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    ll ans = solve(a);

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 696
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

# H時Mふん
A, B, H, M = getNM()
minu = H * 60 + M
angh = minu / 2
angm = M * 6
anglepre = abs(angh - angm)
angle = min(360 - anglepre, anglepre)
ans = (A ** 2) + (B ** 2) - (2 * A * B * math.cos(math.radians(angle)))
print(math.sqrt(ans))

Measured memory_bytes: 68452
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>

#define ll long long

using namespace std;

int main()
{
    vector<int> arr(3);
    for (auto& v : arr) {
        cin >> v;
    }
    sort(arr.begin(), arr.end(), greater<int>());
    cout << arr[0] * 10 + arr[1] + arr[2] << endl;
    return 0;
}



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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var a = ReadIntArray();
            int x1 = a[0];
            int y1 = a[1];
            int x2 = a[2];
            int y2 = a[3];
            int dirx = x2 - x1;
            int diry = y2 - y1;
            int x3 = x2 - diry;
            int y3 = y2 + dirx;
            int x4 = x3 - dirx;
            int y4 = y3 - diry;
            Console.WriteLine($"{x3} {y3} {x4} {y4}");
        }

//ここからテンプレート
        //1行に1入力
        private static string ReadString() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(ReadString()); }
        private static long ReadLong() { return long.Parse(ReadString()); }
        private static double ReadDouble() { return double.Parse(ReadString()); }
        //1行に複数入力(配列で取得)
        private static string[] ReadStringArray() { return ReadString().Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries); }
        private static int[] ReadIntArray() { return ReadStringArray().Select(int.Parse).ToArray(); }
        private static long[] ReadLongArray() { return ReadStringArray().Select(long.Parse).ToArray(); }
        private static double[] ReadDoubleArray() { return ReadStringArray().Select(double.Parse).ToArray(); }


    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define i64 unsigned long long
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(ll x, ll y, ll mod){
    ll ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}
void kill()
{
    cout << "No" << endl;
    exit(0);
}

int main() {
    sonic();
    string s;
    R s;
    if(s.length()%2)kill();
    rep(i, s.length()/2){
        if((s[i*2] != 'h')||(s[i*2+1] != 'i'))kill();
    }
    co("Yes");
}


Measured memory_bytes: 3608
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] k = new Integer[m];
        List<Integer[]> sList = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            k[i] = Integer.parseInt(sc.next());
            Integer[] s = new Integer[k[i]];
            for (int j = 0; j < k[i]; j++) {
                s[j] = Integer.parseInt(sc.next()) - 1;
            }
            sList.add(s);
        }
        Integer[] p = new Integer[m];
        for (int i = 0; i < m; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        // 主処理
        List<List<Integer>> combinationList = combinationList(n);
        int result = 0;

        for (List<Integer> list : combinationList) {
            boolean isAllOn = true;
            for (int i = 0; i < m; i++) {
                int onCount = 0;
                for (int j = 0; j < k[i]; j++) {
                    if (list.contains(sList.get(i)[j])) {
                        onCount++;
                    }
                }
                if (onCount % 2 != p[i]) {
                    isAllOn = false;
                    break;
                }
            }
            if (isAllOn) {
                result++;
            } else {
                continue;
            }
        }

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

    public static List<List<Integer>> combinationList(int n) {
        List<List<Integer>> combinationList = new ArrayList<>();
        for (int i = 0; i < Math.pow(2, n); i++) {
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < n; j++) {
                if ((1 & i >> j) == 1) {
                    list.add(j);
                }
            }
            combinationList.add(list);
        }
        return combinationList;
    }
}


Measured memory_bytes: 36612
use proconio::input;
use std::cmp::{max, min};

const MAX_L: usize = 100_000;
const BASE_SIZE: usize = 1 << 10;

fn main() {
    input! {
        n: usize,
        vw: [(usize, usize); n],
        q: usize,
        vl: [(usize, usize); q],
    }
    let dp = make_dp(&vw);
    for vlq in vl {
        println!("{}", calc(&vw, vlq.0 - 1, vlq.1, &dp));
    }
}

fn make_dp(vw: &Vec<(usize, usize)>) -> Vec<Vec<usize>> {
    let mut dp = Vec::<Vec<usize>>::new();

    dp.push(
        (0..=MAX_L)
        .map(|i| if i < vw[0].1 { 0 } else { vw[0].0 })
        .collect()
    );

    let n = min(vw.len(), BASE_SIZE - 1);
    for c in 1..n {
        let p = (c - 1) / 2;
        dp.push(
            (0..=MAX_L)
            .map(|i| {
                let w = vw[c].1;
                let v = if i < w { 0 } else { dp[p][i - w] + vw[c].0 };
                max(dp[p][i], v)
            })
            .collect()
        );
    }

    dp
}

fn calc(
    vw: &Vec<(usize, usize)>,
    u: usize, 
    l: usize,
    dp: &Vec<Vec<usize>>
) -> u32 {
    if u < dp.len() {
        dp[u][l] as u32
    } else {
        let p = (u - 1) / 2;
        let w = vw[u].1;
        let pv1 = calc(vw, p, l, dp);
        let pv2 = if l < w { 0 } else { calc(vw, p, l - w, dp) + vw[u].0 as u32 };
        max(pv1, pv2)
    }
}


Measured memory_bytes: 814816
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    s = list(sys.stdin.readlines())
    new_s=sorted(s)
    char_list=[]
    dic ={}
    for i in s:
        i = i.replace('\n','')
        new_s=sorted(i)
        new_s = ''.join(new_s)
        char_list.append(new_s)
        if new_s not in dic:
            dic[new_s] = 1
        else:
            dic[new_s] += 1
    # c = 0
    # for j in range(n):
    #     if char_list[j] in char_list[j+1:]:
    #         c+=char_list[j+1:].count(char_list[j])
    # print(c)

    def combinations_count(n, r):
        if n - r < 0:
            return 0
        else:
            return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

    # print(char_list)
    # print(dic)
    c=0
    # print(dic.values())
    for i in dic.values():
        c+=combinations_count(i, 2)
    print(c)

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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

const int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy[] = {-1, -1, 0, 1, 1, 1, 0, -1};
bool inRange(int x, int y, int w, int h) {
	return 0 <= x && x < w && 0 <= y && y < h;
}
int H, W;
void update(vector< vector<int> >& m, queue<P>& q, int x, int y) {
	assert( m[y][x] == 0 );
	REP(i, 8) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (inRange(nx, ny, W, H) && m[ny][nx] > 0) {
			if ( --m[ny][nx] == 0 ) {
				q.push(P(nx, ny));
			}
		}
	}
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> H >> W;
	vector< vector<int> > m(H, vector<int>(W, 0));
	REP(y, H) {
		string s; cin >> s;
		REP(x, W) {
			if (isdigit(s[x])) {
				m[y][x] = s[x]-'0';
			}
			else {
				m[y][x] = 0;
			}
		}
	}
	int ans = -1;
	queue<P> Q;
	REP(y, H) {
		REP(x, W) {
			if (m[y][x] == 0) {
				Q.push(P(x, y));
			}
		}
	}
	while (1) {
		if ( Q.empty() ) break;
		queue<P> q;
		while ( !Q.empty() ) {
			P p = Q.front(); Q.pop();
			int x = p.first, y = p.second;
			update(m, q, x, y);
//			cout << x << " " << y << endl;
		}
//		cout << endl;
		Q = q;
		++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 7156
#include <bits/stdc++.h>
#define ll long long
#define MAXN 100010

using namespace std;

int a[MAXN];

int main() {
	int n, m;
	scanf("%d", &n);
	double ans;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a + 1, a + n + 1);
	ans = a[1];
//	cout << ans << endl;
	for (int i = 2; i <= n; i++) {
//		cout << ans + a[i] << endl;
		ans = (double)(ans + a[i]) / 2;
//		cout << ans << endl;
	}
	printf("%.6lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
# abc133_b.py
N, M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
Xsub = [X[i+1]-X[i] for i in range(M-1)]
Xsub.sort(reverse=True)
print(sum(Xsub[N-1:]))


Measured memory_bytes: 56744
{-# LANGUAGE BangPatterns #-}

import           Data.List
import qualified Data.Set  as S

main = do
  [x, y, z] <- map read.words <$> getLine
  print $ solve x y z

solve :: Int -> Int -> Int -> Int
solve x y z = go S.empty 0 $ sort [x, y, z]
  where
    go s !acc xyz@[x, y, z]
      | any odd xyz = acc
      | S.member xyz s = -1
      | otherwise = go (S.insert xyz s) (acc+1) xyz'
      where
        x' = div (y + z) 2
        y' = div (z + x) 2
        z' = div (x + y) 2
        xyz' = sort[x', y', z']

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
int main()
{
	dhoom;
	string s;
	cin >> s;
	int cnt = 0;
	for(int i = 0 ; i < 4 ;i++){
		if(s[i] == '+')
			cnt++;
		else
			cnt--;
	}
	cout << cnt <<endl;
	return 0;
} 



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
class UnionFindTree {
private:
    vector<int> parent;
    vector<int> count;
public:
    UnionFindTree(int n) : parent(n), count(n, 1) {
        for(int i = 0; i < n; i++) parent[i] = i;
    }
    int get_root(const int x) {
        if (parent[x] == x) return x;
        return parent[x] = get_root(parent[x]);
    }
    void unite(const int x, const int y) {
        int rx = get_root(x), ry = get_root(y);
        if (rx == ry) return;
        parent[rx] = ry;
        count[ry] += count[rx];
        count[rx] = 0;
    }
    bool is_same_root(const int x, const int y) { return get_root(x) == get_root(y); }
    int get_size(const int x) { return count[get_root(x)]; }
    void print() {
        for(auto elm : parent) cout << elm << " ";
        cout << endl;
        for(auto elm : count) cout << elm << " ";
        cout << endl;
    }
};

int main(){
    int n, m; cin >> n >> m;
    vector<pair<int, pair<int, int>>> edge;
    map<int, vector<pair<int, int>>> cost;
    for (auto i = 0; i < m; i++) {
        int s, d, c; cin >> s >> d >> c; s--; d--;
        cost[c].emplace_back(s, d);
    }
    UnionFindTree tree(n); int64_t min_cost = 0;
    for (auto & vec : cost) {
        for (auto & elm : vec.second) {
            if (tree.is_same_root(elm.first, elm.second)) continue;
            tree.unite(elm.first, elm.second);
            edge.emplace_back(vec.first, elm);
            min_cost += vec.first;
        }
    }

    pair<int, int> ans;
    for (auto & a : edge) {
        UnionFindTree tmp(n); int64_t sum = 0;
        for (auto & vec : cost) {
            for (auto & elm : vec.second) {
                if (a.first == vec.first and elm == a.second) continue;
                if (tmp.is_same_root(elm.first, elm.second)) continue;
                tmp.unite(elm.first, elm.second);
                sum += vec.first;
            }
        }
        if(tmp.get_size(0) != n or sum > min_cost) ans.first++, ans.second += a.first;
    }

    cout << ans.first << " " << ans.second << endl;
    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

template<unsigned mod=998244353>struct fp {
   unsigned v;
   static unsigned get_mod(){return mod;}
   unsigned inv() const{
      int tmp,a=v,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0){x+=mod;} return x;
   }
   fp():v(0){}
   fp(ll x):v(x>=0?x%mod:mod+(x%mod)){}
   fp operator-()const{return fp(-v);}
   fp pow(ll t){fp res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;} return res;}
   fp& operator+=(const fp& x){if((v+=x.v)>=mod)v-=mod; return *this;}
   fp& operator-=(const fp& x){if((v+=mod-x.v)>=mod)v-=mod; return *this;}
   fp& operator*=(const fp& x){v=ll(v)*x.v%mod; return *this;}
   fp& operator/=(const fp& x){v=ll(v)*x.inv()%mod; return *this;}
   fp operator+(const fp& x)const{return fp(*this)+=x;}
   fp operator-(const fp& x)const{return fp(*this)-=x;}
   fp operator*(const fp& x)const{return fp(*this)*=x;}
   fp operator/(const fp& x)const{return fp(*this)/=x;}
   bool operator==(const fp& x)const{return v==x.v;}
   bool operator!=(const fp& x)const{return v!=x.v;}
}; using Fp=fp<>;

Fp dp[3010];

int main(){
   int n,s; cin>>n>>s;
   vector<int> a(n);
   rep(i,0,n)cin>>a[i];
   dp[s]=Fp(2).pow(n);
   rep(i,0,n){
      rep(j,a[i],s+1)dp[j-a[i]]+=dp[j]/2;
   }
   cout<<dp[0].v<<endl;
   return 0;
}

Measured memory_bytes: 3652
N = int(input())
A = []
B = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    if(i == 0):
        A.append(B[0])
        continue
    if(i == N-1):
        A.append(B[N-2])
        continue
    a = B[i-1]
    b = B[i]
    if(a < b):
        A.append(a)
    else:
        A.append(b)
for i in A:
    ans += i
print(ans)

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int main(){
	
	string str;cin >> str;
	ll k;cin >> k;k--;
	
	bool flag = false;
	char ans = '1';
	
	REP(i,str.size()){
		if(str[i] != '1'){
			flag = true;
			ans = str[i];
		}
		if(i == k)flag = true;
		if(flag)break;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
string a,b;
std::cin >> a>>b;
rep(i,3){
  if(a[i]==b[i])x++;
}
std::cout << x << '\n';
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        int a=0;
        int b=0;

        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        int m=scan.nextInt();
        if(n<=m){
            System.out.println("unsafe");
        }
        else {
            System.out.println("safe");
        }


    }


}



Measured memory_bytes: 35816
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    bool[] us;
    List<int>[] G;
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int H = int.Parse(str[1]);
        G = new List<int>[N+2*H];
        for(int i=0;i<G.Length;i++){
            G[i] = new List<int>();
        }
        int[] I = new int[2*H];
        int[] O = new int[2*H];
        for(int i=0;i<N;i++){
            str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            int d = int.Parse(str[3]);
            if(c == 0){
                G[a-1].Add(i+2*H);
                O[a-1]++;
            }
            else{
                G[c-1+H].Add(i+2*H);
                O[c-1+H]++;
            }
            if(d == 0){
                G[i+2*H].Add(b-1+H);
                I[b-1+H]++;
            }
            else{
                G[i+2*H].Add(d-1);
                I[d-1]++;
            }
        }
        bool ans = true;
        for(int i=0;i<H;i++){
            ans &= O[i] >= I[i];
        }
        for(int i=H;i<2*H;i++){
            ans &= O[i] <= I[i];
        }
        us = new bool[N+2*H];
        for(int i=0;i<H;i++){
            if(O[i] > I[i]){
                dfs(i);
            }
        }
        for(int i=2*H;i<2*H+N;i++){
            ans &= us[i];
        }
        if(ans){
            sb.Append("YES\n");
        }
        else{
            sb.Append("NO\n");
        }
    }
    void dfs(int v){
        if(us[v]){
            return;
        }
        us[v] = true;
        for(int i=0;i<G[v].Count;i++){
            int t = G[v][i];
            if(!us[t]){
                dfs(t);
            }
        }
    }
}

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

void comb(vector<vector<long long> > &vec){
  for(int i=0;i<vec.size();i++){
    vec[i][0]=1;
    vec[i][i]=1;
  }
  for(int i=1;i<vec.size();i++){
    for(int j=1;j<i;j++){
      vec[i][j]=vec[i-1][j-1]+vec[i-1][j];
    }
  }
}

int main(){
  long long n,ans=0;
  cin >> n;
  map<long long, int> mp,mpp;
  for(int i=1;i<=n;i++){
    long long tmp=i;
    for(int j=2;j<=i;j++){
      while(tmp%j==0){
        mp[j]++;
        tmp/=j;
      }
    }
  }

  vector<long long> v;
  for(int i=1;i<=n;i++){
    if(mp[i]>0){
      v.push_back(mp[i]);
      // cout << i << ' ' << mp[i] << endl;
    }
  }
  sort(v.begin(), v.end());

  long long n2=0,n4=0,n14=0,n24=0,n74=0;
  for(int i=0;i<v.size();i++){
    if(n2==0 and v[i]>=2){
      n2=v.size()-i;
    }
    if(n4==0 and v[i]>=4){
      n4=v.size()-i;
    }
    if(n14==0 and v[i]>=14){
      n14=v.size()-i;
    }
    if(n24==0 and v[i]>=24){
      n24=v.size()-i;
    }
    if(n74==0 and v[i]>=74){
      n74=v.size()-i;
    }
  }

  ans+=n74;

// cout << ans << endl;

  ans+=n14*max(0ll,n4-1);

// cout << ans << endl;

  long long N=n4,R=2;
  vector<vector<long long> > vec(N+1,vector<long long>(N+1,0));
  comb(vec);
  ans+=max(0ll,n2-2)*vec[N][R];
// cout << ans << endl;


  ans+=n24*max(0ll,n2-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int n,m[N][N];

int main(){
  int i,j,num,k,num1;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&num,&k);
    for(j=1;j<=n;j++)m[i][j]=0;
    for(j=1;j<=k;j++){
      scanf("%d",&num1);
      m[i][num1]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n-1;j++){
      printf("%d ",m[i][j]);
    }
    printf("%d\n",m[i][n]);
  }
  return 0;

}



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

int main( )
{
    string s, pre;
    int n, sig = 1;
    cin >> n >> pre;
    map<string, int> mp;
    mp[pre]++;
    for (int i = 1; i < n; i++)
    {
        cin >> s;
        if (mp[s] > 0)
        {
            sig = 0;
        }
        if (s[0] != pre[pre.size( ) - 1])
        {
            sig = 0;
        }
        mp[s]++;
        pre = s;
    }

    if (sig == 1)   cout << "Yes\n";
    else            cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
import sys
n = int(input())
a = list(map(int,input().split()))

s = 0
while 0 not in a:
    for i,elem in enumerate(a):
        if elem % 2 != 0:
            print(s)
            sys.exit()
        else:
            a[i] /= 2

    s += 1

print(s)


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  int n;
  n = inputValue();

  int p[n];
  inputArray(p, n);

  int i;
  int ret = 0;
  repd(i,1,n-1){
      if((p[i-1] > p[i] && p[i] > p[i+1]) || (p[i-1] < p[i] && p[i] < p[i+1])){ret++;}
  }
  cout << ret;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    int num[] = new int[4];
    Scanner scanner = new Scanner(System.in);
    for (int i = 0; i < 4; i++) {
      num[i] = Integer.parseInt(scanner.next());
    }
    scanner.close();
    long max = (long) num[0] * (long) num[2];
    long tmp = 0;

    if (num[0] > 0 && num[2] > 0) {
      max = (long) num[1] * (long) num[3];
    } else if (num[1] < 0 && num[3] < 0) {
      max = (long) num[0] * (long) num[2];
    } else {
      for (int j = 0; j < 2; j++) {
        for (int k = 2; k < 4; k++) {
          tmp = (long) num[j] * (long) num[k];
          if (max < tmp) {
            max = tmp;
          }
        }
      }
    }
    System.out.println(max);
  }
}

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

using namespace std;



int main()
{
    const long long mod = 1e9+7;

    long long n,m;
    cin>>n>>m;

    if(abs(n-m)>1){
        cout<<0<<endl;
        return 0;
    }

    long long nn = 1, mm = 1;
    bool f = (n==m);
    while(n){
        nn*=n;
        nn %= mod;
        n--;
    }

    while(m){
        mm*=m;
        mm %= mod;
        m--;
    }

    long long ans = mm*nn%mod;
    if(f){
        ans *= 2;
    }

    cout<<int(ans%mod)<<endl;

    return 0;
}

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

int h,w,n;
vector<string> s(50);

bool sim(void){
  int num = 0;
  for(int j=0;j<w;j++){
    for(int i=h-1;i>=0;i--){
      if(s[i][j] != '.'){
	num = 1;
	int d = 1;
	while(i+d<h && s[i+d][j] == '.'){swap(s[i+d][j],s[i+d-1][j]);d++;}
      }
    }
  }
  if(!num)return true;

  int u[50][50] = {0};

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j] != '.'){
	int d = 0;
	while(i+d<h && s[i][j] == s[i+d][j])d++;
	if(d>=n)for(int k=0;k<d;k++)u[i+k][j] = 1;

	d = 0;
	while(j+d<w && s[i][j] == s[i][j+d])d++;
	if(d>=n)for(int k=0;k<d;k++)u[i][j+k] = 1;
      }
    }
  }

  num = 0;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(u[i][j]){s[i][j] = '.'; num++;}
  if(!num)return false;

  return sim();
}

int main(){
  cin >> h >> w >> n;
  for(int i=0;i<h;i++)cin >> s[i];
  vector<string> tmp = s;

  bool f = false;
  for(int i=0;i<h;i++){
    for(int j=1;j<w;j++){
      if(s[i][j-1] != s[i][j]){
	swap(s[i][j-1],s[i][j]);
	f = sim();
	if(f)break;
	s = tmp;
      }
    }
    if(f)break;
  }

  if(f)cout << "YES\n";
  else cout << "NO\n";
}

Measured memory_bytes: 1212
import sys


N,M=map(int,input().split())
A=[sys.stdin.readline().strip() for _ in range(N)]
B=[sys.stdin.readline().strip() for _ in range(M)]

for i in range(N-M+1):
  for j in range(N-M+1):
    As=[x[i:i+M] for x in A[j:j+M]]
    if B==As:
      print('Yes')
      sys.exit()
print('No')

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG

int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}

int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}

void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}

void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}

void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}

void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}



int main() {
  long N;
  cin >> N;
  unsigned long long ans=0;
  for(long i=1;i<=N;i++){
    ans+=(N/i)*(N/i+1)*i/2;
  }
  cout << ans;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<math.h>
int main(void) {
	int i, n;
	float s,h;
	scanf("%d",&n);
	float j[n];
	for(i=0;i<n;i++) {
		scanf("%f",&j[i]);
		s = s + (1.0/j[i]); 
   }
	 h=1/s;
		printf("%f",h);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

long long LIS(const vector<long long> &v){
  long long n = v.size();
  long long DP[n];
  for(long long i = 0;i < n;i++)DP[i] = 1000000000000000007;
  for(long long i = 0;i < n;i++){
    *lower_bound(DP,DP+n,v[i]) = v[i];
  }
  return lower_bound(DP,DP+n,1000000000000000007)-DP;
}

signed main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  FOR(i,0,n)cin >> a[i];
  cout << LIS(a) << endl;
}


Measured memory_bytes: 4420
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    a=parseMap(split(readline()))
    b=parseMap(split(readline()))
    c=parseMap(split(readline()))
    ans=0
    for i in 1:n
        ans+=b[a[i]]
        if i>1 && a[i]==a[i-1]+1
            ans+=c[a[i-1]]
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 164992
while True:

    N = int(input())
    if N == 0:
        break

    ans = [0 for i in range(10)]
    for l in range(N):
        k = int(input())
        ans[k] += 1

    for i in range(10):
        if ans[i] == 0:
            print("-")
        else:
            for j in range(ans[i]):
                print("*",end="")
            print("")




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

int main(){
	long long int A,B,C;
	long long int sum;
	cin>>A>>B>>C;
	if(A%2==0||B%2==0||C%2==0){cout<<0<<endl;}
	else {
		if(A>=B&&A>=C){
			sum=B*C;
			cout<<sum<<endl;
		}
		else if(B>=A&&B>=C){
			sum=A*C;
			cout<<sum<<endl;
		}
		else if(C>=A&&C>=C){
			sum=A*B;
			cout<<sum<<endl;
		}
	} 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 998244353
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define pb push_back
#define M6 6000009
#define M5 300009
#define pi 3.14159265
ll power(ll x,ll n){
    ll ret=1;
    x%=M;
    while(n>0){
        if(n&1) ret=(ret*x)%M;
        x=(x*x)%M;
        n/=2;
    }
    return ret;
}
struct my_data{
    int x,y,z;
};
ll prime[M6],sp[M6];
void sieve(){
    for(int i=1;i<M6;i++) prime[i]=1;
    for(ll i=2;i*i<M6;i++){
        if(!prime[i]) continue;
        for(ll j=i*2;j<M6;j+=i) {
            prime[j]=0;
            if(sp[j]==0) sp[j]=i;
        }
    }
    for(int i=1;i<M6;i++) if(!sp[i]) sp[i]=i;
}
ll n,m,ar[M5];
int  main()
{   //ios_base::sync_with_stdio (0), cin.tie (0);
    sieve();
    //init();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll tc=1,t=1,flag,i,j,k,l,p,q,ans,x,y,r,a,b,c;
    //cin>>tc;
    while(tc--){
        cin>>n>>t>>a;
        t*=1000; a*=1000;
        y=1e9,ans=-1;
        for(i=1;i<=n;i++) {
            cin>>ar[i];
            if(abs((t-ar[i]*6)-a)<y){
                y=abs((t-ar[i]*6)-a);
                ans=i;
            }
        }
        cout<<ans;
    }   
    return 0;
} 


Measured memory_bytes: 94336
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}





int main(){
    int N; std::cin >> N;
    std::vector<int> A(N), B(N);
    for(int i(0); i < N; ++i) std::cin >> A[i] >> B[i];
    std::sort(std::begin(A), std::end(A));
    std::sort(std::begin(B), std::end(B));
    if(N % 2){
        std::cout << B[N/2] - A[N/2] + 1 << std::endl;
    }else{
        int a(A[N/2-1]+A[N/2]), b(B[N/2-1]+B[N/2]);
        std::cout << b-a + 1 << std::endl;
    }
    return 0;
}


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

int main() {
	int k, n;
	cin >> k >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int max = k - (a[n-1] - a[0]);
	for (int i = 0; i < n-1; i++) {
		if (max < a[i+1] - a[i]) {
			max = a[i+1] - a[i];
		}
	}

	int ans = k - max;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.io.*;
 
public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String[] cut = input.split(" ");
        int noOne = Integer.parseInt(cut[0]);
        int noTwo = Integer.parseInt(cut[1]);
        int noThree = Integer.parseInt(cut[2]);
        
        
        if(noOne > noTwo || noTwo > noThree) {
            if(noOne > noTwo){
                int temp = noOne;
                noOne = noTwo;
                noTwo = temp;
            }
            if(noTwo > noThree){
                int temp = noTwo;
                noTwo = noThree;
                noThree = temp;
            }
            if(noOne > noTwo){
                int temp = noOne;
                noOne = noTwo;
                noTwo = temp;
            }
        }
        System.out.println(noOne + " " + noTwo + " " + noThree);
        
    }
}


Measured memory_bytes: 24340
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct SCC{
    int V;
    vector<vector<int>> G, rG;
    vector<int> vs; // 帰りがけ順の並び
    vector<int> cmp; //属する強連結成分トポロジカル順序
    vector<bool> used;

    SCC(){}
    SCC(int n){
        V = n;
        G = vector<vector<int>>(n);
        rG = vector<vector<int>>(n);
    }

    void add_edge(int from, int to){
        G[from].push_back(to);
        rG[to].push_back(from);
    }

    void dfs(int v){
        used[v] = true;
        rep(i,G[v].size())if(!used[G[v][i]]) dfs(G[v][i]);
        vs.push_back(v);
    }

    void rdfs(int v, int k){
        used[v]=true;
        cmp[v]=k;
        rep(i,rG[v].size())if(!used[rG[v][i]]) rdfs(rG[v][i],k);
    }

    int scc(){
        used = vector<bool>(V,false);
        vs.clear();
        rep(i,V)if(!used[i]) dfs(i);

        used = vector<bool>(V,false);
        cmp = vector<int>(V);
        int num_scc = 0;
        for(int i=vs.size()-1; i>=0; --i)if(!used[vs[i]]) rdfs(vs[i],num_scc++);
        return num_scc;
    }
};

int main(){
    int n;
    while(scanf(" %d", &n),n){
        vector<double> p(n);
        SCC s(n);

        rep(i,n){
            scanf(" %lf", &p[i]);

            int m;
            scanf(" %d", &m);
            rep(j,m){
                int a;
                scanf(" %d", &a);
                --a;
                s.add_edge(i,a);
            }
        }

        int sz = s.scc();

        vector<vector<int>> cc(sz);
        vector<bool> have_inedge(sz,false);
        rep(i,n){
            cc[s.cmp[i]].pb(i);
            for(int e:s.G[i]){
                int v = s.cmp[e];
                if(s.cmp[i] != v) have_inedge[v] = true;
            }
        }

        double ans = 1;
        rep(i,sz)if(!have_inedge[i]){
            // グループ内の誰か一人が起きる
            double all_sleep = 1;
            for(int j:cc[i]) all_sleep *= p[j];
            ans *= (1 - all_sleep);
        }
        printf("%.10f\n", ans);
    }
    return 0;
}



Measured memory_bytes: 3356