akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;
int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n, 0);
  vector<vector<int>> v;
  rep(i, n) {
    cin >> c[i];
    vector<int> vi(m, 0);
    rep(j, m) {
      cin >> vi[j];
    }
    v.push_back(vi);
  }

  ll min = MOD;
  for (int bits = 0; bits < (1 << n); bits++) {
    ll sum = 0;
    vector<int> xd (m, 0);
    for (int i = 0; i < n; i++) {
      int mask = 1 << i;
      if (bits & mask) {
        sum += c[i];
        rep(j, m) {
          xd[j] += v[i][j];
        }
      }
    }
    bool ngflag = false;
    rep(k,m) {
      //cout << "xd" << xd[k] << endl;
      if (xd[k] < x) {
        ngflag = true;
      }
    }
    if (!ngflag && sum < min)  {
      min = sum;
    }
  }
  if (min != MOD) {
    cout << min << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
import sys

import numpy as np


def search_y(x, points):
    l = np.complex128(x + 0.0j)
    r = np.complex128(x + 1000.0j)

    d1, d2 = 0, 0
    while abs(r - l) > 3e-7:
        diff = (r - l) / 3
        p1 = l + diff
        p2 = l + diff * 2
        d1 = abs(points - p1).max()
        d2 = abs(points - p2).max()
        if d1 >= d2:
            l = p1
        else:
            r = p2
    return (d1 + d2) / 2


def search(points):
    l = 0.0
    r = 1000.0

    d1, d2 = 0, 0
    while r - l > 3e-7:
        diff = (r - l) / 3
        p1 = l + diff
        p2 = l + diff * 2
        d1 = search_y(p1, points)
        d2 = search_y(p2, points)
        if d1 >= d2:
            l = p1
        else:
            r = p2
    return (d1 + d2) / 2


n = int(input())
points = np.array([complex(*map(int, line.split())) for line in sys.stdin], dtype=np.complex128)
print(search(points))


Measured memory_bytes: 13788
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	int h,w,k;
	std::cin >> h >> w >> k;
	std::vector<std::string> g(h);
	rep(i,h) std::cin >> g[i];
	int ans=0;
	rep(s,1<<(h+w)) {
		int count=0;
		int x=s;
		rep(i,h) {
			rep(j,w) {
				if((x>>i&1) && (x>>(h+j)&1) && g[i][j]=='#') count++;
			}
		}
		if(count==k) ans++;
	}
	print(ans);
}


Measured memory_bytes: 3640
## ABC 054 b
import sys

n,m = (int(_) for _ in input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]

if(a[::1] == b[::1]):
    print('Yes')
    sys.exit(0)

for i in range(n-m):
    for j in range(n-m):
        if (b[::1] == [ai[j:j+m] for ai in a[i:i+m]]):
            print('Yes')
            sys.exit(0)

print('No')

Measured memory_bytes: 3064
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>

using namespace std;


int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int R,L,U,D;
    R = tx-sx;
    L = R;
    U = ty-sy;
    D = U;
    for (int i = 0; i < R; i++) cout << "R";
    for (int i = 0; i < U; i++) cout << "U";
    for (int i = 0; i < L; i++) cout << "L";
    for (int i = 0; i < D; i++) cout << "D";
    cout << "D";
    for (int i = 0; i < R+1; i++) cout << "R";
    for (int i = 0; i < U+1; i++) cout << "U";
    cout << "L";
    cout << "U";
    for (int i = 0; i < L+1; i++) cout << "L";
    for (int i = 0; i < D+1; i++) cout << "D";
    cout << "R";




    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <iomanip>
#include <functional>
#include <array>
#include <memory>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#undef NDEBUG
#include <assert.h>

using namespace std;
typedef long long ll;

int n;
ll a[(int)2e5];
ll cs[(int)2e5];
ll ans = 1e18;

void eval(int i, int j, int k) {
	if (0 <= i && i < j && j < k && k < n - 1) {
		ll sums[] = {
			cs[i],
			cs[j] - cs[i],
			cs[k] - cs[j],
			cs[n-1] - cs[k]
		};
		ans = min(ans, *max_element(sums, sums + 4) - *min_element(sums, sums + 4));
	}
}

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

	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	partial_sum(a, a + n, cs);

	for (int j = 0; j < n; ++j) {
		// [0 -> j), [j -> n)


		int i = lower_bound(cs + 0, cs + j, (cs[j - 1] + 1) / 2) - cs; // i], i-1]
		int k = lower_bound(cs + j, cs + n, (cs[j - 1] + (cs[n - 1] - cs[j - 1] + 1) / 2)) - cs;
		eval(i, j - 1, k);
		eval(i - 1, j - 1, k);
		eval(i, j - 1, k - 1);
		eval(i - 1, j - 1, k - 1);
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    int x,y,z,a=1;
    
    cin >> x >> y >> z;
    x-=(y+z+z);
    while(1){
        x-=(y+z);
        if (x<0){
            break;
        }
        a++;



    }
    cout << a << endl;
}


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

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug( fmt, ... ) \
        fprintf( stderr, \
                  fmt "\n", \
                  ##__VA_ARGS__ \
        )

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1 << 29;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}
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; }
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

struct prepare {
	prepare() {
	    cout.setf(ios::fixed, ios::floatfield);
	    cout.precision(8);
	    ios_base::sync_with_stdio(false);
	}
} _prepare;

int MAX_N = 200010;
vll bi(MAX_N);

ll nCk(ll n, ll k){
    ll den = bi[k] * bi[n-k];
    den %= MOD;

    ll gden = fpow(den, MOD-2, MOD);
    ll ans = (bi[n] * gden) % MOD;

    return ans;
}

int main() {
    bi[0] = bi[1] = 1;
    REP(i, 2, MAX_N) {
        bi[i] = bi[i-1] * i;
        bi[i] %= MOD;
    }

    int H, W, A, B;
    cin >> H >> W >> A >> B;

    ll ans = 0;
    REP(i, 1, H-A+1) {
        ll t = nCk((i+B-2), B-1);
        ll t2 = nCk( (H-i)+(W-B-1), H-i);
        ans += (t * t2) % MOD;
        ans %= MOD;
    }

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

Measured memory_bytes: 1920
//AtCoder ABC044 A - 高橋君とホテルイージー / Tak and Hotels (ABC Edit)
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
    int N,K;
    int X,Y;
    cin>>N>>K>>X>>Y;
    int ans=min(N,K)*X+max(0,N-K)*Y;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main() {
    long long n, a, b, ans = -1;
    cin >> n >> a;
    ans = a;
    for (int i = 1; i < n; ++i) {
        cin >> b;

        if (b == 0 || a == 0) {
            cout << 0;
            return 0;
        }

        if (ans > 0) {
            long long max_b = 1000000000000000000LL / ans;
            if (b > max_b) {
                ans = -1;
            } else {
                ans *= b;
            }
        }

        if (ans > 1000000000000000000LL) {
            ans = -1;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	ll k,m;
	cin>>n>>k>>m;
	vector<ll> dp1(n+2,1e18),dp2(n+2,1e18);
	dp1[0]=0;
	dp2[0]=0;
	vector<ll> v;
	ll a;
	cin>>a;
	v.push_back(a);
	for(int i=1;i<n;i++)
	{
		ll a;
		cin>>a;
		dp1[i]=min(dp1[i-1]+(a-v[i-1])*k,dp2[i-1]+(a-v[i-1])*k);
		dp2[i]=min(dp2[i-1]+m,dp1[i-1]+m);
		v.push_back(a);
	}
	cout<<min(dp1[n-1],dp2[n-1])<<endl;
	return 0;
}

Measured memory_bytes: 2936
import java.awt.List;
import java.util.*;
public class Main {
	static int modNum = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		long a = sc.nextLong();
		
		long ans = 1;
		
		int as = (int) (ans % 11);
		if((a % 11) == 0){
			ans = (a/11)*2;
		}else{
			ans += (a / 11) * 2;
			if(a % 11 > 6){
				ans++;
			}
			
		}
		
//		ArrayList<Integer> list = new ArrayList<Integer>();
//		
//		for(int i=1;i<=a*2;i++){
//			int b = sc.nextInt();
//			list.add(b);
//		}


		
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 22868
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x)
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);


    //start from here

    read(n); set < string > s;

    string str;

    fori (i, 1, n) {cin >> str; s.insert(str);}

    cout << sz(s);

    return 0;
}


Measured memory_bytes: 19204
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int h,w;
    cin >> h >> w;
    vector< vector<char>> table(h+2,vector<char>(w+2,'.'));
    for(int i=1;i<=h;i++){
        for(int j=1;j <= w;j++){
            cin >> table[i][j];
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j <= w;j++){
            if(table[i][j] == '.'){
                int cnt = 0;
                if(table[i-1][j] == '#')cnt++;
                if(table[i+1][j] == '#')cnt++;
                if(table[i][j-1] == '#')cnt++;
                if(table[i][j+1] == '#')cnt++;
                if(table[i-1][j-1] == '#')cnt++;
                if(table[i+1][j+1] == '#')cnt++;
                if(table[i+1][j-1] == '#')cnt++;
                if(table[i-1][j+1] == '#')cnt++;
                cout << cnt;
            }else{
                cout << '#';
            }
            
        }
        cout << "\n";
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

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

  if (s == "RRR")
    printf("3\n");
  else if (s == "RRS" || s == "SRR")
    printf("2\n");
  else if (s == "SSS")
    printf("0\n");
  else
    printf("1\n");

  return 0;
}

Measured memory_bytes: 3596
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var x = ReadLine().Split();
		WriteLine(x.Take(x.Length - 1).Zip(x.Skip(1), (a, b) => a.Last() == b[0]).All(y => y) ? "YES" : "NO");
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

Measured memory_bytes: 13396
import std.stdio, std.string, std.conv, std.algorithm, std.ascii;

void main()
{
    foreach(_; 0 .. readln.chomp.to!int)
    {
        auto line = readln;
        auto keys = line.split.filter!(str => str.length == 4);
        loop:foreach(a; [0, 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25])
        {
            foreach(b; 0 .. 26)
            {
                foreach(key; keys)
                {
                    string decoded = key.decode(a, b);
                    if(decoded == "this" || decoded == "that")
                    {
                        line.decode(a, b).write;
                        break loop;
                    }
                }
            }
        }
    }
}

string decode(string encoded, int a, int b)
{
    string decoded;
    foreach(c; encoded)
    {
        if(c.isAlpha)
        {
            decoded ~= (a * (c - 'a') + b) % 26 + 'a';
        }
        else
        {
            decoded ~= c;
        }
    }
    return decoded;
}

Measured memory_bytes: 1236
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, a[200000] = {}, parent[200000] = {}, ans[200000] = {};
bool leaf[200000] = {}, visited[200000] = {};

int main() {
	cin >> n;
	rep(i, n - 1) {
		cin >> a[i];
		parent[i + 1] = a[i] - 1;
		leaf[a[i] - 1] = true;
	}
	rep(i, n) {
		if (!leaf[i]) {
			ll cur = i;
			while (cur != 0 && !visited[cur]) {
				ans[parent[cur]]++;
				visited[cur] = true;
				cur = parent[cur];
			}
		}
	}
	rep(i, n)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 8520
import math
a,b,C=map(float,input().split())
print(f'{a*b/2*math.sin(math.radians(C)):.6f}')
print(f'{a+b+(a**2+b**2-2*a*b*math.cos(math.radians(C)))**0.5:.6f}')
print(f'{b*math.sin(math.radians(C)):.6f}')


Measured memory_bytes: 5716
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if(C >= A && C <= B) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int n,a[200010],b[200010];
int main()
{
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<n;i++) b[i]=a[i];
	sort(b,b+n);
	for (int i=0;i<=n/2;i++)
		if (a[i]==b[n/2])
			cout<<b[n/2-1]<<endl;
		else if (a[i]<b[n/2])
			cout<<b[n/2]<<endl;
		else if (a[i]>b[n/2])
			cout<<b[n/2-1]<<endl;
	for (int i=n/2+1;i<n;i++)
		if (a[i]==b[n/2])
			cout<<b[n/2-1]<<endl;
		else if (a[i]<b[n/2])
			cout<<b[n/2]<<endl;
		else if (a[i]>b[n/2])
			cout<<b[n/2-1]<<endl;
	return 0;
}

Measured memory_bytes: 3712
/*
[agc037] B - RGB Balls
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 1e5;
const int MOD = 998244353;

class gf {
public:
    int n;
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(const gf x) const { return gf((n + x.n) % MOD); }
    gf operator-(const gf x) const { return gf((n - x.n + MOD) % MOD); }
    gf operator*(const gf x) const { return gf((1LL * n * x.n) % MOD); }
    gf& operator+=(const gf x) { return *this = (*this + x); }
    gf& operator-=(const gf x) { return *this = (*this - x); }
    gf& operator*=(const gf x) { return *this = (*this * x); }
};
;
int N;
string S;
int idx[MAX_N][3];

ll solve() {
    int cur[3] = {0, 0, 0};
    for (int i = 0; i < 3 * N; i++) {
        int c = S[i] == 'R' ? 0 : (S[i] == 'G' ? 1 : 2);
        idx[cur[c]++][c] = i;
    }
    for (int i = 0; i < N; i++) {
        sort(idx[i], idx[i] + 3);
    }

    gf ans = 1;
    for (int i = 0, j = 0; i < N; i++) {
        while (j < N && idx[j][0] < idx[i][1]) {
            j++;
        }
        ans *= j - i;
    }
    for (int i = N - 1, j = N - 1; i >= 0; i--) {
        while (j >= 0 && idx[i][1] < idx[j][2]) {
            j--;
        }
        ans *= i - j;
    }
    for (int i = 1; i <= N; i++) {
        ans *= i;
    }

    return ans.n;
}

int main() {
    cin >> N;
    cin >> S;

    cout << solve() << endl;

    return 0;
}


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

//#include "atcoder.hpp"

long long gcd(long long a, long long b) {
    if (a>b) swap(a,b);
    
    auto r = b % a;
    
    return (r ? gcd(r, a) : a);
}

int main() {
    int k,  abcde[5];
    
    cin >> abcde[0] >> abcde[1] >> abcde[2] >> abcde[3] >> abcde[4] >>k;

    
    for (int i =0; i<5;i++)
    for(int j=i+1; j<5;j++)
    if (abcde[j] - abcde[i] > k)
    {cout << ":(" << endl; return 0;}
    
    cout << "Yay!" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define P 1000000007
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
#define ls (root<<1)
#define rs (root<<1|1)
using namespace std;

int n, A, B, a[MAXN], b[MAXN], ans[MAXN];


inline int add(int x, int y) {return x+y>=P?x+y-P:x+y;}
inline int sub(int x, int y) {return x>=y?x-y:x-y+P;}

void solve(int x, int y, int mask, int l, int r)
{
    if(!mask) return;
    int bit=0, t=0, mid=(l+r)>>1;
    for(rint i=0; i<n; ++i)
        if(((x>>i)&1)!=((y>>i)&1) && (mask>>i)&1) bit=1<<i;
    for(rint i=0; i<n; ++i)
        if((mask>>i)&1 && bit!=1<<i) t=1<<i;
    solve(x, x^t, mask^bit, l, mid);
    solve(x^t, y, mask^bit, mid, r);
    for(rint i=l; i<mid; ++i) ans[i]|=x&bit;
    for(rint i=mid; i<r; ++i) ans[i]|=y&bit;

}

int main()
{
    scanf("%d%d%d", &n, &A, &B);
    int c=A^B, tot=0;
    for(rint i=0; i<n; ++i)
        if((c>>i)&1) tot++;
    if(tot%2==0) {printf("NO\n"); return 0;}
    solve(A, B, (1<<n)-1, 0, 1<<n);
    printf("YES\n");
    for(rint i=0; i<(1<<n); ++i) printf("%d ", ans[i]);
    return 0;
}

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

int main() {
  int A,B;
  cin>>A>>B;
  int ret=0;
  for (int i=0;i<2;i++){
    if(A>B){ret+=A;A--;}
    else {ret+=B;B--;}
  }
  cout<<ret<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64
#define n_max 100


bool comp(pair<llong,llong> a,pair<llong,llong>b){
    if(a.first != b.first) return a.first < b.first;
    return a.second > b.second;
}

int main(){
    int n,W;
    cin >> n >>W;
    pair<llong,llong> goods[n_max+5];
    llong w,v;
    set<int> judge;
    REP(i,n){
        cin >>w >> v;
        judge.insert(w);
        goods[i]= make_pair(w,v);
    }
    REP(i,4-judge.size()) goods[n+i]=make_pair(w+5+i,0);
    n+=4-judge.size();
    sort(goods,goods+n,comp);

    int ind=0;
    llong ru1[n_max+5]={},ru2[n_max+5]={},ru3[n_max+5]={},ru4[n_max+5]={};
    int ru1_size,ru2_size,ru3_size,ru4_size;
    llong w1,w2,w3,w4;
    int i=1;
    w1=goods[ind].first;
    while(1){
        ru1[i] = ru1[i-1] + goods[ind].second;
        if(goods[ind].first!=goods[ind+1].first) break;
        i+=1;
        ind+=1; 
    }
    ru1_size=i+1;
    ind+=1;

    i=1;
    w2=goods[ind].first;
    while(1){
        
        ru2[i] = ru2[i-1] + goods[ind].second;
        if(goods[ind].first!=goods[ind+1].first) break;
        i+=1;
        ind+=1; 
    }
    ru2_size=i+1;
    ind+=1;

    i=1;
    w3=goods[ind].first;
    while(1){

        ru3[i] = ru3[i-1] + goods[ind].second;
        if(goods[ind].first!=goods[ind+1].first) break;
        i+=1;
        ind+=1; 
    }
    ru3_size=i+1;
    ind+=1;

    i=1;
    w4=goods[ind].first;
    while(1){
        ru4[i] = ru4[i-1] + goods[ind].second;
        if(goods[ind].first!=goods[ind+1].first) break;
        ind+=1; 
        i+=1;
    }
    ru4_size=i+1;
    ind+=1;






    llong ans=0;
    REP(i,ru1_size){
        if(w1*i> W) break;
        REP(j,ru2_size){
            if(w1*i + w2*j > W) break;
            REP(ii,ru3_size){
                if(w1*i + w2*j + w3 * ii > W) break;
                REP(jj,ru4_size){
                    if(w1*i + w2*j + w3 * ii + w4 *jj > W) break;
                    ans=max(ans,ru1[i] + ru2[j] + ru3[ii] + ru4[jj]);
                }
            }
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
int ans2[100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int len = S.length();
    rep(i, len - 1) {
        if (S[i] != 'R') continue;
        if (S[i + 1] != 'L') continue;
        int L = i, R = i + 1;
        int ans[2] = {};
        while(L >= 0 && S[L] == 'R') {
            ans[abs(i - L) % 2]++;
            L--;
        }
        while(R < len&&  S[R] == 'L') {
            ans[abs(i - R) % 2]++;
            R++;
        }
        //cout << i << " " << ans[0] << " " << ans[1] << endl;
        ans2[i] = ans[0];
        ans2[i + 1] = ans[1];
    }
    rep(i, len) {
        if (i != 0) cout << " ";
        cout << ans2[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1104
# with open('./ABC161/max_02') as f:
#     l = [s.strip() for s in f.readlines()]


n,k,c = map(int, input().split())
s = input()

l = list()
r = list()
i = 0
while i < n:
    if len(l) == k:
        break
    if s[i] == 'o':
        l.append(i)
        i += c
    i+=1

i = n-1
while i >= 0:
    if len(r) == k:
        break
    if s[i] == 'o':
        r.append(i)
        i -= c
    i-=1
r.sort()

for i in range(k):
    if l[i] == r[i]:
        print(l[i]+1)






Measured memory_bytes: 58144
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define root sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n;
  vs d(n);
  vi e(n);
  set<string> g;
  map<string, string> f;
  rep(i, 0, n)
  {
    cin >> d[i];
    f.emplace(to_string(i), d[i]);
    g.insert(d[i]);
  }
  cout << g.size() << endl;
}

Measured memory_bytes: 47880
from collections import defaultdict

primes = defaultdict(int)

N = int(input())

import itertools
def prime_factors(n):
    for i in itertools.chain([2], itertools.count(3, 2)):
        if n <= 1:
            break
        while n % i == 0:
            n //= i
            yield i

for i in range(1, N+1):
    for p in prime_factors(i):
        primes[p] += 1

total = 1
for c in primes.values():
    total *= c + 1
print(total % (10**9 + 7))

Measured memory_bytes: 3444
#include <cstdio>
#include <algorithm>
using namespace std;
#define INF (1<<29)

int main(void) {
    int n, m, a;
    scanf("%d %d", &n, &m);
    int c[m + 1], t[n+1];
    for (int i = 0; i < m; i++) {
        scanf("%d", &a);
        c[i] = a;
    }
    for (int i = 0; i <= n; i++) t[i] = INF;
    t[0] = 0;

    for (int i = 0; i < m; i++) {
        for (int j = 0; j <= n - c[i]; j++) {
            t[j + c[i]] = min(t[j + c[i]], t[j] + 1);
        }
    }

    printf("%d\n", t[n]);

    return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;;
int dp[100002];
bool solve(int k,int a[],int n){
    if(k==0)
        return 0;
        if(dp[k]!=-1)
        return dp[k];
        int ans =0 ;
        for(int i=0;i<n;i++)
        {
            if(k >= a[i] && solve(k - a[i] ,a ,n) == 0){
                
            ans =1;
                break;
            }
        }
        dp[k]=ans ;
        return dp[k];
}
int main(){
    int n , k;

    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];
        memset(dp,-1,sizeof(dp));
  if(solve(k,a,n))
  cout<<"First";
  else
  cout<<"Second";
    
}

Measured memory_bytes: 8552
(defun split (string &key (delimiterp #'(lambda (c) (char= c #\Space))))
  (loop :for beg = (position-if-not delimiterp string)
        :then (position-if-not delimiterp string :start (1+ end))
        :for end = (and beg (position-if delimiterp string :start beg))
        :when beg :collect (subseq string beg end)
        :while end))

(defun count-sums (n a b)
  (max 0 (+ (- (+ a (* b (- n 1))) (+ b (* a (- n 1)))) 1)))

(destructuring-bind (n a b) (mapcar #'parse-integer (split (read-line)))
  (format t "~d~%" (count-sums n a b)))


Measured memory_bytes: 16232
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
bool pcom(pair<int, int>a, pair<int, int>b) {
	return a.second < b.second;
}
int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>>a(m);
	vector<pair<int, int>>b(m);
	map<int, list<pair<int, int>*>>c;
	rep(i, 0, m) {
		int ta, tb;
		cin >> ta >> tb;
		a[i].first = min(ta, tb);
		a[i].second = max(ta, tb);
		b[i] = a[i];

	}

	sort(all(a));
	sort(all(b), pcom);
	rep(i, 0, m) {
		c[b[i].first].push_back(&b[i]);

	}
	int cnt = 0;
	int j = 0;
	rep(i, 0, m) {
		int t = b[i].second;
		if (t > 0) {
			cnt++;
			while (j < m && a[j].first < t) {
				while (!c[a[j].first].empty()) {
					auto p = c[a[j].first].front();
					c[a[j].first].pop_front();
					p->second = -1;
				}
				j++;
			}
		}
	}

	cout << cnt;



	return 0;
}





Measured memory_bytes: 11136
#include <stdio.h>
 
main(){
  int in,out,temp;
 
  while(1){
    if(scanf("%d", &in)==EOF) break;
    printf("3C"); 
 
    temp=in/39;
    out=in-(temp*39);
 
    if(out==0) printf("39\n");
    else if(out<10) printf("0%d\n", out);
    else printf("%d\n", out);
  }
  return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int n;
vector<int> p;

int main() {
    cin >> n;
    p.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int ans = 1;
    int minimum = p[0];
    for (int i = 1; i < n; i++) {
        if (p[i] <= minimum) {
            ans++;
            minimum = p[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i ++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i --)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;}

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 1000000007ll;


int main(){
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
	
using namespace std;

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

const int Nmax=200000;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

struct LCNode{
	typedef LCNode *NP;
	NP l,r,p;
	ll v,vsm,w,wsm,lz;
	ll Get(){
		return wsm+vsm*lz;
	}
	int Pos(){
		if(p&&p->l==this)return -1;
		if(p&&p->r==this)return 1;
		return 0;
	}
	void Update(){
		vsm=v;
		wsm=v*w;
		if(l){
			vsm+=l->vsm;
			wsm+=l->Get();
		}
		if(r){
			vsm+=r->vsm;
			wsm+=r->Get();
		}
	}
	void Propagate(){
		w+=lz;
		wsm+=vsm*lz;
		if(l)
			l->lz+=lz;
		if(r)
			r->lz+=lz;
		lz=0;
	}
	void Push(){
		if(Pos())
			p->Push();
		Propagate();
	}
	void Rotate(){
		NP q=p,c;
		if(Pos()==-1){
			c=r;
			r=p;
			p->l=c;
		}else{
			c=l;
			l=p;
			p->r=c;
		}
		if(c)c->p=p;
		p=p->p;
		q->p=this;
		q->Update();
		if(p&&p->l==q)p->l=this;
		if(p&&p->r==q)p->r=this;
	}
	void Splay(){
		Push();
		while(Pos()){
			int a=Pos(),b=p->Pos();
			if(b&&a==b)p->Rotate();
			if(b&&a!=b)Rotate();
			Rotate();
		}
		Update();
	}
	void Expose(){
		for(NP x=this;x;x=x->p)
			x->Splay();
		for(NP x=this;x->p;x=x->p){
			x->p->r=x;
			x->p->Update();
		}
		Splay();
	}
	void Prepare(){
		Expose();
		r=NULL;
		Update();
	}
	NP Find(NP x,ll k,ll d){
		d+=lz;
		ll a=v*(k-(w+d)*2);
		if(a<=0){
			if(r)
				return r->Find(this,k,d);
			else
				return this;
		}else{
			if(l)
				return l->Find(x,k,d);
			else
				return x;
		}
	}
} lc1[Nmax],lc2[Nmax];

vector<pii> tree[Nmax];
ll dep[Nmax];
void dfs(int i,ll d){
	dep[i]=d;
	for(auto c:tree[i])
		dfs(c.first,d+c.second);
}

ll sum0;

pli Calc(int i,int k){
	lc2[i].Prepare();
	int x=lc2[i].Find(NULL,k,0)-lc2;
	lc1[x].Prepare();
	return MP(sum0+dep[x]*k-lc1[x].Get()*2,x);
}

void Solve(){
	int n=read();
	lc1[0]=LCNode{NULL,NULL,NULL,0,0,0,0,0};
	lc2[0]=LCNode{NULL,NULL,NULL,0,0,0,0,0};
	FOR(i,1,n){
		int p=read()-1,d=read();
		tree[p].PB(MP(i,d));
		lc1[i]=LCNode{NULL,NULL,lc1+p,d,0,0,0,0};
		lc2[i]=LCNode{NULL,NULL,lc2+p,1,0,0,0,0};
	}
	dfs(0,0);
	pli mn(0,0);
	REP(i,n){
		sum0+=dep[i];
		lc1[i].Prepare();
		lc1[i].lz++;
		lc2[i].Prepare();
		lc2[i].lz++;
		pli a=Calc(i,i+1);
		pli b=Calc(mn.second,i+1);
		mn=min(a,b);
		printf("%lld\n",mn.first);
	}
}

#ifdef _WIN32
int main(){
	Solve();
}
#else
ll stackNew,stackOrigin;
int main(){
	const int stackSize=(128)*(1<<20);
	void *stackSpace=malloc(stackSize);
	stackNew=ll(stackSpace)+stackSize-1024;
	asm("mov %rsp, stackOrigin");
	asm("mov stackNew, %rsp");
	Solve();
	asm("mov stackOrigin, %rsp");
}
#endif

Measured memory_bytes: 46188
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  getline(cin, s);
  for (int i = 0; i < n; i++) {
    getline(cin, s);
    for (int i = 6; i < s.length(); i++)
      if (s[i-6] == 'H' &&
          s[i-5] == 'o' &&
          s[i-4] == 's' &&
          s[i-3] == 'h' &&
          s[i-2] == 'i' &&
          s[i-1] == 'n' &&
          s[i] == 'o')
        s[i] = 'a';
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){

  int h,m,s,S;
  
  scanf("%d",&S);
  
  h = S/3600;
  m = (S%3600)/60;
  s = (S%3600)%60;

  printf("%d:%d:%d\n",h,m,s);

  return 0;
}

Measured memory_bytes: 592
program o_rand_
  implicit none
  integer :: n, k, s, t, a(50) = 0, b(50) = 0, m = 0, f(0:262143) = 0, i, j, p
  integer(8) :: c(0:50, 0:50) = 0, g(0:50) = 0, x = 0, y
  read(*,*) n, k, s, t
  read(*,*) a(1:n)
  do i = 1, n
    if (and(a(i), s) /= s .or. or(a(i), t) /= t) cycle
    m = m + 1
    b(m) = xor(a(i), s)
  end do
  c(0, 0) = 1
  do i = 1, m
    c(0, i) = 1
    do j = 1, min(i, k)
      c(j, i) = c(j, i - 1) + c(j - 1, i - 1)
    end do
    g(i) = sum(c(1:k, i))
  end do
  s = xor(s, t)
  i = s
  do
    do j = 1, m
      p = and(b(j), i)
      f(p) = f(p) + 1
    end do
    y = 0
    do j = 1, m
      p = and(b(j), i)
      y = y + g(f(p))
      f(p) = 0
    end do
    x = x + merge(-y, y, btest(popcnt(i), 0))
    if (i == 0) exit
    i = and(i - 1, s)
  end do
  write(*,'(i0)') x
end program o_rand_

Measured memory_bytes: 3840
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int>S(N);
  int sum = 0;
  for(int i=0; i < N; i++){
    cin >> S[i];
    sum += S[i];
  }
  sort(S.begin(),S.end());
  if(sum % 10 == 0){
    for(int i=0; i < N; i++){
      if(S[i] % 10 != 0){
	sum -= S[i];
	break;
      }
    }
  }
  if(sum % 10 != 0)
    cout << sum << endl;
  else
    cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
#define INF 2000000000
int main(){
  long long n;cin>>n;
  long long i,j;
  long long a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }

  long long ans=0;
  long long minus=0,zero=0;
  long long m=INF;
  for(i=0;i<n;i++){
    ans+=abs(a[i]);
    if(a[i]<0) minus++;
    else if(a[i]==0) zero++;
    if(abs(a[i])<m) m=abs(a[i]);
  }
  if(minus%2==1 and zero==0){
    ans-=2*m;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    val cap = (1..5).map { readLine()!!.toLong() }

    if (cap.all { it >= n }) {
        println(5)
        return
    }

    val min = cap.min()!!
    val maxCost = Math.ceil(n.toDouble() / min).toLong()

    println(4 + maxCost)
}

Measured memory_bytes: 33744
/*************************************************************************
    > File Name: A.cpp
    > Author: PumpkinYing
    > Created Time: 2018/11/5 9:19:22
 ************************************************************************/

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define prii pair<int,int>
#define prdd pair<double,double>
#define rep(i,l,r) for(int i = l;i < r;i++)
#define rep_(i,l,r) for(int i = l;i <= r;i++)
typedef long long ll;

const int maxn = 100010;
int cnt1[maxn],cnt2[maxn];

int main() {
	int n;
	scanf("%d",&n);
	rep(i,0,n) {
		int x;
		scanf("%d",&x);
		if(i%2 == 0) cnt1[x]++;
		else cnt2[x]++;
	}
	int p1 = 0,p2 = 0;
	rep_(i,1,100000) {
		if(cnt1[i] > cnt1[p1]) p1 = i;
		if(cnt2[i] > cnt2[p2]) p2 = i;
	}

	if(p1 == p2) {
		int tmp1 = 0,tmp2 = 0;
		rep_(i,1,100000) {
			if(cnt1[i] > cnt1[tmp1] && i != p1) tmp1 = i;
			if(cnt2[i] > cnt2[tmp2] && i != p2) tmp2 = i;
		}
		if(cnt1[p1]-cnt1[tmp1] < cnt2[p2]-cnt2[tmp2]) p1 = tmp1;
		else p2 = tmp2;
	}

	printf("%d\n",n-cnt1[p1]-cnt2[p2]);

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main(){
    int N;
    cin >> N;
 
    if(N%10==7 or (N/10)%10==7 or (N/100)==7 ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


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

typedef long long ll;

#define rep(var,n) for(int var=0;var<(n);++var)
const ll MOD = 1e9+7;

#define MAX_V (long long)(1e5*2+200)

ll MAX_VAL;
ll fac[MAX_V], mmi[MAX_V], temp[MAX_V];

inline void factorial(){
	fac[0] = fac[1] = 1;
	for(long long i = 2; i < MAX_VAL; fac[i]%=MOD,i++)
		fac[i] = fac[i-1]*(i%MOD);
}

inline long long power_mod(long long x, long long n){
  long long ans = 1;
  for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
    if(n&1)ans*=x;
  return ans;
}

inline void modular_multiplicatibe_inverse(){
  mmi[MAX_VAL-1] = power_mod(fac[MAX_VAL-1],MOD-2);
  for(long long i = MAX_VAL-2; i >= 0; mmi[i]%=MOD,i--)
    mmi[i] = mmi[i+1]*(i+1);
}

inline long long combination(long long n, long long r){
  return fac[n]*(mmi[r]*mmi[n-r]%MOD)%MOD;
}

int main(){
  ll n,k;
  cin >> n >> k;

  MAX_VAL = n+3;

  factorial();
  modular_multiplicatibe_inverse();

  rep(i,k)
    cout << (combination(k-1,i)*combination(n-k+1,i+1))%MOD << endl;
  return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string s;
  cin>>s;
  int ans = 0;
  if(s[0] == '2') ans++;
  if(s[1] == '2') ans++;
  if(s[2] == '2') ans++;
  if(s[3] == '2') ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000000000000
#define mod 1000000007

int main(){
	ll n,k;cin>>n>>k;
	vector<pair<ll,ll>> P(n);

	for(ll i=0;i<n;i++){
		ll a,b;
		cin>>a>>b;

		P[i]=make_pair(a,b);
	}

	sort(P.begin(),P.end());

	ll num=0,i=0,ans;
	while(num<k){
		num+=P[i].second;
		if(num>=k){ans=P[i].first;}
		i++;
	}

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

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int n,x;
    cin>>n>>x;

    (n*500>=x)?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

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

int main()
{
	int n, m;
	
	cin>>n>>m;
	
	if(n==m)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {

	int N, M, L[100005], R[100005];

	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d%d", &L[i], &R[i]);
	}

	int Min = c_INF;
	int Max = c_mINF;

	for (int i = 0; i < M; i++) {
		Min = min(Min, R[i]);
		Max = max(Max, L[i]);
	}
	if (Min >= Max) {
		printf("%d", Min - Max +1);
	}
	else {
		printf("0");
	}



}








Measured memory_bytes: 896
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>
#include<cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;



int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

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

 int ans=0,N,num;cin>>N;
 vector<int> A(110099, 0);
 for(int i=1;i<=100;i++) {
   for(int j = 1;j <= 100;j++) {
     for(int k = 1;k <= 100;k++) {
       A[i*i+ j*j + k*k + i*j + j*k + k*i]++;
     }
   }
 }
 // cout<<ans;
 rep(i, N)cout<<A[i+1]<<endl;

 return 0;
}


Measured memory_bytes: 3724
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
s = [LIST()[1:] for _ in range(M)]
p = LIST()

ans = 0
for x in product([0, 1], repeat=N):
    for i in range(M):
    	cnt = 0
    	for n in s[i]:
    		if x[n-1] == 1:
    			cnt += 1
    	if cnt%2 != p[i]:
    		break
    else:
    	ans += 1
print(ans)


Measured memory_bytes: 5304