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

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {

            int a = int.Parse(Console.ReadLine());

            if (a == 3 || a == 5 || a == 7)

                Console.WriteLine("YES");

            else Console.WriteLine("NO");

            Console.ReadKey();









        }
    }
}

Measured memory_bytes: 13140
import java.util.*;

public class Main {
 public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   int i = sc.nextInt();
  if(i == 1) {
     System.out.println("Hello World");
  } else {
    int a = sc.nextInt(), b = sc.nextInt();
    System.out.println(a+b);
  }
 }
}

Measured memory_bytes: 23764
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
	int n;cin>>n;
	V<V<ll>> dp(n+1,V<ll>(n+1,inf));
	V<ll> s(n),sum(n+1,0);
	for(int i=0;i<n;i++)dp[i][i+1]=0;
	for(int i=0;i<n;i++){
		cin>>s[i];
		sum[i+1]=sum[i]+s[i];
		}
		for(int i=2;i<=n;i++){
			for(int l=0;l<=n-i;l++){
				int r=l+i;
				for(int k=l+1;k<r;k++){
					chmin(dp[l][r],dp[l][k]+dp[k][r]);
				}
				dp[l][r]+=(sum[r]-sum[l]);
			}
		}
		cout<<dp[0][n]<<endl;
}


Measured memory_bytes: 1536
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();
    
    for(int i = 0 ; i < k ; ++i){
      if(a >= b){
        b = b*2;
      }else{
        c = c*2;
      }
    }
    
    if(a < b && b < c){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    
  }
}

Measured memory_bytes: 35612
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,m;
int a[105];
int tot;
int cnt;
inline void read(int &x)
{
	int f;char c;
	for (f=1,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for (x=0;c<='9'&&c>='0';c=getchar()) x=x*10+(c&15);x*=f;
}
inline int mn(int _x,int _y)
{
	return _x<_y?_x:_y;
}
inline int mx(int _x,int _y)
{
	return _x>_y?_x:_y;
}
inline int ab(int _x)
{
	if(_x<0) return -_x;
	else return _x;
}
inline bool cmp(int p,int q)
{
	return p>q;
} 
int main()
{
	read(n);read(m);
	for(int i=1;i<=n;i++)
	{
		read(a[i]);
		tot+=a[i];
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=m;i++)
	{
		if(tot>4*m*a[i]) 
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}




Measured memory_bytes: 256
s=input()
x,y,l=0,5,len(s)
for _ in range(10**5):
  if x>=l-7:
    if x==l-7 and s[x:l]=='dreamer':
      print('YES')
    elif x==l-6 and s[x:l]=='eraser':
      print('YES')
    elif x==l-5 and (s[x:l]=='dream' or s[x:l]=='erase'):
      print('YES')
    else:
      print('NO')
    exit()
    
  if s[x:y]=='erase':
    x=y+1 if s[y]=='r' else y
    y=x+5
  elif s[x:y]=='dream':
    x=y if s[y:y+3]=='era' else (y+2 if s[y:y+2]=='er' else y) 
    y=x+5
  else:
    print('NO')
    exit()

Measured memory_bytes: 3188
N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(N)]
ans3 = 0
for i in range(2 ** 3):
    ans2 = 0
    xyzSum = []
    ans = [0 for _ in range(N)]
    for l in range(3):
        if (i >> l) & 1 == 0:
            for q in range(N):
                ans[q] += xyz[q][l]
        else:
            a = [-xyz[i][l] for i in range(N)]
            for q in range(N):
                ans[q] -= xyz[q][l]
    ans.sort()
    for q in range(M):
            ans2 += ans[-q-1]
    if ans2 > ans3:
        ans3 = ans2
print(ans3)


Measured memory_bytes: 3444
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_117
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] tx = ReadInts();
            double t = tx[0];
            double x = tx[1];
            Console.WriteLine(t / x);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 1000000000
#define MAX_N 100005
using namespace std;

int main(){
    int n,m;
    int c[21],dp[21][50001];
    
    cin>>n>>m;
    rep(i,0,m)cin>>c[i];
    
    rep(i,0,m+1)rep(j,0,n+1)dp[i][j]=INF;
    rep(i,0,m+1)dp[i][0]=0;
    
    rep(i,0,m){
        rep(j,0,n+1){
            if(j<c[i]) dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=min(dp[i][j],dp[i+1][j-c[i]]+1);
        }
    }
    /*
    rep(i,0,m+1){
        rep(j,0,n+1){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    */
    
    cout<<dp[m][n]<<endl;
    return 0;
}

Measured memory_bytes: 7200
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct data{int k; int *s; int p;} data;

int main(void){
    int n, m, i, j, k, n_2, tmp, count, ans = 0;
    scanf("%d %d", &n, &m);
    n_2 = pow(2, n);
    data d[m];
    for(i = 0; i < m; ++i){
        scanf("%d", &d[i].k);
        d[i].s = (int *)malloc(d[i].k * sizeof(int));
        for(j = 0; j < d[i].k; ++j){
            scanf("%d", &(d[i].s)[j]);
        }
    }
    for(i = 0; i < m; ++i){
        scanf("%d", &d[i].p);
    }
    for(i = 0; i < n_2; ++i){
        for(j = 0; j < m; ++j){
            for(k = 0, count = 0; k < d[j].k; ++k){
                tmp = (i >> (d[j].s[k] - 1)) % 2;
                if(tmp == 1){count++;}
            }
            if(count % 2 != d[j].p){break;}
        }
        if(j == m){ans++;}
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N := readInt()
	H := readInt()
	a := make([]int, N)
	b := make([]int, N)
	var maxa int
	for i := range a {
		a[i] = readInt()
		b[i] = readInt()
		if maxa < a[i] {
			maxa = a[i]
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(b)))
	var ans int64
	for i := 0; 0 < H && i < N && maxa < b[i]; i++ {
		H -= b[i]
		ans++
	}
	if 0 < H {
		ans += int64(H / maxa)
		if H%maxa != 0 {
			ans++
		}
	}
	println(ans)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>v(n);
  for(int i=0;i<n;i++)cin>>v.at(i);
  sort(v.begin(),v.end());
  double a=v.at(0);
  for(int i=0;i<n-1;i++)a=(a+v.at(i+1))/2;
  cout<<a<<endl;
}

Measured memory_bytes: 256
// 最小全域木 ( プリム法 )
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

static const int MAX = 100;
static const int INFTY = (1 <<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim()
{
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for(int i = 0; i < n; i++)
    {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    // 初期値の設定
    d[0] = 0;

    while(1)
    {
        minv = INFTY;
        // 次に移動するべき頂点
        u = -1;

        for(int i = 0; i < n; i++)
        {
            if( minv > d[i] && color[i] != BLACK )
            {
                // 未訪問の頂点の中で, 最小のコストを持つ辺を探索する
                u = i;
                minv = d[i];
            }
        }

        if( u == -1 )
        {
            // 最初全域木が完成した
            break;
        }

        color[u] = BLACK;

        for(int v = 0; v < n; v++)
        {
            if( color[v] != BLACK && M[u][v] != INFTY )
            {
                // u → v の辺の中で, 最小コストの辺のコストを記録する
                if( d[v] > M[u][v] )
                {
                    // コストの記録
                    d[v] = M[u][v];
                    // 頂点 v の親を記録する
                    p[v] = u;
                    // 訪問状態の記録
                    color[v] = GRAY;
                }
            }
        }
    }

    int sum = 0;

    for(int i = 0; i < n; i++)
    {
        if( p[i] != -1 )
        {
            // 最小コストの辺の和を求める
            sum += M[i][p[i]];
        }
    }

    return sum;
}

int main(void)
{

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            int e;

            // 隣接行列の設定
            cin >> e;

            M[i][j] = ( e == -1 ) ? INFTY : e;
        }
    }

    // 結果の表示
    cout << prim() << endl;

    return 0;

}



Measured memory_bytes: 3140
#include <stdio.h>

int main(void)
{
	int num[5], k, i, j;

	for (i = 0; i < 5; i++) {
		scanf("%d", &num[i]);
	}

	scanf("%d", &k);

	for (i = 0; i < 4; i++) {
		for (j = i; j < 5; ++j) {
			//printf("%d - %d = %d\n", num[j], num[i], (num[j] - num[i]));
			if ((num[j] - num[i]) > k) {
				printf(":(");
				return 0;
			}
		}
	}

	printf("Yay!");

	return 0;
}

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

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<pair<long long, long long>> task;
    for (int i = 0; i < n; ++i) {
        long long a, b;
        cin >> a >> b;
        task.emplace_back(b, a);
    }
    sort(task.begin(), task.end());
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += task[i].second;
        if (sum > task[i].first) {
            cout << "No" << "\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";
    return 0;
}


Measured memory_bytes: 6384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, P;
	cin >> N >> P;
	while (N != 0) {
		vi S(N);
		int cur = P;
		int ind = 0;
		while (true) {
			if (cur == 0) {
				cur += S[ind];
				S[ind] = 0;
			}
			else {
				S[ind]++;
				cur--;
				if (cur == 0 && S[ind] == P) {
					cout << ind << endl;
					break;
				}
			}
			ind++;
			ind %= N;
		}
		cin >> N >> P;
	}
	return 0;
}



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

int prime(int A,int B){
  int ret=0;
  for(int i=2;i<=10;i++){
    if((A%i==0)&&(B%i==0)){
      ret=i;
    }
  }
  return ret;
}

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  int factor=0;
  bool ans=true;
  while(ans){
    factor = prime(A,B);
    if(factor){
      A/=factor;
      B/=factor;
      if(C%factor==0)
        C/=factor;
      else
        ans=false;
    }
    else
      break;
  }
  if(ans)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i = A; i <= B; i++) {
    int s = i % 10;
    int t = (i / 10) % 10;
    int u = (i / 100) % 10;
    int v = (i / 1000) % 10;
    int w = (i / 10000) % 10;
    if (s == w && t == v) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static Dictionary<int,int> dic = new Dictionary<int,int>();
    static void Main(string[] args) {
        var N = int.Parse(Console.ReadLine());
        
        for(int i = 1;i <= N;i++){
            Factor(i);
        }
        var ans = 1L;
        foreach(KeyValuePair<int,int> item in dic) {
            ans *= (item.Value+1)%1000000007;
            ans %= 1000000007;
            }
Console.WriteLine(ans);
     }
     
     
     static void Factor(int N){
         //var org   = N;
         for(int i = 2;i <= (int)Math.Sqrt(N);i++){
             if(N%i == 0){
                 var count = 0;
                 while(N%i == 0){
                     count++;
                     N /= i;
                 }
                 //ディクショナリー登録
                 if(dic.ContainsKey(i)){
                     dic[i] += count;
                 }else{
                     dic.Add(i,count);
                 }
             }
         }
         
         //残りの素数を登録
         if(N > 1){
             //ディクショナリー登録
             if(dic.ContainsKey(N)){
                 dic[N] += 1;
             }else{
                 dic.Add(N,1);
             }
         }
 
     }
     
}


Measured memory_bytes: 13140
import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val S = sc.next()
    val map = mutableMapOf<Char,Int>()
    for (c in S)
        map[c] = (map[c] ?: 0) +1

    var ans = 1L
    for (v in map.values) {//aabbbc ={a,a, }*{b,b,b, }*{c, }
        ans *= v+1
        ans %= 1000000007L
    }
    ans--
    println(ans)
}

Measured memory_bytes: 35000
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
int N,M,Q;

typedef pair<int, int>P;

int main() {
	cin >> N;
	vector<P>pairs;
	rep(i, N) {
		pair<int,int> a;
		cin >> a.first >> a.second;
		pairs.push_back(a);
	}
	sort(pairs.begin(), pairs.end());
	rep(i, N) {
		cout << pairs[i].first << " " << pairs[i].second << endl;
	}
	return 0;
}





Measured memory_bytes: 3880
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    a = N // K
    if K % 2 == 0:
        if N%K >= K//2:
            b = a + 1
        else:
            b = a
        print(a**3+b**3)
    else:
        print(a**3)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
<?php

$input = explode(' ', trim(fgets(STDIN)));
$k = (int)$input[0];
$a = (int)$input[1];
$b = (int)$input[2];

if ($b < 2 || $b <= $a + 2 || $a > $k-1 || $k <= 2) {
	echo $k + 1;
	exit();
}

$k -= ($a + 1);
$bis = $b;
if ($k > 1) {
	$exchange_count = floor($k / 2);
	$bis += (int)$exchange_count * ($b - $a);
}
if ($k % 2 === 1) {
	$bis += 1;
}
echo $bis;

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    int n;cin >> n;
    string s;cin >> s;
    int ans = 0;
    int r = n-1;
    for (int i = 0; i < r; i++) {
        if(s[i] == 'W'){
            while(r > i && s[r] == 'W'){
                r--;
            }
            if(s[r] == 'R'){
                ans++;
                swap(s[r], s[i]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s1 = scanner.next();
		String s2 = scanner.next();
		String s3 = scanner.next();

		String S1 = (s1.substring(0, 1)).toUpperCase();
		String S2 = (s2.substring(0, 1)).toUpperCase();
		String S3 = (s3.substring(0, 1)).toUpperCase();

		System.out.println(S1 + S2 + S3);
	}

}

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

using namespace std;

int n, cnt[4];
string in, t[4] = {"AC","WA","TLE","RE"};

int main()
{
    cin >> n;
    for(int i = 0; i<n; i++)
    {
        cin >> in;
        for(int j = 0; j<4; j++)
            if(in==t[j])
                cnt[j]++;
    }
    for(int i = 0; i<4; i++)
        cout << t[i] << " x " << cnt[i] << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void creatVec(vector<size_t> &vec, int size);
int main() {
    size_t fruit{}, choosen{}, sum{};
    cin >> fruit >> choosen;
    vector<size_t> prices{};
    creatVec(prices, fruit);
    sort(prices.begin(), prices.end());
    for (size_t i{}; i < choosen; i++) sum += prices[i];
    cout << sum;
}
void creatVec(vector<size_t> &vec, int size) {
    for (int i{}; i < size; i++) {
        int in{};
        cin >> in;
        vec.push_back(in);
    }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
typedef long long LL;
const LL maxn=109,Maxn=1e7+9,inf=0x3f3f3f3f;
const LL dx[]={0,-1,0,1,0},dy[]={0,0,1,0,-1};
inline LL Read(){
    LL x(0),f(1); char c=getchar();
    while(c<'0' || c>'9'){
        if(c=='-') f=-1; c=getchar();
    }
    while(c>='0' && c<='9'){
        x=(x<<3)+(x<<1)+c-'0'; c=getchar();
    }return x*f;
}
LL n,K,ans;
LL a[maxn];
std::priority_queue<LL,std::vector<LL>,std::greater<LL> >que1,que2;
inline void Clear(){
	while(que1.size()) que1.pop();
	while(que2.size()) que2.pop();
}
int main(){
	n=Read(); K=Read();
	for(LL i=1;i<=n;++i) a[i]=Read();
	if(K>n){
				LL sum(0);
				for(LL i=1;i<=n;++i) que1.push(a[i]),sum+=a[i];
				LL tmp(K-n);
				while(tmp--&&que1.size()){
					if(que1.top()>0) break;
					sum-=que1.top(); que1.pop();
				}
			    ans=std::max(ans,sum);
		
	}
	LL up1(std::min(n,K));
	for(LL qu=1;qu<=up1;++qu){
//		printf("%lld\n",qu);
		LL chu(up1-qu);
		for(LL L=0;L<=qu;++L){
			LL R(qu-L);
			if(L+R<=n){
			    LL up2(std::min(chu,qu));
				for(LL ll=0;ll<=up2;++ll){
			        Clear();
			        LL sum(0);
				    for(LL i=1;i<=L;++i){
				    	que1.push(a[i]),sum+=a[i];
					}
				    for(LL i=n-R+1;i<=n;++i){
				    	que2.push(a[i]),sum+=a[i];
					}
				    
					LL lt(ll);
					LL rt(up2-lt);
					
					while(lt-- && que1.size()){
						if(que1.top()>0) break;
						sum-=que1.top(); que1.pop();
					}
					while(rt-- && que2.size()){
						if(que2.top()>0) break;
						sum-=que2.top(); que2.pop();
					}
					ans=std::max(ans,sum);
				}
			}else break;
		}
	}
	printf("%lld\n",ans);
}/*
6 7
-6 -100 50 -2 -5 -3
*/

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <vector>

#define rep2(i, b, n) for(int i=b; i < n; ++i)
#define repm(i, b, n) for(int i=b; i > n; --i)
#define rep(i, n) rep2(i, 0, n)
#define sz(v) v.size()
#define pb(e) push_back(e)
#define mp(x, y) make_pair(x, y)
#define fst first
#define scd second
#define X first
#define Y second
#define MEMSET(x, n) memset(x, n, sizeof(x))
#define MEMZERO(x) MEMSET(x, 0)
#define URU(y) (!(y % 4) && y % 100 || !(y % 400))
#define PI 3.1415926535897932384626433
#define ToRadian(r) ((r)/180.0*PI)
#define ToDegree(r) ((r)*180.0/PI)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main ( void )
{
	int n, m;
	
	while ( cin >> n >> m, n | m )
	{
		vector<int> *v = new vector<int>[n];
		
		for ( int i = 0, a, b; i < m; ++i )
		{
			cin >> a >> b;
			v[a-1].pb( b-1 );
			if ( a != 1 )
				v[b-1].pb( a-1 );
		}
		
		set<int> s;
		
		for ( int i = 0; i < sz( v[0] ); ++i )
		{
			s.insert( v[0][i] );
			
			for ( int j = 0, t = v[0][i]; j < sz( v[t] ); ++j )
			{
				s.insert( v[t][j] );
			}
		}
		
		cout << sz( s ) << endl;
		
		delete [] v;
	}
	
	return 0;
}

Measured memory_bytes: 1372
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

ll H,W;
ll dx[] = {-1,0,1,0};
ll dy[] = {0,1,0,-1};

bool inRange(ll x,ll y){
    return 0<=x && 0<=y && x<W && y<H;
}

void solve() {
    cin >> H >> W;
    vstr s(H);
    rep(i,H){
        cin >> s[i];
    }

    bool isIsolated;
    rep(i,H){
        rep(j,W){
            if(s[i][j]=='#'){
                isIsolated = true;
                rep(k,4){
                    ll y = i+dy[k];
                    ll x = j+dx[k];
                    if(inRange(x,y)){
                        if(s[y][x]=='#'){
                            isIsolated = false;
                        }
                    }
                }
            }
            if(isIsolated){
                print("No");
                return;
            }
        }
    }
    print("Yes");
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3540
N = int(input())
ans = "Yes"
x = 0
y = 0
t = 0
for i in range(N):
    t_i,x_i,y_i = map(int,input().split())
    x_i = abs(x_i-x)
    y_i = abs(y_i-x)
    t_i = abs(t_i-t)
    
    if x_i+y_i <= t_i and (x_i+y_i-t_i)%2 == 0:
        continue
    else:
        ans = "No"

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MAX 2e5+1
int n;
vector<int >values(MAX);
vector<vector<int> >graph(MAX);
vector<int>result;
vector<int>answers(MAX);
void dfs(int u,int parent)
{
    int position  = lower_bound(result.begin(),result.end(),values[u])-result.begin();
    int deletable = INT_MIN;

    if(position==result.size())
        result.push_back(values[u]);
    else
    {
        deletable        = result[position];
        result[position] = values[u];
    }
    answers[u]=result.size();

    for(int i=0;i<graph[u].size();i++)
        if(graph[u][i]!=parent)
            dfs(graph[u][i],u);
    if(deletable==INT_MIN)
        result.pop_back();
    else
        result[position]=deletable;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>values[i];
    for(int i=1;i<n;i++)
    {
        int u,v;
        cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    dfs(1,-1);
    for(int i=1;i<=n;i++)
        cout<<answers[i]<<endl;
    return 0;
}


Measured memory_bytes: 30056
from functools import reduce

if __name__ == "__main__":
    n = int(input())
    t = [int(x) for x in input().split()]
    m = int(input())
    improvements = []
    for i in range(m):
        drink = list(map(int, input().split()))
        tmp = t[drink[0] - 1]
        t[drink[0] - 1] = drink[1]
        improvements.append(reduce(lambda x, y: x + y, t))
        t[drink[0] - 1] = tmp
    for el in improvements:
        print(el)

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = LLONG_MAX/4;
const int n_max = 1e5+10;

void print(vector<bool> &ani){
    int n = ani.size();
    rep(i,n)cerr << ani[i] << " ";
    cerr << endl;
    // cerr << ani << endl;
}

int main(){
    ll n; cin >> n;
    string s;cin >> s;
    // 0が羊，1が狼
    vector<bool> ani(n+2);
    bool ok = false;
    rep(i,2){
        rep(j,2){
            ani[0] = i;
            ani[1] = j;
            // debug(i);
            // debug(j);
            rep(k,n){
                if(s[k] == 'o'){
                    if(ani[k+1] == 0){
                        ani[k+2] = ani[k];
                    }
                    else ani[k+2] = !ani[k];
                }
                else{
                    if(ani[k+1] == 0){
                        ani[k+2] = !ani[k];
                    }
                    else ani[k+2] = ani[k];
                }
                // debug(ani[k])
            }
            print(ani);
            debug(ani[n]);
            debug(ani[n+1]);
            debug(i);
            debug(j);
            debug(ani[n] == i);
            debug(ani[n+1] == j);   
            if(ani[n] == i && ani[n+1] == j){
                ok = true;
                goto tobreak;
            }
        }
    }
    tobreak:
    string res;
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    else{
        rep(i,n){
            if(ani[i+1])res += "W";
            else res += "S";
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 768
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans


def nibu(x,n,r):
    ll = 1
    rr = r
    while True:
        mid = (ll+rr)//2
        
        if rr == mid:
            return ll
        
        if cou(x,mid) <= n:
            rr = mid
        else:
            ll = mid+1

def cou(x,le):
    co = 0
    for i in range(len(x)):
        if le != 0:
            co += -(-x[i]//le) - 1
    return co


n,k = m()

a = l()

left = 0

right = 10**9


aaa = nibu(a,k,right)
print(aaa)


Measured memory_bytes: 104372
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

class BOneClue {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int k, x;
        cin >> k >> x;
        int min_index = x - k;
        int max_index = k + x;
        for (int i = min_index + 1; i < max_index; ++i) {
            cout << i << ((i != max_index - 1) ? " " : "\n");
        }
    }
};


int main() {
    BOneClue solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N; cin >> N;

    if(N < 1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }

}

Measured memory_bytes: 256
#ABC129B - Balance
N = int(input())
W = list(map(int,input().split()))
half = sum(W)/2
count = 0
for i in range(N):
    count += W[i]
    if count >= half:
        a = count
        b = count - W[i]
        break
print(min(abs((sum(W)-a)-a),abs((sum(W)-b)-b)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()


vector<int> par(100010);
vector<int> fam(100010,0);
vector<int> oth(100010,0);


int root(int x){
    return par.at(x) == x ? x : par.at(x) = root(par.at(x)); 
}

bool same(int x,int y){
    return root(x) == root(y);
}

void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x == y) return;
    par.at(x) = y;
}

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<pii> data(m);
    rep(i,n){
        par.at(i) = i;
    }
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        data.at(i).first = a;
        data.at(i).second = b;
        unite(a,b);
    }
    rep(i,n){
        fam.at(root(i))++;
    }
    rep(i,n){
        fam.at(i) = fam.at(root(i));
    }
    rep(i,m){
        int a = data.at(i).first;
        int b = data.at(i).second;
        fam.at(a)--;
        fam.at(b)--;
    }
    rep(i,k){
        int c,d;
        cin >> c >> d;
        c--;d--;
        if(same(c,d)){
            fam.at(c)--;
            fam.at(d)--;
        }
    }
    rep(i,n){
        cout << fam.at(i)-1 << " ";
    }
}

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

using namespace std;

const int MOD = 998244353;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> D(N), cnt(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> D[i];
    cnt[D[i]]++;
  }
  if (D[0] != 0) {
    cout << 0 << '\n';
    return 0;
  }
  int res = 1;
  for (int i = 1; i < N; i++) {
    res = 1LL * res * cnt[D[i] - 1] % MOD;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1024
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var numsS = new int[n + 1];
            var nums = Array.ConvertAll(Console.ReadLine().TrimEnd().Split(), int.Parse);
            nums.CopyTo(numsS, 0);
            Console.ReadLine();
            var numsT = Array.ConvertAll(Console.ReadLine().TrimEnd().Split(), int.Parse);
            int ans = 0;

            for (int i = 0; i < numsT.Length; i++)
            {
                numsS[n] = numsT[i];
                var j = 0;
                while (numsS[j] != numsT[i])
                {
                    j++;
                }
                if (n != j) ans++;
                
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 6272
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int ans=1,key[256],id[5];
string s[5];
int main()
{
	key['a']=1;
	key['b']=2;
	key['c']=3;
	for(int i=1;i<=3;++i)
		cin>>s[i];
	while(1)
	{
		int k=key[s[ans][id[ans]++]];
		//cout<<k<<endl;
		//cout<<ans<<' '<<id[ans]<<endl;
		if(id[ans]>s[ans].size())break;
		ans=k;
	}
	cout<<char('A'+ans-1)<<endl;

}

Measured memory_bytes: 256
N=int(input())
result='Yes'

plan=[[0,0,0]]

for _ in range(N):
    plan.append(list(map(int,input().split())))

for i in range(1,N+1):
    t_sp=plan[i][0]-plan[i-1][0]
    dis=abs(plan[i][1]-plan[i-1][1])+abs(plan[i][2]-plan[i-1][2])

    if dis>t_sp or (dis-t_sp)%2==1:
        result='No'
        break

print(result)


Measured memory_bytes: 27300
#include <bits/stdc++.h> 
using namespace std; 
int main() 
{
	float s, a, b, c;
	cin>>s;
	a = s/3;
	s-=a;
	b = s/2;
	c = s-b;
	cout<<fixed<<setprecision(6)<<(a*b*c)<<endl;
	return 0;
}

Measured memory_bytes: 3744
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i,a,b) for(register int i=(a);i<=(b);i++)
#define down(i,a,b) for(register int i=(a);i>=(b);i--)
#define mem(x,y) memset(x,(y),sizeof x)
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d",&a)
#define scl(a) scanf("%lld",&a)
#define scs(a) scanf("%s",a)
#define pr(a,b) printf("%d%c",a,b)
#define prl(a,b) printf("%lld%c",a,b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(),v.end()
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

typedef pair<ll,ll> pii;
typedef map<int,int> mii;
typedef vector<int> V;

template<typename T>
T gcd(T a,T b) {
	return !b?a:gcd(b,a%b);
}

inline int read() {
	int input=0,v=1;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')v=-1,c=getchar();
	while(c>='0'&&c<='9')input=input*10+c-'0',c=getchar();
	return v*input;
}

int a[10],k;
int main() {
	up(i,1,5)sc(a[i]);
	sc(k);
	
	int gg=0;
	up(i,1,5)up(o,i+1,5)if(a[o]-a[i]>k)gg++;

	if(gg)printf(":(");
	else printf("Yay!");

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int K = sc.nextInt();
      
      // 出力
      for(int i = 0; i < K; i++){
        System.out.print("ACL");
      }
    }
    

}

Measured memory_bytes: 35716
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math


def get_int():
    return int(stdin.readline().strip())


def get_tuple():
    return map(int, stdin.readline().split())


def get_list():
    return list(map(int, stdin.readline().split()))

ls = get_list()
print(ls.index(0)+1)

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

typedef pair<int, int> p;
typedef long long ll;

const int mod = 1000000007;
const int inf = 1000000007;

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
from collections import defaultdict

def DD(arg): return defaultdict(arg)
INF = float('inf')

N,M = list(map(int,input().split()))
graph = {i:[] for i in range(N)}
for _ in range(M):
  a,b = list(map(int,input().split()))
  graph[a-1].append(b-1)
p = [None for i in range(N)]
def detect_cycle(graph):
  N = len(graph)
  Q = [i for i in range(N)]
  
  cycle = []
  while Q:
    state = [-1 for i in range(N)]
    FLAG = 0
    s = Q.pop()
    if p[s] != None: continue
    p[s] = -1
    q = [s]
    while q:
      flag = 0
      x = q.pop()
      if x < 0:
        state[~x] = 0
        continue
      q.append(~x)
      for y in graph[x]:
        state[x] = 1
        if state[y] == 0: continue
        elif state[y] == -1:
          p[y] = x
          q.append(y)
        else:
          p[y] = x
          now = x
          while now != y:
            cycle.append(now)
            now = p[now]
          cycle.append(y)
          flag = 1
          break
      if flag:
        FLAG = 1
        break
    if FLAG:
      break
  return cycle

def squeeze(l):
  check = [0 for i in range(N)]
  for i in l:
    check[i] = 1
  global graph
  edges = []
  subgraph = {k:[] for k in l}
  data = DD(lambda:DD(int))
  i = 0
  for k in l:
    for y in graph[k]:
      if check[y]:
        subgraph[k].append(y)
        edges.append([0,k,y])
        data[k][y] = i
        i += 1
  graph = subgraph
  s = l[0]
  i = data[p[s]][s]
  edges[i][0] = 1
  now = p[s]
  heiro = [s]
  while now != s:
    heiro.append(now)
    i = data[p[now]][now]
    edges[i][0] = 1
    now = p[now]
  if len(heiro)==len(edges):
    print(len(heiro))
    for x in heiro:
      print(x+1)
    exit()
  else:
    for b,k,y in edges:
      if not b:
        p[y] = k
        now = p[y]
        heiro = [y]
        while now != y:
          heiro.append(now)
          now = p[now]
        squeeze(heiro)

c = detect_cycle(graph)
if not c:
  print(-1)
else:
  squeeze(c)

Measured memory_bytes: 75392
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int num = 0;
		for(int x=0; x<=Math.min(k, s); x++){
			for(int y=0; y<=k; y++){
				if(0<=s-x-y && s-x-y<=k)num++;
			}
		}
		System.out.println(num);
	}
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    ll n, k;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));

    ll ub = 1e18, lb = -1e18;
    while (ub - lb > 1) {
        ll mid = (ub + lb) / 2;
        auto is_smaller = [&] {
            ll cnt = 0;
            rep(i, n) {
                if (a[i] >= 0) {
                    ll l = -1, r = n;
                    while (r - l > 1) {
                        ll o = (l + r) / 2;
                        if (a[i] * a[o] < mid) {
                            l = o;
                        } else {
                            r = o;
                        }
                        // debug(l);
                        // debug(r);
                        // debug(o);
                    }
                    cnt += r;
                } else {
                    ll l = -1, r = n;
                    while (r - l > 1) {
                        ll o = (l + r) / 2;
                        if (a[i] * a[o] < mid) {
                            r = o;
                        } else {
                            l = o;
                        }
                        // debug(l);
                        // debug(r);
                        // debug(o);
                    }
                    cnt += n - r;
                }

                if (a[i] * a[i] < mid) cnt--;
            }
            cnt /= 2;
            return cnt < k;
        };

        // debug(mid);
        if (is_smaller()) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    cout << lb << endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int m,k,i;
	cin >> m >> k;
	if(k>=(1<<m)){
		cout << "-1" << endl;
		return 0;
	}
	if(m==0){
		cout << "0 0" << endl;
		return 0;
	}else if(m==1){
		if(k==0){
			cout << "0 0 1 1" << endl;
		}else if(k==1){
			cout << "-1" << endl;
		}
		return 0;
	}
	cout << k;
	for(i=0; i<(1<<m); ++i){
		if(i==k){
			continue;
		}
		cout << " " << i;
	}
	cout << " " << k;
	for(i=((1<<m)-1); i>=0; --i){
		if(i==k){
			continue;
		}
		cout << " " << i;
	}
	cout << endl;
	return 0;
}


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


void paint(int id, map<int, vector<int> > &odd_child, map<int, vector<int> > &even_child, std::vector<int> &res){


    bool color = res.at(id);


    if(odd_child.count(id)){//idは自分のid

        for(const int child : odd_child[id]){
            if(res.at(child) == -1){

                res.at(child) = !color;
                paint(child, odd_child, even_child, res);
            }else{
                continue;
            }

        }
    }
    if(even_child.count(id)){//idは自分のid
        for(const int child : even_child[id]){
            if(res.at(child) == -1){
                res.at(child) = color;
                paint(child, odd_child, even_child, res);
            }else{
                continue;
            }
        }
    }
}

int main(){
    int N;
    cin >> N;
    std::vector<int> u(N - 1);
    std::vector<int> v(N - 1);
    std::vector<int> w(N - 1);
    std::vector<int> res(N + 1, -1);
    for(int i=0; i < N-1; i++){
        cin >> u.at(i);
        cin >> v.at(i);
        cin >> w.at(i);
    }
    std::map<int, std::vector<int>> odd_child;
    std::map<int, std::vector<int>> even_child;
    for(int i=0; i < N - 1; i++){
        if(w.at(i)%2 == 0){
            even_child[u.at(i)].push_back(v.at(i));
            even_child[v.at(i)].push_back(u.at(i));
        }else{
            odd_child[u.at(i)].push_back(v.at(i));
            odd_child[v.at(i)].push_back(u.at(i));
        }
    }
    res.at(1) = true;
    // cout << "odd" << endl;
    // for (const auto& dic : odd_child){
    //     std::cout << dic.first << " => "  << endl;
    //     for(const auto &val : dic.second){
    //         cout << " "<< val << endl;
    //     }
    // }
    // cout << "even" << endl;
    // for (const auto& dic : even_child){
    //     std::cout << dic.first << " => "  << endl;
    //     for(const auto &val : dic.second){
    //         cout << " "<< val << endl;
    //     }
    // }
    paint(1, odd_child, even_child, res);

    for(int i=1; i < N + 1; i++){
        cout << res.at(i) << endl;
    }

    return 0;


}


Measured memory_bytes: 22528
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,l,s=0,d=210; cin>>n>>l;
  s=(l+l+n-1)*n/2;
  for(int i=l;i<l+n;i++) d=min(d,abs(i));
  cout<<(s<0?s+d:s-d);
}

Measured memory_bytes: 3680