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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task "runaway"

using namespace std;
typedef long long ll;

int encode(char x)
{
    if (x == 'D') return 0;
    else if (x == 'U') return 1;
    else if (x == 'L') return 2;
    else return 3;
}

int nencode(char x)
{
    if (x == 'U') return 0;
    else if (x == 'D') return 1;
    else if (x == 'R') return 2;
    else return 3;
}

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen("A.INP", "r")){
        freopen("A.INP", "r", stdin);
        freopen("A.OUT", "w", stdout);
    }
    if (fopen(Task".in", "r")){
        freopen(Task".in", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    int H, W, N; cin >> H >> W >> N;
    int nx, ny; cin >> nx >> ny;
    string s, t; cin >> s >> t;
    vector<int> cnt(4), remain(4);
    remain[0] = H - nx + 1;
    remain[1] = nx;
    remain[2] = ny;
    remain[3] = W - ny + 1;
    for (int i=0; i<N; ++i){
        cnt[encode(s[i])]++;
        for (int type=0; type<4; ++type){
            if (cnt[type] >= remain[type]){
                cout << "NO";
                return 0;
            }
        }
        cnt[nencode(t[i])]--;
        cnt[nencode(t[i])] = max(cnt[nencode(t[i])], -remain[encode(t[i])] + 1);
    }
    cout << "YES";
}


Measured memory_bytes: 920
S = input()

l = len(S) - 1
ans = 0
for i in range(1<<l):
    s = S
    n = []
    k = 0
    for j in range(l):
        k += 1
        if i&(1<<j):
            n.append(int(s[:k]))
            s = s[k:]
            k = 0
    else:
        n.append(int(s))
    ans += sum(n)

print(ans)

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

using namespace std;

int main() {
	string s;
	cin >> s;
	string s2 = "";
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			s2 += s[i];
		}
	}
	cout << s2 << endl;
	return 0;
}

Measured memory_bytes: 512
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
    }
    if n > 2 && m > 2 {
        println!("{}", (n - 2) * (m - 2));
    } else if n == 2 || m == 2 {
        println!("0");
    } else if n == 1 && m == 1 {
        println!("1");
    } else {
        println!("{}", n * m - 2);
    }
}


Measured memory_bytes: 2144
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>

using lli = long long int;
int inf = 1000000007;
using namespace std;
#define sort(X) sort(X.begin(),X.end())

int N;
int u, v, w;

class Edge {
public:
	int to;
	int cost;
	Edge(int to, int cost) { this->to = to; this->cost = cost; }
};

class Node {
public:
	int name;
	int cost = inf;
	int color;
	bool visit = false;
	vector<Edge> relate;
	Node(int name = 0) { this->name = name; }
};


int main()
{
	cin >> N;

	vector<Node> nodes(N);

	for (int i = 1; i < N; i++) {
		cin >> u >> v >> w;
		u -= 1;
		v -= 1;
		Edge e1(u, w);
		Edge e2(v, w);
		nodes[u].relate.push_back(e2);
		nodes[v].relate.push_back(e1);
	}

	queue<Node> Q;
	nodes[0].color = 1;
	nodes[0].visit = true;
	Q.push(nodes[0]);

	while (Q.size() != 0) {
		Node now = Q.front();
		Q.pop();
		for (auto x : now.relate) {
			if (!nodes[x.to].visit) {
				if (x.cost % 2 == 0) { nodes[x.to].color = now.color; }
				else { nodes[x.to].color = 1 - now.color; }
				nodes[x.to].visit = true;
				Q.push(nodes[x.to]);
			}
		}
	}

	for (int i = 0; i < N; i++)cout << nodes[i].color << endl;

	return 0;
}

Measured memory_bytes: 10492
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long[][] nums=new long[3][n];
        long[] ans=new long[n+1];
        for(int i=0;i<3;i++){
            for(int j=0;j<n;j++){
                nums[i][j]=sc.nextInt();
            }
            Arrays.sort(nums[i]);
        }
        int index=n;
        for(int i=n-1;i>=0;i--){
            for(int j=index;j>=0;j--){
                if(j==0||nums[1][i]>=nums[2][j-1]){
                    ans[i]=n-j;
                    index=j;
                    break;
                }
            }
        }
        for(int i=n-2;i>=0;i--){
            ans[i]+=ans[i+1];
        }
        index=n;
        long finalans=0;
        for(int i=n-1;i>=0;i--){
            for(int j=index;j>=0;j--){
                if(j==0||nums[0][i]>=nums[1][j-1]){
                    finalans+=ans[j];
                    index=j;
                    break;
                }
            }
        }
        System.out.println(finalans);
    }
}

Measured memory_bytes: 100592
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

WeightedGraph<int> G;
int d[100010];

void dfs(int v,int par){
	for(auto e : G[v]){
		if(e.to == par) continue;
		d[e.to] = d[v] + e.cost;
		dfs(e.to,v);
	}
}

signed main(){
	int n;
	cin >> n;
	G.resize(n);
	for(int i = 0;i < n - 1;i++){
		int u,v,w;
		cin >> u >> v >> w; u--;v--;
		G[u].emplace_back(v,w);
		G[v].emplace_back(u,w);
	}
	dfs(0,-1);
	for(int i = 0;i < n;i++) cout << d[i] % 2 << endl;
}

Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int main(){
  double m,s=0;
  int n;
  cin >> n >> m;
  double a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    s+=a[i];
  }
  sort(a,a+n,greater<int>());
  int m2=m;
  if(a[m2-1]<ceil(s/(4*m)))cout << "No";
  else cout << "Yes";
}


Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>
#include <string>

int main() {
	usize n;
	::std::cin >> n;
	::std::vector<u64> a(n), b(n);
	for (auto &e : a) {
		::std::cin >> e;
	}
	for (auto &e : b) {
		::std::cin >> e;
	}
	usize cnt = 0;
	u64 sum = 0;
	::std::vector<u64> c;
	for (const auto i : rep<>(0, n)) {
		if (a[i] < b[i]) {
			sum += b[i] - a[i];
			++cnt;
		}
		else {
			c.emplace_back(a[i] - b[i]);
		}
	}
	if (cnt == 0) {
		::std::cout << 0 << ::std::endl;
		return 0;
	}
	::std::sort(c.rbegin(), c.rend());
	for (const auto e : c) {
		++cnt;
		if (sum <= e) {
			sum = 0;
			break;
		}
		else {
			sum -= e;
		}
	}
	if (sum == 0) {
		::std::cout << cnt << ::std::endl;
	}
	else {
		::std::cout << -1 << ::std::endl;
	}
	return 0;
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
const int INV2=5e8+4;
int n,q,a[500010],x,y;
LL X[3010],Y[3010],ans,f[3010][3010];
int main(){
	cin>>n>>q;
	FOR(i,1,n) getint(a[i]);
	FOR(i,1,n)
		FOR(j,1,n)
			f[i][j]=(a[i]<a[j]);
	FOR(rp,1,q){
		getint(x),getint(y);
		FOR(i,1,n){
			if (i==x){X[i]=0;continue;}
			if (i==y){X[i]=(f[x][y]+f[y][x])*INV2%MO;continue;}
			X[i]=(f[x][i]+f[y][i])*INV2%MO;
		}
		//f'[x][i]
		FOR(i,1,n){
			if (i==y){Y[i]=0;continue;}
			if (i==x){Y[i]=(f[x][y]+f[y][x])*INV2%MO;continue;}
			Y[i]=(f[x][i]+f[y][i])*INV2%MO;
		}
		//f'[y][i]
		FOR(i,1,n) f[x][i]=X[i],f[y][i]=Y[i];
		FOR(i,1,n) if (i!=x && i!=y) f[i][x]=f[i][y]=(f[i][x]+f[i][y])*INV2%MO;
	}
	FOR(i,1,n)
		FOR(j,1,i-1)
			(ans+=f[i][j])%=MO;
	while (q--) ans=ans*2%MO;
	ans=(ans%MO+MO)%MO;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 71936
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int L[101];
	int sum=0,maxa=0;
	scan(N);
	rep(i,N){
		scan(L[i]);
		sum+=L[i];
		maxa=max(maxa,L[i]);
	}
	if(maxa<sum-maxa) prin("Yes");
	else prin("No");

	return 0;
}


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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
    return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/

const int N = (int) 2e5 + 3;
vector <int> oc[N];
int a[N] , n;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        oc[a[i]].push_back(i);
    }
    int pr = 0 , taken = 0;
    for(int i = 1; i <= n; ++i){
        bool found = false;
        for(auto indx : oc[i]){
            if(indx > pr){
                pr = indx;
                taken++;
                found = true;
                break;
            }
        }
        if(!found)
            break;
    }
    if(taken == 0){
        cout << -1 << "\n";
    }else{
        cout << n - taken << "\n";
    }

    return 0;
}


Measured memory_bytes: 11904
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var a = parseInt(line[0]);
    var b = parseInt(line[1]);
    var c = parseInt(line[2]);
    console.log(a+b+c-Math.max(a,b,c))
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
// AOJ 2618: Trip to Kyoto
// 2018.1.25 bal4u@uu

#include <stdio.h>

#define ABS(a)    ((a)>=0?(a):-(a))
#define MIN(a,b)  ((a)<=(b)?(a):(b))

int x1[10002], y1[10002], x2[10002], y2[10002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int calc(int x1, int y1, int x2, int y2)
{
	x1 += 200000000, y1 += 200000000;
	x2 += 200000000, y2 += 200000000;
	if (x1%20 == 0 && x2%20 == 0) {
		if      (x1 == x2) return ABS(y1-y2);
		else if (y1/20 == y2/20) return ABS(x1-x2) + MIN(y1%20+y2%20, 40-y1%20-y2%20);
	} else if (y1%20 == 0 && y2%20 == 0) {
		if      (y1 == y2) return ABS(x1-x2);
		else if (x1/20 == x2/20) return ABS(y1-y2) + MIN(x1%20+x2%20, 40-x1%20-x2%20);
	}
	return ABS(x1-x2) + ABS(y1-y2);
}

int main()
{
	int n, x, y, i, j, k, s, t, ans;
	int xmin, xmax, ymin, ymax;
	int x0, y0;

	n = in();
	xmin = ymin = 1000000000, xmax = ymax = -1000000000; 
	for (i = 0; i < n; i++) {
		x = in(), y = in();
		x <<= 1, y <<= 1;
		x1[i] = x,   y1[i] = y;
		x2[i] = x+y, y2[i] = x-y;
		if (x2[i] < xmin) xmin = x2[i];
		if (x2[i] > xmax) xmax = x2[i];
		if (y2[i] < ymin) ymin = y2[i];
		if (y2[i] > ymax) ymax = y2[i];
	}
 
	x = (xmin + xmax) >> 1, y = (ymin + ymax) >> 1;
	x0 = (x + y) >> 1, y0 = (x - y) >> 1;

	ans = 0x7fffffff;
	for (i = x0-50; i <= x0+50; i++) {
		for (j = y0-50; j <= y0+50; j++) {
			if (ABS(i) % 20 && ABS(j) % 20) continue;
			t = 0; 
			for (k = 0; k < n; k++) {
				if (t < (s = calc(i, j, x1[k], y1[k]))) t = s;
			}
			if (ans > t) ans = t;
		}
	}
	printf("%.12lf\n", (double)ans/2);
	return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 n, k;
    cin >> n >> k;

    vs64 num(1e5 + 1, 0);
    rep (i, n)
    {
        int a, b;
        cin >> a >> b;
        num[a] += b;
    }

    int ans = 1;
    s64 sum = 0;
    while (sum + num[ans] < k)
    {
        sum += num[ans++];
    }

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



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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadArrayInt();
            while (true)
            {
                var change = false;
                var min = A.Min();
                for (int i = 0; i < N; i++)
                {
                    if (A[i] % min != 0)
                    {
                        if (A[i] % min != A[i])
                        {
                            change = true;
                            A[i] = A[i] % min;
                        }
                    }
                    else
                    {
                        if (A[i] != min)
                        {
                            change = true;
                            A[i] = min;
                        }
                    }
                }
                if (!change) break;
            }

            Console.WriteLine(A.Min());
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 21728
/**
*
* Author : MeGa
*
*/
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string.h>

using namespace std;

int main(){

#ifndef ONLINE_JUDGE
    //freopen("in","r",stdin);
#endif
     ios::sync_with_stdio(false);
     cin.tie(0);
     long long a,b;
     cin>>a>>b;

     long long dif = min(a,b/2);
     long long ans = 0;
     ans +=dif;
     a-=dif;
     b-=(2*dif);
     if(b >0){
         ans+=(b/4);
     }
     cout<<ans<<endl;

     


    
   

}

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

const int N = 1e6+6;
int n, cnt[N], marked[N];

int main() {
    cin >> n;
    for(int i=0; i<n; i++) {
        int a; cin >> a;
        cnt[a]++;
    }
    int ans = n;
    for(int i=1; i<N; i++) {
        if(!cnt[i])  continue;
        if(cnt[i]>1 && !marked[i]) 
            ans -= cnt[i];
        for(int j=i+i; j<N; j+=i) {
            if(!cnt[j] || marked[j])     
                continue;
            ans-=cnt[j]; marked[j] = 1;
        }
    }
    cout << ans;
}

Measured memory_bytes: 11456
#include "bits/stdc++.h"
using namespace std;

//***********************************Functions and macros begin*************************************//

#define pi pair<int,int>
#define pii pair<pi,int>
#define pb push_back
#define fast ios_base::sync_with_stdio
#define fast1 cin.tie(NULL)
#define mod1 1000005187
#define mp make_pair
#define SORT(x) sort(x.begin(),x.end())
#define PI 3.14159265
#define R3 1.7320508
#define R5 2.2360679
typedef long long int  ll;
const ll mod=1e9+7;
int phi(int n) //No of coprimes
{int result=n;for(int i=2;i*i<=n;i++)if(n%i==0){while(n%i==0) n=n/i;result-=result/i;}if(n>1) result-=result/n; return result;}

ll mod_pow(ll base,ll e) 
{ ll ans=1; while(e){if(e&1) ans=(ans*base)%mod;base=(base*base)%mod;e>>=1;}return ans;}

int gcd(int a,int b) //Greatest common divisior
{return b ? gcd(b,a%b) : a;}


//*********************************** Fucntions and macros end  *************************************// 

int main()
{
	ll n,h;
	cin>>n>>h;
	ll a[n],b[n];
	for(int i=0;i<n;i++)
	cin>>a[i]>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	int i=0,j=n-1;
	ll ans=0;
	while(h>0&&j<n)
	{
		if(j==-1)
		{
			if(h%a[n-1]==0)
			{
				ans+=h/a[n-1];
			}
			else
			ans+=h/a[n-1]+1;
			h=-1;
		}
		else
		if(a[n-1]>b[j])
		{
			h=h-a[n-1];
			//cout<<a[n-1]<<" ";
			ans++;
		}
		else
		{
			//cout<<b[j]<<" ";
			h=h-b[j];
			j--;
			ans++;
		}
	}
	cout<<ans;
}

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

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

    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <climits>
#include <vector>
#include <list>

using namespace std;

int main()
{
	int n;
	cin >> n;
	double *x = new double[n];
	double *y = new double[n];
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> y[i];
	}
	for (int i = 0; i < n; i++) {
		x[i] = fabs(x[i] - y[i]);
	}
	for (double p : { 1.0, 2.0, 3.0}) {
		double sum = 0;
		for (int i = 0; i < n; i++) {
			sum += pow(x[i], p);
		}
		printf("%.08f\n", pow(sum, 1 / p));
	}
	double max = 0;
	for (int i = 0; i < n; i++) {
		if (max < x[i]) max = x[i];
	}
	printf("%.08f\n", max);
	return 0;
}

Measured memory_bytes: 3372
let is_rect (x, y, z) = x * x + y * y = z * z
let is_loz (x, y, _)  = x = y
                              
let _ =
  let rn = ref 0 in
  let ln = ref 0 in
  try
    while true do
      let e = Scanf.scanf "%d,%d,%d\n" (fun x y z -> (x,y,z)) in
      if is_rect e then incr rn else if is_loz e then incr ln else ()
    done
  with
    End_of_file -> Printf.printf "%d\n" !rn; Printf.printf "%d\n" !ln

Measured memory_bytes: 2380
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	k := nextInt()

	answer := k

	for i := 1; i < n; i++ {
		answer *= k - 1
	}

	fmt.Println(answer)
}


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

int main(){
    int64_t n, ans = 0;
    cin >> n;
    
    for (int i = 1; i <= n; i++){
      if(i%3 != 0 && i%5 != 0) ans = ans + i;

    
    }
  cout <<  ans  << endl;
}

Measured memory_bytes: 3600
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): any => {
  const [a, b, c] = lines[0].split('').map(line => +line)
  const obj = { a, b, c }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { a, b, c } = parseLines(lines)
  return `${a + b + c}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int solve(const vector<int> &input) {
    vector<int> A(input);
    bool all02 = all_of(begin(A), end(A), [](int a) { return a == 0 || a == 2; });
    if (all02) {
        for (auto &a : A) if (a == 2) a = 1;
    } else {
        for (auto &a : A) if (a == 2) a = 0;
    }
    const int K = 1024;
    while (A.size() >= K) {
        vector<int> B(A.size() - K + 1);
        int x = 0;
        for (int i = 0; i < K - 1; i++) x ^= A[i];
        for (int i = 0; i < B.size(); i++) {
            B[i] = x ^ A[i + K - 1];
            x ^= A[i] ^ A[i + K - 1];
        }
        A.swap(B);
    }
    while (A.size() > 1) {
        for (int i = 0; i < A.size() - 1; i++) {
            A[i] = A[i] ^ A[i + 1];
        }
        A.resize(A.size() - 1);
    }
    if (all02 && A[0] == 1) return 2;
    return A[0];
}
int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (auto &a : A) { char c; cin >> c; a = c - '0' - 1; }
    cout << solve(A) << endl;
    return 0;
}

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

void insertionSort(int *A, int N);

int main()
{
	int N;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++)
		cin >> A[i];

	insertionSort(A, N);
	return 0;
}

void insertionSort(int *A, int N)
{
	int v;
	int j;

	for (int i = 0; i < N; i++) {
		cout << A[i];
		if (i != N-1)
			cout << ' ';
		else
			cout << '\n';
	}

	for (int i = 1; i <= N-1; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;

		for (int k = 0; k < N; k++) {
			cout << A[k];
			if (k != N-1)
				cout << ' ';
			else
				cout << '\n';
		}

	}


}


Measured memory_bytes: 3080
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };

    if s.chars().enumerate().all(|(i, x)| check(i, x)) {
        println!("Yes")
    } else {
        println!("No")
    }
}

fn check(i: usize, x: char) -> bool {
    if i % 2 == 0 {
        x == 'R' || x == 'U' || x == 'D'
    } else {
        x == 'L' || x == 'U' || x == 'D'
    }
}


Measured memory_bytes: 4352
from sys import stdin

N = int(stdin.readline().rstrip())

sosuu = [3, 5, 7, 11, 13]

if N < 105:
    print('0')
elif N < 135:
    print('1')
elif N < 165:
    print('2')
elif N < 189:
    print('3')
elif N < 195:
    print('4')
else:
    print('5')


Measured memory_bytes: 2940
#include<stdio.h>

int main(void){
  int N,count=0;
  int tmp=0;
  scanf("%d",&N);
  for(int n=1; n<=N; n++){
    for(int i=1; i<=N; i++){
      if(n*i>N){
        break;
      }
      if(N>n*i){
        count=count+1;
        //printf("%d \n",count);
      }
    }
  }
  printf("%d",count);
}

Measured memory_bytes: 1720
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

typedef pair<int, int> P;

long long n, a, b, c;
int s[110000];
int ans[110000];

int main(void) {
  cin >> n >> a >> b >> c;
  
  for (int i = 0; i < n; i++) {
    string p;
    cin >> p;
    if (p == "AB") s[i] = 0;
    if (p == "BC") s[i] = 1;
    if (p == "AC") s[i] = 2;
  }
  s[n] = 3;
  
  long long sm = a+b+c;
  
  if (sm == 0) {
    cout << "No" << endl;
    return 0;
  }
  
  if (sm == 1) {
    for (int i = 0; i < n; i++) {
      if (s[i] == 0 and c == 1 or s[i] == 1 and a == 1 or s[i] == 2 and b == 1) {
        cout << "No" << endl;
        return 0;
      }
      if (s[i] == 0) {
        swap(a, b);
      }
      if (s[i] == 1) {
        swap(b, c);
      }
      if (s[i] == 2) {
        swap(c, a);
      }
      
      if (a == 1) ans[i] = 0;
      if (b == 1) ans[i] = 1;
      if (c == 1) ans[i] = 2;
    }
  }
  
  if (sm >= 2) {
    if (a == sm and s[0] == 1 or b == sm and s[0] == 2 or c == sm and s[0] == 0) {
      cout << "No" << endl;
      return 0;
    }
    
    for (int i = 0; i < n; i++) {
      if (s[i] == 0) {
        if (a == 0) {
          b--; a++; ans[i] = 0;          
        } else if (b == 0 or s[i+1] == 1) {
          a--; b++; ans[i] = 1;
        } else {
          b--; a++; ans[i] = 0;
        }
      }
      if (s[i] == 1) {
        if (b == 0) {
          c--; b++; ans[i] = 1;
        } else if (c == 0 or s[i+1] == 2) {
          b--; c++; ans[i] = 2;
        } else {
          c--; b++; ans[i] = 1;
        }
      }
      if (s[i] == 2) {
        if (c == 0) {
          a--; c++; ans[i] = 2;
        } else if (a == 0 or s[i+1] == 0) {
          c--; a++; ans[i] = 0;
        } else {
          a--; c++; ans[i] = 2;
        }
      }
    }
  }
  
  cout << "Yes" << endl;
  for (int i = 0; i < n; i++) {
    cout << char('A'+ans[i]) << endl;
  }
  return 0;
}


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

typedef long long ll;

const int maxn = 100010;
int a[maxn], dpl[maxn], dpr[maxn];

int main() {
#ifdef HOME
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  dpl[0] = a[0];
  dpr[n - 1] = a[n - 1];
  for (int i = 1; i < n; ++i) {
    dpl[i] = __gcd(dpl[i - 1], a[i]);
  }
  for (int i = n - 2; i >= 0; --i) {
    dpr[i] = __gcd(dpr[i + 1], a[i]);
  }
  int ans = 0;
  for (int i = 1; i < n - 1; ++i) ans = max(ans, __gcd(dpl[i - 1], dpr[i + 1]));
  ans = max(ans, max(dpl[n - 2], dpr[1]));
  cout << ans;
  return 0;
}

Measured memory_bytes: 1408
//I-coin_dp
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define prDouble(x) cout<<fixed <<setprecision(10)<<x
#define triplet pair<ll,pair<ll,ll>>
using namespace std;

double dp[3001][3001];

double solve(vector<double>& ar,int i,int x) //it returns the prob when i coin is tossed and the number of heads is atleast x
{
    //base case
    if(x==0)
    return 1;
    if(i==0)
    return 0;
    if(dp[i][x] > -0.9)
       return dp[i][x];

    return dp[i][x]=ar[i]*solve(ar,i-1,x-1)+(1-ar[i])*solve(ar,i-1,x);


}

int main()
{
    int n;
    cin>>n;
    memset(dp,-1,sizeof dp);
    vector<double>ar(n+1);
    fr(1,n+1)
    cin>>ar[i];
    prDouble(solve(ar,n,(n+1)/2));
    return 0;

}

Measured memory_bytes: 70784
n = int(input())
graph = [[] for _ in range(n + 1)]

for i in range(n - 1):
    a, b, w = map(int, input().split())
    graph[a].append((b, w))
    graph[b].append((a, w))

que = [(1, 0)]

colors = [None] * (n + 1)
while que:
    now, color = que.pop(0)
    colors[now] = color

    for b, w in graph[now]:
        if colors[b] is not None:
            continue
        que.append((b, (color + (w & 1)) & 1))
print("\n".join(map(str, colors[1:])))


Measured memory_bytes: 45232
#include <stdio.h>
int main(int argc, char const *argv[]) {
  int a,b;
  scanf("%d %d",&a,&b);

  if(a<b){
    printf("a < b\n"); 
  }else if(a>b){
    printf("a > b\n");
  }else{
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int i = 0;
		int x = 0;
		Scanner sc= new Scanner(System.in);

		while( true ) {

			i++;

			x = sc.nextInt();

			if ( x == 0 ) break;

			System.out.println( "Case " + i + ": " + x );
		}
		sc.close();
	}
}


Measured memory_bytes: 41312
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int m = sc.nextInt();
	    int a[][] = new int[n][m];
	    int b[] = new int[m];
	    
	    for (int i = 0; i < n; i++){
	    	for (int j = 0; j < m; j++){
	    		a[i][j] = sc.nextInt();
	    	}
	    }
	    
	    for (int i = 0; i < m; i++){
	    	b[i] = sc.nextInt();
	    }
	    
	    for (int i = 0; i < n; i++){
		    int total = 0;
	    	for (int j = 0; j < m; j++){
	    		total += a[i][j] * b[j];
	    	}
	    	System.out.println(total);
	    }
	}
}

Measured memory_bytes: 31820
N, K = gets.split.map(&:to_i)

num_map = Hash.new(0)

N.times do
  a, b = gets.split.map(&:to_i)
  num_map[a] += b
end

num_count = 0
num_map.keys.sort.each do |num|
  if num_count + num_map[num] >= K
    puts num
    break
  end

  num_count += num_map[num]
end


Measured memory_bytes: 7304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

map<int, int> prime_factor(int n) {
  map<int, int> mp;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n > 1)
    mp[n]++;
  return mp;
}

const int MOD = 1e9+7;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 2; i <= n; i++) {
    auto tmp = prime_factor(i);
    for (auto e : tmp)
      mp[e.first] += e.second;
  }
  ll ans = 1;
  for (auto e : mp)
    ans = ans*(e.second+1)%MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//Ice Tea Store

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    ll q,h,s,d,n;cin>>q>>h>>s>>d>>n;
    q=4*q;h=2*h;
    ll ans;
    s=min(min(s,h),q);
    if(n%2==0){
        ans = min(n/2*d,s*n);
    }else{
        ans=min(n/2*d+s,s*n);
    }
    cout<<ans<<nnn;
    return 0;
}

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}


struct ft {
  vector<int> s;  //can also use map here
  ft(int n) : s(n) {}
  void update(int pos, int dif) { // a[pos] += dif
    for (; pos < (int)s.size(); pos |= pos + 1) s[pos] += dif;
  }
  int query(int pos) { // sum of values in [0, pos)
    int res = 0;
    for (; pos > 0; pos &= pos - 1) res += s[pos-1];
    return res;
  }
  int debug1() {
    debug(s);
  }
  /*
  int lower_bound(lli sum) {// min pos st sum of [0, pos] >= sum
    // returns n if no sum is >= sum, or -1 if empty sum is.
    if (sum <= 0) return -1;
    int pos = 0;
    for (int pw = 1 << 25; pw; pw >>= 1) {
      if (pos + pw <= sz(s) && s[pos + pw-1] < sum)
        pos += pw, sum -= s[pos-1];
    }
    return pos;
  }*/
};



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n; cin>>n;
  vi p(n);
  ft t(n+1);
  rep(i,0,n) cin>>p[i];
  lli ans = 0;
  rep(i,0,n) {
    if(t.query(p[i]) == 0)
    ans ++;
    debug(i - t.query(p[i]), i);
    t.update(p[i], 1);
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout<<fixed<<setprecision(5);
    double r;
    cin>>r;
    cout<<2*3.14*r;
    return 0;
}

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

int main(){
  int N, X;
  cin >> N >> X;
  
  int count=0;
  int min_m=1000;;
  for(int i=0; i<N; i++){
    int m;
    cin >> m;
    X-=m;
    count++;
    if(m<min_m)
      min_m=m;
  }
  count+=X/min_m;
  cout << count << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

typedef vector<pii> vp;


vp trail;

int r,c,m;
int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
bool dfs(int cx,int cy,int tx,int ty,vp &t,vs &field,vvi &visited){
	visited[cy][cx]=1;
	if(cx==tx&&cy==ty){
		REP(i,t.size()){
			trail.push_back(t[i]);
		}
		return true;
	}
	REP(i,4){
		int x=cx+dx[i],y=cy+dy[i];
		if(x<0||y<0||x>=c||y>=r||field[y][x]=='#'||visited[y][x]){
			continue;
		}
		vp nt(t);
		nt.push_back(make_pair(y,x));
		if(dfs(x,y,tx,ty,nt,field,visited))return true;
	}
	return false;
}

int main(){
	cin>>r>>c>>m;
	vs field(r);
	REP(i,r){
		cin>>field[i];
	}
	vvi con(r,vi(c));
	vvi on(r,vi(c));
	vvi off(r,vi(c));

	REP(i,r)REP(j,c){
		cin>>con[i][j];
	}
	REP(i,r)REP(j,c){
		cin>>on[i][j];
	}
	REP(i,r)REP(j,c){
		cin>>off[i][j];
	}

	vp tasks(m);
	REP(i,m){
		cin>>tasks[i].first>>tasks[i].second;
	}


	vvi last(r,vi(c,-1));
	int cost=0;
	int turn=0;
	FOR(i,1,m){
		vvi visited(r,vi(c));
		vp t;
		if(i==1){
			t.push_back(tasks[i-1]);
		}
		dfs(tasks[i-1].second,tasks[i-1].first,tasks[i].second,tasks[i].first,t,field,visited);
		REP(i,trail.size()){
			int y=trail[i].first,x=trail[i].second;
			if(last[y][x]==-1){
				cost+=on[y][x];
			}else if((turn-last[y][x])*con[y][x]<on[y][x]+off[y][x]){
				cost+=(turn-last[y][x])*con[y][x];
			}else{
				cost+=on[y][x]+off[y][x];
			}
			last[y][x]=turn;
			turn++;
		}
		trail.clear();
	}
	REP(y,r)REP(x,c){
		if(last[y][x]!=-1){
			cost+=off[y][x];
		}
	}
	cout<<cost<<endl;


}

Measured memory_bytes: 15000
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

bool dfs(string s){
  int res = 0;
  if(!s.size()) return 1;
  if(s[0] != 'm' || s[s.size()-1] != 'w') return 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] != 'e') continue;
    string a = s.substr(1, i-1);
    string b = s.substr(i+1); b.erase(b.end()-1);
    if(dfs(a) && dfs(b)) return 1;
  }
  return 0;
}

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

  while(1){
    if(s.empty()){
      puts("Cat");
      break;
    }

    string::size_type p = s.find("mew");
    if(p == string::npos){
      puts("Rabbit");
      break;
    }else{
      if(!(s.size() == 3 || (s[p-1] == 'm' && s[p+3] == 'e') || (s[p-1] == 'e' && s[p+3] == 'w'))){
      puts("Rabbit");
      break;
      }
      s.erase(p, 3);
    }
  }
  return 0;
}

Measured memory_bytes: 1200
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        list.add(a+b);
        list.add(a-b);
        list.add(a*b);
        Collections.sort(list);
        System.out.println(list.get(2));
    }
}

Measured memory_bytes: 35820
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;

//辺の重みも設定できるグラフ
//to , weight の順
vector<vector<pair<ll, ll > > > G;
vector<ll > ans;

void dfs(ll idx, ll from = -1){

    for(ll i = 0; i < G[idx].size(); i++){
        //次の行き先は？
        ll to = G[idx][i].first;
        //同じだったらもう処理しない
        //頂点に戻ってきたら
        if(to == from){
            continue;
        }

        if(G[idx][i].second % 2 == 0){
            ans[to] = ans[idx];
        }else{
            ans[to] = 1 - ans[idx];
        }

        dfs(to, idx);

    }
}

int main(){

    ll N;
    cin >> N;
    
    //初期化
    G.assign(N, vector<pair<ll, ll > >());
    ans.assign(N, 0);

    //ans[0] = 0;

    //グラフ入力
    for(ll i = 0; i < N-1; i++){
        ll u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        //双方向に貼りましょうね
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }

    //伝搬実行
    dfs(0);
    for(ll i = 0; i < N; i++){
        cout << ans[i] << endl;;
    }

}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
#if __has_include("debug.h")
#include "debug.h"
#endif
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (ll i = a; i < b; ++i)
#define rep_(i, a, b) for (ll i = a; i > b; --i)
#define endl '\n'

const ll maxn = 2e5 + 5;

// -------------- Arithmetic --------------
const ll mod = 998244353;

ll power(ll x, ll y, ll m) {
	ll ans = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0) {
		if (y & 1) ans = (ans * x) % m;
		y = y >> 1;
		x = (x * x) % m;
	}
	return ans;
}

ll mod_inv(ll a) {return power(a, mod - 2, mod);}

ll add(ll a, ll b) {return (((a + b) % mod) + mod) % mod;}
ll sub(ll a, ll b) {return (((a - b) % mod) + mod) % mod;}
ll mul(ll a, ll b) {return (((a * b) % mod) + mod) % mod;}
ll div(ll a, ll b) {return mul(a, mod_inv(b));}

// -------------- Code --------------

ll n, q;
ll lazy[4 * maxn] = {}, seg[4 * maxn] = {}, ones[maxn], power10[maxn];

ll get(ll l, ll r, ll d) {
	return mul(d, mul(ones[r - l + 1], power10[n - r]));
}

void update(ll p, ll l, ll r, ll lu, ll ru, ll d) {
	if (lazy[p] != 0) { 
	    seg[p] = get(l, r, lazy[p]);
	    if (l != r) {
	        lazy[p * 2] = lazy[p];
	        lazy[p * 2 + 1] = lazy[p];
	    } 
	    lazy[p] = 0;
	}
	if (l > r || l > ru || r < lu) return;

	// Current segment is fully in range
	if (l >= lu && r <= ru) {
	    // Add the difference to current node
	    seg[p] = get(l, r, d);
	    if (l != r) {
	        lazy[p * 2] = d;
	        lazy[p * 2 + 1] = d;
	    }
	    return;
	} 

	ll mid = (l + r)/2; 
	update(2 * p, l, mid, lu, ru, d); 
	update(2 * p + 1, mid + 1, r, lu, ru, d);

	seg[p] = add(seg[2 * p], seg[2 * p + 1]);
}

void solve() {
	cin >> n >> q;
	update(1, 1, n, 1, n, 1);
	rep(i, 0, q) {
		ll l, r, d;
		cin >> l >> r >> d;
		update(1, 1, n, l, r, d);
		cout << seg[1] << endl;
	}
}

void aux() {
	ones[0] = 0;
	power10[0] = 1;
	rep(i, 1, maxn) {
		power10[i] = mul(power10[i - 1], 10);
		ones[i] = add(power10[i - 1], ones[i - 1]);
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);
	aux();
	ll _ = 1;
	// cin >> _;
	while(_--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 14984
#include<cstdio>
using namespace std;

int main()
{
	long long x, y;
	int i;
	scanf("%lld %lld", &x, &y);
	for( i = 1;; i++)
	{
		x = x * 2;
		if(x > y)
			break;
	}
	printf("%d\n", i);
}

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

int main(void){
    int N;
    int x[MAX+5],y[MAX+5],t[MAX+5];
    bool flag = true;
    
    cin >> N;

    x[0] = y[0] = t[0] = 0;

    rep(i, N)
        cin >> t[i+1] >> x[i+1] >> y[i+1];

    rep(i,N){
        int dist = abs(x[i+1]-x[i])+ abs(y[i+1]-y[i]);
        int dt = t[i+1] -t[i];

        if (dist > dt || dist % 2 != dt % 2)
            flag = false;
    }
    
    if(flag)
        cout << "Yes" << endl;

    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 4772
D = [[-1,0],[0,1],[1,0],[0,-1]]
def s(N):
    used = [[False]*N+[True] for _ in xrange(N)]+[[True]*(N+1)]
    ret = [[" "]*N for _ in xrange(N)]
    q = [(0,N-1,0)]
    used[N-1][0] = used[N-1][1] = True
    while len(q) != 0:
        d,y,x = q.pop(0)
        ret[y][x] = "#"
        sy,sx = D[d]
        ry,rx = D[(d+1)%4]
        if not used[y+sy][x+sx]:
            q.append((d,y+sy,x+sx))
            used[y+sy][x+sx] = used[y+ry][x+rx] = True
        elif not used[y+ry][x+rx]:
            q.append(((d+1)%4,y+ry,x+rx))
            used[y+ry][x+rx] = True
    return ret

n = input()
while True:
    n -= 1
    N = input()    
    print "\n".join(map(lambda a:"".join(a),s(N)))
    if n == 0:
        break
    print

Measured memory_bytes: 4308
dai=list(map(int,input().split()))

# dai[0] 上 
# dai[1] 前 
# dai[2] 右
# dai[3] 左
# dai[4] 後
# dai[5] 下

def zenten():
	dai0 = dai[0]
	dai[0] = dai[4]
	dai[4] = dai[5]
	dai[5] = dai[1]
	dai[1] = dai0

def tokei():
	dai1 = dai[1]
	dai[1] = dai[2]
	dai[2] = dai[4]
	dai[4] = dai[3]
	dai[3] = dai1
	
n=int(input())

def check():
	for j in range(4):
		if a == dai[0] and b == dai[1]:
			print(dai[2])
			return True
		tokei()
	return False

for m in range(n):
	a,b=map(int,input().split())
	# a 上の番号
	# b 前の番号
	if not check():# 0
		zenten()
		if not check(): # 4
			zenten()
			if not check(): # 5
				zenten()
				if not check(): # 1
					tokei()
					zenten()
					if not check(): # 3
						zenten()
						zenten()
						if not check(): #2
							print("ERROR")



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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()

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

const long long INF = 1LL << 60;

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

    bool flag = true;
    rep(i, S.size()) {
        if (i % 2 == 0) {
            if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {
                flag = true;
            }
            else {
                flag = false;
                break;
            }
        }
        else {
            if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {
                flag = true;
            }
            else {
                flag = false;
                break;
            }
        }
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n,m,q = map(int, input().split())
List1 = [[0 for i in range(n+1)] for j in range(n+1)]
List2 = [[0 for i in range(n+1)] for j in range(n+1)]

for i in range(m):
  l,r = map(int, input().split())
  List1[l - 1][r - 1] += 1


for i in range(n):
  for j in range(n - i):
    List2[j][j + i] = List2[j + 1][j + i] + List2[j][j + i - 1] - List2[j + 1][j + i - 1] + List1[j][j + i]


for i in range(q):
  a, b = map(int, input().split())
  print(List2[a - 1][b - 1])

Measured memory_bytes: 11576