akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n,k; cin >> n >> k;
  vi v(n); rep(i, n) cin >> v[i];
  int r = min(n,k);

  int ans = 0;
  for (int a = 0; a <= r; a++) for (int b = 0; a + b <= r; b++) {
    priority_queue<int, vi, greater<int>> pq;
    rep(i, a) pq.push(v[i]);
    rep(i, b) pq.push(v[n - 1 - i]);

    rep(i, k-a-b){
      if(pq.size() > 0 && pq.top() < 0) pq.pop();
    }
    int sum = 0;
    while(pq.size() > 0){
      sum += pq.top();
      pq.pop();
    }
    chmax(ans, sum);
  }
  std::cout << ans << '\n';
}


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

enum class MovePos
{
	MoveLeftToCenter,
	MoveRightToCenter,
	MoveCenterToLeft,
	MoveCenterToRight
};

class Tray
{
public:
	stack<int> t[3];
	inline bool isCompleted()
	{
		if (t[0].empty() && t[1].empty()) return true;
		if (t[1].empty() && t[2].empty()) return true;
		return false;
	}
	inline bool canMoveLeftToCenter()
	{
		if (t[0].empty()) return false;
		if (t[1].empty()) return true;
		if (t[0].top() > t[1].top()) return true;
		return false;
	}
	inline bool canMoveRightToCenter()
	{
		if (t[2].empty()) return false;
		if (t[1].empty()) return true;
		if (t[2].top() > t[1].top()) return true;
		return false;
	}
	inline bool canMoveCenterToLeft()
	{
		if (t[1].empty()) return false;
		if (t[0].empty()) return true;
		if (t[1].top() > t[0].top()) return true;
		return false;
	}
	inline bool canMoveCenterToRight()
	{
		if (t[1].empty()) return false;
		if (t[2].empty()) return true;
		if (t[1].top() > t[2].top()) return true;
		return false;
	}
	inline void MoveLeftToCenter()
	{
		int top = t[0].top();
		t[0].pop();
		t[1].push(top);
	}
	inline void MoveRightToCenter()
	{
		int top = t[2].top();
		t[2].pop();
		t[1].push(top);
	}
	inline void MoveCenterToLeft()
	{
		int top = t[1].top();
		t[1].pop();
		t[0].push(top);
	}
	inline void MoveCenterToRight()
	{
		int top = t[1].top();
		t[1].pop();
		t[2].push(top);
	}
};

int calc(Tray t, MovePos previousMovePos, int m)
{
	for (int i = 1; i <= m; i++)
	{
		if (t.isCompleted()) return i;
		if (t.canMoveLeftToCenter() && previousMovePos != MovePos::MoveCenterToLeft)
		{
			t.MoveLeftToCenter();
			previousMovePos = MovePos::MoveLeftToCenter;
		}
		else if (t.canMoveRightToCenter() && previousMovePos != MovePos::MoveCenterToRight)
		{
			t.MoveRightToCenter();
			previousMovePos = MovePos::MoveRightToCenter;
		}
		else if (t.canMoveCenterToLeft() && previousMovePos != MovePos::MoveLeftToCenter)
		{
			t.MoveCenterToLeft();
			previousMovePos = MovePos::MoveCenterToLeft;
		}
		else if (t.canMoveCenterToRight() && previousMovePos != MovePos::MoveRightToCenter)
		{
			t.MoveCenterToRight();
			previousMovePos = MovePos::MoveCenterToRight;
		}
		if (i > 1251598) return 99999999;
	}
	return 99999999;
}

int main()
{
	int n, m;
	while (cin >> n >> m, n + m)
	{
		Tray tray;

		for (int i = 0; i < 3; i++)
		{
			int a, b;
			cin >> a;
			for (int j = 0; j < a; j++)
			{
				cin >> b;
				tray.t[i].push(b);
			}
		}

		int ans = 99999999;
		if (tray.canMoveCenterToLeft())
		{
			Tray t = tray;
			t.MoveCenterToLeft();
			ans = min(ans, calc(t, MovePos::MoveCenterToLeft, m));
		}
		if (tray.canMoveCenterToRight())
		{
			Tray t = tray;
			t.MoveCenterToRight();
			ans = min(ans, calc(t, MovePos::MoveCenterToRight, m));
		}
		if (tray.canMoveLeftToCenter())
		{
			Tray t = tray;
			t.MoveLeftToCenter();
			ans = min(ans, calc(t, MovePos::MoveLeftToCenter, m));
		}
		if (tray.canMoveRightToCenter())
		{
			Tray t = tray;
			t.MoveRightToCenter();
			ans = min(ans, calc(t, MovePos::MoveRightToCenter, m));
		}
		if (ans == 99999999) cout << -1 << endl;
		else cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3108
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;


class Program
{
    static void Main()
    {
        string S = ReadStr();
        if (S == "AAA" || S == "BBB") WriteLine("No");
        else WriteLine("Yes");

        ReadLine();
    }





    #region Reader
    static string ReadStr()
    {
        return Console.ReadLine();
    }
    static string[] ReadStrN()
    {
        return Console.ReadLine().Split(' ');
    }
    static int ReadInt()
    {
        return Convert.ToInt32(Console.ReadLine());
    }
    static int[] ReadIntN()
    {
        return Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    }
    static long ReadLong()
    {
        return Convert.ToInt64(Console.ReadLine());
    }
    static long[] ReadLongN()
    {
        return Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    }
    static long[,] ReadLongMatrix(int r, int c)
    {
        var mat = new long[r, c];
        for (int i = 0; i < r; ++i)
        {
            var x = ReadLongN();
            for (int j = 0; j < c; ++j)
            {
                mat[i, j] = x[j];
            }
        }
        return mat;
    }
    static Tuple<string, string>[] ReadTupleStr(int n)
    {
        List<Tuple<string, string>> list = new List<Tuple<string, string>>();
        for (int i = 0; i < n; ++i)
        {
            var ab = ReadStrN();
            list.Add(new Tuple<string, string>(ab[0], ab[1]));
        }
        return list.ToArray();
    }
    static Tuple<long, long>[] ReadTupleLong(int n)
    {
        List<Tuple<long, long>> list = new List<Tuple<long, long>>();
        for (int i = 0; i < n; ++i)
        {
            var ab = ReadLongN();
            list.Add(new Tuple<long, long>(ab[0], ab[1]));
        }
        return list.ToArray();
    }
    static Tuple<int, int>[] ReadTupleInt(int n)
    {
        List<Tuple<int, int>> list = new List<Tuple<int, int>>();
        for (int i = 0; i < n; ++i)
        {
            var ab = ReadIntN();
            list.Add(new Tuple<int, int>(ab[0], ab[1]));
        }
        return list.ToArray();
    }
    static Tuple<double, double>[] ReadTupleDouble(int n)
    {
        List<Tuple<double, double>> list = new List<Tuple<double, double>>();
        for (int i = 0; i < n; ++i)
        {
            var ab = ReadLongN();
            list.Add(new Tuple<double, double>(ab[0], ab[1]));
        }
        return list.ToArray();
    }
    static Dictionary<int, HashSet<int>> ReadAdjacencyList(int N, int M)
    {
        Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
        for (int i = 0; i <= N; ++i)
        {
            dict.Add(i, new HashSet<int>());
        }
        for (int i = 0; i < M; ++i)
        {
            var ab = ReadIntN();
            dict[ab[0]].Add(ab[1]);
            dict[ab[1]].Add(ab[0]);
        }
        return dict;
    }
    #endregion
}


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

int main() {
    string s;
    cin >> s;
    string tmp;
    int ans = 0;
    int n = s.length();
    rep(i,n){
       if(tmp.length() > 1){
           tmp = s[i];
           ans++;
       }
       else if(tmp[0] == s[i]){
           i++;
           if(i >= n)break;
           tmp += s[i];
           ans++;
       }
       else{
           tmp = s[i];
           ans++;
       }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
//ALDS1_3_B_19140837_Ojima_Yukiya.cpp
//
//提出日 2020/07/08 wednesday
//
//プログラミング基礎演習2 CS 第9回課題 ALDS1_3_B
//
//学修番号 19140837　小島優希也

#include <iostream>
#include <vector>
#define N 100000
using namespace std;

class process {
public:
    string name;
    int time;
};

class my_queue {
private:
    process p[N];
    int head;
    int tail;
public:
    my_queue();
    void enqueue(string s, int value);
    process* dequeue();
    int get_head();
    int get_tail();
    bool queue_empty();
} ;

my_queue::my_queue() {
    head = 0;
    tail = 0;
}

void my_queue::enqueue(string s, int value) {
    if (head == tail + 1 || (head == 0 && tail == N - 1)) {
        cout << "オーバーフロー" << endl;
    } else {
        p[tail].name = s;
        p[tail].time = value;
        if (tail == N - 1) {
            tail = 0;
        }
        else {
            tail++;
        }
    }
}

process* my_queue::dequeue() {
    if (queue_empty()) {
        cout << "アンダーフロー" << endl;
        return NULL;
    }
    else {
        process* x = &p[head];
        if (head == N - 1) {
            head = 0;
        }
        else {
            head++;
        }
        return x;
    }
}

int my_queue::get_head() {
    return head;
}

int my_queue::get_tail() {
    return tail;
}

bool my_queue::queue_empty() {
    if (head == tail) {
        return true;
    }
    else {
        return false;
    }
}

int main(void) {
    int n, q;
    cin >> n >> q;
    string name;
    int time;
    my_queue mq0;
    for (int i = 0; i < n; i++) {
        cin >> name >> time;
        mq0.enqueue(name, time);
    }
    process* p;
    int jikoku = 0;
    my_queue mq1;
    while (true) {
        if (mq0.queue_empty()) {
            break;
        }
        else {
            p = mq0.dequeue();
            if ((p -> time) > q) {
                (p -> time) -= q;
                jikoku += q;
                mq0.enqueue(p -> name, p -> time);
            }
            else {
                jikoku += (p -> time);
                mq1.enqueue(p -> name, jikoku);
            }
        }
    }
    while (true) {
        if (mq1.queue_empty()) {
            break;
        }
        else {
            p = mq1.dequeue();
            cout << p -> name << " " << p -> time << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 8700
import Data.List

main :: IO ()
main = do
    _ <- getLine
    hw <- lines <$> getContents :: IO [String]
    let hw' = transpose . transpose . transpose
            . removeLn  . transpose . removeLn
            $ hw
    mapM_ putStrLn hw'
  where
    alldot   = all (=='.')
    removeLn = filter (not . alldot)


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

using namespace std;

int main()
{
    int s1 = 0, s2 = 0, i;
    string s;
    cin >> s;
    for(i=0;i<s.size();i++)
    {
        if(i%2 == 0 && s[i] == '0' || i%2 == 1 && s[i]== '1') s2++;
        else s1++;
    }
    cout << min(s1,s2);
    return 0;
}


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

int main() 
{
	int a[6], sum = 0, miin = 10;
	for (int i = 1; i <= 5; i++)
	{
		cin >> a[i];
		if (a[i] % 10 == 0) sum += a[i];
		else if (miin > a[i] % 10) miin = a[i] % 10;
	}
	
	for (int i = 1; i <= 5; i++)
	{
		if (a[i] % 10 == 0) continue;
		else sum += a[i] + (10 - (a[i] % 10));
	}
	
	cout << sum - 10 + miin;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int a = in.nextInt();
			int b = in.nextInt();
			out.println(a * b);
		}
	}

	static boolean permutation_2(String s, String t) {
		if (s.length() != t.length()) {
			return false;
		}

		int[] letters = new int[256];

		char[] s_array = s.toCharArray();
		for (char c : s_array) {
			letters[c]++;
		}

		for (int i = 0; i < t.length(); i++) {
			int c = (int) t.charAt(i);
			if (--letters[c] < 0) {
				return false;
			}
		}
		return true;
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


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

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    string s; cin >> s;
    sort(all(s));
    if(s == "abc") cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  long long x; cin >> x;
  long long ans = 0;
  long long cur = 100;
  while(cur < x) {
    cur += (cur - (cur % 100)) / 100;
    ++ans;
  }
  cout << ans << endl;
}


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

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

vector<bool> IsPrime;
vector<int> Prime;
void sieve(int max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(int i=2; i<=max; ++i) // 0からmaxまで調べる
        if(IsPrime[i]) // iが素数ならば
        {
            for(int j=2; i*j<=max; ++j) // (max以下の)iの倍数は
            IsPrime[i*j] = false;      // 素数ではない
            Prime.emplace_back(i);
        }
}

int N;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
}

int solve(){
    sieve(55555);
    vector<int> ans;
    for (int k = 0; k < Prime.size(); k++)
    {
        if(Prime[k]%5==1) ans.push_back(Prime[k]);
    }
    for(int i=0;i<N;i++) cout << ans[i] << " ";
    cout << "\n";
    
    return 0;
}   

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[5];

int main(){

	scanf("%s",buf);

	int A = 10*(buf[0]-'0')+(buf[1]-'0');
	int B = 10*(buf[2]-'0')+(buf[3]-'0');

	if(A >= 1 && A <= 12 && B >= 1 && B <= 12){

		printf("AMBIGUOUS\n");
	}else if(A >= 1 && A <= 12){

		printf("MMYY\n");

	}else if(B >= 1 && B <= 12){

		printf("YYMM\n");
	}else{

		printf("NA\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define MOD 1000000007
#define INT long long
using namespace std;
int n, p, d[10001], v;
int main()
{
    for(int i = 1 ; i <= 10000 ; i++ )
        d[i] = d[i-1] + i;
    cin>>n;
    for(p = 0 ; d[p] < n ; p++ );
    v = d[p]-n;
    for(int i = 1 ; i <= p ; i++ )
        if( i != v ) cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 384
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto L = RDR.ARR;
	L.sort();
	long ans;
	foreach (i; 0..N)
	{
		ans += L[i*2];
	}
	
	writeln(ans);
	stdout.flush();
	debug readln();
}


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

void printvec(vector<int>& a, int n){
    for(int i=0; i<n; i++){
        cout << a[i];
        if(i!=n-1){
            cout << " ";
        }
    }
    cout << endl;
}

int insertionSort(vector<int>& a, int n, int g){
    int v, j, cnt = 0;
    for(int i=g; i<n; i++){
        v = a[i];
        j = i - g;
        while(j>=0 && a[j]>v){
            a[j+g] = a[j];
            j -= g;
            cnt++;
        }
        a[j+g] = v;
    }
    return cnt;
}

void shellSort(vector<int>& a, int n){
    int cntsum = 0;
    vector<int> g;
    int tmpn = n/2 + 1;
    while(tmpn>0){
        g.push_back(tmpn);
        tmpn = tmpn/2;
    }
    int m = g.size();
    cout << m << endl;
    printvec(g, m);

    for(int i=0; i<m; i++){
        cntsum += insertionSort(a, n, g[i]);
    }
    cout << cntsum << endl;
    
}

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

    shellSort(a, n);
    for(int i=0; i<n; i++){
        cout << a[i] << endl;
    }
}


Measured memory_bytes: 6756
N,K = map(int,input().split())
R,S,P = map(int,input().split())

X  = input()

res = 0
command = []
x  = 0
for i,t in enumerate(X):

    if t == "r":
        res += P
        x = P
        command.append("p")

    if t == "s":
        res += R
        x = R
        command.append("r")

    if t == "p":
        res += S
        x = S
        command.append("s")
    
    if i >= K and command[i] == command[i-K]:
        res -= x
        command.pop()
        command.append("")
    

print(res)

Measured memory_bytes: 4212
#include <stdio.h>

int main()
{
	int N, R;
	scanf("%d %d", &N, &R);
	if(N<=10){
		printf("%d\n", R+(100*(10-N)));
	}
	else if(N>=10){
		printf("%d\n", R);
	}
	return 0;
}

Measured memory_bytes: 2132
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var a = long.Parse(inputs[0]);
            var p = long.Parse(inputs[1]);
            p += a * 3;
            var result = p / 2;
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27288
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  stack <int>aun;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    if(s=="A") aun.push(1);
    else if(s=="Un" && aun.empty()){
      aun.push(2);
    }
    else if(aun.top()==2) aun.push(2);
    else aun.pop();
  }
  if(aun.empty()) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}



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

int main(){
  int five,seven;
  five = seven = 0;
  int n;
  for(int i=0;i<3;i++){
    cin >> n;
    if(n==5){
      five++;
    }else if(n==7){
      seven++;
    }
  }

  if(five==2&&seven==1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }




  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long int n; cin >> n;
	string s; cin >> s;
	long int wcnt[300005];
	long int ecnt[300005];
	long int cnt = 0;
	for(int i=0;i<s.size();i++){
		wcnt[i] = cnt;
		if(s[i]=='W'){
			cnt++;
			//cout << cnt << endl;
		}

	}
	cnt = 0;
	for(long int i=s.size()-1;i>=0;i--){
		ecnt[i] = cnt;
		if(s[i]=='E'){
			cnt++;
		}
	}
	long int ans = n;
	for(int i=0;i<n;i++){
		long int r = wcnt[i] + ecnt[i];
		//cout << r << endl;
		ans = min(r, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5380
# coding: utf-8
# Your code here!
z = int(input())
def s(x):
  y = str(x)
  a = 0
  for i in y:
    a += int(i)
  return (x/a,x)

ls = []
for i in range(1,10):
  for j in range(20):
    for k in range(10):
      for l in range(10):
        x = i*10**j+k*10**(j-1)+l*10**(j-2)-1
        x = int(x)
        if x>0:
          ls.append(s(x))
ls.sort()
ans = [0]
for i in ls:
  if ans[-1] < i[1]:
    ans.append(i[1])
print(*ans[1:z+1])

Measured memory_bytes: 5416
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int n = (X+Y)/3;
		int x = X-n;
		int y = Y-n;
		if((X+Y)%3 != 0 || x<0 || y<0) {
			System.out.println(0);
			sc.close();
			return;
		}
		Combination com = new Combination(n);
		ModInt ans = com.combi(n, x);
		System.out.println(ans.x);
		sc.close();
	}
}

class ModInt {

	 final static int MOD = 1000000007;
	 public long x;
	 ModInt(long x){
		 this.x = (x % MOD + MOD) % MOD;
	 }
	 public ModInt plus(final ModInt a) {
		 ModInt res = new ModInt(this.x);
		 if((res.x += a.x) >= MOD) {
			 res.x -= MOD;
		 }
		 return res;
	 }
	 public ModInt minus(final ModInt a) {
		 ModInt res = new ModInt(this.x);
		 if((res.x += MOD-a.x) >= MOD) {
			 res.x -= MOD;
		 }
		 return res;
	 }
	 public ModInt mul(final ModInt a) {
		 ModInt res = new ModInt(this.x);
		 res.x *= a.x;
		 res.x %= MOD;
		 return res;
	 }
	 public ModInt pow(long t) {
		 if(t == 0) {
			 return new ModInt(1);
		 }
		 ModInt a = pow(t>>1);
		 a = a.mul(a);
		 if((t&1)==1) {
			 a = a.mul(this);
		 }
		 return a;
	 }
	 public ModInt inv() {
		 ModInt res = pow(MOD-2);
		 return res;
	 }
	 public ModInt div(ModInt a) {
		 ModInt inv = a.inv();
		 return mul(inv);
	 }

}
class Combination {
	ModInt[] fact, ifact;
	public Combination(int n){
		assert(n < ModInt.MOD);
		fact = new ModInt[n+1];
		ifact = new ModInt[n+1];
		for(int i=0; i<n+1; i++) {
			fact[i]=new ModInt(0);
			ifact[i]=new ModInt(0);
		}
		fact[0]=new ModInt(1);
		for(int i=1; i<=n; i++) {
			fact[i] = fact[i-1].mul(new ModInt(i));
		}
		ifact[n]=fact[n].inv();
		for(int i=n; i>=1; i--) {
			ifact[i-1] = ifact[i].mul(new ModInt(i));
		}
	}
	public ModInt combi(int n, int k) {
		if(k<0||k>n) return new ModInt(0);
		return fact[n].mul(ifact[k]).mul(ifact[n-k]);
	}
}


Measured memory_bytes: 124112
#include<bits/stdc++.h>
using namespace std;
long long dp[323456];
long long k[323456], b[323456], vin, h[234567];
void dam(long long K, long long B){
    if(vin == 0) {k[1] = K, b[1] = B, vin++; return;}
    while(vin > 1){
        long long k1 = k[vin], b1 = b[vin];
        long long k2 = k[vin - 1], b2 = b[vin - 1];
        if((b2 - B) * (K - k1) > (b1 - B) *(K - k2)) vin --;
        else break;
    }
    vin++;
    k[vin] = K;
    b[vin] = B;
    
}
long long bam (long long X){
    long long lo = 1, hi = vin;
    while(lo  < hi){
        long long mid = (lo + hi + 1) / 2;
        if(k[mid] * X + b[mid] < k[mid - 1] * X + b[mid - 1])
            lo = mid;
        else hi = mid - 1;
    }
    return k[lo] * X + b[lo];

}
int main(){
    long long n, C;
    cin >> n >> C;
    for(long long i = 1;i <= n; i++)
        cin >> h[i];
    dp[1] = 0;
    dam(-2*h[1], h[1] * h[1]);
    for(long long i = 2; i <= n; i++){
        dp[i] = bam(h[i]) + h[i] * h[i] + C;
        dam(-2*h[i], h[i]*h[i] + dp[i]);
    }
    cout << dp[n] << endl;
    //(h[i]*h[i]) - 2h[i]h[j] + h[j]h[j]

}


Measured memory_bytes: 8448
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let N = get!(usize);
    let (A, B) = get!(usize, usize);
    let P = get!(Vec<usize>);

    let ans = vec![
        P.iter().filter(|&p| p <= &A).count(),
        P.iter().filter(|&p| &A < p && p <= &B).count(),
        P.iter().filter(|&p| p > &B).count()
    ].into_iter().min().unwrap();

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


Measured memory_bytes: 4352
#include <stdio.h>

int main(){
int tmp;
int a,b,c;
scanf("%d %d %d", &a, &b, &c);

while(!(a <= b && b <= c)){
if (a > b){
tmp  = b;
b = a;
a =tmp;
}
if (b > c){
tmp  = c;
c = b;
b = tmp;
}

}

printf("%d %d %d\n", a, b, c);
}


Measured memory_bytes: 2028
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <typename T>
struct edge {
    int from, to;
    T cost;

    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const {return to;}
};

template <typename T>
vector<T> dijkstra(int s,vector<vector<edge<T>> > &G){
    size_t n=G.size();
    using P = pair<T, int>;
    vector<T> d(n, INF<T>);
    vector<int> b(n,-1);
    priority_queue<P,vector<P>,greater<> > Q;
    d[s]=0;
    Q.emplace(d[s],s);
    while(!Q.empty()){
        T cost;
        int i;
        tie(cost, i) = Q.top(); Q.pop();
        if(d[i] < cost) continue;
        for (auto &&e : G[i]) {
            auto cost2 = cost + e.cost;
            if(d[e.to] <= cost2) continue;
            d[e.to] = cost2;
            Q.emplace(d[e.to], e.to);
        }
    }
    return d;
}

int main() {
    int n, m;
    while(cin >> n >> m, n|m){
        vector<vector<edge<int>>> v(n);
        for (int i = 0; i < m; ++i) {
            int p, q;
            scanf("%d %d", &p, &q);
            v[p-1].emplace_back(q-1, 1);
            v[q-1].emplace_back(p-1, 1);
        }
        auto d = dijkstra(0, v);
        int ans = 0;
        for (int i = 1; i < n; ++i) {
            if(d[i] <= 2) ans++;
        }
        cout << ans << "\n";
    }
    return 0;

}



Measured memory_bytes: 3468
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
  string c;
  int n,k,r,s,p,ans=0,m;
  vector<int> a(3),b(3);
  cin>>n>>k;
  cin>>r>>s>>p;
  cin>>c;
  for(int i=0;i<k;i++){
    if(c[i]=='s') a={r,0,0};
    else if(c[i]=='p') a={0,s,0};
    else a={0,0,p};
    for(int j=1;j*k+i<n;j++){
      a={max(a[1],a[2]),max(a[0],a[2]),max(a[0],a[1])};
      m=j*k+i;
      if(c[m]=='s') a[0]+=r;
      else if(c[m]=='p') a[1]+=s;
      else a[2]+=p;
    }
    ans=ans+*max_element(a.begin(),a.end());
  }
  cout<<ans<<endl; 
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void) {
  char W[11], T[1001];
  int  C = 0, i;

  scanf("%s\n", W);
  for (i = 0; i < strlen(W); i++)
    W[i] = tolower((int)W[i]);

  while (1) {
    scanf("%s", T);
    if (!strcmp(T, "END_OF_TEXT")) break;
    for (i = 0; i < strlen(T); i++)
      T[i] = tolower((int)T[i]);
    if (!strcmp(T, W)) C++;
  }
  printf("%d\n", C);
  return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int h, w, lim;
  vector<vector<int>> s;
  Solver2(LL h, LL w, LL lim) : h(h), w(w), lim(lim), s(h, vector<int>(w)){};

  void solve() {
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        char c;
        cin >> c;
        s[i][j] = c - '0';
      }
    }

    int ans = INF;
    vector<int> b(h);
    for (int m = 0; m < (1 << (h - 1)); ++m) {
      for (int j = 1; j < h; ++j) {
        if (m & (1 << (j - 1))) {
          b[j] = b[j - 1] + 1;
        } else {
          b[j] = b[j - 1];
        }
      }
      vector<int> cnt(b.back() + 1);
      int tmp = 0;
      bool breakflag = false;
      for (int j = 0; j < w; ++j) {
        bool ok = true;
        for (int k = 0; k < h; ++k) {
          cnt[b[k]] += s[k][j];
          if (cnt[b[k]] > lim) {
            ok = false;
          }
        }
        DBG(cnt)
        if (!ok) {
          tmp++;
          fill(cnt.begin(), cnt.end(), 0);
          for (int k = 0; k < h; ++k) {
            cnt[b[k]] += s[k][j];
            if (cnt[b[k]] > lim) {
              breakflag = true;
              break;
            }
          }
          if (breakflag)
            break;
          DBG("aa", cnt)
        }
      }
      if (breakflag)
        continue;
      DBG(m, tmp)
      for (int j = 0; j < h - 1; ++j) {
        if (m & (1 << j))
          tmp++;
      }
      DBG(m, tmp)
      ans = min(ans, tmp);
    }
    cout << ans << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, m, p;
  std::cin >> n >> m >> p;

  Problem::Solver2 sol(n, m, p);
  sol.solve();
  return 0;
}


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

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

Node* root;
Node* NIL;

void insert(ll key){
	Node* x = root;
	Node* y = NIL;
	Node* z;
	z = (Node*)malloc(sizeof(Node));
	z->key = key;
	z->left = NIL;
	z->right = NIL;
	while(x != NIL){
		y = x;
		if(x->key < z->key){
			x = x->right;
		}else{
			x = x->left;
		}
	}
	z->parent = y;
	if(y == NIL){
		root = z;
	}else{
		if(y->key > z->key){
			y->left = z;
		}else{
			y->right = z;
		}
	}
}

void find(ll key, Node* x){
	if(x == NIL){
		cout << "no" << endl;
		return;
	}
	if(x->key == key){
		cout << "yes" <<endl;
		return;
	}
	if(x->key > key){
		find(key, x->left);
	}else{
		find(key, x->right);
	}
}

Node* find2(ll key, Node* x){
	if(x == NIL){
		return 0;
	}
	if(x->key == key){
		return x;
	}
	if(x->key > key){
		find2(key, x->left);
	}else{
		find2(key, x->right);
	}
}

Node* mini(Node* z){
	while(z->left != NIL){
		z = z->left;
	}
	return z;
}

Node* getsuccessor(Node* z){
	if(z->right != NIL){
		return mini(z->right);
	}else{
		Node* y = z->parent;
		while(y != NIL && z == y->right){
			z = y;
			y = y->parent;
		}
		return y;
	}
}

void delet(ll k){
	Node* z = find2(k, root);
	Node* x;
	Node* y;
	if(z->left == NIL || z->right == NIL){
		y = z;
		if(z->left != NIL){
			x = z->left;
		}else{
			x = z->right;
		}
	}else{
		y = getsuccessor(z);
		x = y->right;
	}
	if(x != NIL) x->parent = y->parent;
	if(y->parent == NIL){
		root = x;
	}else{
		if(y->parent->right == y){
			y->parent->right = x;
		}else if(y->parent->left == y){
			y->parent->left= x;
		}
	}
	if(y->key != z->key){
		z->key = y->key;
	}
	free(y);
}

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

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

int main(){
	int n;
	cin >>n;
	rep(i,n){
		string s;
		ll k;
		cin >> s;
		if(s[0] == 'i'){
			cin >> k;
			insert(k);
		}
		if(s[0] == 'p') {
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
		if(s[0] == 'f'){
			cin >> k;
			find(k, root);
		}
		if(s[0] == 'd'){
			cin >> k;
			delet(k);
		}
	}
}



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

const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);

using Point = complex<double>;
using Polygon = vector<Point>;

inline int sgn(const double &a) { return (a < -EPS ? -1 : (a > EPS ? 1 : 0)); }

inline bool eq(const Point &a, const Point &b) { return abs(a - b) < EPS; }

inline bool operator<(const Point &a, const Point &b){
    if (sgn(a.real() - b.real()))
        sgn(a.real() - b.real()) < 0;
    return sgn(a.imag() - b.imag());
}

double dot(const Point &a, const Point &b) { return real(conj(a) * b); }

double det(const Point &a, const Point &b) { return imag(conj(a) * b); }

struct Line {
    Point p1, p2;

    Line(Point p1 = Point(), Point p2 = Point()) : p1(p1), p2(p2) {}

    bool operator<(const Line &rhs) const {
        if (eq(p2, rhs.p2))
            return p1 < rhs.p1;
        return p2 < rhs.p2;
    }
    bool operator==(const Line &rhs) const {
        return (eq(p1, rhs.p1) && eq(p2, rhs.p2)) ||
               (eq(p1, rhs.p2) && eq(p2, rhs.p1));
    }
};

bool is_in_a_triangle(Point a, Point b, Point c, Point p){
    double c1 = det(b-a, p-a);
    double c2 = det(c-b, p-b);
    double c3 = det(a-c, p-c);
    if(sgn(c1) == sgn(c2) && sgn(c2) == sgn(c3) && sgn(c1) != 0) return true;
    else return false;
}

int main(){
    double x1,y1,x2,y2,x3,y3,xp,yp;
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp) != EOF){
        if(is_in_a_triangle(Point(x1,y1),Point(x2,y2),Point(x3,y3),Point(xp,yp)))cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}



Measured memory_bytes: 3192
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        s: chars
    }
    let v: Vec<usize> = s.iter().map(|&c| (c as u8 - '1' as u8) as usize).collect();
    let mut ans = 0;
    if v.iter().all(|&x| x % 2 == 0) {
        for i in 0..n {
            if v[i] == 2 && n - 1 == i | (n - i - 1) {
                ans += 1;
            }
        }
        ans %= 2;
        ans *= 2;
    } else {
        for i in 0..n {
            if v[i] == 1 && n - 1 == i | (n - i - 1) {
                ans += 1;
            }
        }
        ans %= 2;
    }
    println!("{}", ans);
}


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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n,m;
    cin >> n >> m;

    vector<int> a(n);
    int sum = 0;

    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }

    double tmp = (double)sum / (4 * m);

    sort(ALL(a));
    reverse(ALL(a));

    bool ans = true;

    rep(i, m){
        if(tmp - EPS > a[i]){
            ans = false;
            break;
        } 
    }

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

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく

def input(): return sys.stdin.readline()[:-1]
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    L = tuple(input() for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    l=Counter(L)
    m=max(l.values())
    ans=[]
    for s in l.keys():
        n=l[s]
        if n==m:
            ans.append(s)
    ans.sort()
    printl(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 106440
#include <bits/stdc++.h>
using namespace std;
vector<int> graph[200001];
bool seen[200001];

int dfs(int curr){
	seen[curr] = true;
	int ret = 1;
	for(int i : graph[curr]){
		if(!seen[i]){
			ret += dfs(i);
		}
	}
	return ret;
}

int main(){
	int n,m;
	cin >> n >> m;
	for(int i = 1 ; i <= m ; i += 1){
		int a,b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	int maxi = 0;
	for(int i = 1 ; i <= n ; i += 1){
		if(!seen[i]){
			maxi = max(maxi,dfs(i));
		}
	}
	cout << maxi << endl;
}

Measured memory_bytes: 23916
O = input()
E = input()
if len(O) == len(E):
    for i in range(len(O)):
        print(O[i], end="")
        print(E[i], end="")
elif len(O) > len(E):
    for i in range(len(E)):
        print(O[i], end="")
        print(E[i], end="")
    print(O[i+1])
else:
    for i in range(len(E)):
        print(O[i], end="")
        print(E[i], end="")
    print(E[i+1])

Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  cin >> n;
  vector<pair<mint, mint>> v(62, make_pair(0, 0));
  rep(i, n){
    ll in;
    cin >> in;
    rep(j, 61){
      if(((1LL << j) & in) == 0) v.at(j).first += 1;
      else v.at(j).second += 1;
    }
  }
  mint ans = 0;
  mint power = 1;
  rep(i, v.size()){
    // cerr << v.at(i).first << " " << v.at(i).second << endl;
    ans += (v.at(i).first * v.at(i).second) * power;
    power *= 2;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 256
from statistics import median
N=int(input())
a,b=[],[]
#print(map(int,input().split())
for i in range(N):
  i,j=map(int,input().split())
  a.append(i)
  b.append(j)
amed,bmed=median(a),median(b)
  
if N%2==1:
  print(int(bmed-amed+1))
else:
  print(int(2*(bmed-amed)+1))

Measured memory_bytes: 28736
# numChar種類で条件を満たせるかを判定する
def check(As, numChar):
    Ss = [(-1, -1)]
    APrev = As[0]
    for A in As[1:]:
        if APrev >= A: # 文字列長が同じor短くなる場合
            if numChar == 1: return False
            # A文字目より後ろを削除する
            while Ss[-1][0] > A:
                Ss.pop()
            # A文字目を[+1]する
            posS = A
            while Ss[-1] == (posS, numChar - 1):
                Ss.pop()
                posS -= 1
            if posS == 0:
                return False
            elif Ss[-1][0] == posS:
                Ss[-1] = (posS, Ss[-1][1] + 1)
            else:
                Ss.append((posS, 1))
        APrev = A
    return True

# 条件を満たす最小のnumCharを二分探索する
def solve(As, N):
    lft, rgt = 0, N
    while rgt - lft > 1:
        mid = (lft + rgt) // 2
        isOK = check(As, mid)
        if isOK:
            rgt = mid
        else:
            lft = mid
    return rgt

N = int(input())
As = list(map(int, input().split()))

print(solve(As, N))


Measured memory_bytes: 107192
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		for(int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		long check = 0;
		for(int i=1;i<N;i++) {
			if(A[i-1]>A[i]) {
				check += A[i-1]-A[i];
				A[i] = A[i-1];
			}
		}
		System.out.println(check);

	}
}


Measured memory_bytes: 61260
N = int(input())
X = list(map(int, input().split()))

MaxX = max(X)
MinX = min(X)

ListP = []

for i in range(MinX, MaxX+1):
    P = 0
    for j in range(N):
        P += (X[j]-i)**2
    
    ListP.append(P)

print(min(ListP))


Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  int N;
  cin >> N;
  if (N == 0) {
    cout << "0" << endl;
    return 0;
  }

  vector<int> val(31);
  val[0] = 1;
  for (int i = 1; i < val.size(); i++) {
    val[i] = val[i - 1] * -2;
  }

  string ans;
  int pow = 0;
  while (N != 0) {
    if (N & 1) {
      ans = "1" + ans;
      N--;
    } else {
      ans = "0" + ans;
    }
    pow++;
    N = N / (-2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256