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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b>c+d){
    cout << "Left" << endl;
  }else if(a+b<c+d){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
# n, k = map(int, input().split())
# from collections import OrderedDict
# d = OrderedDict()
# a = list(input().split())
# b = list(map(int, input().split()))
# print(r + max(0, 100*(10-n)))
# print("Yes" if 500*n >= k else "No") 
s = input()
print(chr(ord(s)+1))

Measured memory_bytes: 61664
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
//#define int ll

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  char a, b, c;
  cin >> a >> b >> c;
  cout << a << b << c << '\n';  
} 

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

int main() {
    int S;
    scanf("%d",&S);
    int ans=0;
    
    vector<int> vec(S);
    for (int i=0;i<S;i++)scanf("%d",&vec[i]);
    sort(vec.begin(),vec.end());
    for(int i=0;i<S-1;i++)if(vec[i]==vec[i+1])ans++;
    if (ans>0)cout << "NO" << endl;
    else cout << "YES" << endl;
    
    
}
    
    



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
#define chmax(a, b) a = max(a, b)
using ll = long long;

ll dp[200009][9];

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int k=1+n%2;
  rep(i,n+1)rep(j,k+1)dp[i][j]=-LLINF;
  dp[0][0]=0;
  rep(i,n){
    rep(j,k+1){
      chmax(dp[i+1][j+1],dp[i][j]);
      ll now=dp[i][j];
      if((i+j)%2==0)now+=a[i];
      chmax(dp[i+1][j],now);
    }
  }
  cout<<dp[n][k]<<endl;
  return(0);
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N; cin >> N;
    vl a(3*N); REP(i, 3*N) cin >> a[i];

    vl l(3*N+1), r(3*N+1);
    priority_queue<ll, vector<ll>, greater<ll>> ql;
    priority_queue<ll> qr;
    ll sl = 0, sr = 0;
    REP(i, 3*N)
    {
        if((int)ql.size() == N)
        {
            sl += a[i];
            ql.push(a[i]);
            sl -= ql.top(); ql.pop();
            l[i+1] = sl;
        }
        else
        {
            sl += a[i];
            ql.push(a[i]);
            l[i+1] = sl;
        }
    }
    RREP(i, 3*N)
    {
        if((int)qr.size() == N)
        {
            sr += a[i];
            qr.push(a[i]);
            sr -= qr.top(); qr.pop();
            r[i] = sr;
        }
        else
        {
            sr += a[i];            
            qr.push(a[i]);
            r[i] = sr;
        }
    }

    ll ans = -INFL;
    for(int i = N; i <= 2*N; i++) chmax(ans, l[i]-r[i]);
    cout << ans << endl;
}

Measured memory_bytes: 12620
def resolve():
    Sd = list(input())
    T = input()
    res = ""
    for i in range(len(Sd)):
        for j in range(len(T)):
            if i + j >= len(Sd):
                break
            if Sd[i + j] != "?" and Sd[i + j] != T[j]:
                break
        else:
            tmp = "".join(Sd[:i]) + T + "".join(Sd[i + len(T):])
            if res == "":
                res = tmp
            else:
                if res > tmp:
                    res = tmp
    if res == "":
        print("UNRESTORABLE")
        return
    for s in res:
        if s == "?":
            s = "a"
        print(s, end="")
    print()

resolve()


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

typedef vector<int> vi;

int main() {
	int n;
	cin >> n;

	vi h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	
	int ans = 0;
	int max_height = -1;

	for (int i = 0; i < n; i++) {
		if (max_height <= h[i]) {
			ans += 1;
			max_height = h[i];
		}

	}
	cout << ans << endl;	
}

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

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        long N = fs.nextLong();

        int ans = Long.toString(N).length();

        for (long i = 1; i*i <= N; ++i) {
            if (N % i != 0) continue;
            long num = N / i;

            int tmp = Math.max(Long.toString(i).length(), Long.toString(num).length());

            if (ans > tmp) ans = tmp;
        }

        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

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




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

int main() {
  string N;
  cin>>N;
  if(N[0]==N[1]&&N[1]==N[2]){
    cout<<"Yes"<<endl;
  }
  else if(N[1]==N[2]&&N[2]==N[3]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
N = int(input())
b = [int(x) for x in input().split()]

def solve(b):
    if len(b) == 0:
        return []
    if any(i+1 < b[i] for i in range(len(b))):
        return None
    erasable = [i+1 for i in range(len(b)) if i+1 == b[i]]
    if len(erasable) == 0:
        return None
    i = erasable[-1]  # 一番右から消す
    a = solve(b[:i-1] + b[i:])
    if a != None:
        return [i] + a
    return None

a = solve(b)
if a == None:
    print(-1)
else:
    a.reverse()
    print('\n'.join(map(str, a)))

Measured memory_bytes: 3064
# conding: utf-8
import sys

def main(argv=sys.argv):
  
  abc = list(map(int, input().split()))
  
  if 5 in abc:
    abc.remove(5)
        
    if 5 in abc:
      
      if 7 in abc:
            print("YES")
          
      else:
        print("NO")
        
    else:
      print("NO")  
      
  else:
    print("NO")
    
  return 0


if __name__ == '__main__':
  sys.exit(main())

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


int main(){
	int n;
	vector<int>array;
	cin >> n;
	int input;
	for(int i=0;i<n;i++){
		cin >> input;
		array.push_back(input);
	}
	
	sort(array.begin(),array.end());
	
	int memo = 1000000001;
	int count  = 0;
	int answer = 0;
	for(int i=0;i<n;i++){
		if(memo != array[i]){
			if(count < memo){
				answer += count;
			}
//			answer += min(0,count);
			count = 0;
			memo = array[i];
		}
		count ++;
		if(count > memo){
			answer ++;
		}
	}
	if(count < memo){
		answer += count;
	}
//	answer += min(max(memo - count,0),count);
	
//	answer = min(answer,n);
	cout << answer << endl;
	
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define inf (1<<16)

int main(){
	int n;
	cin>>n;
	
	int ans=inf;
	for(int i=0;i<=n;++i){
		int six =1;
		int nine=1;
		int a=i;
		int b=n-i;
		int v_ans=0;

		while(nine*9<=a)nine*=9;
		while(nine!=1){
			v_ans+=a/nine;
			a%=nine;
			nine/=9;
		}
		v_ans+=a;

		while(six*6<=b)six*=6;
		while(six!=1){
			v_ans+=b/six;
			b%=six;
			six/=6;
		}
		v_ans+=b;
		
		ans=min(ans,v_ans);
	}
	cout<<ans<<endl;
}


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

int calcDigitSums (int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}



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

    if ((N % calcDigitSums(N)) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF_LL 1LL << 40
#define INF 1 << 31
#define MOD 1000000007
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define prique priority_queue
#define PI acos(-1)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vector<int>> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(b) {
        a = b;
        return 1;
    }
    return 0;
}
struct edge {
    int to, cost;
};

bool dp[80][80][12801];

int main() {
    int h, w;
    cin >> h >> w;
    vvi a(h, vi(w)), b(h, vi(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, h) rep(j, w) cin >> b[i][j];
    dp[0][0][abs(a[0][0] - b[0][0])] = true;
    rep(i, h) rep(j, w) {
        if(i == 0 && j == 0) {
            continue;
        }
        if(j > 0) {
            rep(k, 12801) {
                chmax(dp[i][j][k + abs(a[i][j] - b[i][j])], dp[i][j - 1][k]);
                chmax(dp[i][j][abs(k - abs(a[i][j] - b[i][j]))], dp[i][j - 1][k]);
            }
        }
        if(i > 0) {
            rep(k, 12801) {
                chmax(dp[i][j][k + abs(a[i][j] - b[i][j])], dp[i - 1][j][k]);
                chmax(dp[i][j][abs(k - abs(a[i][j] - b[i][j]))], dp[i - 1][j][k]);
            }
        }
    }
    rep(k, 12801) {
        if(dp[h - 1][w - 1][k]) {
            cout << k << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 79488
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
        while(true){
            int in = scan.nextInt();
            if(in == 0) return;

            int aSum = 0;
            int bSum = 0;
            for(int i = 0; i < in; i++){
                int a = scan.nextInt();
                int b = scan.nextInt();
                if(a > b){
                    aSum += a+b;
                }else if(a < b){
                	bSum += a+b;
                }else{
                	aSum += a;
                	bSum += b;
                }
            }
            System.out.println(aSum +" "+ bSum);
        }
	}
}

Measured memory_bytes: 12000
N = int(input())
S = input()
flg = 0
if N%2==0:
  half = int(N/2)
  
  for i in range(half):
    if S[i]!=S[half+i]:
      print("No")
      flg = 1
      break
  if flg==0:
     print("Yes")
  
else:
  print("No")

Measured memory_bytes: 3060
s = input()
k = int(input())

counter = 0
tmp = s[0]
counter_list = []

s_dict = dict()
for i,one in enumerate(s):
    s_dict[one] = i
    
if len(s_dict) == 1:
    print((len(s)*k)//2)
else:
    for one in s[1:]:
        if tmp == one:
            counter += 1
        else:
            #counter_list.append((counter+1)//2)
            counter_list.append(counter+1)
            counter = 0
            tmp = one
    #counter_list.append((counter+1)//2)
    counter_list.append(counter+1)

    sum_counter = sum(counter_list)
    if s[0] == s[-1]:
        tmp_counter_list = counter_list[:-1]
        tmp_counter_list.append(counter_list[-1]+counter_list[0])
        tmp_counter_list = [one//2 for one in tmp_counter_list]
        last_counter_list = [one//2 for one in counter_list]
        print(tmp_counter_list[0]+sum(tmp_counter_list[1:])*(k-1) + sum(last_counter_list[1:]))
    else:
        last_counter_list = [one//2 for one in counter_list]
        print(sum(last_counter_list)*k)
    

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    int n;
    std::cin >> n;

    std::vector<std::pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i].first;
        a[i].second = i + 1;
    }

    std::sort(a.begin(), a.end());

    for (int i = 0; i < n; i++) {
        std::cout << a[i].second << std::endl;
    }
}


Measured memory_bytes: 1664
// Author: 23forever
#include <bits/stdc++.h>
//#define debug
const int MAXN = 40;
const int N = 5 + 7 + 5;
const int P = 1e9 + 7;
using namespace std;

inline void read(int &x) {
  x = 0; char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
}

int n, x, y, z;
int dp[MAXN + 5][1 << N];
int banned, S;

void print(int x) {
  bitset < 20 > tmp(x);
  cout << tmp << endl;
}

void init() {
  read(n), read(x), read(y), read(z);
  //cout << (1 << 5 - 1) << endl;
  banned = (1 << x + y + z - 1) | (1 << y + z - 1) | (1 << z - 1); 
  S = (1 << x + y + z) - 1;
  //print(S);
}

int main() {
#ifdef forever23
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#endif
  init();

  int ans = 1; dp[0][0] = 1; 
  for (int i = 1; i <= n; ++i) {
    for (int s = 0; s <= S; ++s) {
      for (int j = 1; j <= 10; ++j) {
        int nxt_state = ((1 << j - 1) | (s << j)) & S;
        /*print(s); printf("%d\n", j);
        print(nxt_state);
        puts("");*/   
        if ((nxt_state & banned) != banned) {
          dp[i][nxt_state] = (dp[i][nxt_state] + dp[i - 1][s]) % P;
        }
      }
    }
    ans = 1LL * ans * 10 % P;
  }
  
  for (int s = 0; s <= S; ++s) {
    ans = (ans - dp[n][s] + P) % P;
  }
  printf("%d\n", ans);  
  return 0;
}


Measured memory_bytes: 22400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
   
    int H, W;
    cin >> H >> W;
    
    int c[10][10];
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    
    int List[10] = {0};
    rep(i, H) rep(j, W) {
        int A;
        cin >> A;
        if (A == -1) continue;
        List[A]++;
    }
    
    int N = 10;
    rep(k, N) rep(i, N) rep(j, N) {
        if (c[i][k] + c[k][j] < c[i][j]) c[i][j] = c[i][k] + c[k][j];
    }
    
    // rep(i, 10) { rep(j, 10) cout << c[i][j] << " "; cout << endl; }
    
    int ans = 0;
    rep(i, 10) ans += c[i][1] * List[i];
    out(ans);
    
    /* 以下, ooから1への最短経路を求められてない
    int table[10];
    fill_n(table, 10, inf);
    
    rep(i, 10) {
        queue<pii> q;
        rep(j, 10) {
            if (j == i) continue;
            if (table[j] > c[i][j]) {
                q.push(pii{j, c[i][j]});
                table[j] = c[i][j];
            }
            
            
        }
        
        while (!q.empty()) {
            int now = q.front().F;
            int cost = q.front().S;
            q.pop();
            
            rep(j, 10) {
                if (now == j) continue;
                
                if (table[j] > cost + c[now][j]) {
                    table[j] = cost + c[now][j];
                    q.push(pii{j, table[j]});
                }
            }
        }
        
        
    }
    outa(table, 10);
    
    int ans = 0;
    rep(i, 10) {
        if (i == 1) continue;
        ans += table[i];
    }
    out(ans);
     */
}




Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())
A.sort(); B.sort(); C.sort()
ans = 0
for b in B:
    smaller_than_b = bisect_left(A, b)
    larger_than_b = N - bisect_right(C, b)
    ans += smaller_than_b * larger_than_b
print(ans)

Measured memory_bytes: 22720
N, A, B = map(int, input().split())

def digit_sum(n):
  res = 0
  while n:
    res += n % 10
    n //= 10
  return res

answer = 0
for i in range(1, N + 1):
  if A <= digit_sum(i) <= B:
    answer += i
    
print(answer)

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

using namespace std;

/** Interface */

inline int readChar();
template <class T = int> inline T readInt();
template <class T> inline void writeInt( T x, char end = 0 );
inline void writeChar( int x );
inline void writeWord( const char *s );

/** Read */

static const int buf_size = 4096;

inline int getChar() {
	static char buf[buf_size];
	static int len = 0, pos = 0;
	if (pos == len)
		pos = 0, len = fread(buf, 1, buf_size, stdin);
	if (pos == len)
		return -1;
	return buf[pos++];
}

inline int readChar() {
	int c = getChar();
	while (c <= 32)
		c = getChar();
	return c;
}

template <class T>
inline T readInt() {
	int s = 1, c = readChar();
	T x = 0;
	if (c == '-')
		s = -1, c = getChar();
	while ('0' <= c && c <= '9')
		x = x * 10 + c - '0', c = getChar();
	return s == 1 ? x : -x;
}

/** Write */

static int write_pos = 0;
static char write_buf[buf_size];

inline void writeChar( int x ) {
	if (write_pos == buf_size)
		fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
	write_buf[write_pos++] = x;
}

template <class T>
inline void writeInt( T x, char end ) {
	if (x < 0)
		writeChar('-'), x = -x;

	char s[24];
	int n = 0;
	while (x || !n)
		s[n++] = '0' + x % 10, x /= 10;
	while (n--)
		writeChar(s[n]);
	if (end)
		writeChar(end);
}

inline void writeWord( const char *s ) {
	while (*s)
		writeChar(*s++);
}

struct Flusher {
	~Flusher() {
		if (write_pos)
			fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
	}
} flusher;

typedef long long ll;
typedef unsigned long long ull;

const int N = 100100;

int p[N];

int get_root(int v) {
    if (v == p[v]) {
        return v;
    }
    return p[v] = get_root(p[v]);
}

void dsu_un(int v, int u) {
    v = get_root(v);
    u = get_root(u);
    if (v == u) {
        return;
    }
    p[u] = v;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n = readInt(), m = readInt();
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; ++i) {
        a[i].first = readInt();
        a[i].second = i;
        p[i] = i;
    }
    for (int i = 0; i < m; ++i) {
        int v = readInt(), u = readInt();
        dsu_un(v, u);
    }
    sort(a.begin(), a.end());
    int t = 2 * (n - m - 1);
    if (t <= n) {
        if (t == 0) {
            writeInt(0);
            return 0;
        }
        vector<int> used(n), k(n);
        t = t / 2 - 1;
        ll ans = 0;
        for (int i = 0; i < n; ++i) {
            if (!k[get_root(a[i].second)]) {
                used[i] = 1;
                k[get_root(a[i].second)] = 1;
                ans += a[i].first;
            }
        }
        for (int i = 0; i < n && t; ++i) {
            if (!used[i]) {
                ans += a[i].first;
                --t;
            }
        }
        writeInt<ll>(ans);
    } else {
        writeWord("Impossible");
    }
    return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi pair<int, int>
#define pl pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define MOD ll(1000000007)

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	ll i, n, j, t, m, x, y, z, k;

	ll ans=0;

	vl v;
	cin>>n;

	for(i=0; i<n; i++)
	{
		cin>>x;
		v.pb(x);
	}

	ll mx=v[0];

	for(i=1; i<n; i++)
	{
		if(v[i]>=mx)
			mx=max(mx,v[i]);
		else{
			ans+=mx-v[i];
		}
	}

	cout<<ans;
	cout<<"\n";



	return 0;
}


Measured memory_bytes: 5320
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n, m, a, b;
  priority_queue<int> q;
  cin >> n >> m;
  vector<vector <int>> ab(m);
  rep(i, n){
    cin >> a >> b;
    if(a>m){
      continue;
    }
    a--;
    ab[a].push_back(b);
  }
  int ans=0;
  rep(i, m){
    for(int job: ab[i]){
      q.push(job);
    }
    if(!q.empty()){
      int maxjob=q.top(); q.pop();
      ans+=maxjob;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5504
import sys


def main():
    while True:
        x, y = [int(i) for i in sys.stdin.readline().split(' ')]
        if x == 0 and y == 0:
            break
        elif x <= y:
            print(x, y)
        else:
            print(y, x)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5900
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <cstring>
//#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#define mod 1000000007
#define PI acos(-1.0)
typedef long long ll;
typedef unsigned long long ull;
#define gcd __gcd
//const int INF=0x3f3f3f3f;
const ll INF=1000000000000000000;
//priority_queue<int, vector<int>, greater<int> >p;
int n;
int a[200005],b[200005];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    sort(b+1,b+n+1);
    int x=n/2;
    for(int i=1;i<=n;i++)
        if(a[i]>b[x])printf("%d\n",b[x]);
        else printf("%d\n",b[x+1]);
    return 0;
}


Measured memory_bytes: 3712
from itertools import groupby, accumulate, product, permutations, combinations
from collections import Counter
def solve():
    N = int(input())
    dics = [0]*N
    S = [input() for _ in range(N)]
    dic = Counter(S[0])
    for i in range(1,N):
        new_dic = Counter(S[i])
        for k in dic.keys():
            if k in new_dic:
                dic[k] = min(dic[k],new_dic[k])
            else:
                dic[k] = 0
    ans = ''
    for k,v in sorted(dic.items()):
        ans += k*v
    return ans
print(solve())

Measured memory_bytes: 3316
import logging
import heapq

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)


def main():
    N, M = map(int, input().split())
    A_B = [list(map(int, input().split())) for _ in range(N)]
    logging.info("Hello!")

    A_B.sort()
    logging.info(A_B)


    heap_Q = []
    curr = 0
    total = 0
    for i in range(1, M + 1):
        while curr < N and  A_B[curr][0] <= i:
            heapq.heappush(heap_Q, A_B[curr][1] * (-1))
            curr += 1

        if heap_Q:
            total += (-1) * heapq.heappop(heap_Q)

    print(total)
    
if __name__ == "__main__":
    main()


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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

ll dp[101][1000001];

int main(){
    ll N,W;
    cin >> N >> W;
    ll w,v;
    cin >> w >> v;
    dp[0][w] = v;

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

    ll ans = 0;
    rep(j,W+1){
        ans = max(ans, dp[N-1][j]);
    }
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 286976
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args){
        try(BufferedReader r = new BufferedReader(new InputStreamReader(System.in))){
            int x = Integer.parseInt(r.readLine());
            System.out.println(x * x * x);
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 24308
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
using namespace std;

int main(){
  fast;
  int a,b,a0,b0,ans=-1;
  cin>>a>>b;
  for(int i=0;i<1e4;i++){
    a0 = i * 0.08;
    b0 = i * 0.1;
    if(a0 == a && b0 == b){
      ans = i;
      break;
    }
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const int N = 1005;
const int M = 301;
int n,m;
int a,b,c,d;
int main()
{
    while (~scanf("%d%d%d%d",&a,&b,&c,&d))
    {
        printf("%d\n", max(0,min(b,d)-max(a,c)));
    }
    return 0;
}

/*

*/

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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

#define N 3500
int main() {
	ios::sync_with_stdio(0);
	ll n;
	cin>>n;
	FI(N) rep(j, i, N+1) {
		ll a = 4*i*j-n*(i+j);
		if(!a) continue;
		LD val = (LD)n*i*j/a;
		int val1 = (int)val;
		if(val1<0 || val1!=val) continue;
		cout<<i<<' '<<j<<' '<<val1<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
/*
   AOJ - ITP11_1_b
Date: 20181023
Author: Mikoron * ♡mikoiwate351♡
*/

#include<stdio.h>
#include<string.h>

#define CMAX 101
#define TOP 1
#define FRONT 2
#define RIGHT 3
#define LEFT 4
#define BACK 5
#define BOTTOM 6


typedef struct {
        short suf[7];
} dice_state_t;

void show_state(dice_state_t *dice, short s_suf);
void change_state(dice_state_t *dice, char command);
void search_RIGHT(dice_state_t *dice, short s_TOP, short s_FRONT);
void replace_y(dice_state_t *dice);
void replace_x(dice_state_t *dice);
void replace_z(dice_state_t *dice);

int main(void) {

        short i, order_num, s_TOP, s_FRONT;

        dice_state_t dice;

        for(i = 1; i < 7; i++) scanf("%hd", &dice.suf[i]);
        scanf("%hd", &order_num);

        for(i = 0; i < order_num; i++) {
                scanf("%hd %hd", &s_TOP, &s_FRONT);
                search_RIGHT(&dice, s_TOP, s_FRONT);
                show_state(&dice, RIGHT);
        }

        return 0;
}

void show_state(dice_state_t *dice, short s_suf) {
        printf("%hd\n", dice->suf[s_suf]);
}


void change_state(dice_state_t *dice, char command) {
        short i;

        switch(command) {
                case 'N':
                        replace_y(dice);
                        break;
                case 'E':
                        replace_x(dice);
                        break;
                case 'S':
                        for(i = 0; i < 3; i++) replace_y(dice);
                        break;
                case 'W':
                        for(i = 0; i < 3; i++) replace_x(dice);
                        break;
        }

}

void search_RIGHT(dice_state_t *dice, short s_TOP, short s_FRONT) {
        short flag = 0, i, j;
        for(i = 0; i < 2; i++) {
                if(flag == 1) break;
                for(j = 0; j < 4; j++) {
                        if(dice->suf[TOP] == s_TOP) flag = 1;
                        if(flag == 1) break;
                        if(i == 0) replace_y(dice);
                        else if(i == 1) replace_x(dice);
                }
        }

        for(i = 0; i < 3; i++) {
                if(dice->suf[FRONT] == s_FRONT) break;
                replace_z(dice);
        }
}


void replace_y(dice_state_t *dice) {
        short buf;

        buf = dice->suf[TOP];
        dice->suf[TOP] = dice->suf[FRONT]; // 1 -> 2
        dice->suf[FRONT] = dice->suf[BOTTOM]; // 2 -> 6
        dice->suf[BOTTOM] = dice->suf[BACK]; // 6 -> 5
        dice->suf[BACK] = buf; // 5 -> 1
}


void replace_x(dice_state_t *dice) {
        short buf;

        buf = dice->suf[TOP];
        dice->suf[TOP] = dice->suf[LEFT]; // 1 -> 4
        dice->suf[LEFT] = dice->suf[BOTTOM]; // 4 -> 6
        dice->suf[BOTTOM] = dice->suf[RIGHT]; // 6 -> 3
        dice->suf[RIGHT] = buf; // 3 -> 1
}

void replace_z(dice_state_t *dice) {
        short buf;

        buf = dice->suf[FRONT];
        dice->suf[FRONT] = dice->suf[RIGHT]; // 2 -> 3
        dice->suf[RIGHT] = dice->suf[BACK]; // 3 -> 5
        dice->suf[BACK] = dice->suf[LEFT]; // 5 -> 4
        dice->suf[LEFT] = buf; // 4 -> 2
}



Measured memory_bytes: 2060
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>
#include <stack>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */


constexpr int MOD = 998244353;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


std::vector<mint> construct_comb(int n) {
	std::vector<mint> c(n+1);
	mint a = 1;
	c[0] = a;
	for(int i=1;i<=n;i++) {
		a = a*mint(n+1-i)/i;
		c[i] = a;
	}
	return c;
}

signed main() {
	int n,m,k;
	std::cin >> n >> m >> k;
	mint ans=0;
	auto C = construct_comb(n-1);
	rep(a,k+1) {
		ans+=mint(m)*mint(m-1).pow(n-a-1)*C[a];
		debug(ans);
	}
	print(ans);
	return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
// 型シノニム
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
// 定数
constexpr ll INF   = 1e16;
constexpr ll INM   = 114514;
constexpr ll MOD   = 1e9 + 7;
constexpr ld EPS   = 1e-12;
constexpr ll dx[4] = {1, 0, -1, 0};
constexpr ll dy[4] = {0, 1, 0, -1};
// 便利関数
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, ll t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
vector<string> split(const string &s, char delim) {
	vector<string> elems;
	string item;
	for (char ch : s) {
		if (ch == delim) {
			if (!item.empty())
				elems.push_back(item);
			item.clear();
		} else {
			item += ch;
		}
	}
	if (!item.empty())
		elems.push_back(item);
	return elems;
}

// 本体

int main() {
	IOS();
	int n;
	for (int i = 1; i <= 5; i++) {
		cin >> n;
		if (i != n) {
			dump(i);
		}
	}
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 200001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,a,b,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,
q,q1,q2,q3,q4,r,s,t,u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;

queue<L>Q;

void solve(){
    Q.push(1);Q.push(2);Q.push(3);Q.push(4);Q.push(5);Q.push(6); Q.push(7);Q.push(8);Q.push(9);
    c1=0;
    while(c1<k){
        c=Q.front();
        Q.pop();
        c1++;
        
        if(c%10!=0)Q.push(c*10+c%10-1);
        Q.push(c*10+c%10);
        if(c%10!=9)Q.push(c*10+c%10+1);
    }
    printf("%lld\n",c);
}

int main()
{
    scanf("%lld",&k);
    solve();
    return 0;
}

/// empty() lld lld push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 5236
#include <cstdio>
using namespace std;
int main(){
    int a,b,c;
    scanf("%i %i %i",&a,&b,&c);
    if (a+b>=c){
        printf("%i\n",b+c);
    }else{
        printf("%i\n",a+b+b+1);
    }
    return 0;
}

Measured memory_bytes: 128
n = int(input())
s = input()
cnt = 0
cnt2 = 0
tmp = 0
tmp2 = 0
ans = 10**9
for i in s:
    if i=="#":
        cnt += 1
    else:
        cnt2 += 1
for i in s:
    if i=="#":
        tmp += 1
    else:
        tmp2 += 1
    ans = min(ans,tmp+cnt2-tmp2)
print(min(ans,cnt,cnt2))

Measured memory_bytes: 3500
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

ll inf = 1000000007;

int main() {
    ll n;   cin >> n;
    ll k;   cin >> k;
    ll sum = 0;
    ll m = k*(k-1)/2, M = k*(n*2+1-k)/2;
    sum += M-m+1;
    for (ll i = k+1; i <= n+1; i++) {
        m += i-1;
        M += n-i+1;
        sum += M-m+1;
        sum %= inf;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624
// Problem Code: abc162_c

#include <iostream>
#include <numeric>

using namespace std;

long long tuples(int K) {
	long long sum = 0;
	for (int a = 1; a <= K; a++)
		for (int b = 1; b <= K; b++)
			for (int c = 1; c <= K; c++)
				sum += gcd(a, gcd(b, c));
	return sum;
}

int main() {
	int K;
	cin >> K;
	cout << tuples(K);
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long

typedef pair<int, int> P;
const int N = 2e5;
const int INF = 1 << 30;

struct edge{ int to,cost; };
vector< edge > G[N];

void dikstra(int s){
  priority_queue<P,vector<P>,greater<P>> que;
  vector<int> d(N,INF); //sからの最短距離
  d[s] = 1;
  que.push({1,s}); //{最短距離,頂点}

  while( !que.empty() ){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push( {d[e.to],e.to} );
      }
    }
  }
  cout << d[0] << endl;
}

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

  int k; cin >> k;
  for(int i = 1; i < k; i++){
    G[i].push_back({(i+1)%k,1});
    G[i].push_back({(i*10)%k,0});
  }

  dikstra(1);

  return 0;
}


Measured memory_bytes: 12412
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

const int maxn = (1 << 18) + 5;

int f[maxn], s[maxn];

int a[maxn];
int n;

void init(){
    for(int i = 0;i < (1 << n);i++){
        f[i] = a[i];
        s[i] = -1;
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < (1 << n);j++){
            if(j & (1 << i)){
                int v = j ^ (1 << i);
                int u = j;
                if(f[v] > f[u]){
                    s[u] = f[u];
                    f[u] = f[v];
                }else{
                    if(f[v] > s[u]){
                        s[u] = f[v];
                    }
                } 
                if(s[v] > s[u]){
                    s[u] = s[v];
                }
            }
        }
    }
}

int main(){
    cin >> n;
    for(int i = 0;i < (1 << n);i++){
        scanf("%d", &a[i]);
    }
    init();
    int pre = 0;
    for(int i = 0;i < (1 << n);i++){
        pre = max(pre, f[i] + s[i]);
        if(i > 0){
            printf("%d\n", pre);
        }
    }
    return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int l,r,d;
    cin >> l >> r >> d;
    int cnt=0;
    for(int i=l;i<=r;i++){
        if(i%d==0){
            cnt += 1;
        }
    }



    cout << cnt << endl;
}



Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define endl "\n"
// const int N=2e5+10;


void solve()
{
    int x,y;
    cin>>x>>y;
    int mx=4*x,mi=2*x;

    if(y&1)
    {
        cout<<"No"<<endl;return ;
    }

    if(y<=mx and y>=mi)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--) 
    {
        solve();
    }
    return 0;
}


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

int main()
{
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double ans;
  ans = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
  printf("%f\n", ans);
  return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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


int n,m;
string s[60];
bool vis[60][60];
 
void dfs(int x, int y) {
	if (!(0 <= x && x < n)) return;
	if (!(0 <= y && y < m)) return;
	if (vis[x][y]) return;
	if (s[x][y] != '#') return;
 
	vis[x][y]=true;
	
	for(int i=0;i<4;i++)
	{
		dfs(x+dx[i],y+dy[i]);
	}
}
 
bool call(){
	int num=0;
	memset(vis,0,sizeof(vis));
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if (s[i][j] == '#' && !vis[i][j]){
				dfs(i,j);
				num++;
			}
 
	return num>1;
}


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

 

int a,b,m;
cin>>a>>b>>m;

vector<int>x(a+1),y(b+1);


for(int i=1;i<=a;i++)cin>>x[i];
for(int i=1;i<=b;i++)cin>>y[i];

int ans=*min_element(x.begin()+1,x.end()) + *min_element(y.begin()+1,y.end());


for(int i=0;i<m;i++)
{
	int u,v,d;
	cin>>u>>v>>d;
	ans=min(ans,x[u]+y[v]-d);
}
ans=max(ans,0ll);
cout<<ans<<"\n";
	





	
	

  
}



Measured memory_bytes: 1792
#include<iostream>

int main(){
  int a, b, c;
  std::cin >> a >> b >> c;
  int x = (a*100) + (b*10) + c;
  if(x%4 == 0)
    std::cout << "YES" << std::endl;
  else
    std::cout << "NO" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

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

int n, k;
string s;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin >> n >> k;
	cin >> s;
	k--;
	s[k] = s[k] - 'A' + 'a';
	cout << s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,cnt=0;
  string s,c="No";
  cin >> a >> b >> s;
  if(s.at(a)=='-'){
    for(int i=0;i<s.size();i++){
      if(i==a)
        continue;
      else{
      	if(47<s.at(i) && s.at(i)<58)
          cnt++;
      }
    }
  }
  if(cnt==a+b)
    c = "Yes";
  cout << c << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

int a[2][110];

int main(void) {
	int n;
	cin >> n;
	rep(i, 2)rep(j, n) cin >> a[i][j];

	int ans = 0;
	rep(k, n) {
		int cur = 0;
		for (int i = 0; i <= k; ++i) {
			cur += a[0][i];
		}

		for (int i = k; i < n; ++i) {
			cur += a[1][i];
		}
		chmax(ans, cur);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>
#include<numeric>
#include<stdlib.h>

using namespace std;

int main()
{

  int N;
  int K;
  cin >> N >> K;

  vector<int> D(K);

  for(int i=0; i<K; i++){
    cin >> D[i];
  }

  while(1){
    string S = to_string(N);
    int flag = 1;

    for(int i=0; i<S.size(); i++){
      for(int j=0; j<K; j++){
        char c = '0' + D[j];
        if(S[i] == c){
          flag = 0;
          break;
        }
        if(flag == 0){
          break;
        }
      }
    }

    if(flag == 1){
      cout << N << endl;
      return 0;
    }
    N++;
  }
}


Measured memory_bytes: 256
s = input()
t = input()
trans_in = [-1] * 26 
trans_out = [-1] * 26
for i in range(len(s)):
    a = ord(s[i]) - ord("a")
    b = ord(t[i]) - ord("a")
    # print(s[i], a)
    # print(t[i], b)
    if trans_in[a] != -1 or trans_out[b] != -1:
        if trans_in[a] != b or trans_out[b] != a:
            print("No")
            exit()
    trans_in[a] = b
    trans_out[b] = a
print("Yes")


Measured memory_bytes: 3632