akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter
import java.util.*
import kotlin.collections.HashSet
import kotlin.math.max

@JvmField
    val INPUT = System.`in`!!
    @JvmField
    val OUTPUT = System.out!!

    @JvmField
    val reader = INPUT.bufferedReader()

    fun readLine(): String? = reader.readLine()
    fun readLn() = reader.readLine()!!
    @JvmField
    var tokenizer: StringTokenizer = StringTokenizer("")

    fun read(): String {
        while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine() ?: return "", " ")
        return tokenizer.nextToken()
    }

    fun readInt() = read().toInt()
    fun readDouble() = read().toDouble()
    fun readLong() = read().toLong()
    fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
    fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
    fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

    @JvmField
    val rw = PrintWriter(OUTPUT, false)

    inline fun output(block: PrintWriter.() -> Unit) {
        rw.apply(block).flush()
    }

    fun printLArray(a: LongArray) { a.forEach { x -> rw.print(x); rw.print(" ") };rw.println() }
    fun printIArray(a: IntArray) { a.forEach { x -> rw.print(x);rw.print(" ") };rw.println() }

    private var is_prime: BooleanArray? = null
    private var prime: ArrayList<Int>? = null
    fun sieve(n: Int) {
        is_prime = BooleanArray(n + 10)
        prime = ArrayList()
        for (i in 2..n) is_prime!![i] = true
        for (i in 2..n) {
            if (is_prime!![i]) prime!!.add(i)
            var j = 0
            while (j < prime!!.size && i * prime!![j] < n) {
                is_prime!![i * prime!![j]] = false
                if (i % prime!![j] == 0) break
                ++j
            }
        }
    }

    fun mergeSort(a: IntArray) {
        val n = a.size
        if (n < 2) return
        val mid = n / 2; val left = IntArray(mid); val right = IntArray(n - mid)
        for (i in 0 until mid) left[i] = a[i]
        for (i in mid until n) right[i - mid] = a[i]
        mergeSort(left);mergeSort(right);merge(left, right, a)
    }

    fun merge(left: IntArray, right: IntArray, a: IntArray) {
        val nLeft = left.size; val nRight = right.size
        var i = 0; var j = 0; var k = 0
        while (i < nLeft && j < nRight) {
            if (left[i] <= right[j]) {
                a[k] = left[i];k++;i++
            } else {
                a[k] = right[j]; k++;j++
            }
        }
        while (i < nLeft) {a[k] = left[i]; i++; k++}
        while (j < nRight){a[k] = right[j]; j++; k++}
    }

    fun gcd(a: Long, b: Long): Long {
        if (b == 0L) return a
        return gcd(b, a % b)
    }

    fun smallest(a: IntArray): Int {
        var min = a[0]
        for (i in 1 until a.size) {
            if (a[i] < min) min = a[i]
        }
        return min
    }
fun main(){

    val n = readInt()
    var k = readInt()
    val set = HashSet<Int>()
    while (k-- > 0){
       var d = readInt()
        while (d-- > 0){
            val e = readInt()
            set.add(e)
        }
    }
    rw.println(n-set.size)

    rw.close()
}

Measured memory_bytes: 36260
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	priority_queue<int> p;
	priority_queue<int> q;
	priority_queue<int> r;
	REP(i, a) {
		int pp;
		cin >> pp;
		p.push(pp);
	}
	REP(i, b) {
		int qq;
		cin >> qq;
		q.push(qq);
	}
	REP(i, c) {
		int rr;
		cin >> rr;
		r.push(rr);
	}
	int xx = 0, yy = 0, zz = 0;
	ll result = 0;
	REP(i, x + y) {
		int pp, qq, rr;
		if(p.empty()) {
			pp = -INF;
		} else {
			pp = p.top();
		}
		if(q.empty()) {
			qq = -INF;
		} else {
			qq = q.top();
		}
		if(r.empty()) {
			rr = -INF;
		} else {
			rr = r.top();
		}
		//cout << "pp:" << pp << " qq:" << qq << " rr:" << rr << endl;

		if((pp >= qq || yy >= y) && pp >= rr && xx < x) {
			p.pop();
			xx++;
			result += pp;
		} else if((qq >= pp || xx >= x) && qq >= rr && yy < y) {
			q.pop();
			yy++;
			result += qq;
		} else {
			r.pop();
			result += rr;
		}
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 1784
#include <cstdio>
#include<bits/stdc++.h>
#include<cmath>
#include<iostream>
int main()
{
    int h,w;
    scanf ("%d %d",&h,&w);
    int cnt=0;
    for (int i=1;i<=h;i++)
    {
        getchar();
        for (int j=1;j<=w;++j)
        {
            char ch=getchar();
            if (ch=='#') 
            {
                ++cnt;
            }
        }
    }
    puts ((cnt==h+w-1) ? "Possible" : "Impossible");
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll res = 0;
    ll N,M; cin >> N >> M;
    res = (N-2)*(M-2);
    res = abs(res);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split( )))
count=0
for i in range(1,n-1):
  x,y,z=a[i-1],a[i],a[i+1]
  m=min(x,y,z)
  if m==x:
    if y==min(y,z):
      count+=1
  if m==z:
    if y==min(x,y):
      count+=1
print(count)

Measured memory_bytes: 3064
// JAI SHREE RAM
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
// #define all(a) (a).begin(),(a).end()
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
std::vector<ll> v;
ll n, k;
std::vector<ll> memo(100005, -1);
ll dp(ll i)
{
	if (i == 0)
		return 0;

	if (i == 1)
		return abs(v[1] - v[0]);
	if(memo[i]!=-1)
		return memo[i];

	ll Min =  INT_MAX;
	for (int j = i - 1; j >= i - k && j > -1; j--)
	{
		Min = min(dp(j) + abs(v[j] - v[i]), Min);	
	}
	return memo[i]=Min;
}
int main()
{

	fast
	cin >> n >> k;
	FOR(i, n)
	{
		ll x;
		cin >> x;
		v.pb(x);
	}
// std::vector<ll> v2(n);
// v2[0]=0;
// v2[1]=abs(v[1]-v[0]);


// for(int i=2;i<n;i++)
// {
// 	v2[i]=min(v2[i-2]+abs(v[i-2]-v[i]),abs(v[i]-v[i-1])+v2[i-1]);
// }
// cout<<v2[n-1];

	cout << dp(n - 1);
	return 0;
}


Measured memory_bytes: 6644
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		std::vector<int> num;
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (; x; x /= 10) {
			num.push_back(x % 10);
		}
		while (!num.empty()) {
			putchar(num.back() ^ '0');
			num.pop_back();
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 200005;

int n, f[20][10], g[20][10];

void work(int f[][10]) {
	for (int i = 2; i <= 18; ++i) {
		for (int j = 0; j <= 9; ++j) {
			if (j > 0) f[i][j] += f[i - 1][j - 1];
			f[i][j] += f[i - 1][j];
			if (j < 9) f[i][j] += f[i - 1][j + 1];
		}
	}
}

void solve(int n, int p, int lst) {
	if (!p) {
		return;
	}
	for (int i = lst - 1; i <= lst + 1; ++i) {
		if (i < 0 || i > 9) {
			continue;
		}
		if (n > f[p][i]) {
			n -= f[p][i];
		} else {
			putchar(i ^ '0');
			solve(n, p - 1, i);
			break;
		}
	}
}

int main() {
	read(n);
	for (int i = 0; i <= 9; ++i) {
		f[1][i] = 1;
		if (i > 0) g[1][i] = 1;
	}
	work(f), work(g);
	int p = 1;
	while (1) {
		int s = 0;
		for (int i = 0; i <= 9; ++i) {
			s += g[p][i];
		}
		if (n > s) {
			n -= s;
		} else {
			break;
		}
		++p;
	}
	for (int i = 1; i <= 9; ++i) {
		if (n > f[p][i]) {
			n -= f[p][i];
		} else {
			putchar(i ^ '0');
			solve(n, p - 1, i);
			break;
		}
	}
	putchar('\n');
}


Measured memory_bytes: 2304
def RPN(states):

        operator = {
           '+' :(lambda x, y: x + y),
           '-' :(lambda x, y: x - y),
           '*' :(lambda x, y: x * y),
           '/' :(lambda x, y: float(x)/y)
        }
        stack = []
        for index, z in enumerate(states):
                if z not in operator.keys ():
                        stack.append(int(z))
                        continue
                y = stack.pop()
                x = stack.pop()
                stack.append(operator[z](x,y))
        print (stack[0])
        return (stack[0])

if __name__ == '__main__':
        import sys
        RPN(input().split(" "))

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

int main() {
  int a,v;
  cin>>a>>v;
  int b,w;
  cin>>b>>w;
  int t;
  cin>>t;
  
  int res=1;
  
  	if(w>=v)
  	res=0;
  	else
  	{
  		int relative_velocity=v-w;
  		int dist=abs(b-a);
  		double time_taken=double(dist)/double(relative_velocity);
  		if(time_taken<=t)
  		res=1;
  		else res=0;
  		
  	}
  
  if(res)
  cout<<"YES"<<endl;
  else
  cout<<"NO"<<endl;
  
  
}

Measured memory_bytes: 3632
/**THE_SHYAMP_IS_HERE**/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<bits/stdc++.h>
#include<iomanip>
#define lld long long int
#define ld long double
#define pii pair<lld,lld>
#define psi pair<string,lld>
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define nl '\n'
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin())  i= (c).begin(); i!=(c).end(); i++)
#define MOD 1000000007
#define pi 3.1415926536
#define tod 1
#define itr(i,a,b) for(lld i=a;i<=b;i++)
#define itrn(i,a,b) for(lld i=a;i>=b;i—)
using namespace std;
int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
    lld N,K; cin>>N>>K;
  lld flag=0,val;
  itr(i,1,N){
    cin>>val;
    if(val>=K) flag++;
  }
  cout<<flag;}

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

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {

		Scanner sc = new Scanner(System.in);

		int dir[][] = { { 0, -1 }, { 0, 1 }, { 1, 0 } };

		while (true) {
			final int w = sc.nextInt();
			final int h = sc.nextInt();

			if (w == 0 && h == 0) {
				break;
			}

			final int amount = sc.nextInt();
			final int capacity = sc.nextInt();
			final int init = sc.nextInt();

			int[][] map = new int[h][w];

			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					map[i][j] = sc.nextInt();
				}
			}

			PriorityQueue<Walk> queue = new PriorityQueue<Walk>();
			for (int i = 0; i < w; i++) {
				boolean[][] b = new boolean[h][w];
				queue.offer(new Walk(0, init - 1, 0, i, b));
			}

			boolean flag = false;
			loop: while (!queue.isEmpty()) {
				Walk walk = queue.poll();
				int y = walk.y;
				int x = walk.x;

				if (walk.sanso <= 0) {
					continue;
				}
				if (y == h) {
					flag = true;
					System.out.println(walk.cost);
					break loop;
				}

				walk.visited[y][x] = true;

				if (map[y][x] <= 0) {
					walk.cost += (-map[y][x]);
				} else {
					walk.sanso = Math.min(map[y][x] + walk.sanso, capacity);
				}

				if (walk.cost > amount) {
					continue;
				}

				for (int i = 0; i < 3; i++) {
					int ny = y + dir[i][0];
					int nx = x + dir[i][1];
					if (nx >= 0 && nx < w && ny >= 0 && ny <= h - 1
							&& !walk.visited[ny][nx]) {
						boolean[][] nb = new boolean[h][w];
						for (int j = 0; j < h; j++) {
							nb[j] = Arrays.copyOf(walk.visited[j], w);
						}
						queue.offer(new Walk(walk.cost, walk.sanso - 1, ny, nx,
								nb));
					} else if (i == 2 && walk.y == h - 1) {
						boolean[][] nb = new boolean[h][w];
						queue.offer(new Walk(walk.cost, walk.sanso, ny, nx, nb));
					}
				}
			}

			if (!flag) {
				System.out.println("NA");
			}

		}
	}
}

class Walk implements Comparable<Walk> {
	int cost;
	int sanso;
	int x, y;
	boolean[][] visited;

	public Walk(int cost, int sanso, int y, int x, boolean[][] visited) {
		super();
		this.cost = cost;
		this.sanso = sanso;
		this.x = x;
		this.y = y;
		this.visited = visited;
	}

	@Override
	public int compareTo(Walk arg0) {
		return this.cost - arg0.cost;
	}
}

Measured memory_bytes: 75992
import numpy as np

NK=np.array(input().split(" "),dtype=np.int64)
N=NK[0]
K=NK[1]

H=np.array(input().split(" "),dtype=np.int64)

sort_H=np.sort(H)[::-1]

remain_H=np.sum(sort_H[K::])

print(remain_H)

Measured memory_bytes: 37384
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
	int X;
	int Y;
	int N;
	int D;
	double ans;
	int count = 0;
	int k;

	scanf("%d %d", &N, &D);
	for (k = 0; k < N; k++) {
		scanf("%d %d", &X, &Y);
		ans = hypot(X,Y);
		if (ans <= D) { count++; }
	}

	printf("%d\n", count);

	return 0;
}


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

int main() {
    string s;
    cin >> s;
    s.push_back('R');
    int n = s.size();
    vector<int> ans(n - 1);
    int before = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (s[i] == 'R' && s[i + 1] == 'L') {
            s[i] = 'r';
            s[i + 1] = 'l';
        } else if ((s[i] == 'L' || s[i] == 'l') && (s[i + 1] == 'R' || s[i + 1] == 'r')) {
            int m = i - before + 1;
            int p; int q;
            for (int j = before; j < m + before; ++j) {
                if (s[j] == 'r' && s[j + 1] == 'l') {
                    p = j;
                    q = j + 1;
                    break;
                }
            }
            if ((p - before) % 2 == 1) {
                ans[p] = m / 2;
                ans[q] = (m + 1) / 2;
            } else {
                ans[p] = (m + 1) / 2;
                ans[q] = m / 2;
            }
            before = i + 1;
        }
    }
    for (int k : ans) {
        cout << k << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(void)
{
    double a, b, x, z, ans;
    double v;
    cin >> a >> b >> x;

    v = a * a * b;

    if (v / 2 <= x)
    {
        //cout << "A" << endl;
        z = 2 * (v - x) / (a * a);
        ans = asin(z / sqrt(a * a + z * z));
    }
    else
    {
        //cout << "B" << endl;
        z = (2 * x) / (a * b);
        ans = asin(b / sqrt(b * b + z * z));
    }

    ans = ans / M_PI * 180;
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, a[2][105], i, b = 0, mx = 0, d = 0;

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

	for (i = 0; i < n; i++) {
		d += a[0][i];
		mx = max(d + b, mx);
		b -= a[1][i];
	}

	cout << mx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> pr;
const ll inf=1e16;

int main(){
  int a,b;
  cin>>a>>b;
  int ans=max(a+b,max(a-b,a*b));
  cout<<ans<<endl;
}


Measured memory_bytes: 256
def ABC113C():

    N, M = map(int, input().split())
    PY = [list(map(int, input().split())) for i in range(M)]
    P = [[] for i in range(10 ** 5)]

    from operator import itemgetter
    #PY.sort(key = itemgetter(1))
    for k in range(len(PY)):
        i = PY[k][0]
        j = PY[k][1]
        P[i - 1].append([j, k])

    for i in range(len(P)):
        P[i].sort()

    anslist = []
    for i in range(len(P)):
        for j in range(len(P[i])):
            anslist.append([i + 1, j + 1, P[i][j][1] + 1])
    anslist.sort(key = itemgetter(2))
    for i, j, k in anslist:
        i = str(i)
        j = str(j)
        while len(i) != 6:
            i = "0" + i
        while len(j) != 6:
            j = "0" + j
        print(i + j)
ABC113C()

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

int main() {
    int N; cin >> N;
    vector<int> A;
    int Bob=0,Alice=0;
    rep(i,N){
        int a; cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end(),greater<int>());
    rep(i,N){
        if(i%2==0)
        Alice += A[i];
        else
        Bob += A[i];
    }

    cout << Alice-Bob << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Reader r = new Reader(System.in)) {
            int A = r.i();
            int P = r.i();

            System.out.println((A * 3 + P) / 2);
        }
    }

    public static class Reader implements AutoCloseable {

        private BufferedReader br;

        private String[] buf;

        private int bufidx = -1;

        public Reader(InputStream in) {
            this.br = new BufferedReader(new InputStreamReader(in));
        }

        @Override
        public void close() throws Exception {
            br.close();
        }

        private void readBuf() throws IOException {
            if (bufidx == -1 || bufidx == buf.length) {
                buf = br.readLine().split(" ");
                bufidx = 0;
            }
        }

        public String s() throws IOException {
            readBuf();
            return buf[bufidx++];
        }

        public int i() throws IOException {
            return Integer.parseInt(s());
        }

        public long l() throws IOException {
            return Long.parseLong(s());
        }

        public double d() throws IOException {
            return Double.parseDouble(s());
        }

        public String[] sa() throws IOException {
            readBuf();
            if (bufidx != 0) {
                throw new RuntimeException("illegal read");
            }
            bufidx = -1;
            return buf;
        }

        public int[] ia() throws IOException {
            String[] sa = sa();
            int[] ia = new int[sa.length];
            for (int i = 0; i < sa.length; i++) {
                ia[i] = Integer.parseInt(sa[i]);
            }
            return ia;
        }

        public long[] la() throws IOException {
            String[] sa = sa();
            long[] la = new long[sa.length];
            for (int i = 0; i < sa.length; i++) {
                la[i] = Long.parseLong(sa[i]);
            }
            return la;
        }

        public double[] da() throws IOException {
            String[] sa = sa();
            double[] da = new double[sa.length];
            for (int i = 0; i < sa.length; i++) {
                da[i] = Double.parseDouble(sa[i]);
            }
            return da;
        }

        public int[][] im(int N) throws IOException {
            int[][] im = new int[N][];
            for (int i = 0; i < N; i++) {
                im[i] = ia();
            }
            return im;
        }

        public long[][] lm(int N) throws IOException {
            long[][] lm = new long[N][];
            for (int i = 0; i < N; i++) {
                lm[i] = la();
            }
            return lm;
        }

        public double[][] dm(int N) throws IOException {
            double[][] dm = new double[N][];
            for (int i = 0; i < N; i++) {
                dm[i] = da();
            }
            return dm;
        }

    }

}


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

int main(){
    int N; cin >> N;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    multiset<int> ms;
    ms.insert(a[0]);
    for(int i=1;i<N;i++){
        auto tmp=ms.lower_bound(a[i]);
        if(tmp!=ms.begin()){
            tmp--;
            ms.erase(tmp);
        }
        ms.insert(a[i]);
    }
    cout << ms.size() << endl;
}

Measured memory_bytes: 5376
s=input();ans=0
def m(b):
  global s
  ans=""
  for i in range(len(s)-1):ans+=s[i]+("+"if b[i]=="1"else"")
  return eval(ans+s[-1])
for i in range(2**(len(s)-1)):ans+=m(bin(i)[2:].zfill(len(s)-1))
print(ans)

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a >= 1 && a <= 9 && b >= 1 && b <= 9){
	    cout << a*b << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string b, s;
    cin >> b;
    if (b == "A") s = "T";
    else if (b == "T") s = "A";
    else if (b == "G") s = "C";
    else if (b == "C") s = "G";
    cout << s;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
    int a=0,b=0,o=0,ab=0;
    int now;
    char var[100];
    while(~scanf("%d,%s",&now,var)){
        if(var[1]=='B')ab++;
        else if(var[0]=='A')a++;
        else if(var[0]=='B')b++;
        else if(var[0]=='O')o++;
    }
    printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
}


Measured memory_bytes: 2608
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

vector<int> tree[200005];

int d[200005];
void dfs(int v, int pre = -1){
  for(auto to : tree[v]) if(to != pre){
    d[to] = d[v] + 1;
    dfs(to, v);
  }
}

int main(){
  int n;
  cin>>n;
  rep(i,n-1) {
    int a,b;
    cin>>a>>b;
    a--;b--;
    tree[a].pb(b);
    tree[b].pb(a);
  }

  d[0] = 1;
  dfs(0);
  int v = 0;
  rep(i,n) if(d[i] > d[v]) v = i;

  d[v] = 1;
  dfs(v);
  rep(i,n) if(d[i] > d[v]) v = i;

  dbg(d[v]);
  if(d[v]%3 == 2) cout << "Second" << endl;
  else cout << "First" << endl;

  return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  bool ok = false;
  for (int i = 1; i <= 10000; ++i){
    int num = a*i;
    if(num%b == c) ok = true;
  }
  if(ok) puts("YES");
  else puts("NO");
  return 0;
}


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

int main() {
	int a, z;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			a = i;
			break;
		}
	}
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == 'Z') {
			z = i;
			break;
		}
	}
	cout << z - a + 1 << endl;
	return 0;
}

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	LL a;
	string b;
	cin >> a >> b;

	int shift = 0;
	for (int i = 0; i < b.size(); ++i) {
		if (b[i] == '.') {
			shift = b.size() - i - 1;
			b.erase(b.begin() + i);
			break;
		}
	}

	LL c = stoll(b.c_str());
	LL div = 1;
	REP(i, shift) {
		div *= 10;
	}

	LL ans = a * c / div;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


int main() {
    int n, x; std::cin >> n >> x;
    int cnt = 1;
    int d = 0;
    for (int i = 0; i < n; i++) {
        int l; std::cin >> l;
        cnt += (d += l) <= x;
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> posval;
vector<ll> negval;
ll zerocount = 0;
ll n,k;

bool success(ll val){
	//return true if there are >=k elements <=val
	//how many negatives?
	ll negcnt = negval.size()*posval.size();
	ll zerocnt = zerocount*(negval.size()+posval.size())+(zerocount*(zerocount-1))/2;
	ll totalcount=0;
	if (val<0){
		ll av = abs(val);
		for (ll i : negval){
			//how many posval things are >searchval?
			ll searchval = (av+i-1)/i;
			totalcount+=posval.size()-(lower_bound(posval.begin(),posval.end(),searchval)-posval.begin());
		}
	} else if (val==0){
		totalcount=negcnt+zerocnt;
	} else {
		totalcount=negcnt+zerocnt;
		ll av = abs(val);
		for (ll x = 0; x<posval.size(); x++){
			//how many negval things are <=searchval
			ll i = posval[x];
			ll searchval = av/i;
			totalcount+=min(0LL+(upper_bound(posval.begin(),posval.end(),searchval)-posval.begin()),x);
		}
		for (ll x = 0; x<negval.size(); x++){
			//how many negval things are <=searchval
			ll i = negval[x];
			ll searchval = av/i;
			totalcount+=min(0LL+(upper_bound(negval.begin(),negval.end(),searchval)-negval.begin()),x);
		}
	}
	//cout<<val<<" "<<totalcount<<endl;
	return (totalcount>=k);
}

int main(){
	cin>>n>>k;
	for (ll i = 0; i<n; i++){
		ll x;
		cin>>x;
		if (x<0){
			negval.push_back(-x);
		} else if (x>0){
			posval.push_back(x);
		} else {
			zerocount++;
		}
	}
	sort(negval.begin(),negval.end());
	sort(posval.begin(),posval.end());
	ll l=-1e18,r=1e18;
	while (l<=r){
		ll mid = (l+r)/2;
		if (success(mid)){
			r=mid-1;
		} else {
			l=mid+1;
		}
	}
	cout<<l<<endl;
}

Measured memory_bytes: 2420
#include <algorithm>
#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()
#define ll long long
#define INF 1000000000000000000

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

    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<set<ll>> A(26, set<ll>({-INF, INF}));
    rep(i, s.size()) { A[s[i] - 'a'].insert((ll)i); }

    int q;
    cin >> q;
    rep(i, q) {
        int a;
        cin >> a;
        if (a == 1) {
            ll b;
            char c;
            cin >> b >> c;
            b--;
            char ind = s[b];
            s[b] = c;
            A[ind - 'a'].erase(b);
            A[c - 'a'].insert(b);
        } else {
            ll b, c;
            cin >> b >> c;
            b--;
            ll res = 0;
            rep(j, 26) {
                if (A[j].size() == 0)
                    continue;
                ll lid = *A[j].lower_bound(b);
                ll rid = *A[j].lower_bound(c);
                if (rid > lid)
                    res++;
            }

            cout << res << endl;
        }
    }
}

Measured memory_bytes: 24220
# もらうDP
N = int(input())
dp = {}
for n in range(N+1):
    if n == 0:
        dp[0] = 0
    else:
        res = n
        pow6 = 1
        while n - pow6 >= 0:
            res = min(res, dp[n-pow6] +1)
            pow6 *= 6
        pow9 = 1
        while n -pow9 >= 0:
            res = min(res, dp[n-pow9] +1)
            pow9 *= 9
        dp[n] = res
print(dp[N])

Measured memory_bytes: 15088
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b,x;
	int i,j,k;
	int MIN=INT_MAX;
	cin>>a>>b>>x;
	for(i=0;i<=20;i++){
		for(j=0;j<=40;j++){
			if(i*1000+j*500>=x){
				MIN=min(MIN,i*a+j*b);
			}
		}
	}
	cout<<MIN<<endl;
	return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846
 
typedef long long ll;
typedef pair< int, int > P;   
typedef pair< ll, P > PP;

//-----------------------------------------------------------------------------

int n, x;
int ans, mi = INF;

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

	cin >> n >> x;
	REP(i, n) {
		int m; cin >> m;
		x -= m;
		ans++;
		mi = min(mi, m);
	}
	ans += x / mi;
	cout << ans << endl;
 
    return 0;
}


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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    
    int count = 0;
    for (int i = 0; i < N; i++) {
      if (Integer.parseInt(sc.next()) >= K) {
        count++;
      }
    }
    
    System.out.println(count);
  }
}

Measured memory_bytes: 47100
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int mod=1e9+7;
const int maxn=3e3+7;
ll dp[maxn][maxn];
int last[maxn];
int main()
{
	int n,m;
	cin>>n>>m;
	string s;
	cin>>s;
	for(int i=1;i<=n;i++) last[i]=i;
	for(int i=1,l,r;i<=m;i++)
	{
		cin>>l>>r;
		last[l]=max(last[l],r);
	}
	dp[0][0]=1;
	int cur=0;
	for(int i=1;i<=n;i++)
	{
		int cc=0;
		if(last[i]>cur)
		{
			for(int j=cur;j<last[i];j++)
				cc+=(s[j]=='1');
		}
		cur=max(cur,last[i]);
		for(int j=0;j<=cur;j++)
		{
			int nxt=j+cc;
			if(i+nxt<=cur)
				dp[i][nxt]=(dp[i][nxt]+dp[i-1][j])%mod;
			if(nxt>=1)
				dp[i][nxt-1]=(dp[i][nxt-1]+dp[i-1][j])%mod;
			//dbg(i,j,cc,dp[i][j]);
		}
	}
	cout<<dp[n][0]<<endl;
}

Measured memory_bytes: 69120
#include <iostream>
using namespace std;
int get(int n) 
 { 
    int sum; 
    for (sum = 0; n > 0; sum += n % 10, n /= 10); 
  
    return sum; 
 } 
int main() {
	int n;
	cin>>n;
	int ans=get(n);
	if(n%ans==0)cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3624
package main

import "fmt"

func main() {
	xs := make([]int, 5)
	for i := range xs {
		fmt.Scan(&xs[i])
	}

	sum := 0
	max := 0
	for _, x := range xs {
		sum += x
		if v := x % 10; v != 0 {
			p := 10 - v
			if p > max {
				max = p
			}
			sum += p
		}
	}
	fmt.Println(sum - max)
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#define MAXN 200000
using namespace std;
int main(){
	int K, N;
	int d[MAXN+1];
	cin >> K >> N;
	for(int i=0; i<N; i++)
		cin >> d[i];
	sort(d, d+N);
	d[N] = d[0] + K;
	for(int i=0; i<N; i++)
		d[i] = d[i+1] - d[i];
	sort(d, d+N);
	cout << K - d[N-1] << endl;
}

	


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
    for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
    FASTIO
    /*
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //scanf("%d", &T);
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n;
        cin >> n;
        cout << (n * n) << endl;
    }
    return 0;
}

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

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

    if (N < 105) cout << 0 << endl;
  	else if (N >= 105 && N < 135) cout << 1 << endl;
  	else if (N >= 135 && N < 165) cout << 2 << endl;
    else if (N >= 165 && N < 189) cout << 3 << endl;
    else if (N >= 189 && N < 195) cout << 4 << endl;
  	else cout << 5 << endl;



}


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

unsigned long long L(unsigned long long N)
{
    return pow(2, N + 2) - 3;
}

unsigned long long P(unsigned long long N)
{
    return pow(2, N + 1) - 1;
}

unsigned long long f(unsigned long long N, unsigned long long X)
{
    if (X == 0)
    {
        return 0;
    }

    if (N == 0)
    {
        if (X == 0)
        {
            return 0;
        }
        else if (X == 1)
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }

    if (X > (L(N) + 1) / 2)
    {
        return P(N) - f(N, L(N) - X);
    }
    else if (X == (L(N) + 1) / 2)
    {
        return (P(N) + 1) / 2;
    }
    else
    {
        return f(N - 1, X - 1);
    }
}

int main()
{
    unsigned long long N, X;
    cin >> N >> X;
    cout << f(N, X) << endl;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())
W_count = [0] * (N + 1)
E_count = [0] * (N + 1)

for i in range(len(S)):
  W_count[i + 1] = W_count[i] + (1 if S[i] == 'W' else 0)
  E_count[i + 1] = E_count[i] + (1 if S[i] == 'E' else 0)

# print('W_count')
# print(W_count)
# print('E_count')
# print(E_count)

answer = 4 * (10 ** 5)
for i in range(len(S)):
  if i == 0:
    answer = min(answer, E_count[-1] - E_count[1])
  elif i == len(S) - 1:
    answer = min(answer, W_count[len(S) - 1] - W_count[0])
  else:
    answer = min(answer, W_count[i] - W_count[0] + E_count[-1] - E_count[i + 1])

print(answer)


Measured memory_bytes: 29348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;

int n;
vector<pii> G[MX];
struct edge{
    int p, v, sz, res;
    bool done;
} E[2*MX];
int sz[MX], m;

struct node{
    int sum, zcnt;
} V[MX];

void dfs(int v, int p=-1){
    sz[v]=1;
    for(pii &e:G[v]){
        int x,idx; tie(x,idx)=e;
        if(x==p) continue;
        dfs(x,v); sz[v]+=sz[x];
        E[idx].sz=sz[x];
        E[idx+(idx%2 ? 1: -1)].sz=n-sz[x];
    }
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n; m=2*n-2;
    for(int i=1; i<n; i++){
        int u,v; cin>>u>>v;
        G[u].push_back({v, 2*i-1});
        G[v].push_back({u, 2*i});
        E[2*i-1]={u,v,0,0}, E[2*i]={v,u,0,0};
    }
    dfs(0,-1);

    int idx[2*MX]={};
    iota(idx+1, idx+m+1, 1);
    sort(idx+1, idx+m+1, [](int a, int b){ return E[a].sz<E[b].sz; });

    for(int ii=1; ii<=m; ii++){
        int i=idx[ii], j=i+(i%2 ? 1 : -1);
        int v=E[i].v, p=E[i].p, &res=E[i].res;
        E[i].done=true;

        int sum=V[v].sum, zcnt=V[v].zcnt;

        if(E[j].done) sum-=E[j].res, zcnt-=(E[j].res==0);

        E[i].res=sum+max(0,zcnt-1);

        V[p].sum+=res;
        if(res==0) V[p].zcnt++;

        // cout<<p<<' '<<v<<": "<<E[i].res<<'\n';
    }
    // cout<<'\n';

    int ans=inf;
    for(int v=0; v<n; v++){
        int now=1, zcnt=0;
        for(pii &e:G[v]){
            int idx=e.second;
            now+=E[idx].res;
            if(E[idx].res==0) zcnt++;
        }
        now+=max(0, zcnt-1);
        // cout<<v<<": "<<now<<'\n';
        ans=min(ans, now);
    }

    cout<<ans<<'\n';
    
    return 0;
}

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

int main() {
    int x, A, B;
    cin >> x;
    for (long long a = 0; a <= 119; a++) {
        for (long long b = -119; b <= 119; b++)
        if (pow(a, 5) - pow(b, 5) == x) {
            A = a, B = b;
            break;
        }
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 4060
N = int(input())
W = list(map(int,input().split()))

lst = [0]*(N-1)
S1 = [W[0]]*(N-1)
S2 = [sum(W)-W[0]]*(N-1)
lst[0] = abs(S1[0]-S2[0])

for i in range(1,N-1):
    S1[i] = S1[i-1]+W[i]
    S2[i] = S2[i-1]-W[i]
    lst[i] = abs(S1[i]-S2[i])

ans = min(lst)
print(ans)


Measured memory_bytes: 9104
// C++ program to find maximum rectangular area in linear time
#include<iostream>
#include<stack>
#include <vector>

#define endl '\n';
using namespace std;
typedef vector<int> vi;


// The main function to find the maximum rectangular area under given
// histogram with n bars
int getMaxArea(vi &hist) {
    // Create an empty stack. The stack holds indexes of hist[] array
    // The bars stored in stack are always in increasing order of their
    // heights.
    int n = hist.size();
    stack<int> s;

    int max_area = 0; // Initalize max area
    int tp;  // To store top of stack
    int area_with_top; // To store area with top bar as the smallest bar

    // Run through all bars of given histogram
    int i = 0;
    while (i < n) {
        // If this bar is higher than the bar on top stack, push it to stack
        if (s.empty() || hist[s.top()] <= hist[i])
            s.push(i++);

            // If this bar is lower than top of stack, then calculate area of rectangle
            // with stack top as the smallest (or minimum height) bar. 'i' is
            // 'right index' for the top and element before top in stack is 'left index'
        else {
            tp = s.top();  // store the top index
            s.pop();  // pop the top

            // Calculate the area with hist[tp] stack as smallest bar
            area_with_top = hist[tp] * (s.empty() ? i : i - s.top() - 1);

            // update max area, if needed
            if (max_area < area_with_top)
                max_area = area_with_top;
        }
    }

    // Now pop the remaining bars from stack and calculate area with every
    // popped bar as the smallest bar
    while (s.empty() == false) {
        tp = s.top();
        s.pop();
        area_with_top = hist[tp] * (s.empty() ? i : i - s.top() - 1);

        if (max_area < area_with_top)
            max_area = area_with_top;
    }

    return max_area;
}

// Driver program to test above function
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int h, w, v, sol = 0;
    cin >> h >> w;
    vi hist(w, 1);

    for (int j = 0; j < w; ++j) {
        cin >> v;
        if (v == 0) hist[j] = 1;
        else hist[j] = 0;
    }

    sol = max(sol, getMaxArea(hist));

    for (int i = 1; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> v;
            if (v == 0) {
                hist[j]++;
            } else hist[j] = 0;
        }

        sol = max(sol, getMaxArea(hist));
    }

    cout << sol << endl;

    return 0;
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        ans += a[i]/2;
        if(a[i]%2 && i != n-1 && a[i+1] > 0){
            a[i+1]--;
            ans++;
        }
    }
    cout << ans << endl;
}

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

long long n, m;
vector<long long> cnt, cntd, x;

long long solve();

int main() {
  cin >> n >> m;
  x.resize(n);
  cnt.assign(m, 0);
  cntd.assign(m, 0);
  for(int i = 0; i < n; ++i) cin >> x[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  sort(x.begin(), x.end());
  for(int i = 0; i < n; ++i) ++cnt[x[i] % m];
  for(int i = 0; i < n; ++i)
    if(i + 1 < n && x[i] == x[i + 1]) ++cntd[x[++i] % m];
  for(int i = 0; i <= m / 2; ++i) {
    if(i == 0 || i * 2 == m)
      ans += cnt[i] / 2;
    else {
      int mi = i, ma = m - i;
      if(cnt[mi] > cnt[ma]) swap(mi, ma);
      ans += cnt[mi];
      cnt[ma] -= cnt[mi];
      cnt[mi] = 0;
      while(cnt[ma] > 1 && cntd[ma] > 0) {
        ++ans;
        --cntd[ma];
        cnt[ma] -= 2;
      }
    }
  }
  return ans;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

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

    int ans = 0;
    char pre = s[0];
    for (size_t i = 1; i < s.length(); i++)
    {
        if (pre != s[i]) {
            pre = s[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512