akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int x,y;
  cin>>x>>y;
  if (y%2 || y<x*2) cout<<"No";
  else{
  int temp=(y-x*2)/2;
  if (temp>x) cout<<"No";
  else cout<<"Yes";
  }
  return 0;
}

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

// #define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define fst first
#define pb push_back

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

signed main() {
    int N, M;
    cin >> N >> M;

    vector<int> cnt(N);
    REP(i, M) {
        int A, B;
        cin >> A >> B;
        cnt.at(A-1) += 1;
        cnt.at(B-1) += 1;
    }

    REP(i, N) {
        if (cnt.at(i) % 2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


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

long long MOD = 1000000007;

int main(){
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    int n = s.size();
    vector<long long> dp(13);
    dp[0] = 1;

    int mul = 1;
    for(int i = 0; i < n; i++){
        vector<long long> new_dp(13);
        int c;
        if(s[i] == '?') c = -1;
        else c = s[i] - '0';

        for(int j = 0; j < 10; j++){
            if(c != -1 && c != j) continue;
            for(int ki = 0; ki < 13; ki++){
                new_dp[(j* mul + ki) % 13] += dp[ki];
            }
        }

        for(int j = 0; j < 13; j++) new_dp[j] %= MOD;
        dp = new_dp;
        mul *= 10;
        mul %= 13;
    }

    cout << dp[5] << endl;

}

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

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

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

int cnt[200005];

int main()
{
    int n,k;
    cin >> n >> k;
    int a[n];
    
    rep(i,n) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    sort(cnt,cnt+n);
    reverse(cnt,cnt+n);
    int sub = 0;
    for(int i = 0; i < k; i++){
        sub += cnt[i];
    }
    cout << n - sub << endl;
}

Measured memory_bytes: 1792
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            int A = int.Parse(Console.ReadLine());

            var list = new System.Collections.Generic.List<int>();

            ans = 1;

            do
            {
                ans++;
                list.Add(A);

                if (A % 2 == 0)
                {
                    A = A / 2;
                }
                else
                {
                    A = A * 3 + 1;
                }

            } while (!list.Contains(A));
            

            Console.WriteLine(ans.ToString());
        }
    }
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 1e18+1
const ll mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    if(k>a)
    {

        ans+=a;
        k-=a;
    }
    else
    {
        ans+=k;
        k=0;
    }
    if(k>b)
    {

        //ans+=a;
        k-=b;
    }
    else
    {
        //ans+=k
        k=0;
    }
    if(k>c)
    {

        ans-=c;
        k-=c;
    }
    else
    {
        ans-=k;
        k=0;
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
t = int(input())
import heapq
def tr(pnt,m):
  try:
    if use[m] > pnt:
      heapq.heappush(now,[pnt,m])
      use[m] = pnt
  except:
    heapq.heappush(now,[pnt,m])
    use[m] = pnt
inf = 10**18
for _ in range(t):
  n,a,b,c,d = map(int,input().split())
  now = [[0,n]]
  use = {}
  mini = 10**18
  ans = n * d
  while True:
    sc,num = heapq.heappop(now)
    ans = min(ans,sc+d*num)
    if num == 1:
      print(ans)
      break
    if num % 2 == 0:
      tr(sc+a,num//2)
    else:
      tr(sc+a+d,(num-1)//2)
      tr(sc+a+d,(num+1)//2)
    
    if num % 3 == 0:
      tr(sc+b,num//3)
    elif num % 3 == 1:
      tr(sc+b+d,(num-1)//3)
    else:
      tr(sc+b+d,(num+1)//3)
    
    if num % 5 == 0:
      tr(sc+c,num//5)
    elif num % 5 == 1:
      tr(sc+c+d,(num-1)//5)
    elif num % 5 == 2:
      tr(sc+c+2*d,(num-2)//5)
    elif num % 5 == 3:
      tr(sc+c+2*d,(num+2)//5)
    else:
      tr(sc+c+d,(num+1)//5)

Measured memory_bytes: 87840
#include <bits/stdc++.h>
using namespace std;
using V = vector<int>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVbo = vector<Vbo>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define rep(i, n) rep2(i, 0, n)
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
VVbo A;
V cl;
V cnt(2);

bool dfs(int u, int x=0) {
  if (cl[u] == x) return true;
  if (cl[u] == (x^1)) return false;
  cl[u] = x;
  ++cnt[x];
  rep(v, n) if (A[u][v]) {
    if (!dfs(v, x^1)) return false;
  }
  return true;
}


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

  A.assign(n, Vbo(n, true));
  cl.assign(n, -1);
  rep(i, m) {
    int u, v; cin >> u >> v;
    --u; --v;
    A[u][v] = false;
    A[v][u] = false;
  }
  rep(i, n) A[i][i] = false;

  bitset<701> dp;
  dp[0] = 1;
  rep(i, n) {
    if (cl[i] != -1) continue;
    cnt.assign(2, 0);
    if (!dfs(i)) {
      cout << -1 << "\n";
      return 0;
    }
    dp = (dp<<cnt[0]) | (dp<<cnt[1]);
  }

  int ans = n*n;
  rep(i, n) if (dp[i]) chmin(ans, i*(i-1)/2 + (n-i)*(n-i-1)/2);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
set<int> a;
int main(){
	int n;
	cin>>n;
	while(n--){
		int b;
		cin>>b;
		if(a.find(b)!=a.end()) a.erase(b);	
		else a.insert(b);
	}
	cout<<a.size();
	return 0;
}

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

int main() {

    int X;

    cin >> X ;

    int div500;
    int div5;

    div500 = X/500;
    X %=500;
    div5 = X/5;

    cout << div500 * 1000 + div5 * 5 << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut i = 1;
    loop {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).ok();
        let x: i32 = buf.trim().parse().unwrap();
        if x == 0 {
            break;
        }
        println!("Case {}: {}", i, x);
        i += 1;
    }
}


Measured memory_bytes: 5044
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#define inf 2147483647
#define eps 1e-9
using namespace std;
typedef long long ll;
struct node{
	int x,id;
}li[4][100001];
int r,c,n,x,y,xx,yy,nw,tot[4];
stack<int>st;
bool cmp1(node a,node b){
	return a.x<b.x;
}
bool cmp2(node a,node b){
	return a.x>b.x;
}
int main(){
	scanf("%d%d%d",&r,&c,&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d%d",&x,&y,&xx,&yy);
		if((x&&y&&x!=r&&y!=c)||(xx&&yy&&xx!=r&&yy!=c))continue;
		if(!x)nw=3;
		else if(x==r)nw=1;
		else if(!y)nw=0;
		else if(y==c)nw=2;
		if(nw==1||nw==3)li[nw][++tot[nw]]=(node){y,i};
		else li[nw][++tot[nw]]=(node){x,i};
		if(!xx)nw=3;
		else if(xx==r)nw=1;
		else if(!yy)nw=0;
		else if(yy==c)nw=2;
		if(nw==1||nw==3)li[nw][++tot[nw]]=(node){yy,i};
		else li[nw][++tot[nw]]=(node){xx,i};
	}
	for(int i=0;i<4;i++){
		if(i==0||i==1)sort(li[i]+1,li[i]+tot[i]+1,cmp1);
		else sort(li[i]+1,li[i]+tot[i]+1,cmp2);
		for(int j=1;j<=tot[i];j++){
			if(!st.empty()&&li[i][j].id==st.top())st.pop();
			else st.push(li[i][j].id);
		}
	}
	if(st.empty())puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 2176
x=input().split()
h=int(x[0])
w=int(x[1])
d=int(x[2])
grid=[[]*w for i in range(h)]
for i in range(h):
    y=input().split()
    x=0
    while x<w:
        y[x]=int(y[x])
        x=x+1
    grid[i]=y
coor=[[]*2 for i in range(h*w)]
for i in range(h):
    for j in range(w):
        coor[grid[i][j]-1]=[i,j]
cost=[0*i for i in range(h*w-d)]
for i in range(h*w-d):
    cost[i]=abs(coor[i+d][0]-coor[i][0])+abs(coor[i+d][1]-coor[i][1])
ans=[0*i for i in range(h*w)]
for i in range(d,h*w):
    ans[i]=ans[i-d]+cost[i-d]
q=int(input())
for ii in range(q):
    x=input().split()
    l=int(x[0])
    r=int(x[1])
    print(ans[r-1]-ans[l-1])


Measured memory_bytes: 22332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
 
int main(){
	char a,b;
    cin>>a>>b;
    if(a==b)cout<<'H';
    else cout<<'D';
	return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Set<Integer> arrays=new HashSet<>();
		int cnt=1;
		int s=sc.nextInt();
		arrays.add(s);

		while(true) {
			cnt++;
			s=result(s);
			if(arrays.contains(s)) {
				System.out.println(cnt);
				break;
			}
			arrays.add(s);
		}
	}
	public static int result(int a) {
		if(a%2==0) {
			return a/2;
		}
		return 3*a+1;
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
const int mod = 1000000007;
const int N = 1e5+5, M = N;
//=========================================

int a[N][3], dp[N][3];

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    for(int i = 1; i <= n; ++i)
        cin >> a[i][0] >> a[i][1] >> a[i][2];

    memset(dp, 0, sizeof(dp));

    dp[1][0] = a[1][0];
    dp[1][1] = a[1][1];
    dp[1][2] = a[1][2];

    for(int i = 2; i <= n; ++i){
        dp[i][0] = a[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = a[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = a[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
    }

    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;

    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<queue>
#include<ctime>
#include<cassert>
#include<complex>
#include<string>
#include<cstring>
#include<chrono>
#include<random>
#include<bitset>
#include<iomanip>

#define x first
#define y second
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define sz(v) (int) v.size()

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int MAX_N = 105, inf = 1e9;

int n, m;
string a[MAX_N];
int dp[MAX_N][MAX_N];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (i == 0 && j == 0) {
				dp[i][j] = (a[i][j] == '#');
				continue;
			}
			dp[i][j] = inf;
			if (i - 1 >= 0) {
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + (a[i][j] == '#' && a[i - 1][j] == '.'));
			}
			if (j - 1 >= 0) {
				dp[i][j] = min(dp[i][j], dp[i][j - 1] + (a[i][j] == '#' && a[i][j - 1] == '.'));
			}
		}
	}	
	cout << dp[n - 1][m - 1] << "\n";
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
using namespace std;
 
int main(){
    int H=0,W=0;
    int i,k;

while(1){    
    cin >> H >> W;
	if(H==0&&W==0){
		break;
	}
    
    for(k=0;k<H;k++){
    	for(i=0;i<W;i++){
    		cout << "#";
		}
		cout << endl;
    }
    cout << endl;
}

return 0;
}

Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    map<string, int> M;
    int q; cin >> q;
    REP(i, q){
        string key;
        int op, x; cin >> op >> key;
        switch(op){
            case 0:
                cin >> x;
                M[key] = x;
                break;
            case 1:
                cout << M[key] << "\n";
                break;
        }
    }
    return 0;
}



Measured memory_bytes: 27784
#!/usr/bin/env python3

def f(n,memo={}):
    if n == 0 :
        memo[0] = 2
        return memo[0]
    elif n == 1:
        memo[1] = 1
        return memo[1]
    elif n in memo.keys():
        return memo[n]
    else:
        memo[n] = f(n-1) + f(n-2)
        return memo[n]

def main():
    N = int(input())
    print(f(N))

if __name__ == '__main__':
    main()

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

int main() {
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i++) {
    if(S.at(i)=='7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
vector<int> sieve(int n){
    vector<bool> is_prime(n+1,true);
    vector<int> prime(n+1,0);
    //prime[3] = 1;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2 ; i <= n ; i++){
        prime[i] = prime[i-1];
        if(is_prime[i]){
            if(i%2 != 0 && is_prime[(i+1)/2]){
                prime[i] = prime[i-1]+1;//累積和でiまでの素数の数を記憶
            }
            for(int j = 2*i; j <= n; j += i){
                is_prime[j] = false;
            }
        }
    }
    return prime;
}
int main(){
    int Q;cin>>Q;
    vector<pair<int,int>> q;
    int maxr = 0;
    for(int i = 0; i < Q; i++){
        int r,l;
        cin >> l >> r;
        maxr = max(maxr,r);
        q.push_back(make_pair(l,r));
    }
    vector<int> prime_table = sieve(maxr);
    /* 
    for(auto e : prime_table){
        cout << e << endl;
    }
    */
    for(int i = 0 ;i < Q; i++){
        int l = q[i].first;
        int r = q[i].second;
        cout << prime_table[r]-prime_table[l-1] << endl;
    
    }
    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,x,y;
    cin >> n >> x >> y;
    x--;y--;
    vector<int32> ans(n,0);
    REP(i,n-1)FOR(j,i+1,n){
        int32 dist = j-i;
        if(i <= x && y <= j){
            dist = j - i - (y - x - 1);
        }
        if(i <= x && j <= y){
            dist = min(dist, x - i + 1 + y - j);
        }
        if(x <= i && y <= j){
            dist = min(dist, i - x + 1 + j - y);
        }
        if(x <= i && j <= y){
            dist = min(dist, i - x + 1 + y - j);
        }
        // cout << i << " " << j << " " << dist << endl;
        ans[dist]++;
    }
    FOR(i,1,n)ANS(ans[i]);
    return 0;
}

Measured memory_bytes: 256
// finish date: 2018/04/10

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int Q;
    cin >> Q;
    rep(k, Q) {
        int A, B;
        cin >> A >> B;
        int sq = (int) sqrt((ll) A * B);
        if ((int) sqrt((ll) A * B) * 2 == sqrt((ll) A * B) * 2) sq--;
        int ans = sq * 2;
        if (A != B) ans--;
        if ((ll) sq * (sq + 1) >= (ll) A * B) ans--;
        cout << ans << endl;
    }


    return 0;
}

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

int main()
{
	int a, b;
	string s;
	cin >> a >> b >> s;
	bool ok = 1;
	for (int i = 0; i < a; ++i)
	{
		ok *= ('0' <= s[i] && s[i] <= '9');
	}
	ok *= (s[a] == '-');
	for (int i = a+1; i < s.size(); ++i)
	{
		ok *= ('0' <= s[i] && s[i] <= '9');
	}
	cout << (ok?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;
public class Main {

	//SHA KYO
	class P3D {
		double x,y,z;

		public P3D(double x, double y, double z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}
		
		
		public double distance(P3D b) {
			double x = this.x - b.x;
			double y = this.y - b.y;
			double z = this.z - b.z;
			double dissq =  x * x + y * y + z * z;
			return Math.sqrt(dissq);
		}
	}

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0 ) break;
			P3D [] plist = new P3D[n];
			for(int i = 0; i < n; i++){
				double x = sc.nextDouble();
				double y = sc.nextDouble();
				double z = sc.nextDouble();
				plist[i] = new P3D(x, y, z);
			}
			P3D startP = new P3D(50, 50, 50);
			double mindis = 1 << 24;
			double move = 0.5;
			double mostdis = -1;
			while(move > 1.0e-10){
				for(int i = 0; i < 1000; i++){
					mostdis = -1;
					mindis = 1 << 24;
					int mostdisId = -1;
					for(int j = 0; j < n; j++){
						double nowdis = startP.distance(plist[j]);
						mindis = Math.min(mindis, nowdis);
						if(mostdis < nowdis){
							mostdis = nowdis;
							mostdisId = j;
						}
					}
					P3D mostdisP = plist[mostdisId];
					double movex = (mostdisP.x - startP.x) * move;
					double movey = (mostdisP.y - startP.y) * move;
					double movez = (mostdisP.z - startP.z) * move;
					startP.x = startP.x + movex;
					startP.y = startP.y + movey;
					startP.z = startP.z + movez;
				}
				move = move / 2;
			}
			System.out.printf("%.5f\n",mostdis);
		}
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int mod = 998244353, N = 210000;

int n, dgr[N];

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

int main() {
	int x;
	read(n);
	for (R int i = 2; i <= n; ++i) read(x), ++dgr[x];
	for (R int i = 1; i <= n; ++i) printf("%d\n", dgr[i]);
	return 0;
}

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

int main() {
  int h,n,total = 0;
  cin >> h >> n;
  for(int i = 0; i < n; i++) {
    int waza;
    cin >> waza;
    total += waza;
  }
  if(total >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

const int MAX = 210000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
// O(n)
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
// O(1)
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int H,W,A,B;

int main()
{
	COMinit();
	cin >> H >> W >> A >> B;
	ll ans = 0;
	rep(i,B+1,W+1){
		ll u = COM(H-A-1+i-1,i-1)*COM(A-1+W-i,A-1)%MOD;
		ans += u;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5120
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		boolean[] isAc = new boolean[N];
		for(int i=0;i<N;i++) {
			isAc[i]=false;
		}
		int[] waCount = new int[N];
		for(int i=0;i<N;i++) {
			waCount[i]=0;
		}
		for(int i=0;i<M;i++) {
			int p = sc.nextInt();
			String S = sc.next();
			if(S.equals("AC")) {
				isAc[p-1]=true;
			}else if(!isAc[p-1]) {
				waCount[p-1]+=1;
			}
		}
		int watotal=0;
		int actotal=0;
		for(int i=0;i<N;i++) {
			if(isAc[i]) {
				actotal++;
				watotal+=waCount[i];
			}
		}
		System.out.println(actotal+" "+watotal);
}
}

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  long long Namount, amt, inpurt, len, fin=0, start=0;
  cin >> Namount;
  vector<long long> list;
  amt = (Namount*(Namount-1))/2;
  for (int i=0; i<Namount;i++) {
    cin >> inpurt;
    list.push_back(inpurt);}
  len = list.size();
  for (int t=0; t<len; t++){
    start=0;
    for (int i=t+1; i<len; i++) {
      start+=list[i];}
    fin+=list[t]*start;}
  cout << fin;}

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


typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

// #define DEBUG

const string YES = "Yes";
const string NO = "No";

const ll INF = 1123456;

struct UpDown{
    ll shitafure;
    ll up;
};


UpDown getData(string& s){
    vec<ll> temp;
    temp.push_back(0);
    ll now = 0;
    for(auto c: s){
        if(c == '('){
            now++;
        }else{
            now--;
        }
        temp.push_back(now);

    }
    return UpDown{*min_element(temp.begin(), temp.end()), temp.back()};

}


void solve(long long N, std::vector<std::string> S){
    vec<UpDown> pos;  // zezroもふくむ
    vec<UpDown> neg;
    string constructed;

    for(auto s: S){
        auto data = getData(s);
        if(data.up >= 0){
            pos.push_back(data);
        }else{
            reverse(s.begin(), s.end());
            for(auto &t: s){
                if(t == '('){
                    t = ')';
                }else{
                    t = '(';
                }
            }
            data = getData(s);
            neg.push_back(data);
        }
    }

    sort(pos.begin(), pos.end(), [&](UpDown a, UpDown b){
        if(a.shitafure > b.shitafure){
            return true;
        }else if(a.shitafure < b.shitafure){
            return false;
        }else{
            return a.up > b.up;
        }
    });

    ll now = 0;
    for(auto iter: pos){
        if(now + iter.shitafure < 0){
            cout << "No" << endl;
            return;
        }
        now += iter.up;
    }

    sort(neg.begin(), neg.end(), [&](UpDown a, UpDown b){
        if(a.shitafure > b.shitafure){
            return true;
        }else if(a.shitafure < b.shitafure){
            return false;
        }else{
            return a.up > b.up;
        }
    });

    ll nowNeg = 0;
    for(auto iter: neg){
        if(nowNeg + iter.shitafure < 0){
            cout << "No" << endl;
            return;
        }
        nowNeg += iter.up;
    }

    if(now == nowNeg){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 50444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9+3;
const ll INF = 1e18+3;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

const int MAX_V = 1e5;
vector<int> es[MAX_V];
int d1[MAX_V], d2[MAX_V];

void dfs1(int now, int pre){
    if(pre != -1) d1[now] = d1[pre]+1;
    for(auto &e: es[now]){
        if(e == pre) continue;
        dfs1(e, now);
    }
}

void dfs2(int now, int pre){
    if(pre != -1) d2[now] = d2[pre]+1;
    for(auto &e: es[now]){
        if(e == pre) continue;
        dfs2(e, now);
    }
}

int main(){
    int N, u, v;
    cin >> N >> u >> v; u--, v--;
    rep(i, N-1){
        int a, b; cin >> a >> b; a--, b--;
        es[a].pb(b), es[b].pb(a);
    }
    d1[u] = 0, d2[v] = 0;
    dfs1(u, -1), dfs2(v, -1);
    int M = 0;
    rep(i, N){
        if(d1[i] >= d2[i]) continue;
        chmax(M, d2[i]);
    }
    cout << M-1 << endl;
}

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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll a;
   	string s;
   	cin>>a>>s;
   	if(a>=3200)	cout<<s<<endl;
   	else cout<<"red"<<endl;
    return 0;
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}


int gcd(int a,int b){
  if(a%b)return gcd(b,a%b);
  else return b;
}
int main(){
  int n,m;cin>>n>>m;
  int mn = 10000;
  for(int i = 0; n > i; i++){
    int a,b;cin>>a>>b;
    if(m < b)continue;
    mn = min(mn,a);
  }
  if(mn == 10000){
    cout <<"TLE" << endl;
  }else{
    cout <<mn << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define REYNA(i,a,b) for(int i=(a);i<(b);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, pair <int, ll> > PP;
typedef pair <PII, int> PPI;
typedef pair <int, PII> PIP;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;
const int maxn = 1e5 + 5;

vector <string> v;
string s;

int main()
{
	int k;
	boost;
	cin >> s >> k;
	int n = s.length();
	for (int i=0; i<n; i++)
	{
		string tmp = "";
		for (int j=i; j<min(i+7, n); ++j)
		{
			tmp += s[j];
			v.pb(tmp);
		}
	}
	
	sort(v.begin(), v.end());
	if (k == 1) OUT(v[0]); --k;
	for (int i=1; i<v.size(); ++i)
	{
		if (v[i] != v[i - 1]) --k;
		if (k == 0) OUT(v[i]);
	}
}


Measured memory_bytes: 2300
#include <iostream>
#include <set>
#include <map> 
#include <queue>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std; 

typedef long long ll; 
const int up=1000005; 

int main(){
	int n,m,q; cin>>n>>m>>q; 
	vector<int> v[n+2]; 
	for(int i=1;i<=m;i++){
		int l,r; cin>>l>>r; 
		v[l].push_back(r); 
	}
	for(int i=1;i<=n;i++){
		sort(v[i].begin(),v[i].end()); 
	}
	for(int i=1;i<=q;i++){
		int l,r; cin>>l>>r; 
		int ans=0;
		for(int j=l;j<=r;j++){
			int u=upper_bound(v[j].begin(),v[j].end(),r)-v[j].begin();
			ans+=u; 	
		}
		cout<<ans<<endl; 
	}
	

}


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

#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
typedef long double ld;

// Write From This Line
int main()
{
	vector<int> a(3);
	rep(i,3) cin >> a[i];
	int count = 0;
	// まず偶奇を揃える
	int odd_num = 0;
	rep(i,3){
		if(a[i] % 2 == 1) odd_num ++;
	}
	bool flag = false;
	if(odd_num == 1){
		rep(i,3){
			if(a[i] % 2 == 0){
				a[i] ++;
			}
		}
		flag = true;
	}
	if(odd_num == 2){
		flag = true;
		rep(i,3){
			if(a[i] % 2 == 1){
				a[i] ++;
			}
		}
	}
	sort(a.begin(),a.end());
	cout << flag +(a[2] - a[0]) / 2 + ( a[2]- a[1]) / 2 << endl;
}


Measured memory_bytes: 256
#####segfunc#####
def segfunc(x, y):
    return min(x,y)
#################

#####ide_ele#####
ide_ele = float("inf")
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

def main():
    import sys,random

    input=sys.stdin.readline

    N=int(input())
    q=[]
    r=[]
    b=[]
    X=0
    q_append=q.append
    for i in range(N):
        x,y=map(int,input().split())
        r.append(max(x,y))
        b.append(min(x,y))


    X=max(b)
    init_val=[b[i] for i in range(N)]
    for i in range(N):
        x,y=r[i],b[i]
        if X>r[i]:
            init_val[i]=r[i]
        elif X>b[i]:
            q_append((r[i],i,-1))
            init_val[i]=b[i]
        else:
            q_append((b[i],i,1))
            q_append((r[i],i,-1))
            init_val[i]=b[i]

    q.sort()
    test1=float("inf")
    rmq=SegTree(init_val,segfunc,ide_ele)
    

    for i in range(0,len(q)):
        val,index,k=q[i]
        if k==-1:
            rmq.update(index,val)
        res=rmq.query(0,N)
        test1=min(val-res,test1)


    test2=(max(r)-min(r))*(max(b)-min(b))
    test1*=(max(max(b),max(r))-min(min(b),min(r)))
    print(min(test1,test2))

if __name__=="__main__":
    main()


Measured memory_bytes: 129168
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    //std::cout << "Hello, World!" << std::endl;
    char A[101] = {0};
    char B[101] = {0};
    char C[101] = {0};

    scanf("%s", A);
    scanf("%s", B);
    scanf("%s", C);
    printf("%c%c%c\n", A[0], B[0], C[0]);
    return 0;
}

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

int main() {
	ll n, a, b;
	ll ans;
	cin >> n >> a >> b;

	if (b < a) {
		cout << 0 << endl;
		return 0;
	}
	ans = b*(n-2) - a*(n-2) + 1;
	if (ans <= 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
a = input()

b = a[::-1]

i = 0
while i  < len(b):
    if b[i:i+5] == "esare":
        i += 5
    elif b[i:i+5] == "maerd":
        i += 5
    elif b[i:i+6] == "resare":
        i += 6
    elif b[i:i+7] == "remaerd":
        i += 7
    else:
        ans = "NO"
        break

if i  == len(b):
    ans = "YES"
else:
    ans = "NO"

print(ans)

Measured memory_bytes: 9120
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  ll a, b, c, d; cin >> a >> b >> c >> d;

  ll ans = max({a*c, a*d, b*c, b*d});
  if(a <= 0 && 0<= b) chmax(ans, 0LL);
  if(c<= 0 && 0<= d) chmax(ans, 0LL);
  cout << ans << endl;
}


Measured memory_bytes: 3572
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;

int main()
{
	char szVal[4];
	cin >> szVal;

	int nCnt = strlen(szVal);
	for (int i = 0; i < nCnt; i++)
	{
		if (szVal[i] == '1')
			szVal[i] = '9';
		else if(szVal[i] == '9')
			szVal[i] = '1';
	}

	cout << szVal;

	return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn binary_search<F>(mut ok: i64, mut ng: i64, pred: F) -> i64
where
    F: Fn(usize) -> bool
{
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if pred(mid as usize) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    ok
}

fn lower_bound<T: Ord>(v: &Vec<T>, x: T) -> i64 {
    binary_search(v.len() as i64 - 1, -1 as i64, |i| {
        x <= v[i]
    })
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let n: usize = sc.get();
    let S: Vec<usize> = sc.vec(n);
    let q: usize = sc.get();
    let T: Vec<usize> = sc.vec(q);
    let mut cnt = 0;
    for i in 0..q {
        let j = lower_bound(&S, T[i]) as usize;
        if S[j] == T[i] {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}



Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll A,B,C;
int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		if(x<=a){
			A++;
		}
		else if(x<=b){
			B++;
		}
		else{
			C++;
		}
	}
	cout << min({A,B,C});
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>

namespace alas
{
	inline bool check_min(int a,int &b){return a<b?b=a,1:0;}
	typedef long long ll;
	const int N=201000,INF=1000000007;
	struct BIT
	{
		int s[N];
		inline int lowbit(int x){return x&(-x);}
		inline void inc(int p){for(;p<N;p+=lowbit(p))s[p]++;}
		inline int ask(int p){int ret=0;for(;p;p-=lowbit(p))ret+=s[p];return ret;}
		inline int query(int L,int R){return ask(R)-ask(L-1);}
	}T;

	std::deque<int> Q[26];
	char s[N];
	int n;

	bool initialize()
	{
		scanf("%s",s+1);
		n=strlen(s+1);
		for(int i=1;i<=n;i++)
			Q[s[i]-'a'].push_back(i);
		int cnt=0;
		for(int i=0;i<26;i++)
			cnt+=Q[i].size()&1;
		return cnt<=1;
	}

	int calc()
	{
		int ret=INF,x,y=-1;
		for(int i=0;i<26;i++)
			if(Q[i].size()>1)
			{
				x=Q[i].front()-1-T.query(1,Q[i].front());
				x+=n-Q[i].back()-T.query(Q[i].back(),n);
				if(check_min(x,ret))y=i;
			}
		T.inc(Q[y].front());
		T.inc(Q[y].back());
		Q[y].pop_front();
		Q[y].pop_back();
		return ret;
	}
	
	void solve()
	{
		if(!initialize()){printf("-1\n");return;}
		ll ans=0;
		for(int tmp=n/2;tmp--;)ans+=calc();
		printf("%lld\n",ans);
	}
}

int main()
{
	alas::solve();
	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define BOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    int N,K;
    cin>>N>>K;
    vector<int> D(K);
    REP(i,K)cin>>D[i];
    
    for(int i=N;i<=10*N;i++){
        int t=i;
        while(t!=0){
            REP(j,K){
                if(t%10==D[j]){
                    goto nextf;
                }
            }
            t/=10;
        }
        cout<<i<<endl;
        return 0;
    nextf:;
    }
    
    
    return 0;
}

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

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");

		int ans = 0;
		for (int i = 0; i < str.length / 2; i++) {
			if (!str[i].equals(str[str.length - i - 1])) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
#!/usr/bin/env python3

# def solve(N: int, M: int, A: List[int]) -> bool:
def solve(n, m, a):
    sum_a = sum(a)
    return len(list(filter(lambda a_i: a_i * 4 * m >= sum_a, a))) >= m

# generated by online-judge-template-generator (https://github.com/kmyk/online-judge-template-generator)
def main():
    import sys
    tokens = iter(sys.stdin.read().split())
    N = int(next(tokens))
    M = int(next(tokens))
    A = [None for _ in range(N)]
    for i in range(N):
        A[i] = int(next(tokens))
    assert next(tokens, None) is None
    ans = solve(N, M, A)
    print(ans and 'Yes' or 'No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
int inf=1e18;

struct graph{

struct edge{int to,cst;};
struct pos{int i,d;
	pos(){};
	pos(int i_,int d_){i=i_,d=d_;};
	bool operator<(const pos& r)const{return d>r.d;}
};


vector<vector<edge>>g;
vector<bool>used;
int n;

vector<int>dist;
priority_queue<pos> pq;

	graph(){};
	graph(int n_){
	n=n_;
	g.resize(n);
	used.assign(n,false);
	dist.resize(n,inf);
	};

	void add_edge(int x,int y,int cst){
		g[x].push_back(edge({y,cst}));
		g[y].push_back(edge({x,cst}));
	}

	void set_dist(int y){
		dist[y]=0;
		 pq.push(pos(y,0));
		while(!pq.empty()){
			pos x=pq.top();pq.pop();
			if(dist[x.i]<x.d)continue;
			for(auto&& w:g[x.i]){
				if(dist[w.to]> x.d+w.cst){
					dist[w.to]=x.d+w.cst;
					pq.push(pos(w.to,dist[w.to]));
				}
			} 
		}	
	}

};


signed main(){
	int n,m,s,t;cin>>n>>m>>s>>t;s--;t--;
	graph g1(n),g2(n);
	for(int i=0;i<m;i++){
		int x,y,a,b;cin>>x>>y>>a>>b;x--;y--;
		g1.add_edge(x,y,a);
		g2.add_edge(x,y,b);
	}
	g1.set_dist(s);
	g2.set_dist(t);	
	int money=1e15;
	int cst=inf;
	vector<int>cs(n);
	for(int i=n-1;i>=0;i--){
		cst=min(cst,g1.dist[i]+g2.dist[i]);
		cs[i]=cst;
	}
	for(auto&& w:cs)cout<<money-w<<endl;
}


Measured memory_bytes: 20216