akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}

debug dbg;

class BFoodsLovedByEveryone {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, m;
	    in >> n >> m;
	    int k, a;
	    map<int, int> mp;
        map<int, int> newmp;
	    for(int i=0; i<n; i++){
	        in >> k;
	        for(int j=0; j<k; j++){
	            in >> a;
	            if(i == 0) newmp[a] = 1;
	            else{
	                if(mp[a]){
	                    newmp[a] = 1;
	                }
	            }
	        }
	        mp = newmp;
            newmp.clear();
	    }

	    out << mp.size() << endl;
	}
};


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


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, c, d = map(int, input().split())

ans = max(a * c, a * d, b * c, b * d)
print(ans)


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t;
    cin>>t;
    int ar[t];
    for(int i=0;i<t;++i) cin>>ar[i];
  	int mx=*max_element(ar,ar+t);
  	int mi=*min_element(ar,ar+t);
  	cout<<mx-mi;
  	return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

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

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <stack>
#define FOR(arg, ini, end) for(int arg = ini; arg < end; arg++)


using namespace std;
int main(int argc, const char * argv[]) {
    
    int n, d;
    cin >> n >> d;
    
    vector<vector<int> > x(n, vector<int>(d, 0));
    FOR(i, 0, n) {
        FOR(j, 0, d) {
            cin >> x[i][j];
        }
    }

    int c=0;
    FOR(i, 0, n) {
        FOR(j, i+1, n) {
            double dis = 0.0;
            FOR(k, 0, d) {
                dis += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            dis = sqrt(dis);
            if (ceil(dis) == floor(dis)) {
                c++;
            }
        }
    }

    cout << c << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  
  int N = s.size();
  bool b = true;
  for (int i = 0; i < N; i++) {
    if (s.substr(i,5) == "maerd" || s.substr(i,5) == "esare") i += 4;
    else if (s.substr(i,6) == "resare") i += 5;
    else if (s.substr(i,7) == "remaerd") i += 6;
    else {
      b = false;
      break;
    }
  }
  cout << (b ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int n;
vll a, b;

ll solve() {
    if (n&1) return abs(a[n/2] - b[n/2]) + 1ll;
    return abs((a[n/2-1]+a[n/2]) - (b[n/2-1]+b[n/2])) + 1ll;
}

int main() {
    cin >> n;
    a.resize(n);
    b.resize(n);
    rep(i, n) cin >> a[i] >> b[i];
    sort(all(a));
    sort(all(b));
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 6368
#include<stdio.h>
int main()
{
	double n,m,c;
	scanf("%lf",&n);
	scanf("%lf",&m);
	scanf("%lf",&c);
	if(n>=m)
	{
		if((int)(c/n+0.9999999999)==(int)c/n)
			printf("%.lf",c/n);
		else
			printf("%d",(int)(c/n+1));
	}
	if(n<m)
	{
		if((int)(c/m+0.99999999)==(int)c/m)
			printf("%.lf",c/m);
		else
			printf("%d",(int)(c/m+1));	
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int s[100000];
int n;

int binarySearch(int);

int main()
{
  int q, c=0, i;
  int t[50000];

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

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

  for(i = 0; i < q; i++){
    if(1 == binarySearch(t[i])) c++;
  }

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

  return 0;
}

int binarySearch(int key)
{
  int left = 0;
  int right = n;
  int mid;
 
  while(left < right){
    mid = (left + right) / 2;
    if(s[mid] == key) return 1;
    else if(key < s[mid]) right = mid;
    else left = mid + 1;
  }
  return 0;
}

Measured memory_bytes: 1180
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
pair<vector<T>, vector<T>> slide_minmax(const vector< T > &v, int k){

	vector<T> ret_min, ret_max;
	ret_min.reserve(v.size() - k + 1);
	ret_max.reserve(v.size() - k + 1);

	deque<int> deq_min, deq_max;
	for (int i = 0; i < v.size(); i++) {

		while (!deq_min.empty() && v[deq_min.back()] >= v[i]) deq_min.pop_back();
		while (!deq_max.empty() && v[deq_max.back()] <= v[i]) deq_max.pop_back();
		
		deq_min.push_back(i);
		deq_max.push_back(i);

		if (i - k + 1 >= 0) {
			ret_min.emplace_back(v[deq_min.front()]);
			ret_max.emplace_back(v[deq_max.front()]);
			if (deq_min.front() == i - k + 1) deq_min.pop_front();
			if (deq_max.front() == i - k + 1) deq_max.pop_front();
		}

	}
	return { ret_min, ret_max };
}

template< typename T >
vector< T > operator-(const vector< T > &v) {
	vector< T > res(v.size());
	for (int i = 0; i < v.size(); i++) res[i] = -v[i];
	return res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	vector<int> P(N);
	for (int i = 0; i < N; i++) {
		int p; cin >> p;
		P[i] = p;
	}

	//auto [smin, smax] = slide_minmax(P, K);
	vector<int> smin, smax;
	tie(smin, smax) = slide_minmax(P, K);
	DMP(smin, smax);

	int cnt1 = 0;
	for (int i = 0; i < N - K; i++) if (smin[i] == P[i] && smax[i + 1] == P[i + K]) cnt1++;

	int seq = 0, cnt2 = 0;
	for (int i = 0; i < N - 1; i++) {
		if (P[i] < P[i + 1]) seq++;
		else seq = 0;
		if (seq == K - 1) cnt2++;
	}

	DMP(N - K + 1, cnt1, cnt2);
	cout << N - K + 1 - cnt1 - max(cnt2 - 1, 0) << "\n";

	return 0;
}


Measured memory_bytes: 4224
using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Console = System.Console;

    namespace Atcoder
    {
        class Program
        {
            static void Main(string[] args)
            {
                LinkedList<char> s = new LinkedList<char>();
                var firstS = Read();
                s.AddLast('1');
                var N = ReadLong();
                bool isReverse = false;
                for (int i = 0; i < N; i++)
                {
                    var r = Console.ReadLine().Split();
                    if (r.Length == 1)
                    {
                        isReverse = !isReverse;
                        continue;
                    }

                    var putFirst = int.Parse(r[1]) == 1;
                    if (putFirst)
                    {
                        if (isReverse)
                        {
                            s.AddLast(r[2][0]);
                        }
                        else
                        {
                            s.AddFirst(r[2][0]);
                        }
                        
                    }
                    else
                    {
                        if (isReverse)
                        {
                            s.AddFirst(r[2][0]);
                        }
                        else
                        {
                            s.AddLast(r[2][0]);
                        }
                    }
                }

                var ts = new string(s.ToArray());
                ts = ts.Replace("1", firstS);
                var ret = isReverse ? new string(ts.Reverse().ToArray()) : ts;
                Console.WriteLine(ret);
            }
            private static readonly Func<string> Read = () => Console.ReadLine();
            private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
            private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
            private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
            private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
            private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
            private static readonly Action<string> Cw = str => Console.WriteLine(str);
        }
    }

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T>
constexpr T INF = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 2;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T>
istream& operator>>(istream& in, vector<T>& a) { for (T& x : a) cin >> x; }

void LOG(const int& x) { cerr << x << "\n"; }
void LOG(const vector<int>& a) { for (int x : a) cerr << x << " "; cerr << "\n"; }

int ceil(int a, int b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }

class UnionFind {
private:
  vector<int> par;
  vector<int> rnk;
  int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
public:
  UnionFind(int size) { par.resize(size); rnk.resize(size); REP(i, size) par[i] = i, rnk[i] = 0; }
  void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rnk[x] < rnk[y]) { par[x] = y; } else { par[y] = x; if (rnk[x] == rnk[y]) rnk[x]++; } }
  bool same(int x, int y) { return find(x) == find(y); }
};

struct InitCpp { InitCpp() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
} } initCpp;

signed main() {
  int n, m;
  cin >> n >> m;
  map<int, int> cnt;
  REP(_, m) {
    int a, b;
    cin >> a >> b;
    if (a == 1) cnt[b] += 1;
    if (b == n) cnt[a] += 1;
  }
  cout << (any_of(ALL(cnt), [](pair<int, int> p) { return p.second >= 2; }) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 1<<17;

int a[MAX];

int main()
{
  int n;
  scanf("%d", &n);

  for (int i=1; i<=n; i++)
    scanf("%d", &a[i]);

  int r = 0;
  for (int i=1; i<=n; i++)
    if (a[a[i]] == i)
      r++;


  printf("%d\n", r / 2);

  return 0;
}


Measured memory_bytes: 640
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

const P: i64 = 998244353;

pub fn pow(x: i64, n: i64) -> i64 {
    let (mut x, mut y, mut n) = (x % P, 1_i64, n);
    while n > 0 {
        if n % 2 != 0 {
            y = (y * x) % P;
            n -= 1;
        }

        x = (x * x) % P;
        n /= 2;
    }
    y
}

/*

4
0 1 1 3

*/

fn main() {
    let N = read!(usize);
    let D = read![[usize]];

    let mut rev = vec![0_i64; N];
    for i in 0..N {
        rev[D[i]] += 1;
    }
    debug!(rev);

    let m = D.iter().cloned().max().unwrap();
    if !(rev[0] == 1 && D[0] == 0 && (0..m).all(|d| rev[d] != 0)) {
        println!("0");
        return;
    }

    let mut count = 1;
    for d in 1..N - 1 {
        count *= pow(rev[d], rev[d + 1]);
        count %= P;
    }

    println!("{}", count % P)
}


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

#define ll long long

int main(){
    ios::sync_with_stdio(0);
    int n, d, a;
    ll ans = 0;
    cin >> n >> d >> a;
    pair<int,int> arr[n];
    for(int i = 0 ; i < n ;++i)
        cin >> arr[i].first >> arr[i].second;
    sort(arr, arr+n);
    ll acc[n]={0}, s = 0;
    for(int i = 0 ; i < n ; ++i){
        int j = upper_bound(arr, arr+n, make_pair(arr[i].first+2*d+1, 0)) - arr;
        s += acc[i];
        ll c = (arr[i].second-s+a-1)/a;
        if (c <= 0)
            continue;
        ans += c;
        s += a*c;
        if (j != n)
            acc[j] -= a*c;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
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 true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	string s;cin >> s;
	int q; cin >> q;
	vector<int> query(q);
	vector<pair<int,char>> query2(q,{0,'0'});
	rep(i, q)
	{
		cin >> query[i];
		if(query[i]==2) cin >> query2[i].first >> query2[i].second;
	}	
	deque<char> deq;
	rep(i,sz(s))deq.push_back(s[i]);
	int rev = 0;
	rep(i, q)
	{
		if(query[i]==1)rev++;
		else
		{
			if((rev+query2[i].first)%2)deq.push_front(query2[i].second);
			else deq.push_back(query2[i].second);
		}
	}
	if(rev % 2)reverse(all(deq));
	while (sz(deq))
	{
		cout<<deq.front();
		deq.pop_front();
	}
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3280
use std::io::stdin;

fn main(){
    let (_, _) = getpair();
    let xs = geti64s();
    let ys = geti64s();
    println!("{}", (f(&xs)*f(&ys))%1_000_000_007);
}

fn f(xs: &Vec<i64>) -> i64{
    let mut ds: Vec<i64> = Vec::new();
    let mut ls: Vec<i64> = Vec::new();
    for i in 0..xs.len()-1{ ds.push(xs[i+1] - xs[i]); }
    ls.push(0);
    for i in 0..ds.len(){
        let x = ls[i];
        ls.push(((i as i64 +1)*ds[i]) + x % 1_000_000_007)
    }
    return ls.iter().fold(0, |acc, x| {(acc+x)%1_000_000_007})
}

#[allow(dead_code)]
fn getline() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn getvec() -> Vec<usize>{
    let line = getline();
    line.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn geti64s() -> Vec<i64>{
    let line = getline();
    line.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn getpair() -> (usize, usize){
    let nm = getvec();
    (nm[0], nm[1])
}

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

public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;

  private static PrintWriter _err = new PrintWriter(System.err);

  private long sum;

  private void solve(Scanner sc, PrintWriter out) {
    String s = sc.nextLine();

    search(0, s, new boolean[s.length() - 1]);

    out.println(sum);
  }
  private void search(int d, String s, boolean[] b) {
    if (d == b.length) {
      calc(s, b);
      return;
    }
    for (int j = 0; j < 2; ++j) {
      b[d] = (j == 0);
      search(d + 1, s, b);
      b[d] = false;
    }
  }
  private void calc(String s, boolean[] b) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.length(); ++i) {
      sb.append(s.charAt(i));
      if (i < b.length && b[i]) {
        sum += Long.parseLong(sb.toString());
        sb = new StringBuilder();
      }
    }
    sum += Long.parseLong(sb.toString());
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();

    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 10196
n = input().split()
n = [int(x) for x in n]
if n[0] + n[1] == n[2]:
    print ('Yes')
elif n[0] + n[2] == n[1]:
    print ('Yes')
elif n[1] + n[2] == n[0]:
    print ('Yes')
else:
    print ('No')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<map>
#include<vector>

using namespace std;
const int infty = 100000;

struct order{
  string who;
  string does;
  string item;
  int val;
};

struct item{
  vector<int> v;
};

struct dealer{
  int sell;
  int buy;
};

#define SELL 0
#define BUY 1

int minimumValue(const vector<int> &v){
  int ret = infty;
  for(int i = 0; i < (int)v.size(); ++i) ret = min(ret, v[i] );
  return ret;
}
int maximumValue(const vector<int> &v){
  int ret = 0;
  for(int i = 0; i < (int)v.size(); ++i) ret = max(ret, v[i] );
  return ret;
}
int meanValue(const vector<int> &v){
  int sum = 0;
  for(int i = 0; i < (int)v.size(); ++i)sum+=v[i];
  return sum / v.size();
}

int main()
{
  while(true){
    int records;
    cin >> records;
    if(records==0)break;
    vector<order> os;
    map<string,item> items;
    map<string,dealer> dealers;
    bool dealed[records];
    for(int i = 0; i < records; ++i){
      order o;
      cin >> o.who >> o.does >> o.item >> o.val;
      items[o.item] = item();
      dealers[o.who] = dealer();
      os.push_back(o);
      dealed[i] = false;
    }
    for(int i = 0; i < (int)os.size(); ++i){
      int max_deal_val = 0;
      int min_deal_val = infty;
      int anti_dealer = infty;
      for(int j = i-1; j >= 0; --j){
	if( os[j].who != os[i].who && os[j].does != os[i].does && os[j].item == os[i].item &&
	    !dealed[i] && !dealed[j] ){
	  if( os[i].does == "SELL" ){
	    if( os[i].val <= os[j].val ){
	      if( os[j].val > max_deal_val ){
		max_deal_val = os[j].val;
		anti_dealer = j;
	      }else if( os[j].val == max_deal_val ){
		anti_dealer = min( anti_dealer, j );
	      }
	    }
	  }else{
	    if( os[j].val <= os[i].val ){
	      if( os[j].val < min_deal_val ){
		min_deal_val = os[j].val;
		anti_dealer = j;
	      }else if( os[j].val == min_deal_val ){
		anti_dealer = min( anti_dealer, j );
	      }
	    }
	  }
	}
      }
      if( anti_dealer < infty ){
	// deal occured
	dealed[i] = true;
	dealed[anti_dealer] = true;
	int deal_val = (os[anti_dealer].val + os[i].val) /2;
	items[ os[i].item ].v.push_back( deal_val );
	if( os[i].does == "SELL" ){
	  dealers[ os[i].who ].sell += deal_val;
	  dealers[ os[anti_dealer].who ].buy += deal_val;
	}else{
	  dealers[ os[i].who ].buy += deal_val;
	  dealers[ os[anti_dealer].who ].sell += deal_val;
	}
      }
    }

    for(map<string,item>::iterator it = items.begin(); it != items.end(); ++it){
      if( it->second.v.size() > 0 ){
	int minv = minimumValue( it->second.v );
	int maxv = maximumValue( it->second.v );
	int avgv = meanValue( it->second.v );
	cout << it->first << ' ' << minv << ' ' << avgv << ' ' << maxv << endl;
      }
    }
    cout << "--" << endl;
    for(map<string,dealer>::iterator it = dealers.begin(); it != dealers.end(); ++it){
      cout << it->first << ' ' << it->second.buy << ' ' << it->second.sell << endl;
    }
    cout << "----------" << endl;
    
  }
  return 0;
}

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


int main(){
  string S;
  int K ;
  bool onechar = true;
  cin >> S >> K;
  if(S.size() == 1) cout << S[0];
  else{
    int diff=0;
    for(int i = 0 ; i < S.size()-1 ; i ++){
        if(S[i] != S[i+1] ){
          onechar = false;
          diff = i;
          break;
        }
    }
    if(onechar){
      cout << S[0];
    }else{
      if(S[diff] == '1'){
        if( diff+1 < K){
          cout << S[diff+1];
        }else{
          cout << 1;
        }
      }else{
        cout << S[diff];
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using std::min; using std::max;
using std::swap; using std::sort;
using std::unique; using std::lower_bound;
typedef long long ll;
     
template<typename T>
void read(T &x) {
	int flag = 1; x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') flag = -flag; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); x *= flag;
}
#if __cplusplus >= 201103l
template<typename T, typename... V>
void read(T &x, V&... v) { read(x), read(v...); }
#endif
     
const int _ = 1e5 + 20, Inf = 1e5 + 10;
int n, a[_], sum[_];
int c[_ << 1];
void add(int x) { for(; x <= (Inf << 1); x += x & -x) ++c[x]; }
ll que(int x) { ll y = 0; for(; x; x -= x & -x) y += c[x]; return y; }
     
bool check(int mid) {
	for(int i = 1; i <= (Inf << 1); ++i) c[i] = 0;
	for(int i = 1; i <= n; ++i)
		sum[i] = sum[i - 1] + (a[i] <= mid ? -1 : 1);
	ll pair = 0;
	for(int i = 0; i <= n; ++i) {
		add(sum[i] + Inf);
		pair += i + 1 - que(sum[i] + Inf);
	}
	return pair > (1ll * n * (n + 1) / 2) / 2;
}
     
int main () {
	read(n); int l = 0, r = 0;
	for(int i = 1; i <= n; ++i)
		read(a[i]), r = max(r, a[i]);
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(check(mid)) r = mid - 1;
		else l = mid + 1;
	}
	return printf("%d\n", l), 0;
} 


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

int main() {

string a,b ;

cin>>a;
cin>>b ;
if(a[2]==b[0]&&a[1]==b[1]&&a[0]==b[2])
{
    cout<< "YES" ;

}

else {cout<< "NO" ;}

	return 0;
}


Measured memory_bytes: 256
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x != None: x, y = x.left if key < x.key else x.right, x
    if y == None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 63396
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, K, A[1 << 18];

long long solve(long long r) {
	long long cnt = 0;
	for (int i = 1; i <= N; i++) cnt += (r ^ A[i]);
	return cnt;
}

int main() {
	cin >> N >> K;
	for (int i = 1; i <= N; i++) cin >> A[i];

	long long val = 0;
	for (int i = 40; i >= 0; i--) {
		long long nex = val + (1LL << i);
		long long ch1 = solve(val);
		long long ch2 = solve(nex);
		if (nex <= K && ch1 < ch2) { val = nex; }
	}
	cout << solve(val) << endl;
	return 0;
}

Measured memory_bytes: 4392
n, k, q = [int(i) for i in input().split()]
kotaeno = [0]*n

for i in range(q):
  line = int(input())
  kotaeno[line-1] += 1

for i in range(n):
  if k-q+kotaeno[i]>0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 4700
package main

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

func main() {
	sc := newScanner()
	var x = sc.readInt()
	var ans int
	ans += (x / 500) * 1000
	x = x % 500
	ans += (x / 5) * 5
	fmt.Println(ans)

}

//////////////////
//////////////////
//////////////////

func abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func reverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func reverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *scanner) readInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1772
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

ans = 0

for i in range(N):
    if D[i][0] == D[i][1]:
        ans += 1
        

        if ans == 3:
            break

    else:
        ans = 0


if ans >= 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
h = inp()
w = inp()
print((n-h+1)*(n-w+1))

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

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0; i<N; i++) cin >> A[i];
  long long wat1[N][2];
  for(int i=0; i<N; i++){
    if (i==0){
      wat1[0][0] = A[0];
      wat1[N-1][1] = A[N-1];
    } else if (i&1){
      wat1[i][0] = wat1[i-1][0] - A[i];
      wat1[N-i-1][1] = wat1[N-i][1] - A[N-i-1];
    } else {
      wat1[i][0] = wat1[i-1][0] + A[i];
      wat1[N-i-1][1] = wat1[N-i][1] + A[N-i-1];
    }
  }
  long long ans;
  for(int i=0; i<N; i++){
    // i番目の答え
    if (i==0){
      ans = wat1[i][1];
    } else if (i%2==1){
      ans = wat1[i-1][0] - wat1[i][1];
    } else {
      ans = - wat1[i-1][0] + wat1[i][1];
    }
    cout << ans << " ";
  }
}

Measured memory_bytes: 3328
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int max = 0;
        int sum = 0;
        for (int i = 0; i < 3; i++)
        {
            int a = sc.NextInt();
            max = Math.Max(max, a);
            sum += a;
        }

        Console.WriteLine(sum - max == max ? "Yes" : "No");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
class Point
  attr_accessor :x, :y
  def initialize(x, y)
    @x = x
    @y = y
  end

  def -(p)
    Point.new(x - p.x, y - p.y)
  end

  def norm
    @x * @x + @y * @y
  end
end

def dot(a, b)
  a.x * b.x + a.y * b.y
end

def cross(a, b)
  a.x * b.y - a.y * b.x
end

Segment = Struct.new('Segment', :p1, :p2)

def is_orthogonal?(s1, s2)
  dot(s1.p2 - s1.p1, s2.p2 - s2.p1).zero?
end

def is_parallel?(s1, s2)
  cross(s1.p2 - s1.p1, s2.p2 - s2.p1).zero?
end

def ccw(p0, p1, p2)
  a = p1 - p0
  b = p2 - p0
  return "COUNTER_CLOCKWISE" if cross(a, b) > 0
  return "CLOCKWISE" if cross(a, b) < 0
  return "ONLINE_BACK" if dot(a, b) < 0
  return "ONLINE_FRONT" if a.norm < b.norm
  return "ON_SEGMENT"
end

x0, y0, x1, y1 = gets.split.map(&:to_i)
p0 = Point.new(x0, y0)
p1 = Point.new(x1, y1)
n = gets.to_i
n.times do
  x2, y2 = gets.split.map(&:to_i)
  p2 = Point.new(x2, y2)
  puts ccw(p0, p1, p2)
end



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

using ll = long long;
static const int MAX = 1e5;
static const int INF = 1e9;

// 隣接リストを用いた幅優先探索 O(|V|+|E|)
int n;
vector<pair<ll, ll>> G[MAX]; // 頂点数がnのグラフを表す隣接リスト
vector<ll> d(MAX, INF); // 始点sから頂点iまでの最短距離をd[i]に記録
// main関数からこれらを削除すること

void bfs(int s) {
  queue<int> q;
  q.push(s);
  d[s] = 0;
  while(!q.empty()){
    int u = q.front();
    q.pop();
    for(int v = 0; v < G[u].size(); v++){
      if(d[G[u][v].first] == INF){
        d[G[u][v].first] = d[u] + G[u][v].second;
        q.push(G[u][v].first);
      }
    }
  }
}

int main() {
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  
  // 重み付き無向(有向)グラフの隣接リスト
  ll u, v, w;
  cin >> n;
  
  for(int i = 0; i < n - 1; i++){
    cin >> u >> v >> w;
    u--;
    v--;
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w)); // 有向グラフではこの行をコメントアウト
  }
  
  int q, k;
  cin >> q >> k;
  
  bfs(k - 1);
  
  int x, y;
  for(int i = 0; i < q; i++){
    cin >> x >> y;
    cout << d[x - 1] + d[y - 1] << "\n";
  }
}

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

typedef long long ll;
int N;
ll A[51],B[51];

int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> A[i];
	}
	bool judge = false;
	ll ans = 0;
	while(!judge){
		ll sum = 0;
		for(int i=1;i<=N;i++){
			ans += A[i]/N;
			sum += A[i]/N;
			B[i] = A[i]/N;
			A[i] %= N;
		}
		judge = true;
		for(int i=1;i<=N;i++){
			A[i] = A[i] + sum - B[i];
			if(A[i]/N!=0) judge = false;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  set<ll> st;
  for(int i=0;i<n;i++){
    auto itr = st.find(a[i]);
    if(itr == st.end()){
      st.insert(a[i]);
    }else{
      st.erase(a[i]);
    }
  }

  cout << st.size() << endl;
}


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

int main() {
  
  int N,K;
  cin >> N >> K;
  int zero = 0;
  int total = 0;
  
  
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    
    if (K - x <= x){
      total = total + (K -x) * 2;
    }
    else if (K - x > x){
      total = total + x * 2;
    }
    
  }
  
  cout << total << endl;

 }

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define all(x) (x).begin(), (x).end() 
 
typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
long long INF=numeric_limits<long long>::max();
 
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
  int n,x; cin >> n >> x;
  int d[n+1]; 
  d[0] = 0;
  int ptr = n+1;
  for(int i = 1; i <= n; i++){
  	cin >> d[i];
  }
  for(int i = 1; i <= n; i++){
	d[i] += d[i-1];
    if(d[i]>x){
		ptr = i;
		break;
	}
  }
  cout << ptr << endl;
}


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

typedef long long ll;
typedef long double lld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef pair<ll, ll> pll;
typedef pair<ll, pair<ll, ll>> plll;

void solve()
{
  ll n;
  cin >> n;
  if (n % 1000 == 0)
  {
    cout << 0 << endl;
    return;
  }
  cout << 1000 - n % 1000 << endl;
  return;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  // int t;
  // cin >> t;
  // for (int i = 0; i < t; i++)
  // {
  //   solve();
  // }
  solve();
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(void){
    int i;
    char n[4];

    scanf("%s",n);
    
    for(i=0; i<3; i++){
        if(n[i]=='1')
            n[i]='9';
        else if(n[i]=='9')
            n[i]='1';
    }
    printf("%s\n",n);
}


Measured memory_bytes: 128
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N,M;
    cin>>N>>M;
    vector<vector<ll>> V(N,vector<ll>(3));
    REP(i,N){
        REP(j,3){
            cin>>V[i][j];
        }
    }
    //入力部おわり
    ll valueall=0;
    vector<ll> sumv(N);
    REP(X,2){
        REP(Y,2){
            REP(Z,2){
                ll value=0;
                int x,y,z;
                x=2*X-1;
                y=2*Y-1;
                z=2*Z-1;
                REP(i,N){
                    sumv[i]=x*V[i][0]+y*V[i][1]+z*V[i][2];
                }
                sort(ALL(sumv),greater<ll>());

                REP(i,M){
                    value+=sumv[i];
                }
                if(value>=valueall){
                    valueall=value;
                }
            }
        }
    }
    cout<<valueall<<endl;
}

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

int main(){
  int f=0;
  string s;
  string t;
  cin>>s;
 
  for(int i=0;i<s.size();i++){
    if(f==0&&s[i]=='A'){
      t+='A';
      f=1;
    }
    if(f==1&&s[i]=='Z'){
      t+='Z';
      f=0;
    }
  }

  if(t.size()<=1)cout<<"-1"<<endl;
  else if(t[t.size()-1]=='A'){
    for(int i=0;i<t.size()-1;i++)cout<<t[i];
    cout<<endl;
  }
  else cout<<t<<endl;
  return 0;
}

Measured memory_bytes: 1180
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		String[] checked = new String[s.length()];

		for (int i = 0; i < s.length(); i++) {
			String tar = s.substring(i, i + 1);
			if (Arrays.asList(checked).contains(tar)) {
				System.out.println("no");
				return;
			}
			checked[i] = tar;
		}

		System.out.println("yes");
	}
}

Measured memory_bytes: 25428
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

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

        for (int i = 0; i < h; i++) {
            System.out.println(s[i]);
            System.out.println(s[i]);
        }
        

        sc.close();
    }

}





Measured memory_bytes: 24404
#include<stdio.h>
#define MAX 10000
#define NIL -1
void depth(int,int);
void printz(int);
int height(int);
int sibling(int);
struct Node{int parent,left,right;};
struct Node A[MAX];
int n,X[MAX],Y[MAX];
int main(){
  int i,a,b,c,x;
  scanf("%d",&n);
for(i=0;i<n;i++){
  A[i].parent=NIL;
}
  for(i=0;i<n;i++){
    scanf("%d %d %d",&a,&b,&c);
    A[a].left=b;
      A[a].right=c;
      if(b!=NIL)
	A[b].parent=a;
      if(c!=NIL)
	A[c].parent=a;
  }
  for(i=0;i<n;i++){
    if(A[i].parent==NIL)
      x=i;
  }
  depth(x,0);
  height(x);
  for(i=0;i<n;i++) printz(i);
  return 0;
}

void depth(int x,int y){
  if(x==NIL)
    return;
  X[x]=y;
    depth(A[x].right,y+1);
    depth(A[x].left,y+1);
}

int height(int x){
  int h1=0,h2=0;
    if(A[x].left!=NIL)
      h1=height(A[x].left)+1;
  if(A[x].right!=NIL)
    h2=height(A[x].right)+1;
  return Y[x]=(h1>h2?h1:h2);
}
int sibling(int x){
  if(A[x].parent==NIL)
    return NIL;
  if(A[A[x].parent].left!=x&&A[A[x].parent].left!=NIL)
    return A[A[x].parent].left;
   if(A[A[x].parent].right!=x&&A[A[x].parent].right!=NIL)
    return A[A[x].parent].right;
   return NIL;
}
  
void printz(int x){
int i,y=0;
  printf("node %d: ",x);
  printf("parent = %d, ",A[x].parent);
  printf("sibling = %d, ",sibling(x));
  if(A[x].left!=NIL)
    y++;
  if(A[x].right!=NIL)
    y++;
  printf("degree = %d, ",y);
  printf("depth = %d, ",X[x]);
  printf("height = %d, ",Y[x]);
  if(A[x].parent==NIL)
    printf("root\n");
  else if(A[x].left==NIL&&A[x].right==NIL)
    printf("leaf\n");
  else
    printf("internal node\n");
}



Measured memory_bytes: 2148
MOD = 10 ** 9 + 7

if __name__ == "__main__":
    N, K = [int(x) for x in input().split(" ")]
    A = [int(x) for x in input().split(" ")]

    count_a = 0
    count_b = 0
    A_ = K * (K + 1) // 2
    B = K * (K - 1) // 2
    for i in range(N):
        for j in range(i + 1, N):
            if A[i] > A[j]:
                count_a += 1
            if A[i] < A[j]:
                count_b += 1

    print((A_ * count_a + B * count_b) % MOD)

Measured memory_bytes: 69020
import sys
import heapq
import random
import collections

# available on Google, not available on Codeforces
# import numpy as np
# import scipy
import math


def solve(lst):  # fix inputs here
    # console("----- solving ------")
    if 0 in lst:
        return 0
        
    res = 1
    for r in lst:
        res *= r
        if res > 10**18:
            return -1

    return res

def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return


# for case_num in range(int(input())):
    # read line as a string
    # strr = input()

    # read line as an integer
_ = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer

lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    # grid = []
    # for _ in range(nrows):
    #     grid.append(input())

res = solve(lst)

    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
print(res)


Measured memory_bytes: 23316
#!/usr/bin/env python3

# from typing import Optional
# from typing import List
# from typing import Dict
# from typing import Tuple
# from typing import Sequence


def main():
    N = map(lambda x: int(x), list((input())))

    result = 0
    for item in N:
        result += item

    if result % 9 == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 10480
// n <= 2*10^5
let n = stdin.ReadLine() |> int
let ps = stdin.ReadLine().Split() |> Array.map int

ps 
|> Seq.fold 
    (fun (min, count) x ->
        if min >= x then (x, count+1)
        else (min, count))
    (200001, 0)
|> snd
|> stdout.WriteLine

Measured memory_bytes: 34268
n,h = map(int,input().split())

li_a = []; li_b = []

for i in range(n):
    a,b = map(int,input().split())
    li_a.append(a)
    li_b.append(b)

li_a = sorted(li_a,reverse=True)
li_b = sorted(li_b,reverse=True)

dmg = li_a[0]
ttl = 0
ans = 0

for i in range(n):
    if ttl >= h:
        break
    if li_b[i] <= dmg:
        break
    ttl += li_b[i]
    ans += 1

if ttl < h:
    if (h-ttl)%dmg == 0:
        ans += ((h-ttl)//dmg)
    else:
        ans += ((h-ttl)//dmg)+1


print(ans)

Measured memory_bytes: 12116