akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define X first
#define Y second
#define R(i, n) for(i = 1; i <= n; i ++)

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 10;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {-1, 0, 1, 0};

int w, h, cnt = 0;
int dm[N][N], m[N][N];
bool visited[N][N];

void dfs(pii, int, int);
void countM(pii, int);

int main(void){
    for(vi a(5); cin >> h >> w >> a[4], h;){

        rep(y, h) rep(x, w) cin >> dm[y][x];
        
        int res = 0;
        
        R(a[0], 6){
            if(dm[0][0] == a[0]) continue;
            R(a[1], 6){
                if(a[0] == a[1]) continue;
                R(a[2], 6){
                    if(a[1] == a[2]) continue;
                    R(a[3], 6){
                        if(a[2] == a[3] || a[3] == a[4]) continue;
                        rep(y, h) rep(x, w) m[y][x] = dm[y][x];
                        rep(i, 5){
                            MEMSET(visited, false);
                            cnt = 0;
                            dfs(mp(0, 0), m[0][0], a[i]);
                        }
                        MEMSET(visited, false);
                        countM(mp(0, 0), m[0][0]);
                        res = max(res, cnt);
                    }
                }
            }
        }

        cout << res << endl;
    }
    
    return 0;
}

void dfs(pii p, int bc, int ac){
    if(p.X < 0 || w <= p.X ||
       p.Y < 0 || h <= p.Y)
        return;
    
    if(!visited[p.Y][p.X] && m[p.Y][p.X] == bc) m[p.Y][p.X] = ac;
    else return;

    visited[p.Y][p.X] = true;
    rep(i, 4) dfs(mp(p.X + dx[i], p.Y + dy[i]), bc, ac);
}

void countM(pii p, int c){
    if(p.X < 0 || w <= p.X ||
       p.Y < 0 || h <= p.Y)
        return;
    
    if(!visited[p.Y][p.X] && m[p.Y][p.X] == c) cnt ++;
    else return;

    visited[p.Y][p.X] = true;
    rep(i, 4) countM(mp(p.X + dx[i], p.Y + dy[i]), c);
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include "math.h"

using namespace std;

int main() {
    
    int n;
    int min_a = 1000000000+1, min_i=0;
    
    cin >> n;
    
    vector<int> a(n,0);
    vector<int> zeros(n, 0);
    
    for (int i=0; i<n; i++) {
        cin >> a[i];
        if (min_a > a[i]) {
            min_a = a[i];
            min_i = i;
        }
    }
    
    int count = n;
    
    while (count > 1) {
        
        for (int i=0; i<n; i++) {
            
            int this_min_i = min_i;
            
            if (zeros[i]==0 && i != this_min_i) {
                
                a[i] = a[i] % min_a;
                
                if (a[i] == 0) {
                    
                    zeros[i] = 1;
                    count = count - 1;
                    
                } else if (min_a > a[i]) {
                    
                    min_a = a[i];
                    min_i = i;
                    
                }
            }
        }
    }
    
    cout << min_a << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
char s[maxn];
int main()
{
	scanf("%s",s);
	int len=strlen(s),sum=0;
	for(int i=0;i<len;i++)
		sum=(sum+s[i]-'0')%9;
	puts(sum?"No":"Yes");
}

Measured memory_bytes: 3920
use proconio::input;
use std::cmp;

#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        M: usize,
        X: i64,
        CA: [(i64, [i64; M]); N],
    }

    let mut stack = Vec::new();
    //
    stack.push((0, 0, vec![0; M]));

    let mut ans = std::i64::MAX; // 1e5よりでかいので多分 ok
    while let Some((i, mut cost, score)) = stack.pop() {
        // 終了判定
        if score.iter().all(|&x| x >= X) {
            ans = cmp::min(ans, cost);
            continue;
        }

        if i >= N {
            continue;
        }

        // i + 1 番目の本を購入しない場合
        stack.push((i + 1, cost, score.clone()));

        // i + 1 番目の本を購入する場合
        let (c, A) = &CA[i];
        cost += c;
        let score_new: Vec<i64> = score.iter().zip(A.iter()).map(|(a, b)| a + b).collect();
        stack.push((i + 1, cost, score_new));
    }

    if ans == std::i64::MAX {
        ans = -1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2180
"use strict";

// 最大公約数その2（多入力対応）
const getGcd = array => {
  let len, a, b;
	
  len = array.length;
	a   = array[0];
	
  for (let i=1; i<len; i++) {
		b = array[i];
		a = gcdTwoNumbers(a, b);
	}

	return a;
}

function gcdTwoNumbers(x, y) {
  x = Math.abs(x);
  y = Math.abs(y);
  while(y) {
    let t = y;
    y = x % y;
    x = t;
  }
  return x;
}

//　組み合わせ 被りなし
const combineWithoutRepetitions = (comboOptions, comboLength) => {
  if (comboLength === 1) {
    return comboOptions.map(comboOption => [comboOption]);
  }

  // Init combinations array.
  const combos = [];

  // Eliminate characters one by one and concatenate them to
  // combinations of smaller lengths.
  comboOptions.forEach((currentOption, optionIndex) => {
    const smallerCombos = combineWithoutRepetitions(
      comboOptions.slice(optionIndex + 1),
      comboLength - 1
    );

    smallerCombos.forEach((smallerCombo) => {
      combos.push([currentOption].concat(smallerCombo));
    });
  });

  return combos;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const K = parseInt(arg[0].split(" ")[0]);
    
    let answer = 0;
    let A = [];
    
    for(let i=1; i<=K; i++) {
        A.push(i);
    }
    
    // 1種類の時
    for(let i=1; i<=K; i++) {
        answer += i;
    }
    
    // console.log("answer:" + answer)
    
    // 2種類の時
    const combos2 = combineWithoutRepetitions(A, 2);
    const N2 = combos2.length;
    
    for(let i=0; i<N2; i++) {
        answer += gcdTwoNumbers(combos2[i][0], combos2[i][1]) * 6;
    }
    
    // console.log("answer:" + answer)
    
    // 3種類の時
    const combos3 = combineWithoutRepetitions(A, 3);
    const N3 = combos3.length;
    
    for(let i=0; i<N3; i++) {
        answer += getGcd(combos3[i]) * 6;
    }
    
    // console.log("answer:" + answer)
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 194584
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        _n: usize, m: usize,
        lr: [(usize1, usize1); m]
    }

    let mut lv = lr.iter().map(|&(l,_)| l) .collect::<Vec<_>>();
    let mut rv = lr.iter().map(|&(_,r)| r) .collect::<Vec<_>>();
    lv.sort();
    rv.sort();
    if rv[0] >= lv[lv.len()-1] {
        println!("{}", rv[0] - lv[lv.len()-1] + 1);
    } else {
        println!("0");
    }
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i)  
#else
  #define DUMP(i)  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const int EPS = 1e-9;

string s;
bool check(int cnt){
  DUMP(s[cnt]);
  if(s[cnt] - '0' < 0 ||  s[cnt] - '0' > 9)return false;
  return true;
}

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char a,b,c,x,y,z;
  while(cin >> a >> b >> c >>  x >> y >> z){
    bool ans = false;
    if(a - z == 0 && b - y == 0 && c - x == 0) ans = true;
    
    if(ans)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

class Solution():
    def dp(self, pos, sign):
        if pos == self.n-1:
            if sign == 0:
                return +self.lst[pos]
            else:
                return -self.lst[pos]
        elif (pos, sign) in self.vis:
            return self.rcd[pos][sign]
        elif sign == 0:
            self.rcd[pos][sign] = max(self.dp(pos+1, 0) + self.lst[pos], self.dp(pos+1, 1) - self.lst[pos])
            self.vis.add((pos, sign))
            return self.rcd[pos][sign]
        else:
            self.rcd[pos][sign] = max(self.dp(pos+1, 0) - self.lst[pos], self.dp(pos+1, 1) + self.lst[pos])
            self.vis.add((pos, sign))
            return self.rcd[pos][sign]

    def run(self):
        self.n = int(input())
        self.lst = list(map(int, raw_input().split()))
        self.rcd = [[0, 0] for _ in range(self.n)]
        self.vis = set()
        print(self.dp(0, 0))

solution = Solution()
solution.run()


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

int main()
{
    string s, t;
    cin >> s >> t;

    for(int i = 0; i < s.size(); i++){
        cout << s[i];
        if(s.size() - t.size() == 1 && i == s.size() - 1){
            break;
        }else{
            cout << t[i];
        }
    }

    cout << endl;

    return 0;
}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#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 REPA(i,a) for(ll i=0;i<(ll)(a.size());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 COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n;
  cin >> n;
  vll d(n);
  REP(i, n) {
    cin >> d[i];
  }
  SORT(d);
  //COUTA(i, d);

  COUT(d[n/2] - d[n/2 - 1]);

}



int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*
6
9 1 4 4 6 7
*/


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int pat[5];
// B*A
// B**
// **A

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	int ret=0;
	FOR(i,N) {
		cin>>s;
		if(s[0]=='B' && s.back()=='A') pat[0]++;
		else if(s[0]=='B') pat[1]++;
		else if(s.back()=='A') pat[2]++;
		FOR(j,s.size()-1) if(s[j]=='A' && s[j+1]=='B') ret++;
	}
	
	while(pat[2]&&pat[0]) {
		pat[0]--;
		ret++;
	}
	while(pat[0]&&pat[1]) {
		pat[0]--;
		ret++;
	}
	ret+=min(pat[1],pat[2]);
	ret+=max(0,pat[0]-1);
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] ints = new int[n];
		for (int i=0; i<n; i++) {
			ints[i] = sc.nextInt();
		}

		int count = 0;
		for (int i=0; i<n; i++) {
			int minj = i;
			boolean flag = false;
			for (int j=i; j<n; j++) {
				if (ints[j] < ints[minj]) {
					minj = j;
					flag = true;
				}
			}
			if (flag==true) {
				int temp = ints[i];
				ints[i] = ints[minj];
				ints[minj] = temp;
				count++;
			}
		}

		for (int i=0; i<n; i++) {
			System.out.print(ints[i]);
			if (i!=n-1) {System.out.print(" ");}
		}
		System.out.println();
		System.out.println(count);
	}
}			


Measured memory_bytes: 26460
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int a, b;
	cin>>a>>b;
	for(int i=1;i<1250; i++){
		if(i*8/100 == a && i/10 == b){
			cout<<i<<endl;
			break;
		}
		if(i*8/100 > a || i/10 > b){
			cout<<-1<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int q = sc.nextInt();
        ArrayList<Point> li = new ArrayList<Point>();
        for(int i = 0; i < q; i++){
            li.add(new Point(sc.nextInt()-1,sc.nextInt()-1,sc.nextInt(),sc.nextInt()));
        }
        int[] arr = new int[n];
        arr[0] = 1;
        System.out.println(dfs(1,arr,li,n,m));
    }
    
    public static long dfs(int cnt, int[] arr, ArrayList<Point> li, int n, int max){
        long ret = 0;
        if(cnt == n){
            for(Point p : li){
                if(arr[p.b] - arr[p.a] == p.c){
                    ret += p.d;
                }
            }
            return ret;
        }
        for(int i = arr[cnt-1]; i <= max; i++){
            arr[cnt] = i;
            ret = Math.max(ret,dfs(cnt+1,arr,li,n,max));
        }
        return ret;
    }
}

class Point{
    int a,b,c,d;
    public Point(int a, int b, int c, int d){
        this.a = a;
        this.b = b;
        this.c = c;
        this.d = d;
    }
}


Measured memory_bytes: 30056
N = int(input())
chars = "Xabcdefghijklmnopqrstuvwxyz"
ans = ""
while True:
    la = N // 26
    sm = N % 26
    if sm == 0:
        sm = 26
        la -= 1
    ans += chars[sm]
    N = la
    if N < 1:
        break
print(ans[::-1])

Measured memory_bytes: 9112
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

ll N;
ll ans = -1;

int main() {
    cin >> N;
    vector<ll> res, res2;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.emplace_back(i);
            if (i != N / i) res.emplace_back(N / i);
        }
    }
    for (ll i = 1; i * i <= N - 1; ++i) {
        if ((N - 1) % i == 0) {
            //res2.emplace_back(i);
            ans++;
            if (i != (N - 1) / i) {
                //res2.emplace_back((N - 1) / i);
                ans++;
            }
        }
    }
    //REP(i, res.size()) {
    //    cout << res[i] << endl;
    //}

    //とりあえず全部わって余り求める
    REP(i, res.size()) {
        ll n = N;
        if (res[i] == 1) continue;
        while (n % res[i] == 0 && n >= res[i]) {
            n /= res[i];
        }
        if (n == 1) ans++;
        else if (n % res[i] == 1) ans++;
    }
    cout << ans << endl;
}


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


int main(){
  int a,b;
  cin>>a>>b;
  int c=a+b,d=a*b,e=a-b;
  cout<<max(max(c,d),e)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    char s[12],t[12];
    int a,b;
    char u[12];
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    
    if(strcmp(s,u) == 0) a--;
    else if(strcmp(t,u) == 0) b--;
    cout << a << " " << b << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
long long W;
const long long INF = 1e16;

long long dp[110][100100];
int main() {
    cin >> n >> W;
    vector<long long> w(n, 0);
    vector<int> v(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> w.at(i) >> v.at(i);
    }

    int Vmax = n*1000;
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= Vmax; ++j) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= Vmax; ++j) {
            dp[i+1][j+v.at(i)] = dp[i][j]+w.at(i);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }

    long long ans = 0;
    for(int j = 0; j <= Vmax; ++j) {
        if(dp[n][j] <= W) {
            ans = j;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 80128
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>


int main() {
	int n, k; std::cin >> n >> k;
	std::vector<int> jewels(n); for (auto& v : jewels) std::cin >> v;
	if (n + std::count_if(jewels.begin(), jewels.end(), [](const int i) { return i < 0; }) <= k) {
		std::cout << std::accumulate(jewels.begin(), jewels.end(), 0, [](const int acc, const int i) {return i < 0 ? acc : acc + i; }) << std::endl;
	}
	else {
		std::vector<int> taken;
		int max = 0;
		for (auto left = 0; left < n; ++left) {
			for (auto right = n - 1; left <= right; --right) {
				const auto rest = k - left - (n - 1 - right);
				if (rest < 0) continue;
				taken.clear();
				for (auto i = 0; i < left; ++i) {
					taken.push_back(jewels[i]);
				}
				for (auto i = right + 1; i < n; ++i) {
					taken.push_back(jewels[i]);
				}
			std:sort(taken.begin(), taken.end());
				int minus{ 0 };
				for (auto i = 0; i < taken.size() && i < rest; ++i) {
					if (taken[i] < 0) minus += taken[i];
				}
				max = std::max(max, std::accumulate(taken.begin(), taken.end(), 0) - minus);
			}
		}
		std::cout << max << std::endl;
	}
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

#define UQ(v) v.erase(unique(ALL(v)), v.end())

int n;
vector<int> v;

int main() {
	cin >> n;
	inc(i, n) {
		int d;
		cin >> d;
		v.PB(d);
	}
	sort(ALL(v));
	UQ(v);
	
	cout << v.size() << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define LONGMAX 1e18
#define MOD 1000000007
#define mp make_pair
#define endl "\n"
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define fr(a,n) for(int i=a;i<n;i++)

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

	string s,t;
	cin>>s>>t;

	int n,m;
	n=s.length();
	m=t.length();

	int dp[n+1][m+1];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i-1]==t[j-1])
				dp[i][j]=max((1+dp[i-1][j-1]),max(dp[i-1][j],dp[i][j-1]));
			else
				dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
		}
	}
	string ans="";

	int i=n,j=m;



	while(i and j)
	{
		if(dp[i][j-1]==dp[i][j])
			j--;
		else if(dp[i-1][j]==dp[i][j]){
			i--;}
		else
		{
			ans=s[i-1] + ans;
			i--,j--;
			// cout<<ans<<endl;
		}


	}
		cout<<ans;

}	



Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  a += b;c += d;
  if(a > c){
    cout << "Left";
  } else if(a < c) {
    cout << "Right";
  } else{
    cout << "Balanced";
  }
  cout << endl;
}

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

const int N = 1e5+7;
int a[N];

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

    int n;
    cin>>n;

    int mn = n, mx=0;
    for (int i=1; i<=n; i++) {
        cin>>a[i];
        mx = max(a[i], mx);
        mn = min(a[i], mn);
    }

    if (mx-mn>1) {
        cout<<"No"<<endl;
        return 0;
    }
    else if (mx-mn == 1) {
        int kom = 0, beshi = 0;
        for (int i=1; i<=n; i++)
            if (a[i] == mn)     kom++;
            else                beshi++;

        int unq = kom;
        int prs = beshi/2;

//        cout<<unq<<" "<<prs<<endl;

        if (unq < mx && mx <= unq+prs)    cout<<"Yes"<<endl;
        else                            cout<<"No"<<endl;
    }
    else {
        if (mn == n-1)  cout<<"Yes"<<endl;
        else {
            if (mn <= n/2)  cout<<"Yes"<<endl;
            else            cout<<"No"<<endl;
        }
    }
//    main();
}



Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int max = Math.max(a, b);
        int min = Math.min(a, b);
        if (max + min - n <= 0) {
            System.out.println(min + " " + 0);
            return;
        }
        System.out.println(min + " " + (max + min - n));
    }
}


Measured memory_bytes: 21972
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		long[] A = new long[N];
		HashMap<Long, Integer> map = new HashMap<Long, Integer>();
		for(int i=0;i<N;i++) {
			A[i] = sc.nextLong();
			if (map.containsKey(A[i])) map.put(A[i],1+map.get(A[i]));
			else map.put(A[i],1);
 		}
		Arrays.sort(A);
		int ret = 0;
		for(int i=N-1;i>=0;i--) {
			if(map.get(A[i])==0) continue;
			map.put(A[i],map.get(A[i])-1);
			//一番左のbitを１にしたのを２倍
			long k2 = 2*Long.highestOneBit(A[i]);
			long diff = k2-A[i];
			if(map.containsKey(diff) && map.get(diff)>0) {
				map.put(diff,map.get(diff)-1);
				ret++;
			}
		}
		System.out.println(ret);
	}
}


Measured memory_bytes: 105084
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n),b(n) ;
	for(int i=0;i<n;i++) cin >> a.at(i) >> b.at(i) ;
	ll ans = 0 ;
	for(int i=n-1;i>=0;i--){
		a.at(i) += ans ;
		ans += (b.at(i)-a.at(i)%b.at(i))%b.at(i) ;
	}
	cout << ans << endl ;
}


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

int main() {
    int n;
    cin >> n;
    
    int tmp = n / 1.08;
    int r = 0;
    for (int i = tmp-1; i <= tmp+1; i++) {
        int j = i * 1.08;
        if (j == n) r = i;
    }

    if (r == 0) {
        cout << ":(" << endl;
    } else {
        cout << r << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;


int main(void)
{
	int N, K; cin >> N >> K;
	int ans = 1;

	while (ans <= K && N != 0) {
		ans *= 2;
		N--;
	}
	cout << ans + N * K << endl;

	return 0;
}

Measured memory_bytes: 256
local k, s = io.read("*n", "*n")
local ret = (s + 2) * (s + 1) // 2
if k + 1 <= s then
  local a = s - (k + 1)
  ret = ret - 3 * (a + 2) * (a + 1) // 2
end
if 2 * (k + 1) <= s then
  local a = s - 2 * (k + 1)
  ret = ret + 3 * (a + 2) * (a + 1) // 2
end
if 3 * (k + 1) <= s then
  local a = s - 3 * (k + 1)
  ret = ret - (a + 2) * (a + 1) // 2
end
print(ret)


Measured memory_bytes: 888
#include<iostream>
using namespace std;
const int N=100;

int selectionSort(int A[],int n){
  int count=0;
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(A[j]<A[minj])
	minj=j;
    }
    swap(A[i],A[minj]);
    if(i!=minj){
      count++;
    }
  }
  return count;
}

int main(){
  int num;
  int A[N];
  int count;
  
  cin>>num;

  for(int i=0;i<num;i++){
    cin>>A[i];
  }

  count=selectionSort(A,num);

  int i=0;
  for(;i<num-1;i++){
    cout<<A[i]<<' ';
  }
  cout<<A[i]<<endl;

  cout<<count<<endl;

  return 0;

}




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

int main(){
    int N;
    vector<int> bingocard(9);
    for( int i = 0; i < 9; i++ ) cin >> bingocard[i];
    cin >> N; 
    vector<int> nums(N);
    for( int i = 0; i < N; i++ ){
        cin >> nums[i];
    }

    vector<int> matchcheck(9);
    for( int i = 0; i < N; i++ ){
        for( int j = 0; j < 9; j++ ){
            if( bingocard[j] == nums[i] ){
                matchcheck[j] = 1;
            }
        }
    }

    if( matchcheck[0] == 1 && matchcheck[1] == 1 && matchcheck[2] == 1 ){
        cout << "Yes" << endl;
        return 0;
    }
    if( matchcheck[3] == 1 && matchcheck[4] == 1 && matchcheck[5] == 1 ){
        cout << "Yes" << endl;
        return 0;
    }
    if( matchcheck[6] == 1 && matchcheck[7] == 1 && matchcheck[8] == 1 ){
        cout << "Yes" << endl;
        return 0;
    }
    if( matchcheck[0] == 1 && matchcheck[3] == 1 && matchcheck[6] == 1 ){
        cout << "Yes" << endl;
        return 0;
    }
    if( matchcheck[1] == 1 && matchcheck[4] == 1 && matchcheck[7] == 1 ){
        cout << "Yes" << endl;
        return 0;
    }
    if( matchcheck[2] == 1 && matchcheck[5] == 1 && matchcheck[8] == 1 ){
        cout << "Yes" << endl;
        return 0;
    }
    if( matchcheck[0] == 1 && matchcheck[4] == 1 && matchcheck[8] == 1 ){
        cout << "Yes" << endl;
        return 0;
    }
    if( matchcheck[2] == 1 && matchcheck[4] == 1 && matchcheck[6] == 1 ){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int MAXN = 1e5 + 1;
const long long MOD = 1e9 + 7;
int n, k;
vi adj[MAXN];
long long dp[MAXN];

long long permu(int x, int y) {
	if (x < y) return 0;
	long long r = 1;
	for (int i = 0; i < y; i++)
		r = (r * (x - i)) % MOD;
	return r;
}

void dfs(int u, int p) {
	dp[u] = 1;
	for (int v : adj[u]) if (v != p) {
		dfs(v, u);
		dp[u] = (dp[u] * dp[v]) % MOD;
	}

	int x = k - 2;
	int y = adj[u].size() - 1;
	if (!p) {
		++x;
		++y;
	}
	dp[u] = (permu(x, y) * dp[u]) % MOD;
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);

	scanf("%d%d", &n, &k);
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	dfs(1, 0);
	//for (int i = 1; i <= n; i++) printf("%lld ", dp[i]); printf("\n");
	long long ans = (dp[1] * k) % MOD;
	printf("%lld\n", ans);
}


Measured memory_bytes: 11136
#include <cstdio>
#include <vector>

using int64 = long long;

int main() {
  int n;
  scanf("%d", &n);
  std::vector<int> s;
  int64 ret = 0;
  for (int i = 0; i < n; ++i) {
    int64 d, c;
    scanf("%lld%lld", &d, &c);
    for (; c > 1; c >>= 1) {
      if (c & 1) s.push_back(d);
      if (d + d > 9) ret += c / 2 * 2;
      else ret += c / 2;
      if (d != 0 && d != 9) d = d * 2 % 9;
    }
    s.push_back(d);
  }
  while (s.size() > 1) {
    int a = s.back(); s.pop_back();
    int b = s.back(); s.pop_back();
    int c = a + b;
    if (c > 9) ret += 2, c = c % 10 + c / 10;
    else ++ret;
    s.push_back(c);
  }
  printf("%lld\n", ret);
  return 0;
}


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

const int MOD = 1000000007;
const int N = 1005;

void pp(int &x, int y) {
	x += y;
	if (x >= MOD) x-= MOD;
}

int n, m;
long long k;

struct Mat {
	int v[3][3];
	Mat() {memset(v, 0, sizeof(v));}
	Mat operator * (const Mat& c) const {
		Mat ans;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					pp(ans.v[i][j], 1LL * v[i][k] * c.v[k][j] % MOD);
				}
			}
		}
		return ans;
	}
};

Mat pow_mod(Mat x, long long k) {
	Mat ans;
	for (int i = 0; i < 3; i++) ans.v[i][i] = 1;
	while (k) {
		if (k&1) ans = ans * x;
		x = x * x;
		k >>= 1;
	}
	return ans;
}

int tmp[3], ans[3];
int solve(int cc, int ca, int cb) {
	Mat A;
	A.v[0][0] = cc; A.v[1][1] = cc; A.v[1][2] = cb; A.v[2][2] = ca;
	if (k <= 1) return 1;
	A = pow_mod(A, k - 2);
	tmp[0] = cc; tmp[1] = cb; tmp[2] = ca;
	for (int i = 0; i < 3; i++) {
		ans[i] = 0;
		for (int j = 0; j < 3; j++)
			pp(ans[i], 1LL * A.v[i][j] * tmp[j] % MOD);
	}
	if (!ca) return ans[0];
	return (ans[0] - ans[1] + MOD) % MOD;
}

char str[N][N];

int main() {
	scanf("%d%d%lld", &n, &m, &k);
	for (int i = 0; i < n; i++) scanf("%s", str[i]);
	int a = 0, bh = 0, bw = 0, ch = 0, cw = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			a += (str[i][j] == '#');
	for (int i = 0; i < m; i++)
		bh += (str[0][i] == str[n - 1][i] && str[0][i] == '#');
	for (int i = 0; i < n; i++)
		bw += (str[i][0] == str[i][m - 1] && str[i][0] == '#');
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m - 1; j++)
			cw += (str[i][j] == str[i][j + 1] && str[i][j] == '#');
	for (int i = 0; i < m; i++)
		for (int j = 0; j < n - 1; j++)
			ch += (str[j][i] == str[j + 1][i] && str[j][i] == '#');
	if (bh && bw) {
		printf("1\n");
		return 0;
	}
	if (bh) {
		swap(bh, bw);
		swap(ch, cw);
	}
	printf("%d\n", solve(a, bw, cw));
	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
int main(){
  int sum,n,i,a,k;
  while(1){
    sum=0;
    scanf("%d",&a);
  if(a==0){
    return 0;
  }
  for(i=0;i<9;i++){
    scanf("%d",&n);
    sum+=n; 
}
  
  k=a-sum;
  printf("%d\n",k);
  }
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> roots(m);
    rep(i, m) {
        cin >> roots[i].first >> roots[i].second;
    }

    vector<vector<int>> conects(n+1);
    for (pair<int, int> root : roots) {
        conects[root.first].push_back(root.second);
        conects[root.second].push_back(root.first);
    }
    vector<int> cnts(n+1, -1);
    vector<int> befores(n+1, -1);
    queue<int> que;
    cnts[1] = 0;
    befores[1] = 0;
    que.push(1);
    while (!que.empty()) {
        int now = que.front();
        que.pop();

        for (int next : conects[now]) {
            if (cnts[next] != -1) continue;
            cnts[next] = cnts[now]+1;
            befores[next] = now;
            que.push(next);
        }
    }

    bool isOk = true;
    for (int i = 1; i < n+1; i++) {
        if (cnts[i] == -1) {
            isOk = false;
            break;
        }
    }
    
    if (isOk) {
        cout << "Yes" << endl;
        for (int i = 2; i < n+1; i++) {
            cout << befores[i] << endl;
        }
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 12064
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<map>
#include<set>
#include<functional>

using namespace std;

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

int N, M;

int main() {
	cin >> N >> M;
	vector<int> s(N, 0);
	for (int i = 0; i < M; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int x;
			cin >> x;
			x--;
			s[x] |= (1 << i);
		}
	}
	int p = 0;
	for (int i = 0; i < M; i++) {
		int x;
		cin >> x;
		p |= (x << i);
	}

	int ans = 0;
	for (int i = 0; i < (1 << N); i++) {
		int now = 0;
		for (int j = 0; j < N; j++) {
			if (1 & (i >> j)) {
				now ^= s[j];
			}
		}
		if (now == p) { ans++; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


D = int(input())
c = list(map(int, input().split()))
s = [None]*D
for i in range(D):
    s[i] = list(map(int, input().split()))
    
current = [0]*26
ans = [None]*D
def greedy():
    ans = [None]*D
    for i,ss in enumerate(s):
        vs = [None]*26
        for j in range(26):
            vs[j] = (ss[j] + current[j], j)
            current[j] += c[j]
        vs.sort()
        v = vs[-1][1]
        ans[i] = v+1
        current[v] = 0
    return ans
ans = greedy()
write("\n".join(map(str, ans)))

Measured memory_bytes: 74136
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[100010],f[100010]; 
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=2;i<=n;i++)if(i==2)f[i]=f[i-1]+abs(a[i]-a[i-1]);else f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
	cout<<f[n];
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
using namespace std;
int main() {
	int long x;
	list <string> name;
	string tmp;
	cin >> x;
	for (int i = 0; i < x; i++) {
		cin >> tmp;
		name.push_back(tmp);
	}
	if (2 < name.size()) {
		name.sort();
	}
	name.unique();
	cout << name.size() << endl;



	
}

Measured memory_bytes: 16060
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<lint> L(N);
  REP(i, N) cin >> L[i];
  lint ans = 0;
  REP(i, N) FOR(j, i+1, N) FOR(k, j+1, N) {
    if(L[i] == L[j] || L[i] == L[k] || L[j] == L[k]) continue;
    lint ma = max(L[i], max(L[j], L[k]));
    lint sum = L[i] + L[j] + L[k] - ma;
    if(sum > ma) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3644
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		for(int i=1;i<10;i++){
			for(int j=1;j<10;j++){
				pw.printf("%dx%d=%d\n",i,j,i*j);
			}
		}
		pw.close();
		sc.close();
	}
}

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

const int N = 105;
int n, m, A[N][N], cnt[N], val[N], p[N], bel[N], ibel[N];
bool edge[N][N], vis[N];
bool find(int x) {
	for (int i = 0; i < n; ++i) if (!vis[i] && edge[x][i]) {
		vis[i] = 1;
		if (!~bel[i] || find(bel[i])) {
			bel[i] = x; return 1;
		}
	}
	return 0;
}
void solve(int col) {
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) edge[i][j] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = col; j < m; ++j)
			edge[i][A[i][j] / m] = 1;
		bel[i] = -1;
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) vis[j] = 0;
		assert(find(i));
	}
	for (int i = 0; i < n; ++i) ibel[bel[i]] = i;
	for (int i = 0; i < n; ++i)
		for (int j = col; j < m; ++j)
			if (A[i][j] / m == ibel[i])
				std::swap(A[i][j], A[i][col]);
}
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j) std::cin >> A[i][j], --A[i][j];
	for (int i = 0; i < m; ++i) solve(i);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			std::cout << A[i][j] + 1 << " \n"[j == m - 1];
	for (int i = 0; i < m; ++i)
		for (int j = 0; j < n; ++j)
			for (int k = j + 1; k < n; ++k)
				if (A[j][i] > A[k][i]) std::swap(A[j][i], A[k][i]);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			std::cout << A[i][j] + 1 << " \n"[j == m - 1];
	return 0;
}

Measured memory_bytes: 384
import numpy as np
n, m = map(int, input().split())
t = np.zeros((n+1),np.int64)
w = np.zeros((n+1),np.int64)
if n >= 2:
    t[n] = 1

for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and n >= 2:
        print(-1)
        exit()
    if w[n+1-s] == 0:
        t[n+1-s] = c
        w[n+1-s] = 1
    else:
        if t[n+1-s] == c:
            pass
        else:
            print(-1)
            exit()

ans = 0
for i in range(1,n+1):
    ans += t[i] * 10**(i-1)
print(ans)


Measured memory_bytes: 12424
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>

#define ld long double
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll,ll>
#define MP make_pair
#define MT make_tuple
#define SZ(a) ll((a).size())
#define X first
#define Y second
#define endl '\n'
#define PB push_back
#define has(i, m) (m.find(i) != m.end())

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REPEAT(t) FOR(name_that_will_never_apper, 0, t)
#define iter(el, arr) for(auto& el : arr)
#define ALL(a) a.begin(), a.end()

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define vch vector<char>
#define vb vector<bool>
#define vvi vector<vi>
#define vvll vector<vll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvch vector<vch>
#define vvb vector<vb>
#define vs vector<string>
#define vss vector<vs>
#define pdd pair<ld, ld>
#define vpll vector<pll>
#define vpdd vector<pdd>
#define PI 3.141592653589793
using namespace std;

#define alphabet_size 26
#define mod 1000000007
#define INF (ll)1e18
#define MAXN 100001

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	//freopen("door.in", "r", stdin);
	//freopen("door.out", "w", stdout);

	int n;
	cin >> n;
	vll a(n);
	FOR(i, 0, n)
		cin >> a[i];

	map<int, int> can;
	FOR(i, 0, n)
		can[a[i]]++, can[a[i] + 1]++, can[a[i] - 1]++;


	int ans = 0;
	for (auto i : can)
		ans = max(ans, i.second);
	cout << ans;





	return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int H,W;
char S[20][20];
int dx[4] = { -1, 1, 0, 0 };
int dy[4] = { 0, 0, 1, -1 };
struct ichi {
    int y;
    int x;
    int depth;
};

queue<ichi> q;
int res = 0;
int bfs(int s, int t, int h) {
    int hantei[20][20] = {};
    struct ichi start;
        start.x = t;
        start.y = s;
        start.depth = h;
        hantei[start.y][start.x] = 1;
       
    q.push(start);
        while(!q.empty()) {
            ichi now = q.front(); q.pop();
             
         res = max(res, now.depth);
            
        for(int i = 0; i < 4; i++) {
            ichi next = { now.y + dy[i], now.x + dx[i], now.depth + 1};
        
        if(next.x < 0 || next.y >= H || next.y < 0 || next.x >= W) continue;
        if(S[next.y][next.x] == '#') continue;
        if(hantei[next.y][next.x] == 1) continue;
        if(next.y >= 0 && next.y < H && next.x >= 0 && next.x < W && S[next.y][next.x] == '.') {
            q.push(next);
           hantei[next.y][next.x] = 1;
        }
        }
        }

        return res;
}
int main() {
    cin >> H >> W;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }
    int ans = 0;
    for(int a = 0; a < H; a++) {
        for(int b = 0; b < W; b++) {
           if(S[a][b] == '#') continue;

           ans = max(ans, bfs(a, b, 0));
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
int a;
map<int,bool> mp; 
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n){
		cin>>a;
		if(mp[a]){
			cout<<"NO";
			re 0;
		}
		mp[a]=true;
	}
	cout<<"YES";
	re 0;
}


Measured memory_bytes: 9600