akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8


struct Node{
	int key;
    Node *right, *left,*parent;
};

Node *root, *NIL;

void insert(int k){
    Node  *y = NIL;
    Node  *x = root;
    Node  *z;

    z = (Node *)malloc(sizeof(Node));
    z -> key = k;
    z -> left = NIL;
    z -> right = NIL;

    while( x!=NIL ) {
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
        else{
            x = x->right;
        }
    }
    z->parent =y;
    if(y==NIL){
        root = z;
    }
    else{
        if (z->key < y->key){
            y->left = z;
        }
        else{
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if(u==NIL){
        return;
    }
    inorder(u->left);
    cout <<" "<< u->key ;
    inorder(u->right);
}

void preorder(Node *u){
    if(u==NIL){
        return;
    }
    cout <<" "<< u->key ;
    preorder(u->left);
    preorder(u->right);
}

void pastorder(Node *u){
    if(u==NIL){
        return;
    }
    pastorder(u->left);
    pastorder(u->right);
    cout <<" "<< u->key ;
}

int main(){
	int N,X;
    string S;
    cin >> N;
    rep(i,N){
        cin >> S;
        if(S[0]=='i'){
            cin >> X;
            insert(X);
        }
        if(S[0]=='p'){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
}



Measured memory_bytes: 26616
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    Map<String, Integer> map = new HashMap<>();
    map.put(s, sc.nextInt());
    map.put(t, sc.nextInt());
    String u = sc.next();
    map.put(u, map.get(u) - 1);
    StringBuilder sb = new StringBuilder();
    sb.append(map.get(s));
    sb.append(" ");
    sb.append(map.get(t));
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 22612
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		boolean[] x = new boolean[3];
		x[0] = true;
		while(stdIn.hasNext()) {
			String[] a = stdIn.next().split(",");
			int a1 = -1;
			int a2 = -1;
			if(a[0].charAt(0) == 'A') {
				a1 = 0;
			}
			if(a[0].charAt(0) == 'B') {
				a1 = 1;
			}
			if(a[0].charAt(0) == 'C') {
				a1 = 2;
			}
			if(a[1].charAt(0) == 'A') {
				a2 = 0;
			}
			if(a[1].charAt(0) == 'B') {
				a2 = 1;
			}
			if(a[1].charAt(0) == 'C') {
				a2 = 2;
			}
			boolean tmp = x[a2];
			x[a2] = x[a1];
			x[a1] = tmp;
		}
		if(x[0]) {
			System.out.println("A");
		}
		if(x[1]) {
			System.out.println("B");
		}
		if(x[2]) {
			System.out.println("C");
		}
	}
}

Measured memory_bytes: 17152
class DTree
  def initialize(p, n)
    # @p = p
    @t = Array.new(n)
    @np = 0
    makeDTree(0, n, p, 0)
  end

  def makeDTree(l, r, p, axis)
    unless l < r
      return nil
    end

    mid = (l + r) / 2
    t = @np
    @np += 1

    new_p = p[l...r].sort_by{ |p| p[axis] }
    # puts "l: #{l}, r: #{r}, depth: #{depth} px: #{@p.map{|p| p.x}}, py: #{@p.map{|p| p.y}}"
    # puts "l: #{l}, r: #{r}, mid: #{mid}, new_p: #{new_p}"
    node = new_p[mid - l]
    @t[t] = node
    axis ^= 1
    @t[t][3] = makeDTree(0, mid - l, new_p, axis)
    @t[t][4] = makeDTree(mid+1 - l, r - l, new_p, axis)

    return t
  end

  def find(v, sx, tx, sy, ty, ans, axis)
    x = @t[v][0]
    y = @t[v][1]

    if sx <= x && x <= tx && sy <= y && y <= ty
      ans << @t[v][2]
    end

    if axis.zero?
      axis ^= 1
      if @t[v][3] && sx <= x
        find(@t[v][3], sx, tx, sy, ty, ans, axis)
      end
      if @t[v][4] && x <= tx
        find(@t[v][4], sx, tx, sy, ty, ans, axis)
      end
    else
      axis ^= 1
      if @t[v][3] && sy <= y
        find(@t[v][3], sx, tx, sy, ty, ans, axis)
      end
      if @t[v][4] && y <= ty
        find(@t[v][4], sx, tx, sy, ty, ans, axis)
      end
    end
  end
end

# MyNode is too late.
# class MyNode
#   attr_accessor :x, :y, :id, :l, :r
#   def initialize(id:, x:, y:)
#     @id = id
#     @x = x
#     @y = y
#     @l = nil
#     @r = nil
#   end
# end

# start_time = Time.now
n = gets.to_i
p = Array.new
n.times do |i|
  x, y = gets.split.map(&:to_i)
  p << [x, y, i]
end
# p "Initialze #{Time.now - start_time}s"

d_tree = DTree.new(p, n)
# p "Make tree #{Time.now - start_time}s"

q = gets.to_i
q.times do
  ans = []
  sx, tx, sy, ty = gets.split.map(&:to_i)
  d_tree.find(0, sx, tx, sy, ty, ans, 0)
  ans.sort!
  ans.each do |id|
    puts id
  end
  puts
end
# p "End #{Time.now - start_time}s"



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

int main() {
    int a, b;
    int ans = 0;
    
    cin >> a >> b;
    
    if (a > b) {
        ans += a;
        a--;
    }
    else {
        ans += b;
        b--;
    }
    
    if (a > b) {
        ans += a;
        a--;
    }
    else {
        ans += b;
        b--;
    }
    
    cout << ans << endl;
    return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define f18 1000000000000000000

int main()
{
  int n;cin>>n;
  vector<ll> a(n);
  int i;
  rep(i,n)cin>>a[i];
  sort(all(a));
  ll ans=1;
  if(a[0]==0)ans=0;
  else
  {
    rep(i,n)
    {
      if(ans>f18/a[i])
      {
        ans=-1;
        break;
      }
      ans=ans*a[i];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4000
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, a, b; cin >> n >> a >> b;
  cout << ((b - a) & 1 ? "Borys\n" : "Alice\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  if(n >= 10) {
    cout << m <<endl;
    return 0;
  }
  cout << m + 100 * (10 - n) << endl;
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> H >> W >> K;
	int sx, sy, gx, gy;
	cin >> sy >> sx >> gy >> gx;
	sy--, sx--, gy--, gx--;
	vector<string>s(H);
	for (auto &i : s)cin >> i;
	int dir[] = { -1,0,1,0,-1 };
	vector<vector<vector<pair<int, int>>>>dis(H, vector<vector<pair<int, int>>>(W, vector<pair<int, int>>(4, { MOD,MOD })));
	queue<pair<pair<int, int>, int>>Q;
	queue<pair<pair<int, int>, int>>NQ;
	for (int i = 0; i < 4; i++) {
		dis[sy][sx][i] = { 0,K };
	}
	Q.push({ { sy,sx },0 });
	while (!Q.empty()) {
		int cy = Q.front().first.first;
		int cx = Q.front().first.second;
		int d = Q.front().second;
		//	cout << cy << " " << cx << " " << d << endl;
		//	cout <<"dis "<< dis[cy][cx][d].first << " " << dis[cy][cx][d].second << endl;
		Q.pop();
		for (int i = 0; i < 4; i++) {
			int ny = cy + dir[i], nx = cx + dir[i + 1];
			if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
			//cout << ny << " " << nx << endl;
			if (s[ny][nx] == '@')continue;
			if (i == d && dis[cy][cx][d].second != K) {
				if (dis[ny][nx][i] > make_pair(dis[cy][cx][d].first, dis[cy][cx][d].second + 1)) {
					dis[ny][nx][i] = make_pair(dis[cy][cx][d].first, dis[cy][cx][d].second + 1);
					Q.push({ { ny,nx },i });
				}
			}
			else {
				if (dis[ny][nx][i] > make_pair(dis[cy][cx][d].first + 1, 1)) {
					dis[ny][nx][i] = make_pair(dis[cy][cx][d].first + 1, 1);
					NQ.push({ { ny,nx },i });
				}
			}
		}
		if (Q.empty()) {
			Q = NQ;
			while (!NQ.empty()) {
				Q.push(NQ.front());
				NQ.pop();
			}
		}
	}
	int ans = MOD;
	for (int i = 0; i < 4; i++) {
		ans = min(ans, dis[gy][gx][i].first);
	}
	if (ans == MOD)ans = -1;
	cout << ans << endl;
}


Measured memory_bytes: 144960
#include<algorithm>
#include<iostream>
#include<map>
#include <bits/stdc++.h>
#include<cmath>
#define mod 1000000007
#define ll long long 
using namespace std;

int main() {


  
ll x,y;
cin>>x>>y;
cout<<(x*y)<<endl;
	return 0;
}

Measured memory_bytes: 3644
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		long ans = (X / 500) * 1000;
		ans += (X % 500 / 5) * 5;
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;


int main(void)
{
	int X; cin >> X;
	int A, B, C, D; 
	D = X % 10; X /= 10;
	C = X % 10; X /= 10;
	B = X % 10; X /= 10;
	A = X % 10; 
	if (A + B + C + D == 7)printf("%d+%d+%d+%d=7\n", A, B, C, D);
	else if (A - B + C + D == 7)printf("%d-%d+%d+%d=7\n", A, B, C, D);
	else if (A + B - C + D == 7)printf("%d+%d-%d+%d=7\n", A, B, C, D);
	else if (A + B + C - D == 7)printf("%d+%d+%d-%d=7\n", A, B, C, D);
	else if (A + B - C - D == 7)printf("%d+%d-%d-%d=7\n", A, B, C, D);
	else if (A - B + C - D == 7)printf("%d-%d+%d-%d=7\n", A, B, C, D);
	else if (A - B - C + D == 7)printf("%d-%d-%d+%d=7\n", A, B, C, D);

	return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

/*
class Compare
{
  public:
    bool operator()(pi a,pi b)
    {
      if(a.first<b.first || (a.first==b.first && a.second>b.second))
        return true;
      return false;
    }
};
*/

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	ll h = (h2 - h1) * 60 + (m2 - m1) - k;
	cout << h << endl;
	return 0;
}































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

#define deb(x) cout << #x << " " << x << "\n";
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define endl "\n"
#define ll long long
#define vi vector<int>

// memset(arr, value, size);

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);

	long t, i;
	map<string, long> m;
	vector<string> v = {"AC", "WA", "TLE", "RE"};
	for (int j = 0; j < 4; j++) {
		m[v[j]] = 0;
	}
	cin >> t;
	fo(i, t) {
		string l;
		cin >> l;
		m[l] += 1;
	}
	for (int j = 0; j < 4; j++) {
		cout << v[j] << " x " << m[v[j]] << endl;
	}


	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
		cout << "pon";
	else if (n % 10 == 3)
		cout << "bon";
	else
		cout << "hon";

}

Measured memory_bytes: 3552
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] h = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int n = nk[0];
            int k = nk[1];
            int count = 0;

            foreach(var hi in h)
            {
                if (hi >= k) count++;
            }

            Console.WriteLine(count.ToString());
        }
    }
}


Measured memory_bytes: 19040
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
using ll = long long; 
using namespace std;
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 main() {
	int n;
	cin >> n;
	vector<int>v(n);
	rep(i,n) cin >> v[i];
	//cnt1は偶数,cnt2は奇数
	vector<int>cnt1(100010),cnt2(100010);
	rep(i,n) {
		if(i%2 == 0) {
			cnt1[v[i]]++;
		}
		if(i%2 == 1) {
			cnt2[v[i]]++;
		}
	}
	int mode1 = -1;//偶数の最頻値
	int tmp1 = -1;
	for(int i = 0;i<100010;i++) {
		if(tmp1<=cnt1[i]) {
			tmp1 = cnt1[i];
			mode1 = i;
		}
	}
	
	int mode2 = -1;//偶数で2番目に大きい最頻値
	int tmp2 = -1;
	for(int i = 0;i<100010;i++) {
		if(i != mode1 && tmp2<cnt1[i]) {
			tmp2 = cnt1[i];
			mode2 = i;
 		}
	}
	
	int mode3 = -1;//奇数の最頻値
	int tmp3 = -1;
	for(int i = 0;i<100010;i++) {
		if(tmp3<=cnt2[i]) {
			tmp3 = cnt2[i];
			mode3 = i;
		}
	}
	int mode4 = -1;//奇数で2番目に大きい最頻値
	int tmp4 = -1;
	for(int i = 0;i<100010;i++) {
		if(i != mode3 && tmp4<cnt2[i]) {
			tmp4 = cnt2[i];
			mode4 = i;
 		}
	}
	int ans = 0;
	//偶数番目の配列と奇数番目の配列の最頻値が互いに異なるとき
	if(mode1 != mode3) {
		rep(i,n) {
			if(i%2==0) {
				if(v[i] != mode1) ans++;
			}
			if(i%2 == 1) {
				if(v[i] != mode3) ans++;
			}
		}
		cout << ans << endl;
		return 0;
	}
	int ans2 = 0;
	int ans3 = 0;
	//偶数番目と奇数番目で最頻値が同じとき
	//２番目に大きい最頻値を使って２通り試して最小値をとる
	if(mode1 == mode3) {
		rep(i,n) {
			if(i%2==0) {
				if(v[i] != mode1) ans2++;
			}
			if(i%2 == 1) {
				if(v[i] != mode4) ans2++;
			}
		}
		rep(i,n) {
			if(i%2==0) {
				if(v[i] != mode2) ans3++;
			}
			if(i%2 == 1) {
				if(v[i] != mode3) ans3++;
			}
		}
		cout << min(ans2,ans3) << endl;
		return 0;
	}
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i+=2)
	if(s[i]=='L')
	{
		cout<<"No";
		return 0;
	}
	for(int i=1;i<s.size();i+=2)
	if(s[i]=='R')
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>> ans;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0)continue;
        ans.emplace_back(i,0);
        while(n%i==0){
           ans.back().second++;
           n/=i;
        }
    }
    if(1!=n) ans.emplace_back(n,1);
    return ans;
}

int main(){
    ll n;
    cin>>n;
    auto ret=factorize(n);
    ll ans=0;
    for(const auto& item:ret){
        ll calc=0;
        for(ll i=0;i<=item.second;i++){
            ll temp=i*(i+1)/2;
            if(temp==item.second){
                calc=i;
                break;
            }else if(temp>item.second){
                calc=i-1;
                break;
            }
        }
        ans+=calc;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3640
cnt = int(input())
la = list(map(int, input().split()))
lb = list(map(int, input().split()))
lc = list(map(int, input().split()))

total  =0
for i in range(cnt):
  total += lb[la[i] - 1]
  if i != 0 and (la[i-1] +1) == la[i]:
    total += lc[la[i] - 2]

print(total)


Measured memory_bytes: 3060
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//239///F.Sugoroku
	int p,q,r,mx=0;
	cin>>p>>q>>r;
	mx = max(p,max(q,r));
	cout<<p+q+r-mx;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll n, ans; cin >> n;
  for(ll i = 1;;i++)
  {
    if(i * i <= n)
    {
      ans = i * i;
    }
    else
    {
      fin(ans)
      exit(0);
    }
    
  }
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

int main(){
	int N,W;
	cin >> N >> W;
	int v[N],w[N];
	for(int i=0; i<N; i++){
		cin >> v[i];
		cin >> w[i];
	}
//DPテーブル
	int DP[N+1][W+1];

	for(int j=0; j<=W; j++)
		DP[0][j]=0;

	for(int i=1; i<=N; i++){
		for(int j=0; j<=W; j++){
			if(j<w[i-1])
				DP[i][j]=DP[i-1][j];
			else{
				if(DP[i-1][j] > DP[i][j-w[i-1]]+v[i-1])
					DP[i][j]=DP[i-1][j];
				else
					DP[i][j]=DP[i][j-w[i-1]]+v[i-1];

			}
		}
	}

	cout << DP[N][W] << endl;

	return 0;
}

Measured memory_bytes: 5108
package main

import "fmt"

func main() {
	var (
		n, k int
		s    string
	)
	fmt.Scan(&n, &k, &s)

	l := 0
	sum := 0
	var bls, brs byte = '1', '1'
	ans := 0
	for r := 0; r < n; r++ {
		if brs != s[r] {
			brs = s[r]
			if s[r] == '0' {
				k--
			}
		}
		if k < 0 {
			for l < n {
				if bls != s[l] {
					bls = s[l]
					if s[l] == '1' {
						k++
						break
					}
				}
				l++
				sum--
			}
		}
		sum++
		if sum > ans {
			ans = sum
		}
	}
	fmt.Println(ans)
}


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

int n;
int e[101];
int dp[101][101];

int main() {
    cin >> n;

    for(int j=2; j<=n; j++)
    {
        int m = j;
        for(int i=2; i<=j; i++)
        {
            while(true)
            {
                if(m % i == 0)
                {
                    m = m / i;
                    e[i]++;
                }
                else
                {
                    break;
                }
            }
        }
    }


    dp[1][1] = 1;
    for(int i=2; i<=100; i++)
    {
        for(int k=0; k<=e[i]; k++)
        {
            for(int j=1; j * (k + 1)<=75; j++)
            {
                dp[i][j * (k + 1)] += dp[i-1][j];
            }
        }
    }
    /*
    int ans = 0;
    for(int i=2; i<=100; i++)
    {
        ans += dp[i][75];
    }
    */
    cout << dp[n][75] << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  map<string,int> M;
  int ma = 0;
  for(int i = 0; i < N; ++i){
    string s;
    cin >> s;
    ++M[s];
    ma = max(ma,M[s]);
  }
  for(auto e : M){
    if(e.second != ma) continue;
    cout << e.first << endl;
  }
}


Measured memory_bytes: 25216
#include<iostream>
using namespace std;
int main()
{
   int n;
  cin>>n;
  if(n>=1 && n<=199)
    cout<<10;
  else
  if(n>=200 && n<=399)
    cout<<9;
  else
  if(n>=400&& n<=599)
    cout<<8;
  else
     if(n>=600&& n<=799)
    cout<<7;
  else
     if(n>=800&& n<=999)
    cout<<6;
  else
     if(n>=1000&& n<=1199)
    cout<<5;
  else
     if(n>=1200&& n<=1399)
    cout<<4;
  else
     if(n>=1400&& n<=1599)
    cout<<3;
  else
     if(n>=1600&& n<=1799)
    cout<<2;
  else
     if(n>=1800&& n<=1999)
    cout<<1;
    
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define int long long int
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL);
#define fr(i,a,b)  for(int i=a;i<=b;i++)
#define rf(j,b,a)  for(int j=b;j>=a;j--)
#define frr(k,a,b) for(int k=a;k<=b;k++)
#define mp make_pair
#define pb push_back
#define MOD 1000000007
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
signed main()
{   
	IOS
   /* #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif*/
int n,k;
cin>>n>>k;
 vector<int> a(n);
    vector<bool> dp(k+1);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int stones=1;stones<=k;stones++){
        for(int j=0;j<n;j++){
            if(stones-a[j]>=0 && dp[stones-a[j]]==false){
                dp[stones]=true;
                break;
            }
        }
    }
    if(dp[k])
    {
        cout<<"First";
    }
    else{
        cout<<"Second";
    }
}









Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    double a_d,b_d;
    scanf("%d %d",&a,&b);
    a_d = static_cast<double>(a);
    b_d = static_cast<double>(b);
    printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}


Measured memory_bytes: 2752
function getMax(blue, red) {
  var BLUE = {};
  var RED = {};
  max = 0;
  blue.forEach(keyword => {
    if (typeof BLUE[keyword] === "undefined") {
      BLUE[keyword] = 1;
    } else {
      BLUE[keyword] += 1;
    }
  });
  red.forEach(keyword => {
    if (typeof RED[keyword] === "undefined") {
      RED[keyword] = 1;
    } else {
      RED[keyword] += 1;
    }
  });
  Object.keys(BLUE).forEach(key => {
    if (typeof RED[key] === "undefined") {
      if (BLUE[key] > max) max = BLUE[key];
    }
    var tmp = (BLUE[key] - RED[key]) < 0 ? 0 : BLUE[key] - RED[key];
    if (tmp > max) max = tmp;
  })
  return max;
}

function Main(input) {
  input = input.split('\n');
  BLUE = input.slice(1, parseInt(input[0], 10) + 1);
  RED = input.slice(parseInt(input[0], 10) + 2, -1);
  console.log(getMax(BLUE, RED));
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e9)
// #define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}

const int N = 1e5+1;
int cnt[N];

void solve(int &test) {
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        cnt[x]++;
        ans += x;
    }
    int q; cin >> q;
    while(q--){
        int b, c;
        cin >> b >> c;
        ans -= cnt[b]*b;
        ans += cnt[b]*c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << ans << endl;
    }
}

signed main(){

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

    int t = 1;

    start = clock(); 

    cout << fixed << setprecision(20);
    
  
  
   
    // cin >> t;
     
    for(int i = 1; i <= t; ++i){
        solve(i);
    }
    //cerr << time(start);
    return 0;
}

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

struct edge{int to,cost;};
typedef pair<ll,int> P;

vector<vector<edge> > G(100000);
vector<ll> d(100000);

vector<vector<edge> > G2(100000);
vector<ll> d2(100000);

vector<ll> d3(100000);

int n,m,s,t;

ll INF=1000000000000000000;

void dijkstra(int s,vector<vector<edge> >& G,vector<ll>& d){
  priority_queue<P,vector<P>,greater<P> > que;
  fill(d.begin(),d.begin()+n,INF);
  d[s]=0;
  que.push(P(0,s));
  while(!que.empty()){
    P p=que.top();que.pop();
    int v = p.second;
    if(d[v]<p.first) continue;
    for(int i=0;i<G[v].size();i++){
      edge e = G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        que.push(P(d[e.to],e.to));
      }
    }
  }
}

int main(){
  cin >> n >> m >> s >> t;
  s--;
  t--;
  for(int i=0;i<m;i++){
    int u,v,a,b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    edge e = {v,a};
    G[u].push_back(e);
    e.cost=b;
    G2[u].push_back(e);
    e.to=u;
    e.cost=a;
    G[v].push_back(e);
    e.cost=b;
    G2[v].push_back(e);
  }
  dijkstra(s,G,d);
  dijkstra(t,G2,d2);

  for(int i=0;i<n;i++){
    d3.at(i)=d.at(i)+d2.at(i);
  }
  vector<ll> d4(100000);
  d4.at(0)=d3.at(n-1);
  ll mini;
  for(int i=1;i<n;i++){
    mini = d4.at(i-1);
    if(d3.at(n-1-i)<mini){
      mini=d3.at(n-1-i);
    }
    d4.at(i)=mini;
  }
  for(int i=0;i<n;i++){
    cout << 1000000000000000-d4.at(n-i-1) << endl;
  }
}

Measured memory_bytes: 17092
import math

n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

sum1 = 0
sum2 = 0
sum3 = 0
inf = 0
for i in range(n):
    tmp = abs(x[i] - y[i])
    sum1 += tmp
    sum2 += tmp ** 2
    sum3 += tmp ** 3
    inf = max(inf, tmp)
print("{:.6f}".format(sum1))
print("{:.6f}".format(sum2 ** (1 / 2)))
print("{:.6f}".format(sum3 ** (1 / 3)))
print("{:.6f}".format(inf))



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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c;
    if(a > c){
        d = a;
        a = c;
        c = d;
    }
    if(a > b){
        d = a;
        a = b;
        b = d;
    }
    if(b > c){
        d = b;
        b = c;
        c = d;
    }
    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 1168
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var S = cin.ReadLine;
			Console.WriteLine(S[1]=='B'?"ARC":"ABC");
		}
	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}

Measured memory_bytes: 26168
#include <iostream>
#include <string>
#include <math.h>
    using namespace std;

    int main() {
        int K,X,M;
        cin>>K>>X;
        for (int i = 0; i <(K*2)-1 ; ++i) {
            M=X-(K-1)+i;
            cout<<M<<" ";
        }
        return 0; }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define mod 1000000007
#define x first
#define y second
#define codec ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef vector<int> vi;
typedef vector<long long int> vl;
#define deb cout<<"Heelo"<<endl;
typedef pair<int, int> pi;
int main()
{
    int n;
    cin>>n;
    int  a[n][2];
    rep(i,0,n){
        cin>>a[i][0]>>a[i][1];
    }
    rep(i,2,n){
        if(a[i][1]==a[i][0] && a[i-1][1]==a[i-1][0] && a[i-2][0]==a[i-2][1]) {
            cout<<"Yes";
            goto label;        }
    }
    cout<<"No";label:;


}

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

int main(){
  int n;
  cin >>n;
  double a[n];
  rep(i,n) cin >>a[i];
  double sum = 0;
  rep(i,n){
    sum += 1/a[i];
  }
  double ans = 1/sum;
  cout << fixed << setprecision(9) << ans << endl;
  return 0;
}

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

int main() {
  string O,E;

  cin >> O >> E;
  for(int i=0;i<O.size();++i){
    cout << O.at(i);
    if(i < E.size()) cout << E.at(i);
  }
  cout << endl;
  return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int A,B,Q;
  cin>>A>>B>>Q;
  vector<ll>s(A),t(B),x(Q);
  for(int i=0;i<A;i++)cin>>s[i];
  for(int i=0;i<B;i++)cin>>t[i];
  for(int i=0;i<Q;i++)cin>>x[i];
  sort(rng(s));
  sort(rng(t));
  for(int i=0;i<Q;i++){
    auto sp=lower_bound(rng(s),x[i]);
    auto tp=lower_bound(rng(t),x[i]);
    ll ans=LONG_MAX;
    //sr->t
    if(sp<s.end()){
      auto p=lower_bound(rng(t),*sp);
      ll D=abs(x[i]-*sp);
      if(p<t.end())ans=min(ans,abs(*sp-*p)+D);
      if(p>t.begin())ans=min(ans,abs(*(p-1)-*sp)+D);
    }
    //sl->t
    if(sp>s.begin()){
      sp--;
      auto p=lower_bound(rng(t),*sp);
      ll D=abs(x[i]-*sp);
      if(p<t.end())ans=min(ans,abs(*sp-*p)+D);
      if(p>t.begin())ans=min(ans,abs(*(p-1)-*sp)+D);
    }
    //tr->s
    if(tp<t.end()){
      auto p=lower_bound(rng(s),*tp);
      ll D=abs(x[i]-*tp);
      if(p<s.end())ans=min(ans,abs(*tp-*p)+D);
      if(p>s.begin())ans=min(ans,abs(*(p-1)-*tp)+D);
    }
    //tl->s
    if(tp>t.begin()){
      tp--;
      auto p=lower_bound(rng(s),*tp);
      ll D=abs(x[i]-*tp);
      if(p<s.end())ans=min(ans,abs(*tp-*p)+D);
      if(p>s.begin())ans=min(ans,abs(*(p-1)-*tp)+D);
    }
    cout<<ans<<endl;
  }
  return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl

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


int main() {
    ll n;
    cin>>n;
	ll a[n],b[n],c[n];
	for(ll i=0;i<n;i++)
	{
	    cin>>a[i]>>b[i]>>c[i];
	}
	ll dp[n+1][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(ll i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
        dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
        dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
    }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}

Measured memory_bytes: 4992
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        int maxabs = -1;
        int maxabs_idx = 0;
        for (int i = 0; i < n; i++) {
            if (Math.abs(array[i]) > maxabs) {
                maxabs = Math.abs(array[i]);
                maxabs_idx = i;
            }
        }
        
        boolean isPositive = false;
        if (array[maxabs_idx] > 0) {
            isPositive = true;
        }
        
        List<String> ans = new ArrayList<String>();
        for (int i = 0; i < n; i++) {
            int x = maxabs_idx+1;
            int y = i+1;
            
            ans.add(x + " " + y);
        }
        
        if (isPositive) {
            ans.add((maxabs_idx+1) + " " + (0+1));
            for (int i = 0; i < n-1; i++) {
                int x = i+1;
                int y = (i+1)+1;
                
                ans.add(x + " " + y);
            }
        } else {
            ans.add((maxabs_idx+1) + " " + (n-1+1));
            for (int i = n-1; i > 0; i--) {
                int x = i+1;
                int y = (i-1)+1;
                
                ans.add(x + " " + y);
            }
        }
        
        System.out.println(ans.size());
        for (String a : ans) {
            System.out.println(a);
        }
    }
}


Measured memory_bytes: 39220
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi>
#define pb push_back
#define vs vector<string>
#define all(x) x.begin(),x.end()
#define mii map<int,int>
const int inf=0x3f3f3f3f3f3f3f3f;
void print(vi &v){
    for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
    cout<<endl;
}
int power(int a,int b){
    int res = 1;
    while(b!=0){
        if(b&1){
            res *= a; 
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
int x,y,a,b,c;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t,i;
    t = 1;
    while(t--){
        cin>>x>>y>>a>>b>>c;
        vi red(a),green(b),color(c);
        priority_queue< pii,vpii,greater< pii > >pq;
        for(i=0;i<a;i++)cin>>red[i];
        for(i=0;i<b;i++)cin>>green[i];
        for(i=0;i<c;i++)cin>>color[i];
        sort(red.rbegin(),red.rend());
        sort(green.rbegin(),green.rend());
        sort(all(color));
        for(i=0;i<x;i++){
        	pq.push({red[i],0});
        }
        for(i=0;i<y;i++){
        	pq.push({green[i],1});
        }
        for(i=0;i<c;i++){
        	pii p = pq.top();
        	if(p.ff<color[i]){
        		pq.pop();
        		pq.push({color[i],p.ss});
        	}
        }
        int sum = 0;
        while(!pq.empty()){
        	sum+=pq.top().ff;
        	pq.pop();
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 8816
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
	vector<int> taro;
	vector<int> hanako;
	int num[201] = {0};
	int n;
	int i, j;
	int b = 0;
	int nyuryoku;
	int nowcard;
	int tnokori;
	int hnokori;
	bool flag;
	int tarosco = 0;
	int hanasco = 0;
	
	cin >> n;
	while (n != 0) {
	tnokori = n;
	hnokori = n;
	
	for (i = 1; i <= n; i++){
		cin >> nyuryoku;
		taro.push_back(nyuryoku);
		num[nyuryoku]++;
	}
	
	for (j = 1; j <= n * 2; j++){
		if (b == n) break;
		
		if (num[j] == 0){
			hanako.push_back(j);
			b++;
		}
	}
	
	sort(taro.begin(),taro.end());
	
	nowcard = taro[0];
	tnokori--;
	taro[0] = -100;
	
	while (1){
		for (i = 0; i < n; i++){
			if (nowcard < hanako[i]){
				nowcard = hanako[i];
				hanako[i] = -100;
				flag = true;
				hnokori--;
				break;
			}
			else {
				flag = false;
			}
		}
		if (hnokori == 0)break;
		if (flag == false){
			nowcard = 0;
		}
		
		for (i = 0; i < n; i++){
			if (nowcard < taro[i]){
				nowcard = taro[i];
				taro[i] = -100;
				flag = true;
				tnokori--;
				break;
			}
			else {
				flag = false;
			}
		}
		if (tnokori == 0)break;
		if (flag == false){
			nowcard = 0;
		}
	}
	
	for (i = 0; i < n; i++){
		if (taro[i] != -100){
			hanasco++;
		}
		if (hanako[i] != -100){
			tarosco++;
		}
	}
	
	cout << tarosco << "\n";
	
	cout << hanasco << "\n";

    cin >> n;

    tarosco = hanasco = 0;
    taro.clear();
    hanako.clear();

    for (int i = 0; i < 201; i++) {
        num[i] = 0;
    }
    i = j = b = 0;
    }
	return (0);
}




Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {

	private static final String YES = "Yes";

	private static final String NO = "No";

	public static void main(String[] args) {

		int[] scanResult = scan();

		if (calc(scanResult)) {
			System.out.println(YES);
		} else {
			System.out.println(NO);
		}
	}

	private static int[] scan() {

		Scanner sc = new Scanner(System.in);
		int[] arr = new int[2];
		arr[0] = sc.nextInt();
		arr[1] = sc.nextInt();
		sc.close();
		return arr;
	}

	private static boolean calc(int[] arr) {

		int yen = arr[0];
		int oneNum = arr[1];

		return (yen % 500) <= oneNum;
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

long long ans=0;
int tot=0,h[100005];
int n,m,x,y,S,T,k[100005],siz[100005];
int s[100005],top;
bool odd;
struct Edge{
	int x,next;
}e[200005];

inline void add_edge(int x,int y){
	e[++tot].x=y;
	e[tot].next=h[x],h[x]=tot;
}

void dfs1(int x,int fa){
	for(int i=h[x];i;i=e[i].next){
		if(e[i].x==fa)continue;
		if(siz[e[i].x]){
			if(siz[x]==siz[e[i].x])odd=true;
			S=x,T=e[i].x;
		}else{
			siz[e[i].x]=-siz[x];
			dfs1(e[i].x,x);
		}
	}
}

void dfs2(int x,int fa){
	for(int i=h[x];i;i=e[i].next){
		if(e[i].x==fa||(x==S&&e[i].x==T)||(x==T&&e[i].x==S))continue;
		dfs2(e[i].x,x);
		siz[x]+=siz[e[i].x];
		k[x]+=k[e[i].x];
	}
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		add_edge(x,y);
		add_edge(y,x);
	}
	siz[1]=1,dfs1(1,0);
	int sum=0;
	for(int i=1;i<=n;i++)sum+=siz[i];
	if(m==n-1){
		if(sum)return printf("-1"),0;
	}else{
		if(odd){
			if(sum&1)return printf("-1"),0;
			ans+=abs(sum>>1);
			siz[S]-=sum>>1,siz[T]-=sum>>1;
		}else{
			if(sum)return printf("-1"),0;
			else k[S]=1,k[T]=-1;
		}
	}
	dfs2(1,0);
	for(int i=1;i<=n;i++){
		if(k[i])s[++top]=k[i]*siz[i];
		else ans+=abs(siz[i]);
	}
	s[++top]=0;
	sort(s+1,s+top+1);
	int mid=s[top+1>>1];
	for(int i=1;i<=top;i++)ans+=abs(s[i]-mid);
	printf("%lld",ans);
}

Measured memory_bytes: 8064
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long
const int dx[4] = { 1,-1,0,0 };
const int dy[4] = { 0,0,1,-1 };
bool OOA(int x,int y,int H,int W){return (0<=x&&x<H)&&(0<=y&&y<W);}

struct Graph{
	int V,E;
	vector<int>cost;
	vector<bool>vzt;
	vector<vector<int>>adj;
	void init(int dflt){//dflt!=0
		adj=vector<vector<int>>(V+1);
		cost=vector<int>(V+1,dflt);
		vzt=vector<bool>(V+1,false);
	}

	void bfs(int s, int scost){
		queue<pair<int,int>>q;
		q.push({scost,s});
		vzt[s]=true;
		cost[s]=0;
		while(!q.empty()){
			auto top=q.front();
			q.pop();
			int cst=top.first,now=top.second;
			for(int i=0;i<adj[now].size();i++){
				if(!vzt[adj[now][i]]){
					vzt[adj[now][i]]=true;
					cost[adj[now][i]]=cost[now]+1;
					q.push({cost[adj[now][i]],adj[now][i]});
				}
			}
		}
	}
};

int n;
Graph G;

int main() {
	cin>>n;
	G.V=n;
	G.init(-1);
	for(int i=0;i<n;i++){
		int u,k;
		cin>>u>>k;
		for(int j=0;j<k;j++){
			int v;
			cin>>v;
			G.adj[u].push_back(v);
		}
	}
	G.bfs(1,0);
	for(int i=1;i<=G.V;i++)cout<<i<<" "<<G.cost[i]<<endl;
	return 0;
}


Measured memory_bytes: 3176
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

double PI = acos((double)-1);
const ld eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
//const ll mod = 1e9 + 9;
const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

void solve() {
	int n, l;
	cin >> n >> l;
	vector<int> a(n);
	for (int& i : a) cin >> i;
	for (int i = 1; i < n; i++) {
		if (a[i] + a[i - 1] >= l) {
			cout << "Possible\n";
			for (int j = 1; j < i; j++)
				cout << j << endl;
			for (int j = n - 1; j > i; j--)
				cout << j << endl;
			cout << i << endl;
			return;
		}
	}
	cout << "Impossible\n";
	return;
}

Measured memory_bytes: 1280