akhauriyash/Code-Regression huggingface dataset:
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    let aryX = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    let b = n / 2 - 1
    var aryXSorted = aryX.sorted(by: >)
    let median = aryXSorted[b]
    aryXSorted.remove(at: b)
    let secondMedian = aryXSorted[b]
    
    for i in aryX {
        print(i < median ? median: secondMedian)
    }
}
main()


Measured memory_bytes: 24108
n,m = gets.chomp.split.map(&:to_i)
sums = Array.new(8).map{Array.new(n,0)}

n.times do |i|
	line = gets.chomp.split.map(&:to_i)
	8.times do |bi|
		tmp = 0
		3.times do |ci|
			tmp += line[ci] * (bi.to_s(2).rjust(3,"0")[ci] == '1' ? 1 : -1)
		end
		sums[bi][i] = tmp
	end
end

p sums.map{|itm|itm.sort.reverse[0,m].inject(:+)}.max || 0

Measured memory_bytes: 1912
#include <iostream>
using namespace std;
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int i;
  for(i=0;i<k;i++){
    if(a>b-k) break;
    cout << a << "\n";
    a++;
  }
  for(i=k-1;i>=0;i--){
    if(b-i<=a) i=b-a;
    cout << b-i << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>                                                       
using namespace std;                                                      
                                                                          
int main(){                                                               
  int a,b,S,l;                                                            
                                                                          
  cin >> a >> b;                                                          
                                                                          
  S = a * b;                                                              
  l = 2 * (a + b);                                                        
                                                                          
  cout << S << " " << l << endl;                                          
                                                                          
  return 0;                                                               
} 

Measured memory_bytes: 3096
n = int(input())
H = list(map(int, input().split()))
flag = True
highest = 0
for i in range(n):
    if H[i] > highest:
        highest = H[i]
    else:
        if highest > H[i] + 1:
            flag = False
            
print('Yes' if flag == True else 'No')

Measured memory_bytes: 14396
n,y= map(int,input().split())
for i in range(n+1):
    for f in range(n+1):
        s = n-i-f
        if s<0:
            break
        if 10000*i + f*5000 +(n-i-f)*1000==y:
            print("{} {} {}".format(i,f,n-i-f))     
            exit()
 
print(-1, -1, -1)

Measured memory_bytes: 40940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
const int MOD = 1e9 + 7;

int main() {
    ll n, a, b;
    cin >> n;
    vector<int>p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    ll ans = 0;
    vector<int> one_case;
    for (int i = 1; i <= n; i++) { // one_case = {0,1,2,3,...n-1} とする
        one_case.emplace_back(i);
    }
    int c = 0;
    do {
        bool ok = 1;
        rep(i, n) {
            if (one_case[i] != p[i]) {
                ok = 0;
                break;
            }
        }
        if (ok) {
            a = c;
        }
        ok = 1;
        rep(i, n) {
            if (one_case[i] != q[i]) {
                ok = 0;
                break;
            }
        }
        if (ok) {
            b = c;
        }
        c++;
    } while (next_permutation(one_case.begin(), one_case.end()));
    cout << abs(a - b) << endl;
    return 0;
}


Measured memory_bytes: 3604
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		sc.close();
		int ans = 0;
		if(b>1) {
			b -= a; 
			ans = 1;
			if(b>0) {
				ans += (int) Math.ceil((double)b / (a-1));
			}
		}
		out.println(ans);
	}
}


Measured memory_bytes: 23892
from sys import stdin

s = stdin.readline().rstrip()

even0 = 0
even1 = 0
odd0 = 0
odd1 = 0

for i in range(len(s)):
    if (i % 2 == 0):
        if int(s[i]) == 0:
            even0 += 1
        else:
            even1 += 1
    else:
        if int(s[i]) == 0:
            odd0 += 1
        else:
            odd1 += 1

max = max(even0, even1, odd0, odd1)

if max == even0 or max == odd1:
    cnt = even1 + odd0
elif max == even1 or max == odd0:
    cnt = even0 + odd1

print(cnt)


Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
//typedef vector<int> vi;
//typedef vector<vi> vvi;
//typedef vector<string> vs;
//typedef pair<int, int> pii;
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}



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

	set<int> sn;
	int n, k;
	cin >> n >> k;
	REP(i, k) {
		int d;
		cin >> d;
		REP(j, d) {
			int a;
			cin >> a;
			sn.insert(a);
		}
	}

	int ans = 0;
	REPS(i, n) {
		if (sn.find(i) == sn.end()) {
			ans++;
		}
	}
	cout << ans << endl;
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    i32 L = input();

    vector<pair<pair<i32, i32>, i32>> v;

    range(i, 0, 20) {
        cerr << bitset<32>(L) << endl;
        if (i != 19 && (1 << i) & L) {
            L -= (L & -L);
            v.emplace_back(make_pair(1, 20 - i), L);
        }

        if ((1 << i) >= L) break;
        v.emplace_back(make_pair(19 - i, 20 - i), 0);
        v.emplace_back(make_pair(19 - i, 20 - i), 1 << i);
    }

    cout << 20 << " " << v.size() << endl;
    for (auto p : v) {
        cout << p.first.first << " " << p.first.second << " " << p.second
             << endl;
    }
}

signed main(int argc, char *argv[]) {
    solver();
}

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

int main() {
  string S;
  cin >> S;
  if(S=="AAA") {
    cout << "No" <<endl;
  }
  else if(S=="BBB") {
    cout << "No" <<endl;
  }
  else {
    cout << "Yes" <<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);

		//?°?????????????
		while(true){
			//H??????????????????
			int H = sc.nextInt();
			//W?¨????????????????
			int W = sc.nextInt();
			//H??¨W???0????????????
			if(H == 0 && W == 0){
				break;
			}
			//???????????¨???
			for(int i = 1; i <= H; i++){
				//?¨?????????¨???
				for(int j = 1; j <= W; j++){
					//?????¶???
					if(i == 1 || i == H || j==1|| j == W){
						System.out.print('#');
					}else{
						System.out.print('.');
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 37608
#include<bits/stdc++.h>
using namespace std;
int cnt[100000],flag[100000];
int main()
{
  //#ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=m;i++)
  {
  	int x;
  	string s;
  	cin>>x>>s;
  	if(s=="WA")
  	{
  		if(!flag[x])
  		{
               cnt[x]++;
  		}

  	}
  	else
  		flag[x]=1;

  }

  int x=0,y=0;
  for(int i=1;i<=n;i++)
  {
  	if(flag[i])
  	{
  		x++;
  		y+=cnt[i];
  	}
  }
  cout<<x<<" "<<y;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    cout << ((n+max(h,w)-1)/max(h,w)) << endl;
    return 0;
}


























Measured memory_bytes: 256
/*input
40
ferelibenterhominesidquodvoluntcredunt
*/ 
#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;

#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=1e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=INF64;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int main(){
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(sz(s)<=k) cout<<s;
    else{
        cout<<(s.substr(0,k))<<"...";
    }
}

Measured memory_bytes: 3596
/**
 * A - Curtain
 * https://atcoder.jp/contests/abc143/tasks/abc143_a
 **/
#include<iostream>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    if (A<2*B) {
        cout << 0 << endl;
    } else {
        cout << A-2*B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int t = sc.nextInt();
    int hun = n / x;
    if (n % x != 0){
      hun+= 1;
    }
    System.out.println(hun * t );
    sc.close();
  }
}

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll a,b;
	cin>>a>>b;
	(abs(b-a)%2==0)?cout<<abs(b-a)/2+min(a,b):cout<<"IMPOSSIBLE";
	cout<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int A,B,C,X,Y;

int main(){
    cin>>A>>B>>C>>X>>Y;

    int ans=1001001001;
    rep(i,max(X,Y)+1){
        int x=max(0,X-i);
        int y=max(0,Y-i);
        int res=A*x+B*y+2*C*i;
        ans=min(ans,res);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

vector<int> G[100001];
vector<int> color;

bool bi = true;

void dfs(int cur){
    for(auto e:G[cur]){
        if(color[e]==-1){
            color[e] = !color[cur];
            dfs(e);
        }
        else if(color[e]==color[cur]){
            bi = false;
            return ;
        }
    }
}

signed main(){
    int v,e;
    cin>>v>>e;
    rep(i,e){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    color.resize(v,-1);
    color[0] = 0;
    dfs(0);
    
    if(!bi){
        cout<<v*(v-1)/2-e<<endl;
        return 0;
    }
    int zero = 0, one = 0;
    rep(i,color.size()){
        if(color[i]==0)zero++;
        else if(color[i]==1)one++;
        else abort();
    }
    
    cout<<zero*one-e<<endl;
}

Measured memory_bytes: 7552
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    if ((A*B) %2 == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n,a[100],sum=0;
	cin>>n;
	for (int i = 0; i < n; i++){
		cin>>a[i];
		sum+=a[i];
	}

	int ave;
	if(sum&1)
		ave=round((sum+1)/(double)n);
	else
		ave=round(sum/(double)n);

	int ans=0;
	for (int i = 0; i < n; i++){
		ans+=(a[i]-ave)*(a[i]-ave);
	}

	cout<<ans<<endl;


}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
for i in range(n):
  l[i]=l[i]-i-1
l=sorted(l)
if n%2==0:
  mid=(l[n//2-1]+l[n//2])//2
else:
  mid=l[(n-1)//2]
sum=0
for i in range(n):
  sum+=abs(l[i]-mid)
print(sum)

Measured memory_bytes: 26180
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long h,w;
  cin >> h >> w;
  char s[h+1][w+1],red[h+1][w+1],blue[h+1][w+1];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i%2==0){
        if(j==0){
          red[i][j]='#';
          blue[i][j]='.';
        }else{
          red[i][j]='.';
          blue[i][j]='#';
        }
      }else{
        if(j==w-1){
          red[i][j]='.';
          blue[i][j]='#';
        }else{
          red[i][j]='#';
          blue[i][j]='.';
        }
      }
      if(s[i][j]=='#'){
        red[i][j]='#';
        blue[i][j]='#';
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout << red[i][j];
    }
    cout << endl;
  }
  cout << endl;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout << blue[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dp[5010][5010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    for(int i = n-1; i >= 0; i--){
        for(int j = n-1; j >= 0; j--){
            if(s[i] == s[j]) dp[i][j] = dp[i+1][j+1] + 1;
        }
    }
    int ans = 0;
    rep(i,n)rep(j,n){
        if(i >= j) continue;
        int now = min(dp[i][j], j-i);
        chmax(ans, now);
    }
    cout << ans << endl;
    return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N,K;
    cin >> N >> K;

    vector<i64> V(N);
    rep(i,0,N) cin >> V[i];

    i64 ans=0;
    rep(l,-1,N){
        rep(r,l+1,N+1){
            i64 rem=K-(l+1)-(N-r);
            if(rem<0) continue;
            vector<i64> vec;
            rep(i,0,l+1) vec.emplace_back(V[i]);
            rep(i,r,N) vec.emplace_back(V[i]);
            sort(rbegin(vec),rend(vec));
            i64 sum=0;
            for(auto x:vec) sum+=x;
            while(rem and !vec.empty() and vec.back()<0){
                --rem;
                sum-=vec.back();
                vec.pop_back();
            }
            chmax(ans,sum);
        }
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <numeric>

#define SCAN_INT(i) scanf("%d",i)
#define FOR(i,start,end) for(int i = start;i < end;i++)
#define PRINT_INT(i) printf("%d \n",i)
#define PRINT_TWO_INT(i,j) printf("%d %d \n",i,j)
#define PRINT_THREE_INT(i,j,k) printf("%d %d %d \n",i,j,k)

int main()
{
    int y,m,d;
    
    scanf("%d/%d/%d", &y,&m,&d);
    
    if(y < 2019 || (y == 2019 && (m < 4 || (m == 4 && d <= 30))))
    {
        printf("Heisei");
        return 0;
    }
    
    printf("TBD");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
  ll K; cin>>K;
  queue<ll> q;
  for(int i=1; i<=9; i++){ 
    q.push(i);
  }
  ll x, y;
  while(K>0){
    x=q.front();
    y=x%10;
    K--;
    if(K==0){
      cout<<x<<endl;
      return 0;
    }
    q.pop();
    if(y!=0){
      q.push(10*x+y-1);
    }
    q.push(10*x+y);
    if(y!=9){
      q.push(10*x+y+1);
    }
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string s;
void input(){
    fast_io();
    cin >> s;
}

int solve(){
    for (int i = 0; i < s.length(); i++)
    {
        if(i+1<s.length()) if(s[i]==s[i+1]){
            cout << (i+1) << " " << (i+2) << endl;
            return 0;
        }
        if(i+2<s.length()) if(s[i]==s[i+2]){
            cout << (i+1) << " " << (i+3) << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 512
// ITP1_7_D:   Matrix Multiplication
// 2017.7.27

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a[101][101], b[101][101];
	long long c[101][101], s;
	int i, j, k;
	int n, m, l;

	scanf("%d%d%d", &n, &m, &l);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) scanf("%d", &b[i][j]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			s = 0;
			for (k = 0; k < m; k++) {
				s += a[i][k] * b[k][j];
			}
			c[i][j] = s;
		}
	}

	for (i = 0; i < n; i++) {
		printf("%lld", c[i][0]);
		for (j = 1; j < l; j++) printf(" %lld", c[i][j]);
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2104
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] tmp = scanner.nextLine().split(" ");
		long n = Long.parseLong(tmp[0]);
		long k = Long.parseLong(tmp[1]);
		Set<Integer> map = new HashSet<>();

		int num = 0;
		for(int i = 0; i < k; i++) {

			int now = Integer.parseInt(scanner.nextLine());
			String[] temp = scanner.nextLine().split(" ");
			for(int j = 0; j < now; j++) {

				num = Integer.parseInt(temp[j]);
				if(!map.contains(num)) map.add(num);


			}


		}

		System.out.println(n - map.size());


	}

}


Measured memory_bytes: 37108
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto i: a)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        fl(i,0,n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define what(x) cerr <<  #x << " is " << x << endl;
int sum() { return 0; }template<typename T,typename... Args>T sum(T a, Args... args) { return a + sum(args...); }


 
void solve()
{  
  double r;
  cin>>r;
  double pi =3.14159265;
   double ans=2*pi*r;
   cout<<ans;
 
}
signed main()
{fast
    int t;
 t=1;
  //cin>>t;
  while(t--)
     {
      solve();
     }
 
 
 
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
int main(void)
{
    int n,a,b;
    cin >> n >> a >> b;
    pr(a*n>b?b:a*n);
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {
    List<Integer>[] tree;
    int[] arr;
    int[] ansArr;
    int n;
    int[] dp;

    void run() {
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        arr = new int[n];
        ansArr = new int[n];
        dp = new int[n + 1];

        Arrays.fill(dp, Integer.MAX_VALUE);
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        tree = new List[n];
        for (int i = 0; i < n; i++) {
            tree[i] = new ArrayList<>();
        }
        for (int i = 0; i < n - 1; i++) {
            int u = sc.nextInt() - 1;
            int v = sc.nextInt() - 1;
            tree[u].add(v);
            tree[v].add(u);
        }

        dfs(0, 0, 0);

        StringBuilder out = new StringBuilder();

        for (int i = 0; i < n; i++) {
            out.append(ansArr[i]);
            out.append("\n");
        }

        PrintWriter pw = new PrintWriter(System.out);
        pw.println(out);
        pw.flush();
        pw.close();


    }

    void dfs(int i, int p, int len) {
        int a = arr[i];
        int j;
        if (len == 0 || dp[len - 1] < a) {
            j = len;
            len++;
        } else {
            j = lowerBound(dp, a);
        }
        int tmp = dp[j];
        dp[j] = a;

//        // ans計算
//        if (j == len) {
//            len++;
//        }
        ansArr[i] = len;
//        int ans = lowerBound(dp, Integer.MAX_VALUE);
//        ansArr[i] = ans;

        for (int nextIdx : tree[i]) {
            if (nextIdx == p) {
                continue;
            }
            dfs(nextIdx, i, len);
        }
        dp[j] = tmp;
    }


    public int upperBound(int[] array, int value) {
        int left = -1;
        int right = array.length;
        while (right - left > 1) {
            int middle = (right + left) / 2;
            if (array[middle] > value) {
                right = middle;
            } else {
                left = middle;
            }
        }
        return right;
    }

    public int lowerBound(int[] array, int value) {
        int left = -1;
        int right = array.length;
        while (right - left > 1) {
            int middle = (right + left) / 2;
            if (array[middle] >= value) {
                right = middle;
            } else {
                left = middle;
            }
        }
        return right;
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 100788
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;


int main(){
    int N, M, A, B, C;
    string s1, s2;
    cin >> A >> B >> C;
    int n = A * 100 + B * 10 + C;
    if(n % 4==0)cout <<"YES" << endl;
    else cout <<"NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
int main()
{
    ll ini, mov, dis; cin>>ini>>mov>>dis;
    if(ini<0) ini*=-1;
    if(ini>dis)
    {
        ll a=ini/dis;
        if(mov<=a)
        {
            ll r=ini-(dis*mov);
            cout<<r;
            return 0;
        }
        ll rem=ini%dis;
        //cout<<rem<<endl;
        //cout<<mov<<" "<<a<<endl;
        ll mov_rem=mov-a;
        //cout<<mov_rem<<endl;
        if(mov_rem%2==0)
        {
           cout<<rem; return 0;
        }
        cout<<abs(rem-dis); return 0;
    }
    else if(ini==dis)
    {
        if(mov%2==0)
        {
           cout<<dis; return 0;
        }
        cout<<"0"; return 0;
    }
    ll d=abs(ini-dis);
    if(d<=ini)
    {
        if(mov%2!=0)
        {
            cout<<d; return 0;
        }
        cout<<ini; return 0;
    }
    if(mov%2==0)
    {
        cout<<ini; return 0;
    }
    cout<<d; return 0;
}

Measured memory_bytes: 3648
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
const double PI = acos(-1.0);
const double  EPS = 1e-11;
typedef long long ll;
//freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
void fast()
{
	std::ios_base::sync_with_stdio(0);
}
int main()
{
	int arr[3];
	cin >> arr[0] >> arr[1] >> arr[2];
	sort(arr, arr + 3);
	int cnt=0;
	if ((arr[0] % 2 == 0 && arr[1] % 2 != 0) || (arr[0] % 2 != 0 && arr[1] % 2 == 0))
	{
		arr[0]++, arr[2]++;
		cnt++;
	}
	cnt += (arr[1] - arr[0]) / 2;
	cnt += arr[2] - arr[1];
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>


const long long int infty = 1e14;
long long int zero = 0;

int main(){
  
  // read problem
  long long int N, K, tmp;
  std::vector<long long int> H;
  scanf("%lld%lld", &N, &K);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    H.push_back(tmp);
  }
  
  // solve problem
  std::vector<std::vector<long long int> > dp(N);
  for(long long int i = 0; i < N; i++){
    for(long long int j = 0; j <= K; j++){
      dp[i].push_back(0);
    }
  }
  
  // calculate dp
  for(long long int i = 0; i < N; i++){
    
    // dp[i][j] for j<i
    for(long long int j = 0; j < i && j<=K; j++){
      // initialize
      if(j>0){
        dp[i][j] = dp[i][j-1];
      }
      else{
        dp[i][j] = infty;
      }
      // upadte
      for(long long int d = 0; j-d>=0; d++){
        dp[i][j] = std::min(dp[i][j], dp[i-1-d][j-d] + std::max(zero, H[i]-H[i-1-d]));
      }
    }
    // dp[i][i]
    if(i==0){
      dp[0][0] = H[0];
    }
    if(i>0 && i<=K){
      dp[i][i] = std::min(H[i], dp[i][i-1]);
    }
  }
  
  /*std::cerr << "result of dp:" << std::endl;
  for(long long int i = 0; i < N; i++){
    for(long long int j = 0; j <= K; j++){
      std::cerr << dp[i][j] << " ";
    }std::cerr << std::endl;
  }*/
  
  
  // calculate answer
  if(N==K){
    std::cerr << "Answer:" << std::endl;
    std::cout << 0 << std::endl;
    return 0;
  }
  
  long long int ans = infty;
  for(long long int i = 0; i < N; i++){
    if(K >= N-i-1){
      ans = std::min(ans, dp[i][K-(N-i-1)]);
    }
  }
  std::cerr << "Answer:" << std::endl;
  std::cout << ans << std::endl;
  
  return 0;
}


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


int main() {
  int N, M; cin >> N >> M;
  vector<int> A(N);
  rep(i, M) cin >> A[i];
  
  rep(i, M) N -= A[i];
  
  if(N < 0) cout << -1 << endl;
  else cout << N << endl;
  
}

Measured memory_bytes: 7216
#include<bits/stdc++.h>
using namespace std;
#define fo(i, k, n) for (int i = k; i <= n; ++ i)
#define fod(i, k, n) for (int i = k; i >= n; -- i)
template <typename T, typename U>
static inline void maxx (T &x, U y) {
  if (x < y) {
    x = y;
  }
}
template <typename T, typename U>
static inline void minn (T &x, U y) {
  if (x > y) {
    x = y;
  }
}
template<typename T>
void read (T &x) {
  x = 0;
  T neg = 1;
  register T c = getchar ();
  if (c == '-') {
    neg = -1;
  }
  while (c < 48 || c > 57) {
    c = getchar ();
  }
  for (; c < 48 || c > 57; c = getchar ());
  for (; c <= 57 && c >= 48; c = getchar ()) {
    x = (x << 3) + (x << 1) + (c & 15);
  }
  x *= neg;
}
template<typename T>
void write (T x) {
  bool neg = 0;
  if (x < 0) {
    x *= -1;
    neg = 1;
  }
  char snum[65];
  int i = 0;
  do {
    snum[++ i] = x % 10 + '0';
    x /= 10;
  }
  while (x);
  //-- i;
  if (neg) {
    putchar ('-');
  }
  while (i > 0) {
    putchar (snum[i --]);
  }
}
///declare
int main () {
  if (fopen ("test.inp", "r")) {
    freopen ("test.inp", "r", stdin);
  }
//  else {
//    freopen(".inp", "r", stdin);
//    freopen(".out", "w", stdout);
//  }
  ios_base :: sync_with_stdio (0);
  cin.tie (nullptr);
  cout.tie (nullptr);
  int n;
  read (n);
  write (n * n * n);
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
INF = float("inf")

# Binary Indexed Tree
class BIT:
    def __init__(self, N):
        self.N = N
        self.bit = [0] * (N+1)
    def add(self, x, a):
        while x <= self.N:
            self.bit[x] += a
            x += x & -x
    def sum(self, x):
        ret = 0
        while x != 0:
            ret += self.bit[x]
            x -= x & -x
        return ret

N = int(input())
S = list(input())
Q = int(input())
bit = [BIT(N+1) for i in range(26)]
for i in range(N):
    bit[ord(S[i])-97].add(i+1, 1)
for i in range(Q):
    q, x, y = input().split()
    q = int(q)
    if q == 1:
        i = int(x)-1
        bit[ord(S[i])-97].add(i+1, -1)
        S[i] = y
        bit[ord(y)-97].add(i+1, 1)
    else:
        l, r, ans = int(x), int(y), 0
        for i in range(26):
            ans += (bit[i].sum(r)-bit[i].sum(l-1))> 0
        print(ans)


Measured memory_bytes: 164380
s = list(input())
def dfs(s, rest):
    if len(rest) != 0:
        r = rest.pop(0)
        return dfs(s[:] + ['+'] + [r], rest[:]) + dfs(s[:] + [r], rest[:])
    else:
        return eval(s)
def eval(s):
    sum = 0
    c = ""
    for i in s:
        if i == "+":
            sum += int(c)
            c = ""
        else:
            c += i
    return sum + int(c)
r = s.pop(0)
print(dfs([r],s))

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N, M;
    cin >> N >> M;
    vector<pair<LP, LL>> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i].F.F >> v[i].F.S >> v[i].S;

    }

    LL res = 0;
    for(int i = 0; i < 8; ++i) {
        vector<LP> sum;
        for(int j = 0; j < N; ++j) {
            LL s = 0;
            if(i & 1) s += v[j].F.F;
            else s -= v[j].F.F;
            if((i >> 1) & 1) s += v[j].F.S;
            else s -= v[j].F.S;
            if((i >> 2) & 1) s += v[j].S;
            else s -= v[j].S;
            sum.pb(MP(s, j));

        }
        sort(all(sum), greater<LP>());

        LL a = 0, b = 0, c = 0;
        for(int j = 0; j < M; ++j) {
            int pos = sum[j].S;
            a += v[pos].F.F;
            b += v[pos].F.S;
            c += v[pos].S;

        }
        res = max(res, llabs(a) + llabs(b) + llabs(c));
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 384
// AOJ ALDS1_9_B: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_B

package main

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

type maxHeap struct {
	heap []int
	size int
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func (mh maxHeap) buildMaxHeap() {
	for i := mh.size / 2; i >= 1; i-- {
		mh.maxHeapify(i)
	}
}

func (mh maxHeap) maxHeapify(i int) {
	l := mh.left(i)
	r := mh.right(i)

	// 自分、左の子、右の子で値が最大のnodeを選ぶ
	largest := i
	if l <= mh.size && mh.heap[l] > mh.heap[i] {
		largest = l
	}

	if r <= mh.size && mh.heap[r] > mh.heap[largest] {
		largest = r
	}

	// iの子のほうが値が大きい場合
	if i != largest {
		mh.heap[i], mh.heap[largest] = mh.heap[largest], mh.heap[i]
		mh.maxHeapify(largest) // 再帰的に呼び出し
	}
}

func (mh maxHeap) left(i int) int {
	return 2 * i
}

func (mh maxHeap) right(i int) int {
	return 2*i + 1
}

func (mh maxHeap) printHeap() {
	buf := bufio.NewWriter(os.Stdout)
	for i := 1; i < mh.size+1; i++ {
		buf.Write([]byte(fmt.Sprintf(" %d", mh.heap[i])))
	}
	buf.Write([]byte("\n"))
	buf.Flush()
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	h := nextInt(sc)

	mh := maxHeap{make([]int, h+1), h}

	for i := 1; i < h+1; i++ {
		mh.heap[i] = nextInt(sc)
	}

	mh.buildMaxHeap()
	mh.printHeap()
}



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

int main(){
  int year = 0;
  ll money = 100;
  ll X;
  cin >> X;
  while (money < X){
    money = money + money / 100;
    year++;
  }
  
  cout << year << endl;
  
}  


Measured memory_bytes: 3580
n = int(input())
s = input()

a = 0
ii = [0]*10
for i in range(n-2):
  si = int(s[i])
  if sum(ii) == 10:
    break
  elif ii[si] == 1:
    continue
  else:
    ii[si] = 1
  jj = [0]*10
  for j in range(i+1,n-1):
    sj = int(s[j])
    if sum(jj) == 10:
      break
    elif jj[sj] == 1:
      continue
    else:
      jj[sj] = 1
    kk = [0]*10
    for k in range(j+1,n):
      sk = int(s[k])
      if sum(kk) == 10:
        break
      else:
        kk[sk] = 1
    a += sum(kk)
print(a)

Measured memory_bytes: 44892
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    if (n == 1)
    {
    	cout<<"Hello World";
    }
    else
    {
    	int a,b;
    	cin>>a>>b;
    	cout<<a+b;
    }
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int n,i,u,v;
	cin>>n;
	vi adj[n+1];
	REP(i,1,n-1){
		cin>>u>>v;
		adj[u].EB(v);
		adj[v].EB(u);
	}
	ll ans=0,prev=0;
	int idx=0,p;
	set<int> s;
	REP(i,1,n){
		set<int> v;
		for(auto u:adj[i]){
			if(s.find(u)!=s.end()) v.insert(u);
		}
		ans+=prev+i;
		prev+=i;
		idx=0;
		p=0;
		for(auto u:v){
			ans-=(u-p)*(sz(v)-idx);
			prev-=(u-p)*(sz(v)-idx);
			idx++;
			p=u;
		}
		s.insert(i);
		// dbg(ans,prev,s,ma,mi);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 33648