akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define S 1000000000
int N[500000], L[250001], R[250001], count=0;
 
int main(){
  int i, n;
  scanf("%d",&n);
  for(i = 0; i < n; i++)
    scanf("%d",&N[i]);
 
  merge_sort(0,n);
 
  for(i = 0; i < n; i++){
    if(i > 0) printf(" ");
    printf("%d",N[i]);
  }
  printf("\n%d\n",count);
  return 0;
}

void merge(left, mid, right){
  int n1, n2, i, j, k;
  n1 = mid - left;
  n2 = right - mid;
  for(i = 0; i < n1; i++)
    L[i] = N[left + i];
  for(i = 0; i < n2; i++)
    R[i] = N[mid + i];
  L[n1] = S;
  R[n2] = S;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      N[k] = L[i];
      i = i + 1;
      count++;
    }
    else{
      N[k] = R[j];
      j = j + 1;
      count++;
    }  
  }
}
 
void merge_sort(left, right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    merge_sort(left, mid);
    merge_sort(mid, right);
    merge(left, mid, right);
  }
}
 

Measured memory_bytes: 4508
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MOD 1000000007

char S[1111111];
int n;

int num[26];

int main(){
	scanf("%d", &n);
	scanf("%s", S + 1);
	for(int i = 1; i <= n; i++) num[S[i] - 'a']++;
	int ans = 1;
	for(int i = 0;i < 26; i++) ans = 1ll * ans * (num[i] + 1) % MOD;
	printf("%d\n", (ans - 1 + MOD)%MOD);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n)
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drrep(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int SED(int n) { //Sum of each digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	int n, a, b;
	cin >> n >> a >> b;

	int sum = 0;

	rrep(i, n) {
		if (a <= SED(i) && SED(i) <= b) {
			sum += i;
		}
	}
	cout << sum << rt;

	please AC;
}

Measured memory_bytes: 256
# 1.入力
X = int(input())
A = int(input())
B = int(input())

# 2.制約チェック
if A<1 or A>1000:
    print("制約条件1<=A<=1000")
    raise ValueError
elif B<1 or B>1000:
    print("制約条件1<=B<=1000")
    raise ValueError
elif X<A+B or X>10000:
    print("制約条件A+B<=X<=10000")
    raise ValueError

# 3.Aを引く
residue = X-A

# 4.Bを引く
while(1):
    if residue-B >= 0:
        residue = residue-B
    else:
        break
    
    
# 5.結果の表示
print(residue)

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n;cin>>n;
  ll ans=0;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.rbegin(), v.rend());
  ans=v[0];
  int cnt=2;
  for(int i=1;i<n;i++){
    if(cnt==n)break;
    ans+=v[i];
    cnt++;
    if(cnt==n)break;
    ans+=v[i];
    cnt++;
    if(cnt==n)break;
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3996
n = int(input())
ac, wa, tle, re = 0,0,0,0

for i in range(n):
    x = input()
    if x == 'AC':
        ac += 1
    elif x == 'WA':
        wa += 1
    elif x == 'TLE':
        tle += 1
    elif x == 'RE':
        re += 1

print('AC x', ac)
print('WA x', wa)
print('TLE x', tle)
print('RE x', re)

Measured memory_bytes: 9208
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int a, b, c, x, y;

int main()
{
    cin >> a >> b >> c >> x >> y;

    if(a + b <= 2 * c){
        cout << x * a + y * b << endl;
    }
    else{
        int num = min(x, y);
        int dx = x - num;
        int dy = y - num;
        cout << c * 2 * num + min(dx * a, c * 2 * dx) + min(dy * b, c * 2 * dy) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>

using namespace std;

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

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const int PI = acos(-1);
const int INF = numeric_limits<int>::infinity() / 2;
const ll INFLL = numeric_limits<ll>::infinity() / 2;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a[3];
  cin >> a[0] >> a[1] >> a[2];

  int k;
  cin >> k;

  sort(a, a + 3);

  while (k--) a[2] *= 2;

  cout << a[0] + a[1] + a[2] << endl;
  return 0;
}


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

const int N = 4e3;
pair<long long, long long> dp[N][N];
int a[N];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i<n; i++)
		cin >> a[i];

	for (int l = 1; l <= n; l++)
		for (int i = 0, j = l; j <= n; i++, j++) {
			dp[i][j] = { dp[i + 1][j].second + a[i] , dp[i + 1][j].first };
			dp[i][j] = max(dp[i][j], { dp[i][j - 1].second + a[j - 1], dp[i][j - 1].first });
		}

	cout << dp[0][n].first - dp[0][n].second << endl;
	cin >> n;
	return  0;
}

Measured memory_bytes: 188288
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}

const ll mod = 1e9 + 7;


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

    int cnt = 0;
    for (int i = 0;i < n - 2;i++){
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define re register
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define per(i,n,m) for(int i=m;i>=n;i--)
#define rrep(i,m,n) for(register int i=m;i<=n;i++)
#define rper(i,n,m) for(register int i=m;i>=n;i--)
#define ull unsigned  long long
using namespace std;
const int INF =1e9+10;
const int N = 5e2 + 10;
signed main() {
    string s;
    cin>>s;
    int n=s.length();
    int cnt=0,cnt2=0;
    rep(i,0,n-2){
        if(s[i]==s[i+1])cnt++;
        else cnt2++;
    }
    if(cnt==n-1){
        puts("0");
    }else{
        pi(cnt2);
    }
    return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, m, q; scanf("%d %d %d", &n, &m, &q);
	std::vector<std::vector<int>> vec(n + 1);
	for(int i = 0; i < m; i++) {
		int a, b; scanf("%d %d", &a, &b);
		
		vec[a].push_back(b);
	}
	for(int i = 0; i <= n; i++) sort(begin(vec[i]), end(vec[i]));
	
	while(q--) {
		int l, r; scanf("%d %d", &l, &r);
		
		int ans = 0;
		for(int i = l; i <= r; i++) {
			ans += upper_bound(begin(vec[i]), end(vec[i]), r) - begin(vec[i]);
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int N;
    string S;
    int K;

    cin >> N;
    cin >> S;
    cin >> K;

    char SK = (char)S[K-1];

    for(int i;i<S.size();i++)
    {
        if(S[i] == SK);
        else S[i] = '*';
    }

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

vector<vector<int> > g, dp;

int main() {
    int n, m, q;
    cin >> n >> m;
    g.resize(n);
    dp.resize(n, vector<int>(12,0));
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cin >> q;
    vector<P3> ls;
    for(int i=0;i<q;i++){
        int v, d, c;
        cin >> v >> d >> c;
        v--;
        ls.push_back({v,{d,c}});
    }
    reverse(ls.begin(), ls.end());
    queue<P> que;
    for(int i=0;i<q;i++){
        int v, d, c;
        v = ls[i].first;
        d = ls[i].second.first;
        c = ls[i].second.second;
        if(dp[v][d] != 0) continue;
        dp[v][d] = c;
        que.push({v,d});
        while(!que.empty()){
            P p = que.front();
            que.pop();
            int now = p.first, r = p.second;
            if(r==0) continue;
            if(dp[now][r-1] == 0){
                dp[now][r-1] = c;
                que.push({now,r-1});
            }
            for(auto nxt : g[now]){
                if(dp[nxt][r-1] == 0){
                    dp[nxt][r-1] = c;
                    que.push({nxt,r-1});
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=11;j++){
            if(dp[i][j] > 0){
                cout << dp[i][j] << endl;
                break;
            }
            if(j==11){
                cout << 0 << endl;
            }
        }
    }
    return 0;
}


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

int main() {
	int a, b;
	while (true){
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		cout << min(a, b) << " " << max(a, b) << endl;
	}
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            sum += v[i] * v[j];
            //cout << sum << endl;
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(5e5 + 10);
int n, D, Q, d[N], ans[N];
long long f[N];

int main()
{
	n = read(), D = read();
	for (int i = 1; i <= n; i++) d[i] = read();
	f[n + 1] = 1;
	for (int i = n; i; i--)
		if (f[i + 1] <= d[i] / 2) f[i] = f[i + 1];
		else f[i] = f[i + 1] + d[i];
	for (int i = 1; i <= n; i++)
		ans[i] = f[i + 1] <= D, D = std::min(D, std::abs(D - d[i]));
	for (Q = read(); Q--; ) puts(ans[read()] ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 9880
from collections import deque
N = int(input())
P = list(map(int, input().split()))

d = deque(P)
count = 1

for i in range(1, N):
    if (d[0] >= d[1]):
        d.popleft()
        count += 1
    else:
        d1 = d.popleft()
        d2 = d.popleft()
        d.appendleft(d1)

print(count)

Measured memory_bytes: 25124
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main(int argc, char**argv){
    int n, m, x;
    cin >> n >> m >> x;
    // vector<int> a(m);
    int l_cost = 0, r_cost = 0;
    for (int i = 0; i < m; i++){
        int tmp;
        cin >> tmp;
        if (tmp < x){
            l_cost++;
        }else{
            r_cost++;
        }
    }

    cout << min(l_cost, r_cost) << endl;

    return 0;
}




















Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
using namespace std;
   
int main(){
    int a[3];
    int fir=0;
    int sec=0;
    int thi=0;
    for(int i=0;i<3;i++){
    cin>>a[i];
    if(a[i]>fir){
    thi=sec;
    sec=fir;
    fir=a[i];}else
    if(a[i]>sec){
    thi=sec;
    sec=a[i];}else
    if(a[i]>thi){
    thi=a[i];}}
    cout<<thi<<" "<<sec<<" "<<fir<<endl;
  
    return 0;}


Measured memory_bytes: 1168
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := input()
	existsN := false
	existsS := false
	existsW := false
	existsE := false
	for i := 0; i < len(s); i++ {
		if s[i] == 'N' {
			existsN = true
		} else if s[i] == 'S' {
			existsS = true
		} else if s[i] == 'W' {
			existsW = true
		} else {
			existsE = true
		}
	}

	if existsN == existsS && existsE == existsW {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
a,b=map(int,input().split())
if a*b<0:
  ans=(abs(abs(a)-abs(b))+1)
elif a*b==0:
  ans=(max(abs(a),abs(b)))
  if a>b:
    ans+=1
elif a<=b:
  ans=(b-a)
else:
  ans=(a-b+2)
print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>

using namespace std;
typedef long long  ll;

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

int main()
{
	ll N;
	cin >> N;
	vector<ll> a(N);
	cin >> a[0];
	ll g = a[0];
	for (ll i = 1; i < N; i++)
	{
		cin >> a[i];
		g = gcd(a[i], g);
	}
	cout << g << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<min(b/a,c)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
const int INF = 1000000000;
 
int c, n, m, s, d;
int visited[100][11];
int edge[100][100];
 
 
void dfs(int p, int rem, int cost){
   if(visited[p][rem] < cost) return;
   visited[p][rem] = cost;
   if(p == d) return;
   for(int i=0;i<n;i++){
      if(edge[p][i] == INF) continue;
      if(rem > 0 ) dfs(i, rem-1, cost+(edge[p][i]/2));
      dfs(i, rem, cost+edge[p][i]);
   }
}
 
main(){
   while(cin >> c >> n >> m >> s >> d && (c || n || m || s || d)){
      fill(edge[0], edge[100], INF);
      fill(visited[0], visited[100], INF);
      --s; --d;
      for(int i=0;i<m;i++){
         int a, b, f;
         cin >> a >> b >> f;
         --a; --b;
         edge[a][b] = edge[b][a] = f;
      }
      dfs(s, c, 0);
      int ans = INF;
      for(int i=0;i<c;i++){
         ans = min(ans, visited[d][i]);
      }
      cout << ans << endl;
   }
   return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int Y=0, M=0;
    char S[15];
    scanf("%s", S);
    Y += 1000*(S[0]-'0');
    Y += 100*(S[1]-'0');
    Y += 10*(S[2]-'0');
    Y += S[3]-'0';
    M += 10*(S[5]-'0');
    M += S[6]-'0';
    //printf("%d %d\n", Y, M);
    if(Y>2019) printf("TBD\n");
    else if(Y==2019){
        if(M>4) printf("TBD\n");
        else printf("Heisei\n");
    }
    else printf("Heisei\n");
    return 0;
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    string s; cin>>s;
    cout<<((s[2]==s[3] && s[4]==s[5]) ? "Yes" : "No")<<endl;
}

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

int main() {
  int64_t a, b, c, d;
  int64_t x, y, z, w;
  int64_t ans, ans1, ans2;
  cin >> a >> b >> c >> d;
  x=a*c;
  y=a*d;
  z=b*c;
  w=b*d;
  ans1=max(x, y);
  ans2=max(z, w);
  ans=max(ans1, ans2);
  cout << ans << endl;
}

Measured memory_bytes: 3636
N,M = map(int, input().split())
p = [[] for i in range(8)]
for i in range(N):
    x, y, z = map(int, input().split())
    p[0].append(x+y+z)
    p[1].append(x+y-z)
    p[2].append(x-y+z)
    p[3].append(x-y-z)
    p[4].append(-x+y+z)
    p[5].append(-x+y-z)
    p[6].append(-x-y+z)
    p[7].append(-x-y-z)

p_sum = [0 for i in range(8)]
for i in range(8):
    p[i] = sorted(p[i], reverse=True)
    p_sum[i] = sum(p[i][:M])

print(max(p_sum))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    sort(A.rbegin(), A.rend());

    ll ans = 0;
    rep(i,N){
        if (i == 0) continue;
        ans += A[i/2];
    }

    cout << ans << endl;
}

Measured memory_bytes: 4840
/*
 * main.cpp
 *
 *  Created on: 2018/04/26
 *      Author: mac
 */

#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>


using namespace std;

int main(){

    string s;

    cin >> s;

    vector<char> v;

    for(int i = 0;i < s.length();i++){
    	if(s[i] == '0'){
    		v.push_back('0');
    	}
    	if(s[i] == '1'){
    		v.push_back('1');
    	}
    	if(s[i] == 'B'){
    		if(v.size() > 0){
    			v.pop_back();
    		}
    	}

    }

    for(auto itr = v.begin();itr != v.end();itr++){
    	cout << *itr;
    }


    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
struct edge{
	ll x;
	ll y;
	bool operator<(const edge& e)const{
		return x+y<e.x+e.y;
	}
	bool operator>(const edge& e)const{
		return x+y>e.x+e.y;
	}


};
struct road{ll cost;int to;};
int c[100005]={},d[100005]={},e[100005]={};
vector<int> v1[100005],v2[100005];
int n,m;
int main() {
	memset(d,-1,sizeof(c));
	cin>>n>>m;
	int a,b;
	rep(i,0,n+m-1){
		cin>>a>>b;
		v1[a-1].push_back(b-1);
		v2[b-1].push_back(a-1);
		c[b-1]++;
	}
	queue<int> que;
	rep(i,0,n){
		if(v2[i].empty())que.push(i);
	}
	rep(i,0,n){
		int q=que.front();que.pop();
		d[q]=i;
		e[i]=q;
		for(int j:v1[q]){
			if(c[j]==0)continue;
			c[j]--;
			if(c[j]==0){
				que.push(j);
			}
		}
	}
	rep(i,0,n){
		int h=-1;
		for(int j:v2[i]){
			h=max(h,d[j]);
		}
		if(h==-1)cout<<0<<endl;
		else cout<<e[h]+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    map<int,int> mp2;
    map<int,int> m1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m1[a[i]]++;
        mp2[a[i]%m]++;
    }
    sort(begin(a),end(a));
    int ans=mp2[0]/2;
    mp2[0]=0;
    map<int,int> st;
    for(int i=1;i<=(m-1)/2;i++)
    {
        int p=min(mp2[i],mp2[m-i]);
        ans+=p;
        mp2[i]-=p;
        mp2[m-i]-=p;
    }
    if(m%2==0)
    {
        ans+=mp2[m/2]/2;
        mp2[m/2]=0;
    }
    for(auto it:m1)
    {
        int rem=mp2[it.first%m];
        int p=min(rem/2,it.second/2);
        ans+=p;
        mp2[it.first%m]-=2*p;


    }
    cout<<ans<<endl;

}

Measured memory_bytes: 12956
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var a = inputLongArray[0];
            var v = inputLongArray[1];

            inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var b = inputLongArray[0];
            var w = inputLongArray[1];

            inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var t = inputLongArray[0];

            var kyori = Math.Abs(a - b);
            var tumererukyori = v - w;

            string result = "";
            if (a == b)
            {
                result = "YES";
            }
            else if (tumererukyori <= 0)
            {
                result = "NO";
            }
            else if (tumererukyori * t >= kyori)
            {
                result = "YES";
            }
            else
            {
                result = "NO";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

const ll INF = 1e18;

int N;
ll h[100001];
ll dp[100001];

int main(){
    cin >> N;
    for (int i=0; i<N; i++) cin >> h[i];
    for (int i=0; i<N; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i=1; i<N; i++) {
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i-2]));
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
N,X=map(int,input().split())
L=[int(a) for a in input().split()]

d=0
cnt=0
for i in range(N+1):
    if d>X:
        break
    elif i==N:
        cnt+=1
    else:
        d+=L[i]#next
        cnt+=1
   
print(cnt)

Measured memory_bytes: 3060
(defn inner [X x]
  (let [tmp (->> (map #(Math/pow x %) (range 2 100))
              (take-while #(<= % X)))]
    (if ((complement empty?) tmp)
      (->> (apply max tmp)
        int)
      0)))


(defn Exponential [X]
  (->> (range 2 (inc X))
    (map #(inner X %))
    (cons 1)
    (apply max)))



(-> (int (read))
  Exponential
  println)

Measured memory_bytes: 70004
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long int n;cin>>n;
  vector<long long int> h(n);for(int i=0;i<n;i++) cin>>h[i];
  vector<long long int> dp(n,100000000000);
  
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=1;j<=2;j++){
      	if(i+j>n-1) continue;
    	dp[i+j]=min(abs(h[i]-h[i+j])+dp[i],dp[i+j]);
    }
  }
     cout<<dp[n-1]<<endl;
 }

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

int main(){
  string s;
  cin >> s;
  int cnt = 0;
  for(int i = 0;i < s.size();i++){
    if(s.at(i) == 'x'){
      cnt++;
    }
  }
  
  if(cnt < 8){
    cout <<  "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
    }

    map<int64_t, int64_t> num;
    int64_t sum = 0;
    for (int64_t a : A) {
        num[a]++;
        sum += a;
    }

    int64_t Q;
    cin >> Q;
    for (int64_t i = 0; i < Q; i++) {
        int64_t B, C;
        cin >> B >> C;

        int64_t sub = B * num[B];
        int64_t add = C * num[B];
        sum += add - sub;
        cout << sum << endl;
        num[C] += num[B];
        num[B] = 0;
    }
}

Measured memory_bytes: 9888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int count0=0;
  int count1=0;
  
  for(int i=0; i < S.size(); i++){
    if(S.at(i)=='0') count0++;
    if(S.at(i)=='1') count1++;
  }
  cout << 2*min(count0, count1) << endl;
}

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

/**
 * C - Distinct or Not
 * 整数列 A1,A2,...,AN が与えられます。
 * この整数列のどの 2 つの要素も互いに異なるならば YES を、そうでないなら NO を出力してください。
 */
public class Main {

    public static void main( String[] args ) {

        Scanner sc = new Scanner( System.in );
        // 入力値
        int n = sc.nextInt();   // 入力される整数列の整数の数
        // 整数列
        Set<Integer> a = new HashSet<>();
        for( int i = 0; i < n; i++ ) {
            a.add( sc.nextInt() );
        }

        System.out.println( ( n > a.size() ) ? "NO" : "YES" );

        sc.close();
    }
}

Measured memory_bytes: 69952
n = gets.to_i
xys = n.times.map{ gets.split.map(&:to_i) }

if n == 1
  p 1
else
  ary = []
  xys.combination(2).to_a.map do |xy|
    p1, p2 = xy
    dx = p1[0] - p2[0]
    dy = p1[1] - p2[1]
    ary << [dx, dy]
    ary << [-dx, -dy]
  end
  s = ary.group_by(&:itself).map{|k, v| v.size}.max
  p n - s
end

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

string to_string(string s) { return '"' + s + '"'; }
string to_string(char c) { string s = "'"; s += c; return s + "'"; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } 
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
istream_iterator<string> eos;
void dbg_out(istream_iterator<string> it) { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(istream_iterator<string> it, Head H, Tail... T) {
    cerr << *it << " = " << to_string(H);
    if(++it != eos) cerr << ", ";
    dbg_out(it, T...);
}
#ifdef LOCAL
    #define dbg(...) { string _s = #__VA_ARGS__; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); dbg_out(_it, __VA_ARGS__); }
#else
    #define dbg(...)
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define sz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 2e5+5;

void solve(){
    string s;
    cin >> s;
    int n = sz(s);
    string t = s;
    reverse(all(t));
    if(t == s){
        string x = s.substr(0, (n-1)/2);
        t = x;
        reverse(all(x));
        if(t == x){
            string y = s.substr((n+3)/2 - 1);
            t = y;
            reverse(all(t));
            if(t == y){
                cout << "Yes\n";
            }
            else cout << "No\n";
        }
        else cout << "No\n";
    }
    else cout << "No\n";
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N;
	cin >> N;
	for (int i = 1; i <= 9; i++){
		for (int k = 1; k <= 9; k++){
			if (i*k == N){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N;
	int A[100];
	int i;
    scanf("%d", &N);
	for(i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	int j;
	int flag = 1;
	int tmp;
	int count = 0;
	while(flag) {
		flag = 0;
		for(j = N - 1; j > 0; j--) {
			if(A[j] < A[j-1]){
				tmp = A[j];
				A[j] = A[j-1];
				A[j-1] = tmp;
				count++;
				flag = 1;
			}
		}
	}
	for(i = 0; i < N - 1; i++) {
		printf("%d",A[i]);
		printf(" ");
	}
	//printf("%d\n%d", A[N-1], count);
printf("%d\n",A[N-1]);
printf("%d\n", count);
			
    return 0;
}

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

using namespace std;

int main(){
  int v[6];
  const int c[6] = {1,5,10,50,100,500};
  for(int i = 0 ; i < 6 ; i++){
    cin >> v[i];
  }
  int sum = 0;
  for(int i = 0 ; i < 6 ; i++){
    sum += v[i]*c[i];
  }
  cout << (sum >= 1000) << endl;
  return 0;
}

Measured memory_bytes: 1160
N,A=gets.split.map(&:to_i)
x=gets.split.map(&:to_i)
N2=N

dp = Array.new(N2+1).map{Array.new(N2+1).map{Array.new(N2*50+1,0)}}
dp[0][0][0]=1
(0...N).each{|i|
    (0..i).each{|j|
        (0..i*50).each{|k|
            dp[i+1][j][k] += dp[i][j][k]
            dp[i+1][j+1][k+x[i]] += dp[i][j][k]
        }
    }
}

total = 0
(1..N).each{|j|
    total += dp[N][j][j*A]
}

puts total


Measured memory_bytes: 52604
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

	void run() throws FileNotFoundException {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N + 1];
		int[] R = new int[N + 1];
		for (int i = 0; i < N; ++i) {
			L[i] = sc.nextInt();
			R[i] = -sc.nextInt();
		}
		long ans = 0;
		Arrays.sort(L);
		Arrays.sort(R);
		for (int i = N; i >= 0; --i) {
			if (L[i] + R[i] > 0) {
				ans += 2 * (L[i] + R[i]);
			}
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 84644
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}


int main(){
	ll n,k;
	cin>>n>>k;
	if(k==0){
		cout<<n*n<<endl;
		return 0;
	}
	ll ans=0;
	for(ll b=1;b<n+1;b++){
		if(b>k){
			if(n-(b*(n/b)+k)+1>0){
				ans+=(n/b)*(b-k)+n-(b*(n/b)+k)+1;
			}else{
				ans+=(n/b)*(b-k);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
       string s,t ; cin >> s >> t;
       ll cnt=0;
       rep(i,sz(s)){
       	if(s[i]==t[i]) cnt++;
	   }
	   cout << cnt << endl;
    }
}


Measured memory_bytes: 256
s = input()
if int(s[:4]) <= 2019:
  if int(s[5:7]) <= 4:
    if int(s[8:10]) <= 30:
      print('Heisei')
    else:
      print('TBD')
  else:
    print('TBD')
else:
  print('TBD')


Measured memory_bytes: 2940
package main

import (
	"fmt"
	"container/heap"
)

type Node struct {
	C rune
	H int
	P *Node
	C0 *Node
	C1 *Node
}

type Npq []*Node

func (npq Npq) Len() int { return len(npq) }
func (npq Npq) Swap(i,j int) { npq[i], npq[j] = npq[j], npq[i] }
func (npq Npq) Less(i,j int) bool { return npq[i].H < npq[j].H }
func (npq *Npq) Push(x interface{}) {
	*npq = append(*npq, x.(*Node))
}
func (npq *Npq) Pop() interface{} {
	n := len(*npq)
	item := (*npq)[n-1]
	*npq = (*npq)[0:n-1]
	return item
}

func main() {
	var s string
	fmt.Scan(&s)
	ss := []rune(s)
	m := make(map[rune]int)
	for i := 0; i < len(ss); i++ {
		if _, ok := m[ss[i]]; !ok {
			m[ss[i]] = 0
		}
		m[ss[i]] += 1
	}

	n := len(m)
	var npq Npq = make([]*Node, n)
	i := 0
	for k, v := range m {
		npq[i] = &Node{k, v, nil, nil, nil}
		i++
	}
	heap.Init(&npq)

	for len(npq) > 1 {
		n1 := heap.Pop(&npq).(*Node)
		n2 := heap.Pop(&npq).(*Node)
		node := &Node{C: -1, H: n1.H + n2.H, P:nil, C0: n1, C1: n2}
		n1.P = node
		n2.P = node
		heap.Push(&npq, node)
	}

	que := make([]*Node, 1, 2)
	que[0] = heap.Pop(&npq).(*Node)
	if que[0].C0 == nil && que[0].C1 == nil {
		fmt.Println(que[0].H)
		return
	}

	val, d := 0, 0
	for len(que) > 0 {
		size := len(que)
		for j := 0; j < size; j++ {
			node := que[j]
			if node.C != -1 {
				val += d * node.H
			}
			if node.C0 != nil {
				que = append(que, node.C0)
			}
			if node.C1 != nil {
				que = append(que, node.C1)
			}
		}
		if len(que) == size {
			break
		}
		que = que[size:]
		d++
	}
	fmt.Println(val)
}


Measured memory_bytes: 2232
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int h,w;
	while(cin>>h>>w)
	{
		char a[h][w];
		string str="";
		int i,j;
		int th=h,tw=w;
		for(i=0;i<h;i++)
			for(j=0;j<w;j++)
				cin>>a[i][j];
		for(i=0;i<h;i++)
		{
			int cnt1=0;
			for(j=0;j<w;j++)
			{
				if(a[i][j]=='.')
					cnt1++;	
			}
			if(cnt1==w)
			{
				th--;
				for(j=0;j<w;j++)
					a[i][j]='!';
			}
				

		}
		
		
		for(j=0;j<w;j++)
		{
			int cnt2=0;
			for(i=0;i<h;i++)
			{
				if(a[i][j]=='.'||a[i][j]=='!')
					cnt2++;
			}
			if(cnt2==h)
			{
				tw--;
				for(i=0;i<h;i++)
					a[i][j]='!';
			}
				
		}
	
		for(i=0;i<h;i++)
		{
			for(j=0;j<w;j++)
				if(a[i][j]!='!')
					str+=a[i][j];
					
		}
	//	cout<<th<<" "<<tw<<endl;
		for(i=0;i<th*tw;i++)
		{
			if(i%tw==0)
				cout<<endl;
			cout<<str[i];
		}
		 cout<<endl;
			
			
	} 	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by hirai on 2016/08/30.
 */
public class Main {

    /*
    public static final void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println((scanner.nextInt()
                + scanner.nextInt()
                + scanner.nextInt())
                + " "
                + scanner.next());
    }
    */
    public static final void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();
        final int x = scanner.nextInt();
        final int y = scanner.nextInt();

        int sum = 0;
        for(int i=0;i<n;i++){
            if(i<k){
                sum += x;
            }else{
                sum += y;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 9556
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    int n;
    cin >> n;
    unordered_map<ll, int> mp;

    ll sum = 0;
    mp[0] ++;
    ll a;
    ll res = 0;
    for(int i = 0;i < n;i++){
        cin >> a;
        sum += a;
        res += mp[sum];
        mp[sum]++;
    }
    cout << res;
}


Measured memory_bytes: 8520
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	d := int(1e9) + 7
	list := []string{"A", "C", "G", "T"}
	dict := make(map[string]int)
	for _, i := range list {
		for _, j := range list {
			for _, k := range list {
				dict[i+j+k] = 0
			}
		}
	}
	dict["TTT"] = 1
	for i := 0; i < n; i++ {
		tmp := make(map[string]int)
		for _, c := range list {
			for k, v := range dict {
				key := k[1:] + c
				if judge1(key) && judge2(k, c) {
					tmp[key] += v
					tmp[key] %= d
				}
			}
		}
		for k, _ := range dict {
			dict[k] = tmp[k]
		}
	}
	ans := 0
	for _, v := range dict {
		ans += v
	}
	fmt.Println(ans % d)
}
func judge1(s string) bool {
	if s == "AGC" {
		return false
	} else if s == "ACG" {
		return false
	} else if s == "GAC" {
		return false
	} else {
		return true
	}
}
func judge2(k, c string) bool {
	if string(k[0]) == "A" && (string(k[1]) == "G" || string(k[2]) == "G") && c == "C" {
		return false
	} else {
		return true
	}
}


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

// 0-indexed
template <class T>
struct SegmentTree {
  // a,b,c: T, e:T(unit)
  // abc = (ab)c = a(bc)
  // ae = ea = a
  typedef function<T(T, T)> F;
  int n;
  F f;
  T unit;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int newn, F f, T t) : f(f), unit(t) { init(newn); }
  SegmentTree(const vector<T> &v, F f, T t) : f(f), unit(t) {
    int _n = v.size();
    init(v.size());
    for (int i = 0; i < _n; ++i) dat[n + i] = v[i];
    for (int i = n - 1; i; --i) dat[i] = f(dat[i << 1], dat[(i << 1) | 1]);
  }
  void init(int newn) {
    n = 1;
    while (n < newn) n <<= 1;
    dat.assign(n << 1, unit);
  }

  // "go up" process
  void update(int k, T newdata) {
    dat[k += n] = newdata;
    while (k >>= 1) {
      dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }
  }
  // [a,b)
  T query(int a, int b) {
    T vl = unit, vr = unit;
    for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vl = f(vl, dat[l++]);
      if (r & 1) vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
  // func(unit) == false
  // min left: <false>0,1...st-1<true>st,...n-1
  template <typename C>
  int find_left(int st, C &func, T acc, int k, int l, int r) {
    if (l + 1 == r) {
      acc = f(acc, dat[k]);
      return func(acc) ? k - n : -1;
    }
    int mid = (l + r) >> 1;
    if (mid <= st) return find_left(st, func, acc, (k << 1) | 1, mid, r);
    if (st <= l && !func(f(acc, dat[k]))) {
      acc = f(acc, dat[k]);
      return -1;
    }
    int nres = find_left(st, func, acc, (k << 1), l, mid);
    if (~nres) return nres;
    return find_left(st, func, acc, (k << 1) | 1, mid, r);
  }
  template <typename C>
  int find_left(int st, C &func) {
    T acc = unit;
    return find_left(st, func, acc, 1, 0, n);
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (auto &p : a) cin >> p;
  auto f = [](int l, int r) { return max(l, r); };
  SegmentTree<int> seg(a, f, -1);
  while (q--) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1)
      seg.update(x - 1, y);
    else if (t == 2)
      cout << seg.query(x - 1, y) << endl;
    else {
      auto c = [&](int p) { return p >= y; };
      int res = seg.find_left(x - 1, c);
      if (res < 0) res = n;
      cout << res + 1 << endl;
    }
  }

  return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

double L;

void solve() {
  double v = L / 3.0;
  double ans = v * v * v;
  
  printf("%.10f\n",ans);
}

int main() {
  cin >> L;
  solve();
  return 0;
}


Measured memory_bytes: 256
s = list(input())
flag = True
for i in range(len(s)):
    if i%2 == 0 and s[i] == 'L':#odd
        flag = False
        break
    elif i%2 == 1 and s[i] == 'R':
        flag = False
        break
    
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int,int> Paint;
bool Pairsecond(const Paint& pf,Paint&ps){//sortCompare
  return pf.second < ps.second;
}
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(){
  int n;cin>>n;
  int kekka = 0;
  vector<Paint> a;
  rep(i,n){
    int tmp;cin>>tmp;
    a.push_back(Paint(i+1,tmp));
  }
  sort(a.begin(),a.end(),Pairsecond);
  rep(i,n){
    if(a[i].first%2 != (i+1)%2)kekka++;
  }
  cout  << kekka/2 << endl;
}

Measured memory_bytes: 1400
def main():
    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    suma = sum(a)
    sumb = sum(b)
    k = sumb - suma

    s = [0] * N
    t = [0] * N
    for i in range(N):
        diff = a[i] - b[i]
        if diff < 0:
            if diff % 2 == 1:
                s[i] += (abs(diff)+1)//2
                t[i] += 1
            else:
                s[i] += abs(diff)//2
        else:
            t[i] += diff
    sums = sum(s)
    sumt = sum(t)
    remains = k - sums
    remaint = k - sumt
    if remains < 0 or remaint < 0:
        print('No')
        return
    if remains == 0 and remaint == 0:
        print('Yes')
        return
    if remains * 2 == remaint:
        print('Yes')
        return

if __name__ == "__main__":
    main()


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

int main(){
  
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.size()-1;i++)
    if(s[i]=='A'&&s[i+1]=='C')ans=1;

  cout<<(ans?"Yes":"No")<<endl;
  
  return 0;
}


Measured memory_bytes: 764
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

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

  cout << "Christmas ";
  
  for(int rep = 0; rep < 25 - N; ++rep) cout << "Eve ";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a;std::cin >> a;
  std::cout << a + (a*a) + (a*a*a) << '\n';
  return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define db double
#define ldb long double
#define uint unsigned
#define ll long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef map<int,int> mii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
int inline nextin(){
	int t;
	if(scanf("%d",&t)!=1)exit(0);
	return t;
}
int inline in(){
	int x=0,c;
	for(;(uint)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((uint)((c=getchar())-'0')<10);
	return x;
}
char p[100005];
int P[100005],S[100005];
int main(){
	int n;
	scanf("%d%s",&n,p);
	for(int i=0;p[i];i++){
		if(p[i]=='o')P[i+1]=0;
		else P[i+1]=1;
	}
	P[n+1]=P[1];
	for(int i=0;i<8;i++){
		S[0]=i&1;
		S[1]=(i>>1)&1;
		S[2]=(i>>2)&1;
		for(int j=2;j<=n+1;j++){
			S[j+1]=S[j-2]^P[j];
		}
		if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^S[2]^S[n+2])continue;
		for(int j=1;j<=n;j++){
			printf("%c",(S[j]^S[j-1])?'W':'S');
		}
		printf("\n");
		return 0;
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 1280