akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

//===
template<typename T, typename Compare = less<T> >
struct SkewHeap {
    struct Node {
        T dat;
        Node *l, *r;

        Node (T dat): dat(dat), l(nullptr), r(nullptr) {};
    };

    Node *root;
    Compare cmp;

    SkewHeap (Compare cmp = Compare()): root(nullptr), cmp(cmp) {};

    Node *meld(Node *h1, Node *h2) {
        if (h1 == nullptr) return h2;
        else if (h2 == nullptr) return h1;

        if (cmp(h2->dat, h1->dat)) swap(h1, h2);

        h1->r = meld(h1->r, h2);
        swap(h1->l, h1->r);

        return h1;
    };

    void push(T dat) {
        Node *u = new Node(dat);
        root = meld(root, u);
    };

    T top() { return root->dat; };
    
    T pop() {
        T ret = top();
        Node *rm = root;
        root = meld(root->l, root->r);
        delete rm;
        
        return ret;
    };

    void merge_with(SkewHeap &h) {
        root = meld(root, h);
        h.root = nullptr;
    };

    bool empty() { return root == nullptr; };
};
// MinHeap<T> = SkewHeap<T, less<T>>
// MaxHeap<T> = SkewHeap<T, greater<T>>
//===

int ABC141D() {
    llong n, m;
    llong a;
    SkewHeap<llong, greater<llong> > h;

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a;
        h.push(a);
    }

    for (int i = 0; i < m; i++) {
        a = h.pop() / 2;
        h.push(a);
    }

    llong sum = 0;
    while (!h.empty()) {
        sum += h.pop();
    }

    cout << sum << endl;
    
    return 0;
}

int main() {
    return ABC141D();
}


Measured memory_bytes: 3328
/**
*	created: 10.08.2020 00:10:36
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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 (b < a) {a = b; return 1;} return 0;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8] = {1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, k; cin >> n >> k;
    string s; cin >> s;
    int x = 0, y = 0;
    if (s[0] == 'L') y++;
    if (s[n-1] == 'R') y++;
    rep(i,n-1) if (s[i] == 'R' && s[i+1] == 'L') x++;
    int ans = n - 2 * x - y;
    if (k > x + y) ans = n-1;
    else if (k > x) ans += x + k;
    else ans += k*2;
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const ll INF = 1001001001;
const ll MOD = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  ll a[100000];
  ll m = INF;
  ll cnt = 0;
  ll ans = 0;
  rep(i, n){
    cin >> a[i];
    m = min(abs(a[i]), m);
    if(a[i] < 0) cnt++;
    ans += abs(a[i]);
  }
  if(cnt % 2) cout << ans - 2*m <<endl;
  else cout << ans <<endl;
}

Measured memory_bytes: 4368
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        boolean TF = false;
        
        for (int i = A; i <= B; i++) {
            if(i % K == 0) {
                TF = true;
                break;
            } 
        }

        if (TF) {
            System.out.println("OK");
        } else {
            System.out.println("NG");
        }
    }
}


Measured memory_bytes: 35696
<?php
fscanf(STDIN, "%d", $a);
$datas = explode(' ',trim(fgets(STDIN)));

$count = 0;
for($i = 0; $i < $a; $i++) {
  if($datas[$i] != $i+1) {
    $count++;
  }
}

if($count == 2 || $count == 0){
    echo "YES";
}else{
    echo "NO";
}

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

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;
    // 上限N-1
    int ans = 0;
    S = "R" + S + "L";
    for (int i = 1; i <= N; ++i) {
        if(S[i] == 'R'){
            if(S[i+1] == 'R') ans++;
        } else{
            if(S[i-1] == 'L') ans++;
        }
    }
    ans += 2*K;
    ans = min(N-1, ans);
    cout << ans;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<climits>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;

int main(){
	int N, M;
	cin >> N >> M;
	vector<pii> ab(N), cd(M);
	for (int i = 0; i < N; ++i)
		cin >> ab[i].first >> ab[i].second;
	for (int i = 0; i < M; ++i)
		cin >> cd[i].first >> cd[i].second;

	for (int i = 0; i < N; ++i){
		int mi = INF, p = 0;
		for (int j = 0; j < M; ++j){
			int tmp = abs(ab[i].first - cd[j].first) + abs(ab[i].second - cd[j].second);
			if (tmp < mi){
				mi = tmp;
				p = j + 1;
			}
		}
		cout << p << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())

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

for i in range(1,n):
    arr = list(map(int, input().split()))

    dp[0],dp[1],dp[2] = arr[0] + max(dp[1],dp[2]),arr[1] + max(dp[0],dp[2]),arr[2] + max(dp[0],dp[1])

print(max(dp))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{

    string a,b,u;
    cin >> a >> b;
    int aa,bb;
    cin >> aa >> bb;

    cin >> u;

    if(u == a){
        aa--;
    }else{
        bb--;
    }

    cout << aa << " " << bb << endl;
    

// cout << ans << endl;
return 0;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b, c, n, x, y;
  cin >> a >> b >> x; //>> y;
  pr((a + b) * x / 2);

  return 0;
}

Measured memory_bytes: 3612
a,b,k = map(int, input().split())
a_div = {i for i in range(1,a+1) if a%i == 0}
b_div = {i for i in range(1,b+1) if b%i == 0}
sorted_div = sorted(list(a_div & b_div), reverse=True)
print(sorted_div[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll h, w, sharp = 0;
    cin >> h >> w;
    char field[9][9];
    fill(field[0], field[9], '.');
    rep(i, h){
        rep(j, w){
            cin >> field[i][j];
            if(field[i][j] == '#') sharp++;
        }
    }
    ll x = 0, y = 0, cnt = 1;
    while(true){
        if(field[y+1][x] == '.' && field[y][x+1] == '.') break;
        else if(field[y][x+1] == '#') x++;
        else if(field[y+1][x] == '#') y++;
        cnt++;
    }
    if(cnt == sharp) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    bool found = false;
    int i,j,n;
    cin >> n;
    for(i=1;i<10;i++){
        for(j=0;j<10;j++){
            if(i*j==n){
                cout << "Yes"<<endl;
                found = true;
                break;
            }
        }
        if(found == true){
            break;
        }
    }
    if(found == false){\
        cout << "No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>

using namespace std;

int main() {
	int n,m;
	cin >> n >> m;
	int a[31][31];
	for(int i = 0;i < 31;i++) for(int j = 0;j < 31;j++) a[i][j] = 0;
	for(int i = 0;i < n;i++) {
		int k;
		cin >> k;
		for(int j = 0;j < k;j++) {
			int q;
			cin >> q;
			a[i][q]++;
		}
	}
	int count = 0;
	for(int i = 1;i <= m;i++) {
		bool ok = true;
		for(int j = 0;j < n;j++) {
			if(a[j][i] == 0) {
				ok = false;
			}
		}
		if(ok) count++;
	}
	cout << count<<endl;
}


Measured memory_bytes: 256
s = str(input())
if len(s) % 2 == 1:
    print("No")
    exit()
j = 0
while j < len(s) - 1:
        # 前から5文字ずつ見ていく
        if s[j:j + 2] == "hi":
            # 一致すれば5文字分進める
            j += 2
        else:
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 2940
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	var l int

	fmt.Scan(&n, &l)
	t := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&t[i])
	}

	sort.Strings(t)

	ret := ""
	for i := 0; i < n; i++ {
		ret += t[i]
	}
	fmt.Println(ret)
}

Measured memory_bytes: 1280
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
#define F first
#define S second 
#define pb push_back
#define all(x) x.begin(),x.end()
#define fileoi freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
using ll = long long;
const ll maxn=1e6+6,inf=1e18+18,mod=1e9+7;
ll n,a[maxn],x,num[maxn],num2[1005];
vector <ll> prm;
bool mark[1005],b;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	for(int i=2;i<1000;i++){
		if(mark[i])continue;
		for(int j=i+i;j<1000;j+=i)mark[j]=1;
		prm.pb(i);
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i==0)x=a[i];
		else x=__gcd(x,a[i]);
		if(!b){
			for(int j:prm){
				if(a[i]%j==0)num2[j]++;
				if(num2[j]>1){
					b=1;
					break;
				}
				while(a[i]%j==0)a[i]/=j;
			}
			if(a[i]>1){
				if(num[a[i]]>0)b=1;
				num[a[i]]++;
			}
		}
	}
	if(!b)cout<<"pairwise coprime"<<endl;
	else if(x==1)cout<<"setwise coprime"<<endl;
	else cout<<"not coprime"<<endl;
}


Measured memory_bytes: 12044
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> A;
    cin >> B;

    cout << A*B << endl;    

}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){
	int n;
	int a,b;
	int i,j,k;
	int s=0;
	cin>>n;
	for(i=0,b=0;i<n;i++){
		cin>>a;
		if(a==i+1)b++;
		else{
			s+=(b+1)/2;
			b=0;
		}
	}
	s+=(b+1)/2;
	cout<<s<<endl;
	return 0;
}
	
	
	
	
	


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;


int ans,ans2;
int n,m;
int a[111111];
signed main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n-1){
        if(a[i]<a[i+1]){
            a[i+1]--;
        }
    }
    rep(i,n-1){
        if(a[i]>a[i+1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(solve(a, b));
	}

	private static int solve(int a, int b) {
		int r = a + b;
		if(a-b>r)
			r=a-b;
		if(a*b>r)
			r=a*b;
		return r;
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std ;
 
const long long mod = 1e9 + 7 ;
 
string a[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int main ( ) {

	
	string s;
	cin >> s;
	int pos =0 ;
	for(int i = 0; i < 7; i++) if(a[i]==s)pos=i;

	cout << 6 - pos+1;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

template<typename T>
int index(const vector<T> &zip, T i) { return lower_bound(zip.begin(), zip.end(), i) - zip.begin(); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K; cin >> N >> K;
	vector<int> H(N); rep(i, 0, N) {
		cin >> H[i];
	}

	vector<int> h = H;
	h.push_back(0);
	sort(all(h));
	h.erase(unique(h.begin(), h.end()), h.end());

	dump(h);
	int M = h.size();

	auto dp = gen_v<int>(2, M, K + 1);
	fill_v(dp, INF);
	dp[0][0][0] = 0;


	rep(i, 0, N) {
		dump(dp[i & 1]);
		rep(j, 0, M) { // 前の列の高さ h[j]
			rep(k, 0, K + 1) {
				chmin(dp[!(i & 1)][index(h, H[i])][k], dp[i & 1][j][k] + max(H[i] - h[j], 0LL));
				if (k < K)chmin(dp[!(i & 1)][j][k + 1], dp[i & 1][j][k]);
			}
		}

		rep(j, 0, M)rep(k, 0, K + 1) {
			dp[i & 1][j][k] = INF;
		}
	}

	int ans = INF;
	rep(j, 0, M)rep(k, 0, K + 1) {
		chmin(ans, dp[N & 1][j][k]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2432
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int min = arr.length;
		for (int i = 1; i < arr.length; i++) {
			if (arr[i] != arr[i - 1]) {
				min = Math.min(min, Math.max(i, arr.length - i));
			}
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 28000
#include<stdio.h>
#include<iostream>

using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie();
	int t;
	cin>>t;
	int a,b;
	cin>>a>>b;
	bool f=false;
	for(int i=a;i<=b;i++){
		if(i%t==0){
			f=true;
			break;
		}
	}
	if(f) cout<<"OK"<<endl;
	else cout<<"NG"<<endl;
}

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

int main() {
    int n, y;
    cin >> n >> y;
    rep(a, n + 1) {
        rep(b, n + 1) {
            if (b * 10000 + a * 5000 > y) break;
            int c = n - a - b;
            if (c >= 0 && b * 10000 + a * 5000 + c * 1000 == y) {
                printf("%d %d %d", b, a, c);
                return 0;
            }
        }
    }
    printf("%d %d %d", -1, -1, -1);
    return 0;
}


Measured memory_bytes: 256
from itertools import product
import numpy as np
inputs = open(0).readlines()

class Grid():
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, rows in zip(range(h), grid):
            for j, val in zip(range(w), rows):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, rows)) for rows in self.grid])

h, w = map(int, inputs[0].split())
grid = Grid(inputs[1:])

def dfs(root):
    count = 1
    stack = [root]
    while stack:
        x, y = stack.pop()
        grid.grid[y, x] = '.'
        for dx, dy in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            if grid.is_valid_xy(x+dx, y+dy) and grid.grid[y+dy, x+dx] == '#':
                stack.append((x+dx, y+dy))
                count += 1
    return count

ans = 'Yes'
for i, j in product(range(h), range(w)):
    if grid.grid[i, j] == '#':
        if dfs((j, i)) == 1:
            ans = 'No'
            break
print(ans)

Measured memory_bytes: 12248
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
typedef pair<int,int> op;
const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n;
	int a[55]={};
	int mm=0,pp=0,absmax=0,bb=1,idx=0;
	queue<op> qq;
	cin>>n;
	FOR(i,0,n){
		cin>>a[i];
		if(a[i]>0)pp=1;
		else if(a[i]<0)mm=1;
		if(absmax<abs(a[i])){
			absmax=abs(a[i]);
			if(a[i]>0)bb=0;
			else bb=1;
			idx=i;
		}
	}
	if(mm==1&&pp==1){
		if(bb==0)mm=0;
		else pp=0;
		FOR(i,0,n){
			qq.push(op(idx+1,i+1));
			a[i]+=a[idx];
		}

	}
	if(mm==0&&pp==1){
		FOR(i,0,n-1){
			if(a[i]>a[i+1]){
				qq.push(op(i+1,i+2));
				a[i+1]+=a[i];
			}
		}
	}else if(mm==1&&pp==0){
		FORD(i,n-1,0){
			if(a[i]>a[i+1]){
				qq.push(op(i+2,i+1));
				a[i]+=a[i+1];
			}
		}
	}else{
		//cout<<0<<endl;
	}
	cout<<qq.size()<<endl;
	while(!qq.empty()){
		op o=qq.front();
		qq.pop();
		cout<<o.ST<<" "<<o.ND<<endl;
	}
    return 0;
}


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

int countSubstr(string S, string substr){
    int count = 0;
    size_t offset = 0;
    while((offset = S.find(substr, offset)) != string::npos){
        count++;
        offset++;
    }
    return count;
}


int main(){
    int N;
    string S;
    cin >> N >> S;
    cout << countSubstr(S, "ABC") << endl;
    return 0;
}

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

int dsum(int a) {
  int d = 0;
  while(a != 0) {
    d += a % 10;
    a /= 10; 
  }
  return d;
}

int main(){
  int n;
  cin >> n;
  int ans = INF;
  for(int i = 1; i < n; i++) {
    ans = min(ans,dsum(i)+dsum(n-i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main ()
{
	string s;
	cin>>s;
	ll ar[1000001] = {0};
	string a = "Yes";
	for(size_t i = 0; i<s.size(); i++)
	{
		ar[s[i]]++;
	}
	for(ll i = 'a'; i<'z'; i++)
	{
		if(ar[i]%2 != 0)
		{
			a = "No";
		}
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 11416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll n, m, k;
    cin >> n >> m >> k;

    ll A[n];
    ll a[n + 1];
    a[0] = 0;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        a[i + 1] = a[i] + A[i];
    }

    ll B[m];
    ll b[m + 1];
    b[0] = 0;
    for(int i = 0; i < m; i++){
        cin >> B[i];
        b[i + 1] = b[i] + B[i];
    }

    ll ans = 0;
    ll j = m;
    for(int i = 0; i < n + 1; i++){
        if(a[i] > k)
            break;
        while(b[j] > k - a[i]){
            j -= 1;
        }
        ans = max(ans, i + j);
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 9816
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn is_odd_dig(x: u32) -> bool {
  x.to_string().len() % 2 == 1
}

fn main() {
  let n: u32 = read();
  let mut ans = 0;
  for i in 1..n + 1 {
    if is_odd_dig(i) { ans += 1 };
  }

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


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

int main(){
    int n,m;
    cin >> n >> m;
    set<int> a;
    vector<pair<int,int>> b;
    vector<int> from(m),to(m);
    for(int i = 0; i < m; i++){
        cin >> from[i] >> to[i];
        if(from[i] == 1)
        a.insert(to[i]);
        if(from[i] != 1 && to[i] == n)
        b.push_back(make_pair(from[i],to[i]));
    }
    for(int i = 0; i < b.size(); i++){
        if(a.count(b[i].first)){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

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

using namespace std;

#define MAX_N 4000

typedef long long ll;

const ll INF = 1e15;


ll dp[MAX_N+1][MAX_N+1], K[MAX_N+1][MAX_N+1];
int main() {
	int N; cin >> N;
	vector<ll> cost(N+1);
	for (int i = 0; i < N; ++i) {
		cin >> cost[i+1];
		cost[i+1] += cost[i];
	}

	fill(dp[0], dp[MAX_N+1], INF);
	for (int i = 0; i <= N; ++i) {
		dp[i][i] = 0;
		K[i][i] = i;
	}
	for (int w = 1; w <= N; ++w) {
		for (int l = 0, r = l+w; r < N; ++l, ++r) {
			for (int k = K[l][r-1]; k <= K[l+1][r]; ++k) {
//			for (int k = l; k < r; ++k) {
				ll c = dp[l][k]+dp[k+1][r]+cost[r+1]-cost[l];
				if (c <= dp[l][r]) {
					K[l][r] = k;
					dp[l][r] = c;
				}
			}
		}
	}
	cout << dp[0][N-1] << endl;
}

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

#define mod 1000000007

#define rep(i, n) for(int i=0; i<n; ++i)

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N;
	int ans = 0, count = 0;
	
	cin >> N;
	
	ll H[N];
	
	rep(i, N)
		cin >> H[i];
		
	rep(i, N){
		if(H[i] >= H[i+1])
			count++;
		else{
			ans = max(ans, count);
			count = 0;
		}
	}
	
	cout << ans;
	
	return 0;
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/4;
    public static final int inf = Integer.MAX_VALUE/4;

    static void solve(InputReader in, PrintWriter out){
        int a = in.ni(), b = in.ni(), c = in.ni();
        boolean flag = false;
        for (int i = 0; i < b; i++) {
            if(a*i%b==c){
                flag = true;
                break;
            }
        }
        out.println(flag?"YES":"NO");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;

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

    ll t = 0, ans = 1e18;
    for (int i = 0; i < n; i++) {
        t += a[i];
        ans = min(ans, abs(2 * t - s));
    }
    cout << ans << endl;

    

}


Measured memory_bytes: 1792
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    t1 = 0
    t2 = 0
    b = True
    for i in range(len(s)):
        if bool(int(s[i])) != b:
            t1 += 1
        if bool(int(s[i])) == b:
            t2 += 1
        b = not b
    print(min(t1, t2))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 42220
#include "bits/stdc++.h"
using namespace std;
#define debug(var) cout << #var << ": " << var << endl;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
using ll = long long;
using ull = unsigned long long;
using vvint = vector<vector<int>>;
constexpr ll mod = 1e9 + 7;

int main() {

  int A, B; cin >> A >> B;
  int sum = A;
  if (B == 1) {
	cout << 0;
	return 0;
  }
  int i = 0;
  for (i = 0; sum < B; i++)sum += (A - 1);
  cout << i + 1;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>  
#include<algorithm>  
#include<vector>  
#include<queue>  
#include<string>  
#include<cstring>  
#include<iostream>  
#include<map>
using namespace std;
#define ll long long  
const int maxn = 1e5 + 500;
map<ll,ll>a;
int main() {
	int n;
	while (~scanf("%d", &n)) {
		a.clear();
		ll x, sum = 0, ans = 0;
		for (int i = 0; i < n; i++) {
			scanf("%lld", &x);
			sum += x;
			ans += a[sum];
			if (sum == 0)ans++;
			a[sum]++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<vector>
#include<algorithm>


using namespace std;

int N, H;
vector<int> a;
vector<int> b;

int main() {
    cin >> N >> H;
    for (int i = 0; i < N; ++i) {
        int ai, bi;
        cin >> ai >> bi;
        a.push_back(ai);
        b.push_back(bi);
    }

    sort(b.begin(), b.end(), greater<int>());
    sort(a.begin(), a.end(), greater<int>());

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        if(b[i] < a[0]) break;
        H -= b[i];
        ans++;
        if (H <= 0) break;
    }

    if (H > 0) {
        ans += (H + a[0] - 1) / a[0];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1276
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

//UnionFind
class UnionFind {
private:
    vector<int> par;
public:
    UnionFind(int n) {
        par = vector<int>(n, -1);
    }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (size(rx) < size(ry)) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
    }

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

    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    UnionFind uni(N);
    int connect = N;
    REP(i, M) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        if (!uni.same(x, y)) {
            uni.unite(x, y);
            connect--;
        }
    }
    cout << connect << endl;
    getchar(); getchar();
}

Measured memory_bytes: 640
<?php
$S=trim(fgets(STDIN));
$Q=trim(fgets(STDIN));
for($I=0;$I<$Q;$I++){
  $C=explode(' ',trim(fgets(STDIN)));

  if($C[0][2]=='i'){
    $p='';
    for($i=$C[1];$i<=$C[2];$i++) $p.=$S[$i];
    echo $p,PHP_EOL;
    continue;
  }
  if($C[0][2]=='v'){
    $l=($C[2]-$C[1]+1)>>1;
    for($i=0;$i<$l;$i++){
      $j=$C[2]-$i;
      $k=$C[1]+$i;
      $s=$S[$j];
      $S[$j]=$S[$k];
      $S[$k]=$s;
    }
    continue;
  }
  for($i=$C[1];$i<=$C[2];$i++) $S[$i]=$C[3][$i-$C[1]];
}

Measured memory_bytes: 15520
#include<bits/stdc++.h>
using namespace std;
#define int long long 

signed main(void){
  int N,K; cin >> N >> K;
  vector<int> H(N);
  for(int i = 0; i < N; i++){ 
    cin >> H[i];
  }
  
  sort(H.rbegin(),H.rend());
  
  int cnt = 0;
  
  for(int i = K; i < N; i++){ 
    cnt += H[i];
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <cmath>
#include <cstring>
#include <iostream>
#include <ostream>
#include <vector>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> v) {
	os << "[";
	for(int i = 0; i < int(v.size()); i++) {
		os << v[i] << (i == int(v.size()) - 1 ? "" : ", ");
	}
	os << "]";
	return os;
}

// n 以下の素数のリストを返す O(nlog(log(n)))
std::vector<int> eratosthenes(int n) {
	std::vector<int> is_prime(n + 1, 1);
	std::vector<int> primes;

	is_prime[0] = is_prime[1] = 0;
	primes.push_back(2);
	for(int i = 3; i <= n; i += 2) {
		if(is_prime[i]) {
			primes.push_back(i);
			for(int j = 3; i * j <= n; j += 2) {
				is_prime[i * j] = 0;
			}
		}
	}

	return primes;
}

int main() {
	int n;

	while(cin >> n, n) {
		std::vector<int> primes = eratosthenes(n);

		for(int i = int(primes.size()) - 1; i > 0; i--) {
			if(primes[i] - primes[i - 1] == 2) {
				cout << primes[i - 1] << " " << primes[i] << endl;
				break;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3192
import sys #追加
sys.setrecursionlimit(10**9)
import time
s = time.time()

n,m = map(int,input().split())
al = list(map(int,input().split()))

bl = [i//2 for i in al]
from fractions import gcd
ans = 1
for b in bl:
   if time.time() - s > 1.9:
      print(0)
      import sys
      sys.exit()
   ans = (ans * b) // gcd(ans, b)

for a in al:
   if time.time() - s > 1.9:
      print(0)
      import sys
      sys.exit()
   if ans % a == 0:
      print(0)
      import sys
      sys.exit()

def ceil(a, b):
   return a // b + (a % b > 0)

print(ceil(m // ans, 2))


Measured memory_bytes: 15056
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define pi acos(-1)
using namespace std;
int main() {
    int x,y;
    while (cin>>x>>y&&(x!=0||y!=0)) {
        for(int i=1;i<=x;i++)
            for(int j=1;j<=y;j++)
            {
                if(i%2==1)
                {
                    if(j%2==1)printf("#");
                    else printf(".");
                }
                if(i%2==0)
                {
                    if(j%2==0)printf("#");
                    else printf(".");
                }
                if(j==y)printf("\n");
            }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 3052
from math import sqrt
def is_prime(n):
	u = int(sqrt(n)+1)
	for i in range(2,u):
		if n%i == 0:
			return 0
	return 1

num = int(input())
a = 11
b = 0
while b<num:
	if is_prime(a):
		print(a, end = ' ')
		b+=1
	a += 10


Measured memory_bytes: 3060
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++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 SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    string n;
    cin >> n;

    int k;
    cin >> k;

    vector< vector< vector<lint> > > dp(n.size() + 1, vector< vector<lint> >(2, vector<lint>(k + 1, 0LL)));
    dp[0][0][0] = 1;

    rep(i, n.size()){
        rep(j, 2){
            rep(l, k + 1){
                int lim = j ? 9 : n[i] - '0';
                for(int d = 0 ; d <= lim ; ++d){
                    if(l + (d > 0) <= k) dp[i + 1][j || d < n[i] - '0'][l + (d > 0)] += dp[i][j][l];
                }
            }
        }
    }

    cout << dp[n.size()][0][k] + dp[n.size()][1][k] << endl;

    cout << flush;

    return 0;
}

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

int main(){

    int X, Y;
    cin >> X >> Y;

    for (int i = 0; i <= X; i++){
        if (i*2 + (X-i)*4 == Y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cmath>

using namespace std;

int main(void){
  int sum = 0, N, K, difa, difb;
  cin >> N >> K;
  int x[N];
  for(int i=0; i<N; i++){
    cin >> x[i];
    difa = abs(x[i]);
    difb = abs(x[i]-K);
    sum += difa < difb ? difa * 2 : difb * 2;
  }
  cout << sum << endl;
}


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

int main()
{
	int n,m;
    cin>>n>>m;
    long long a[n],sum=0;;
    for(int i=0; i<n; i++){
        cin>>a[i];
        sum+=a[i];
    }
    double min=sum/(4.0*m);
    long long count=0;
    for(int i=0; i<n; i++){
        if(a[i]>=min) count++;
    }
    
    if(count>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll  pown(ll a, ll n, ll mod)
{
    ll res=1;
    while(n>0)
    {
        if(n%2!=0)
        {
            res=(res*a)%mod;
        }
        n/=2;
        a=(a*a)%mod;
    }
    return res;
}
ll ncr(ll n, ll r, ll mod)
{
  ll res=1;
  for(ll i=n-r+1;i<=n;i++)
    res=(res*i)%mod;
  //cout<<res<<" ";
  for(ll i=1;i<=r;i++)
    res=(res * pown(i,mod-2, mod))%mod;
  return res;
}
int main()
{
  ll mod=1000000007;    
  ll n,a,b;
  cin>>n>>a>>b;
  ll res=pown(2,n,mod)-1;
  ll x=ncr(n,a,mod);
  ll y=ncr(n,b,mod);
  //cout<<res<<" "<<x<<" "<<y<<"\n";
  res = (res-x)%mod;
  res = (res-y)%mod;
  if(res<0)
    res+=mod;
  cout<<(res);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	long long ret = 0;
	vector<long long>arr[3];
	for(int i=0; i<n; i++){
		for(int j=0; j<3; j++){
			long long a;
			cin>>a;
			arr[j].push_back(a);
		}
	}
	for(int state = 0; state<8; state++){
		vector<long long>temp;
		for(int i=0; i<n; i++){
			long long curr = 0;
			for(int j=0; j<3; j++){
				if((1<<j)&state) curr+=arr[j][i]*-1;
				else curr+=arr[j][i];
			}
			temp.push_back(curr);
		}
		sort(temp.begin(),temp.end());
		reverse(temp.begin(),temp.end());
		long long sum = 0;
		for(int i=0; i<m; i++) sum+=temp[i];
		ret = max(ret,sum);
	}
	cout<<ret;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int A, B;
    cin >> A >> B;
    int C;
    C = A - B * 2;
    if (C < 0)
        C = 0;
    cout << C << endl;
    // system("pause");
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2



int main(){
	int n;
  	cin >> n;
	cout << 180 * (n - 2) << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(M, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll H, W, N; std::cin >> H >> W >> N;
  std::unordered_map<int,std::unordered_map<int,int>> map;
  rep(i,N) {
    ll a,b; std::cin >> a >> b; a--,b--;
    for(int i=-1; i<=1; i++) for(int j=-1; j<=1; j++) {
      if ( a + i >= 0 && a+i < H && b+j >= 0 && b+j < W ) map[a+i][b+j]++;
    }
  }

  ll ans[10] = { 0 };
  ll cnt = 0;
  for(auto&& m : map) for(auto&& n : m.second) {
    if ( m.first >= 1 && m.first < H-1 && n.first >= 1 && n.first < W-1 ) {
      //std::cout << m.first << " " << n.first << " : " << n.second << std::endl;
      ans[ n.second ]++;
      cnt++;
    }
  }

  std::cout << (H-2)*(W-2) - cnt << std::endl;
  for(int i=1; i<10; i++) std::cout << ans[i] << std::endl;
  
  
  return 0;
}


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

using namespace std;

#define ll long long
#define ar array



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

	int n;
	cin >> n;
	ll arr[n];
	for(int i=0;i<n;i++) cin >> arr[i];
	sort(arr,arr+n,greater<ll>() );
	ll ans = 0;
	ll b2=arr[1];ans+=arr[0];
	int cnt = 0,var=1;
	for(int i = 2;i < n;i++){
		if(cnt > 0 && cnt%2==0){
			cnt=0;
			var++;
			b2 = arr[var];
			ans+=b2;
		}else{
			ans+=b2;
		}
		cnt++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 5200
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l,l+N)

int main(void)
{
	string a;
	cin >> a;
	int ka = 700;
	if (a[0] == 'o')
		ka += 100;
	if (a[1] == 'o')
		ka += 100;
	if (a[2] == 'o')
		ka += 100;
	cout << ka << endl;


}

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


public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		int n = sc.nextInt();
		int v;
		int m1 = 0, m2 = 0;
		int mm1 = 0, mm2 = 0;
		int cnt1[] = new int[100001];
		int cnt2[] = new int[100001];
		Arrays.fill(cnt1, 0);
		Arrays.fill(cnt2, 0);
		for(int i = 0; i < n / 2; i++) {
			v = sc.nextInt();
			cnt1[v]++;
			if(cnt1[m1] < cnt1[v]) {
				mm1 = m1;
				m1 = v;
			}
			else if(cnt1[mm1] <= cnt1[v] && m1 != v)mm1 = v;
			//System.out.println(m1+" " + mm1 + " " + v);
			v = sc.nextInt();
			cnt2[v]++;
			if(cnt2[m2] <= cnt2[v]) {
				if(m2 != v)mm2 = m2;
				m2 = v;
			}
			else if(cnt2[mm2] < cnt2[v] && m2 != v)mm2 = v;
		}
		//System.out.println(Arrays.toString(cnt1));
		//System.out.println(m1 +" "+ m2 + " " +mm1 +" " +mm2);
		int min;
		if(m1 == m2) {
			min = cnt1[m1] + cnt2[mm2];
			if(cnt2[m2] + cnt1[mm1] > min) 
				min = cnt2[m2] + cnt1[mm1];
		}
		else min = cnt1[m1] + cnt2[m2];
		System.out.println(n - min);
	}
	Main(){doIt();}
	public static void main(String[] args) {
		new Main();
	}

}


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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
//#define int long long

signed main(){
    int n; cin >> n;
    map<int, int> amount;
    rep(i,n){
        int a; cin >> a;
        amount[a]++;
    }
    
    int ans = 0;
    for(auto p : amount){
        if(p.second < p.first){
            ans += p.second;
        }else{
            ans += p.second - p.first;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 4736
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main 
{
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int t = sc.nextInt();
		Set<String> set = new HashSet<>();
		
		for(int i=0; i< t; i++)
		{
			String s = sc.next();
			set.add(s);
		}
		
		System.out.println(set.size());
		
		sc.close();

	}

}


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

int main()
{
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    auto diff1 = abs(A1 - A2);
    auto diff2 = abs(A2 - A3);
    auto diff3 = abs(A3 - A1);
    auto diffMax = max(diff1, max(diff2, diff3));
    int sum = diff1 + diff2 + diff3 - diffMax;

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256