akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.D_Challenge
{
    class ABC_069
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] hw = ReadInts();
            int n = ReadInt();
            int[] array = ReadInts();
            var colors = new int[n][];
            for (int i = 0; i < n; i++)
            {
                colors[i] = new int[2] { array[i], i };
            }
            Array.Sort(colors, (a, b) => a[0] - b[0]);
            var grid = new int[hw[0], hw[1]];
            bool forward = true;
            int x = 0;
            int y = 0;
            for (int i = 0; i < n; i++)
            {
                //Console.WriteLine(colors[i][0]);
                for (int j = 0; j < colors[i][0]; j++)
                {
                    grid[y, x] = colors[i][1] + 1;
                    x = forward ? x + 1 : x - 1;
                    if (forward && x == hw[1])
                    {
                        forward = false;
                        x--;
                        y++;
                    }
                    else if (!forward && x == -1)
                    {
                        forward = true;
                        x++;
                        y++;
                    }
                }
            }

            for (int i = 0; i < hw[0]; i++)
            {
                for (int j = 0; j < hw[1]; j++)
                {
                    Console.Write(grid[i, j] + " ");
                }
                Console.WriteLine();
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268
#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 x,a,b; cin>>x>>a>>b;
  cout <<(x-a)%b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    if(x > y)
    {
        cout << min(min(c * 2 * max(x,y),a * x + b * y),(c * 2 * y + a * (x - y)));
    }
    else
    {
        cout << min(min(c * 2 * max(x,y),a * x + b * y),(c * 2 * x + b * (y - x)));
    }
    
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations_with_replacement
n,m,q=map(int,input().split())
l=list(combinations_with_replacement(range(1,m+1),n))

res=0
lt=[list(map(int,input().split())) for _ in range(q)]

for j in range(len(l)):
    tmp=0
    for i in range(len(lt)):
        a,b,c,d = lt[i][0],lt[i][1],lt[i][2],lt[i][3]
        if l[j][b-1]-l[j][a-1] == c:
            tmp += d
    res=max(tmp,res)

print(res)


Measured memory_bytes: 84480
s = input()
a = int(s[0:2])
b = int(s[2:4])

if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
elif (a == 0 or 12 < a < 100) and (b == 0 or 12 < b < 100):
    print("NA")
elif (a == 0 or 12 < a < 100) and 1 <= b <= 12:
    print("YYMM")
else:
    print("MMYY")

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

const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
const int SIZE = 31;
const int INF = 1<<27;

int G[SIZE][SIZE], C[4];
int H, W;

class State {
public:
  int x, y, d, cost;
  State() {}
  State(int x, int y, int d, int cost) : x(x), y(y), d(d), cost(cost) {}
  bool operator<(const State &s) const {
    return cost>s.cost;
  }
};

int solve() {
  int cost[4][SIZE][SIZE];
  priority_queue<State> pq;
  pq.push(State(0,0,0,0));
  fill(cost[0][0], cost[4][0], INF);
  cost[0][0][0] = 0;
  while(!pq.empty()) {
    const State s = pq.top(); pq.pop();
    if(cost[s.d][s.y][s.x] < s.cost) continue;
    if(s.x == W-1 && s.y == H-1) return s.cost;
    for(int i=0; i<4; i++) {
      State t = s;
      t.cost += ( G[s.y][s.x] == i ? 0 : C[i] );
      t.d = (s.d + i) % 4;
      t.x += dx[t.d], t.y += dy[t.d];
      if(0 <= t.x && t.x < W 
	 && 0 <= t.y && t.y < H 
	 && cost[t.d][t.y][t.x] > t.cost) {
	pq.push(t);
	cost[t.d][t.y][t.x] = t.cost;
      }
    }
  }
  
  return INF;
}

int main() {
  while(cin >> W >> H, W+H) {
    for(int i=0; i<H; i++)
      for(int j=0; j<W; j++)
	cin >> G[i][j];
    
    for(int i=0; i<4; i++) cin >> C[i];
    
    cout << solve() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1328
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            C();
        }

        static void C()
        {
            var NW = ReadSplitInt();
            var N = NW[0];
            var W = NW[1];
            var v = new long[N];
            var w = new long[N];
            var dp = new long[N+1, W+1];
            for (var i = 0; i < N; i++)
            {
                var wv = ReadSplitLong();
                w[i] = wv[0];
                v[i] = wv[1];
            }

            for (int i = 0; i < N; i++)
            {
                for (int sum_w = 0; sum_w <= W; sum_w++)
                {
                    if (sum_w - w[i] >= 0)
                    {
                        dp[i + 1, sum_w] = Max(dp[i + 1, sum_w], dp[i, sum_w - w[i]] + v[i]);
                    }

                    dp[i + 1, sum_w] = Max(dp[i + 1, sum_w], dp[i, sum_w]);
                }
            }

            Println(dp[N, W]);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 89056
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main {
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		//InputStream in = new FileInputStream("src/input.txt");
		InputStream in = System.in;

		sc = new Scanner(in);

		int N = sc.nextInt();

		long[] L = new long[N+1];

		L[0] = 2;
		L[1] = 1;
		for(int i = 2; i <= N; i++){
			L[i] = L[i-2] + L[i-1];
		}
		System.out.println(L[N]);
	}
}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
    private static int nCombination3(int[] list,int aim) {
        int count = list.length;
        int num = 0;
        int ans=0;
        int ansNum=0;
        for (int i = 0; i < count - 2; i++) {
            for (int j = i + 1; j < count - 1; j++) {
                for (int k = j + 1; k < count; k++) {
                    num++;
                    ans = list[i]+list[j]+list[k];
                    if(ans == aim)ansNum++;
                }
            }
        }
        return ansNum;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = 0;
        int x = 0;
        int[] A;
        int[] ans;
        ans = new int[50];
        int i = 0;
        while (true) {
            n = scan.nextInt();
            if (n == 0)
                break;
            A = new int[n];
            for (int k = 0; k < n; k++) {
                A[k] = k + 1;
            }
            x = scan.nextInt();
            ans[i] = nCombination3(A,x);
            i++;
        }
        for (int j = 0; j < i; j++) {
            System.out.println(ans[j]);
        }
        return;
    }
}


Measured memory_bytes: 26796
#include<bits/stdc++.h>
using namespace std;
int N,K;
int main () {
    cin >> N >> K;
    double ans = 0;
    for(int i=1; i<=N; i++) {
        double p = (double)1/N;
        for(int j=i; j<K; j*=2) p*=0.5;
        ans += p;
    }
    printf("%.12f\n",ans);
    return 0;
}

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

int main(){
  int n,a[100];
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int p=0;p<n-1-p;p++)
      swap(a[p],a[n-1-p]);
  for(int l=0;l<n;l++){
    cout<<a[l];
    if(l==n-1) break;
    cout<<" ";
    }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  if(a == "H" && b == "H"){
    cout << "H" << endl;
  }
  else if(a == "D" && b == "D"){
    cout << "H" << endl;
  }
  else{
    cout << "D" << endl;
  }
} 

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	LLI n, m, k;
	cin >> n >> m >> k;
	vector<LLI> a(n + 1), b(m + 1);


	LLI sum = 0;

	REP(i, n)
	{
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	REP(i, m)
	{
		cin >> b[i + 1];
		b[i + 1] += b[i];
	}

	LLI ia = 0, ib = 0;

	while (ia < n && a[ia + 1] <= k)
	{
		ia++;
	}

	while (ib < m && a[ia] + b[ib + 1] <= k)
	{
		ib++;
	}


	LLI ans = ia + ib;
	while (0 <= --ia)
	{
		while (ib < m && a[ia] + b[ib + 1] <= k)
		{
			ib++;
		}
		chmax(ans, ia + ib);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 6420
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	int ans = 1,s=a[0];
	for (int i = 1; i < n; i++) {
		if (s <= a[i]) {
			ans++;
			s = max(s, a[i]);
		}
	}
	cout << ans << endl;
	return 0;
}










Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef pair<int, int> pii;
int dx[]={0, 0, 1, -1};
int dy[]={1, -1, 0, 0};
char fld[20][21];
int used[20][20];
int W, H;

void rec(int i, int j){
   used[i][j]=1;
   for(int k=0; k<4; k++){
      int ni=i+dy[k];
      int nj=j+dx[k];
      if(0<=ni&&ni<H&&0<=nj&&nj<W&&fld[ni][nj]!='#'&&used[ni][nj]==0){
         rec(ni, nj);
      }
   }
}

int main(){

   while(1){
      cin>> W>> H;
      if(!(H||W)) break;
      int sx, sy;
      for(int i=0; i<H; i++){
         for(int j=0; j<W; j++){
            cin>> fld[i][j];
            if(fld[i][j]=='@'){
               sy=i;
               sx=j;
            }
         }
      }

      for(int i=0; i<20; i++)for(int j=0; j<20; j++) used[i][j]=0;
      used[sy][sx]=1;
      rec(sy, sx);
      int ans=0;
      for(int i=0; i<H; i++)for(int j=0; j<W; j++){
         ans+=used[i][j];
      }
      cout<< ans<< endl;

   }

   return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int N, D;
    cin >> N >> D;
    D = D * 2 + 1;
    cout << (N + D - 1) / D << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int ans = N % 10;
    if (ans == 3)
    {
        cout << "bon" << endl;
    }
    else if (ans == 0 || ans == 1 || ans == 6 || ans == 8)
        cout << "pon" << endl;
    else
    {
        cout << "hon" << endl;
    }
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    int n;
    cin>>n;
    vector<long long>A(n);
    rep(i,n){
        cin>>A[i];
    }
    rep(i,n)A[i]=-A[i];
    multiset<long long>color;
    color.emplace(1);
    rep(i,n){
    auto it=color.upper_bound(A[i]);
        if(it!=color.end()){
        color.erase(it);
        color.emplace(A[i]);
        }
        else{
        color.emplace(A[i]);
        }
    }
    cout<<color.size()<<endl;
    
    return 0;

}
/*


*/


Measured memory_bytes: 5760
//https://blog.csdn.net/hesorchen
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define endl "\n"
#define lowbit(a) (a & (-a))
#define INF 0x3f3f3f3f
#define MAX 1010
#define mod 1000000007
#define PI 3.1415926

int p[100010];
int ans[100010];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> p[i];
    int temp = p[n];
    for (int i = 1; i < n; i++)
    {
        if (i & 1)
            temp -= p[i];
        else
            temp += p[i];
    }
    ans[n] = temp;
    for (int i = n - 1; i >= 1; i--)
        ans[i] += 2 * p[i] - ans[i + 1];
    for (int i = 1; i < n; i++)
        cout << ans[i] << ' ';
    cout << ans[n] << endl;

    return 0;
}

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

int main(){
  int i,j,cnt;
  int n,k;
  cin>>n>>k;
  int h[n];
  for(i=0;i<n;i++)cin>>h[i];
  sort(h,h+n);
  int mi=INT_MAX;
  for(i=0;i<n-k+1;i++){
    mi=min(mi,h[i+k-1]-h[i]);
  }
  cout<<mi;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

#include <bits/stdc++.h>
using namespace std;

void init()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int n, m;
    cin >> n >> m;
    vector<vector<int>> d(m, vector<int>(2));
    rep(i, m)
    {
        rep(j, 2)
        {
            cin >> d[i][j];
        }
    }

    vector<vector<int>> link(n + 1);
    rep(i, m)
    {
        link[d[i][0]].push_back(d[i][1]);
        link[d[i][1]].push_back(d[i][0]);
    }

    vector<int> heya_f(n + 1, 0);
    heya_f[1] = 1;
    queue<int> q;
    q.push(1);
    int count = 0;
    int flag = 0;
    while (q.empty() != true){
        for (int x : link[q.front()]){
            if (heya_f[x] == 0){
                heya_f[x] = q.front();
                q.push(x);
                count++;
                if (count == n - 1){
                    flag = 1;
                    break;
                }
            }
        }
        if (flag == 1)
            break;
        q.pop();
    }

    if (flag == 0){
        cout << "No" << endl;
    }else if (flag == 1){
        cout << "Yes" << endl;
        rep(i, n - 1){
            cout << heya_f[i + 2] << endl;
        }
    }
}


Measured memory_bytes: 21084
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    int n, k;
    cin >> n >> k;
    ll sum = 0;
    vector<ll> v;
    for(int i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        v.push_back(a);
        sum += a;

    }
    sort(v.rbegin(), v.rend());
    for(int i = 0; i < min(k, n); i++)
        sum -= v[i];
    cout << sum;
    return 0;
}


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

const int MAX_N = 1 << 17;

struct MinSegTree3 {
	int n;
	struct S {
		bool flag;
		int dat;
		S() : dat((1LL << 31) - 1), flag(false) {}
	};

	S node[2 * MAX_N - 1];
	void init(int n_) {
		n = 1;
		while(n < n_) n *= 2;
	}

	void propagate(int k, int level) {
		if(!node[k].flag) return;
		node[k].flag = false;
		if(2 * k + 1 < 2 * n - 1) {
			S& t = node[k];
			S& l = node[2 * k + 1];
			S& r = node[2 * k + 2];
			l.flag = r.flag = true;
			l.dat = r.dat = t.dat;
		}
	}

	void update(int a, int b, int x) { update(a, b, x, 0, 0, 0, n); }

	void update(int a, int b, int x, int level, int k, int l, int r) {
		propagate(k, level);
		if(r <= a || b <= l) return;
		if(a <= l && r <= b) {
			node[k].dat = x;
			node[k].flag = true;
			propagate(k, level);
			return;
		}
		update(a, b, x, level + 1, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, level + 1, k * 2 + 2, (l + r) / 2, r);
		// merge
		node[k].dat = min(node[2 * k + 1].dat, node[2 * k + 2].dat);
	}

	int query(int a, int b) { return query(a, b, 0, 0, 0, n); }

	int query(int a, int b, int level, int k, int l, int r) {
		propagate(k, level);
		if(r <= a || b <= l) return (1LL << 31) - 1;
		if(a <= l && r <= b) return node[k].dat;
		int vl = query(a, b, level + 1, k * 2 + 1, l, (l + r) / 2);
		int vr = query(a, b, level + 1, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};

MinSegTree3 st;

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

	int n, q;
	cin >> n >> q;
	st.init(n);

	while(q--) {
		int a, s, t, x;
		cin >> a;
		if(a == 0) {
			cin >> s >> t >> x;
			st.update(s, t + 1, x);
		}
		else {
			cin >> s >> t;
			cout << st.query(s, t + 1) << endl;
		}
	}
}

Measured memory_bytes: 5220
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

int n,bl;
char ch[maxn],a[] = "keyence",b[maxn];
int fail[maxn];

inline int cmp(int l1,int r1,int l2,int r2){
	int id = 0;
	rep(i,l1,r1){
	   	if ( a[id] != ch[i] ) return 0;
		id++;
	}
	rep(i,l2,r2){
	   	if ( a[id] != ch[i] ) return 0;
		id++;
	}
	return 1;
}
int main(){
	scanf("%s",ch + 1);
	n = strlen(ch + 1);
	rep(i,1,8){
		if ( cmp(1,i - 1,n + i - 7,n) ){
			bl = 1;
			break;
		}
	}
	if ( bl )	puts("YES");
	else 	puts("NO");
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define MAXN 100100
using namespace std;
int n,k;
int a[MAXN];
int e[MAXN]={};
int p[MAXN];
int tot=0;
int ans=1;
inline void check(int P)
{
	for (int i=1;i<=n;i++) p[i]=(a[i]%P);
	sort(p+1,p+n+1);
//	printf("P::%d\n",P);
//	for (int i=1;i<=n;i++) printf("%d",p[i]);
//	printf("\n");
	for (int i=1;i<=n;i++) p[i]+=p[i-1];
	
	
	
	for (int i=0,l,r;i<=n;i++)
	{
		l=p[i]; r=(P*(n-i))-(p[n]-p[i]); 
//		printf("lll:%d rrr:%d\n",p[i],p[n]-p[i-1]);
//		printf("L:%d   R:%d\n",l,r);
		if (l==r&&l<=k)
		{
			ans=max(ans,P);
			return;
		}
	}
}

int main()
{
	scanf("%d%d",&n,&k);
	int sum=0;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	int len=sqrt(sum);
	for (int i=1;i<=len;i++) if (!(sum%i)) e[++tot]=i,e[++tot]=sum/i;
	for (int i=1;i<=tot;i++) /*printf("%d ",e[i]),*/check(e[i]);// printf("\n");
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int res = 0;

	int n = 0;
	cin >> n;

	int* v = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}

	int* c = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
	}

	for (int i = 0; i < n; i++)
	{
		if (v[i] > c[i])
		{
			res += v[i] - c[i];
		}
	}

	cout << res;

	return 0;
}


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

int main() {
   int n,c=0;
    cin >> n;
    
       
       for(int i=1;i<=9;i++)
        {
            for(int j=1;j<=9;j++)
                {
                   if(n==(i*j))
                    { 
                        c=1;
                        break;
                    }
                }
                if(c==1)
                    {
                        break;
                    }
        }
                if(c==0)
                    {
                        cout << "No";
                    }
                    if(c==1)
                        {
                             cout << "Yes";
                        }
        
        return 0;
        
}

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

int main() {
  int x, y;
  cin >> x >> y;
  for (int i = 0; i <= x; i++) {
    if (i * 2 + (x - i) * 4 == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3600
import math
class SegmentTree:
    __slots__ = ["elem_size", "tree_size", "tree", "default", "op"]

    def __init__(self, a: list, default: int, op):
        real_size = len(a)
        self.elem_size = 1 << math.ceil(math.log2(real_size))
        self.tree_size = 2 * self.elem_size
        self.tree = [default] * self.elem_size + a + [default] * (self.elem_size - real_size)
        self.default = default
        self.op = op
        self.init_tree(op)

    def init_tree(self, op) -> None:
        tree = self.tree
        for i in range(self.elem_size - 1, 0, -1):
            left, right = tree[i << 1], tree[(i << 1) + 1]
            # ===== change me =====
            tree[i] = op(left, right)

    def get_value(self, x: int, y: int):
        l, r = x + self.elem_size, y + self.elem_size
        tree, result = self.tree, self.default
        while l < r:
            if l & 1:
                # ===== change me =====
                result = self.op(tree[l], result)
                l += 1
            if r & 1:
                r -= 1
                # ===== change me =====
                result = self.op(tree[r], result)
            l, r = l >> 1, r >> 1

        return result

    def set_value(self, i: int, value: int, op: str = "="):
        tree = self.tree
        k = self.elem_size + i
        if op == "=":
            tree[k] = value
        elif op == "+":
            tree[k] += value
        elif op == "?":
            # ===== change me =====
            tree[k] = value if value < tree[k] else tree[k]

        while k > 1:
            k >>= 1
            left, right = tree[k << 1], tree[(k << 1) + 1]
            # ===== change me =====
            tree[k] = self.op(left, right)

import sys
n, q = map(int, input().split())
tree = SegmentTree([2**31-1]*n, 2**31-1, min)
ans = []
append = ans.append
for com, x, y in (map(int, l.split()) for l in sys.stdin.readlines()):
    if com == 0:
        tree.set_value(x, y)
    else:
        append(tree.get_value(x, y+1))
print(*ans, sep="\n")


Measured memory_bytes: 16364
// Problem : C - Switches
// Contest : AtCoder - AtCoder Beginner Contest 128
// URL : https://atcoder.jp/contests/abc128/tasks/abc128_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
vector<ll> p;
vector<ll> adj[11];
ll n,m;
ll check(ll x)
{
	ll turnon=0;
	for(ll i=0;i<m;i++)
	{
		ll on=0;
		for(auto j:adj[i])
		{
			if(x & (1<<(j-1)))
			{
				on++;
			}
		}
		if(on%2 == p[i])
		{
			turnon++;
		}
	}
	if(turnon==m)
		return 1;
	return 0;
}
void solve()
{
    cin>>n>>m;
    ll k;
    ll x;
    p.resize(m);
    for(ll i=0;i<m;i++)
    {
    	cin>>k;
    	rep(j,0,k)
    	{
    		cin>>x;
    		adj[i].pb(x);
    	}
    }
    rep(i,0,m)
    {
    	cin>>p[i];
    }
    ll cnt=0;
    for(ll i=0;i<(1<<n);i++)
    {
    	if(check(i))
    		cnt++;
    }
    cout<<cnt;
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

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

int main() {

    ll x, y, a, b, c; cin >> x >> y >> a >> b >> c;
    vector<ll> p_(a), q_(b);
    for (ll i = 0; i < a; i++) {
        cin >> p_[i];
    }
    for (ll i = 0; i < b; i++) {
        cin >> q_[i];
    }
    vector<pair<ll, string>> pa;
    sort(p_.rbegin(), p_.rend());
    for (ll i = 0; i < x; i++) {
        pa.push_back({ p_[i], "red" });
    }
    sort(q_.rbegin(), q_.rend());
    for (ll i = 0; i < y; i++) {
        pa.push_back({ q_[i], "green" });
    }
    for (ll i = 0; i < c; i++) {
        ll r; cin >> r;
        pa.push_back({ r,"non" });
    }
    sort(pa.rbegin(), pa.rend());
    ll ans = 0;
    for (ll i = 0; i < x + y; i++) {        
            ans += pa[i].first;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 25544
import sys
input = sys.stdin.readline
from collections import *

S = input()[:-1]
cnt = defaultdict(int)
cnt[0] = 1
now = 0
ans = 0

for i in range(len(S)-1, -1, -1):
    now = (int(S[i])*pow(10, len(S)-1-i, 2019)+now)%2019
    ans += cnt[now]
    cnt[now] += 1

print(ans)

Measured memory_bytes: 69244
#include<stdio.h>
#define max 10000
main(){
  int i,j,n1,n2,f[max],s[max],count=0;
  scanf("%d",&n1);
  for(i=0;i<n1;i++)
    scanf("%d",&f[i]);
  scanf("%d",&n2);
  for(i=0;i<n2;i++)
    scanf("%d",&s[i]);
  for(i=0;i<n2;i++)
    for(j=0;j<n1;j++)
      if(f[j]==s[i]){
	count++;
	break;
      }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    int m = 0 , h;
    for(int i = 0; i < n; i++){
        cin >> h;
        if(h <= m - 2){
            cout << "No" << endl;
            return 0;
        }
        m = max(m , h);
    }
  
    cout << "Yes" << endl;
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 200000000
#define MOD 1000000007
#define PI 3.1415926536
typedef long long ll;
typedef pair<int, int> P;

int main() {
	int N, M;
	int dist[100][100], G[1001][3];
	cin >> N >> M;
	rep(i, N)rep(j, N) {
		dist[i][j] = (i == j ? 0 : INF);
	}
	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		dist[a][b] = c;
		dist[b][a] = c;
		G[i][0] = a;
		G[i][1] = b;
		G[i][2] = c;
	}
	rep(i, N)rep(j, N)rep(k, N) {
		dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
	}

	int ans = 0;
	rep(i, M) {
		if (dist[G[i][0]][G[i][1]] != G[i][2])ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import math

a, b, c, d = map(int, input().split())

gcd = (c * d) // math.gcd(c, d)

r = b // c + b // d - b // gcd
l = (a - 1) // c + (a - 1) // d - (a - 1) // gcd

print((b - a) - (r - l) + 1)


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

#define ll long long
#define endl '\n'

void max_self(int &a, int b){ a = max(a, b);}
void min_self(int &a, int b){ a = min(a, b);}

void solve(){
	string s; cin>>s;
	int cnt = 0, ans = 0;
	for(int i = 0; i<3; i++){
		if(s[i] == 'R') cnt++;
		else cnt = 0;
		max_self(ans, cnt);
	}
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	for(int i = 1; i<=t; i++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  string K;
  ll D;
  cin >> K >> D;
  ll N = K.size();

  vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(D, vector<ll>(2, 0)));
  dp.at(0).at(0).at(0) = 1;
  for (ll i = 0; i < N; i++)
  {
    for (ll j = 0; j < D; j++)
    {
      for (ll k = 0; k < 10; k++)
      {
        ll nj = (j + k) % D;

        // 0: i 桁目の数字が, K の i 桁目を越えてはいけない
        if (k == myctoi(K.at(i)))
        {
          dp.at(i + 1).at(nj).at(0) += dp.at(i).at(j).at(0);
          dp.at(i + 1).at(nj).at(0) %= MOD;
        }
        if (k < myctoi(K.at(i)))
        {
          dp.at(i + 1).at(nj).at(1) += dp.at(i).at(j).at(0);
          dp.at(i + 1).at(nj).at(1) %= MOD;
        }

        // 1: i 桁目の数字が, K の i 桁目を越えてもよい
        dp.at(i + 1).at(nj).at(1) += dp.at(i).at(j).at(1);
        dp.at(i + 1).at(nj).at(1) %= MOD;
      }
    }
  }

  /*
  for (ll i = 0; i < N + 1; i++)
  {
    for (ll j = 0; j < D; j++)
    {
      cerr << dp.at(i).at(j).at(0) << " ";
    }
    cerr << endl;
  }
  cerr << endl;
  for (ll i = 0; i < N + 1; i++)
  {
    for (ll j = 0; j < D; j++)
    {
      cerr << dp.at(i).at(j).at(1) << " ";
    }
    cerr << endl;
  }
  */

  ll ans = (dp.at(N).at(0).at(0) + dp.at(N).at(0).at(1) + MOD - 1) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 55296
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll N;
  ll x;
  cin >> N >> x;
  
  vll a(N);
  rep(i, N) {
    cin >> a[i];
  }
  
  ll ct = 0;
  rep(i, N - 1) {
    if(a[i] + a[i+1] > x) {
      if(a[i] > x) {
        ct += a[i] - x;
        a[i] = x;
        ct += a[i+1];
        a[i+1] = 0;
      } else {
        ct += a[i] + a[i+1] - x;
        a[i+1] -= a[i] + a[i+1] - x;
      }
    }
  }
  
  fin(ct);
}

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

int main()
{

    int N;
    cin >> N;

    int ans = pow(10, 9);
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;

        int cnt = 0;
        while (A % 2 == 0)
        {
            cnt++;
            A /= 2.0;
        }

        if (ans > cnt)
        {
            ans = cnt;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define ji -
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define fe(x) for(int i=be[x];i;i=e[i].ne)
using namespace std;
int n,a,b;
long long L,R,c,d;
int main(){
	scanf("%d%d%d%lld%lld",&n,&a,&b,&c,&d);
	a=abs(a-b);n--;
	fo(i,0,n){
		L=i*c-(n-i)*d;
		R=i*d-(n-i)*c;
		if (L<=a&&a<=R){
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,a,b;
  cin >> h >> w >> a >> b;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i<b){
        if(j<a){
          cout << 0;
        }
        else{
          cout << 1;
        }
      }
      else{
        if(j<a){
          cout << 1;
        }
        else{
          cout << 0;
        }
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int a,b;
    cin >> a >> b;
    cout << max(llong(0), a - 2 * b) << endl;

}

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

using namespace std;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define pb push_back
#define ll long long
const int maxn=2e6+10;
const int mod=1e9+7;
const double pi=-acos(-1);

ll A[maxn],B[maxn],C[maxn<<2];
bool cmp(ll a,ll b)
{
    return a>b;
}
int main()
{
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    for(int i=0; i<a; i++)
        sll(A[i]);
    for(int i=0; i<b; i++)
        sll(B[i]);
    sort(A,A+a,cmp);
    for(int i=0; i<x; i++)
        C[i]=A[i];
    sort(B,B+b,cmp);
    for(int i=0; i<y; i++)
        C[i+x]=B[i];
    for(int i=0; i<c; i++)
        sll(C[i+x+y]);
    sort(C,C+c+x+y,cmp);
    ll sum=0;
    for(int i=0; i<x+y; i++)
        sum+=C[i];
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 400000
#define int LL
#define LL long long
using namespace std;
int n,b[N+5],S[N+5];LL a[N+5],c[N+5],tmp[N+5];
struct P
{
	LL x,y;I P(Con LL& a=0,Con LL& b=0):x(a),y(b){}
	I P operator - (Con P& o) Con {return P(x-o.x,y-o.y);}
	I LL operator ^ (Con P& o) Con {return x*o.y-y*o.x;}
}p[N+5];
main()
{
	RI i,Mx,t;scanf("%lld",&n);
	for(Mx=0,i=1;i<=n;++i) scanf("%lld",a+i),a[i]>=a[Mx]&&(Mx=i);
	for(t=0,i=Mx;i<=n;++i) tmp[++t]=a[i];for(i=1;i^Mx;++i) tmp[++t]=a[i];
	for(i=1;i<=n;++i) a[i]=tmp[i];
	for(i=1;i<=n;++i) scanf("%lld",b+i);
	for(t=0,i=Mx;i<=n;++i) tmp[++t]=b[i];for(i=1;i^Mx;++i) tmp[++t]=b[i];
	for(i=1;i<=n;++i) b[i]=tmp[i];
	for(a[++n]=a[1],i=2;i<=n;++i) c[i]=2*c[i-1]-c[i-2]+2*b[i-1],a[i]-=c[i];
	RI T=0;for(i=1;i<=n;++i)
	{
		p[i]=P(i,a[i]);W(T>1&&((p[S[T]]-p[S[T-1]])^(p[i]-p[S[T]]))>0) --T;S[++T]=i;
	}
	LL ans=a[S[1]]+a[S[T]];for(i=2;i<=T;++i) ans+=(a[S[i]]+a[S[i-1]])*(S[i]-S[i-1]);
	for(i=1;i<=n;++i) ans+=2*c[i];return printf("%.12lf",0.5*(ans-2*a[1])/(n-1)),0;
}

Measured memory_bytes: 17764
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;
const int limit = 50;
bool graph[limit][limit];
int a[limit],b[limit];
bool visited[limit];
int n,m;

void dfs(int id){
  visited[id] = true;
  for (int k=0;k<n;++k){
    if(graph[id][k] == false) continue;
    if(visited[k] == true) continue;
    dfs(k);
  }
}

int main() {
  cin >> n >> m;
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      graph[i][j] = false;
    }
  }
  for(int i=0;i<m;++i){
    cin >> a[i]>>b[i];
    --a[i];--b[i];
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;
  }
  int ans=0;
  for(int i=0;i<m;++i){
    graph[a[i]][b[i]] = false;
    graph[b[i]][a[i]] = false;

    for(int j=0;j<n;++j) visited[j] = false;
    dfs(0);

    bool bridge = false;
    for(int k =0;k<n;++k) if(visited[k] == false) bridge = true;
    if(bridge) ++ans;
    graph[b[i]][a[i]] = true;
    graph[a[i]][b[i]] = true;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
multiset<ll> s1;
void primefactorization(ll n){
    while(n%2==0){
        s1.insert(2);
        n=n/2;
    }
    for (int i = 3; i*i<=n; i+=2)
    {
        while(n%i==0){
            n=n/i;
            s1.insert(i);
        }
    }
    if(n>2){
        s1.insert(n);
    }
}

ll numLen(ll K) 
{  
    if (K % 2 == 0 || K % 5 == 0) {
        return -1; 
    }
    ll number = 0; 
    ll len = 1; 
    for (len = 1; len <= K; len++) { 
        number = (number * 10 + 1) % K; 
        if (number == 0) {
            return len; 
        }
    }
    return -1; 
} 


int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll k;
    cin>>k;
    if(numLen(k)==-1){
        cout<<-1;
    }
    else{
        primefactorization(k);
        if(s1.find(7)!=s1.end()){
            k=k/7;
        }
        ll ans=numLen(k);
        cout<<ans;
    }

    return 0;
}

Measured memory_bytes: 3624
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let x1 = input::<i64>();
    let y1 = input::<i64>();
    let x2 = input::<i64>();
    let y2 = input::<i64>();

    let x3 = x2 - (y2 - y1);
    let y3 = y2 + (x2 - x1);
    let x4 = x1 - (y2 - y1);
    let y4 = y1 + (x2 - x1);
    println!("{} {} {} {}", x3, y3, x4, y4);
}


Measured memory_bytes: 4352