akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let X: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let B: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = (X - A) % B;

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> list(3);
  for (int i=0; i<3; i++) {
    int t;
    cin >> t;
    list.at(i) = t;
  }
  sort(list.begin(),list.end());
  cout << list.at(0)+list.at(1) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define int long long
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + 5;
int n;
int head[MAXN] , to[MAXN << 1] , nxt[MAXN << 1] , cnt , ans , du[MAXN << 1];
LL f[MAXN] , a[MAXN];
void add(int u , int v) {nxt[++cnt] = head[u];head[u] = cnt;to[cnt] = v;}
void dfs(int x , int fa) {
	LL _sum = 0 , mx = 0;
	for (int i = head[x]; i; i = nxt[i]) {
		if(to[i] == fa) continue;
		dfs(to[i] , x);
		if(ans) return;
		mx = max(mx , f[to[i]]);
		_sum += f[to[i]];
	}
	if(!_sum) {
		f[x] = a[x];
		return;
	}
	f[x] = 2ll * a[x] - _sum;
	if(f[x] < 0 || f[x] > a[x] || mx - f[x] > _sum - mx || a[x] < mx) {
		printf("NO");
		exit(0);
	}
}
signed main() {
	scanf("%lld" , &n);
	for (int i = 1; i <= n; ++i) scanf("%lld" , &a[i]);
	if (n == 2) return puts(a[1] == a[2] ? "YES" : "NO"), 0;
	int root = 0;
	for (int i = 1; i < n; ++i) {
		int u , v;
		scanf("%lld %lld" , &u , &v);
		du[u] ++;du[v] ++;
		add(u , v);add(v , u);
		if(du[u] > 1) root = u;
		if(du[v] > 1) root = v;
	}
	dfs(root , 0);
	if(f[root]) printf("NO");
	else printf("YES");
	return 0;
}

Measured memory_bytes: 15784
#include <stdio.h>



long memo[31];

long fanc(int flo)
{
	int i;
	long sum=0;
	if(flo<0){return 0;}
	if(memo[flo]!=0){return memo[flo];}

	for(i=1;i<=3;i++)
	{
		sum+=fanc(flo-i);
	}
	
	return memo[flo]=sum;
}
int main()
{
	long int num;
	int n;
	int i;
	int ans;
	
	for(i=0;i<31;i++)
	{
		memo[i]=0;
	}
	memo[0]=1;
	while(scanf("%d",&n)&&n!=0)
	{
		num=fanc(n);
		ans=num/3650 + !!(num % 3650);
		
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1028
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cstring>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}
/*
ll Integer_factorization(ll n){
    ll num = 0;
    ll ndash = n;
    if(n == 1) return 1;
    ll a = 2;
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    return num;
}
*/

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

ll prime(ll n){
    ll i = 2;
    ll sum = 0;
    ll m = 10000000000000;
    bool flag = true;
    while(i*i < n+1){
        if(n%i == 0){
            sum = n/i+i;
            m = min(sum,m);
            flag = false;
        }
        i++;
    }
    if(flag) m = n+1;
    return m;
}

void solve() {
    int a,b,c;
    //cin >> a >> b;
    ll n;
    cin >> n;
    cout <<  prime(n)-2LL << endl;
    
}




int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[100];
	int i, j;
	int n;
	int tmp;
	int count;
	int ans;
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
	
		for (i = 0; i < n; i++){
			scanf("%d", &a[i]);
		}
		j = 1;
		ans = 0;
		while (1){
			for (i = 0; i < n - j; i++){
				if (a[i] > a[i + 1]){
					tmp = a[i];
					a[i] = a[i + 1];
					a[i + 1] = tmp;
					ans++;
				}
			}
			j++;
			count = 0;
			for (i = 0; i < n - 1; i++){
				if (a[i] <= a[i + 1]){
					count++;
				}
			}
			if (count == n - 1){
				break;
			}
		}
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 600
from operator import itemgetter


def main():
    N = int(input())
    ab = [tuple(int(j) for j in input().split()) for i in range(N)]
    cd = [tuple(int(j) for j in input().split()) for i in range(N)]
    # y 降順
    ab.sort(key=itemgetter(1), reverse=True)
    # x 昇順
    cd.sort(key=itemgetter(0))
    ans = 0
    for bx, by in cd:
        for rx, ry in ab:
            if rx < bx and ry < by:
                ab.remove((rx, ry))
                ans += 1
                break
    print(ans)
    return


main()


Measured memory_bytes: 3316
h,w=(int(x) for x in input().split())
s=[]
for i in range(h):
  s.append(input())
for i in range(h):
  res=[]
  for j in range(w):
    if s[i][j]==".":
      ini_i=i if i==0 else i-1
      fin_i=i if i==h-1 else i+1
      ini_j=j if j==0 else j-1
      fin_j=j if j==w-1 else j+1
      count=0
      for x in range(ini_i,fin_i+1):
        for y in range(ini_j,fin_j+1):
          if s[x][y]=="#":
            count+=1
      res.append(str(count))
    else:
      res.append("#")
  print("".join(res))

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

#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

int main()
{
    int N,M,C;
    int ans = 0;
    int temp;
    cin >> N >>M >>C;
    int A[20][20];
    int B[20];
    for(int i = 0 ; i<M ; i++) {
        cin >> B[i];
    }
    for(int i = 0 ; i<N ; i++) {
        for(int j = 0 ;j<M; j++) {
            cin >> A[i][j];
        }
    }
    for(int i = 0 ; i<N ; i++) {
        temp = 0;
        for(int j = 0 ;j<M; j++) {
            temp = temp + A[i][j]*B[j];
        }
        temp += C;
        if(temp>0)
            ans++;
    }
    cout << ans;
    return 0;
}


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

bool checkKaibun(string S) {
    bool flag = true;
    string T;
    for (int i = S.length() - 1; i >= 0; i--) {
        T = T + S.at(i);
    }
    for (int i = 0; i < S.length(); i++) {
        if (S.at(i) != T.at(i)) {
            flag = false;
            break;
        }
    }
    return flag;
}


int main()
{
    string S;
    cin >> S;
    string S1 = S.substr(0, (S.length() - 1) / 2);
    string S2 = S.substr((S.length() + 1) / 2, (S.length() - 1) / 2);
    if (checkKaibun(S) && checkKaibun(S1) && checkKaibun(S2)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main()
{
    int K;
    string S;
    cin>> K;
    cin>> S;
    if(S.size()>K){
        rep(i,K){
            cout << S[i];
        }
        cout << "..."<< endl;
    }else{
        cout << S << endl;
    }
}

Measured memory_bytes: 3596
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int N = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] a = sc.next().toCharArray();
		char[] b = sc.next().toCharArray();
		sc.close();
		if(a[0] == 'D') {
			if(b[0] == 'H') {
				b[0] = 'D';
			} else {
				b[0] = 'H';
			}
		}
		out.println(b);
	}
}


Measured memory_bytes: 21716
use proconio::input;

fn main() {
    input!(s: String);
    
    let mut b = s.len();
    let mut ans = 0;

    for i in (0..s.len()).rev() {
        if &s[i..i+1] == "B" {
            ans += b - i - 1;
            b -= 1;
        }
    }

    println!("{}", ans);
}


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

using namespace std;

int main(void){
  string s, t;
  int ans = 0;
  cin >> s >> t;
  
  for(int i = 0; i < 3; i++){
    if(s[i] == t[i]){
    ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

int m,n,ans;

int main() {
  cin >> n >> m;
  std::vector<int> s(m);
  std::vector<char> c(m);
  for (size_t i = 0; i < m; i++) {
    cin >> s.at(i) >> c.at(i);
  }
  string num(n,'x');
  ans = 0;
  for (size_t i = 0; i < m; i++) {
    if (num.at(s.at(i) - 1) != 'x' && num.at(s.at(i) - 1) != c.at(i)) {
      ans = -1;
      break;
    }else{
      num.at(s.at(i) - 1) = c.at(i);
    }
  }
  if (num.at(0) == '0' && n != 1) {
    ans = -1;
  }else if(num.at(0) == 'x' && n != 1){
    num.at(0) = '1';
  }else if (num.at(0) == 'x'){
    num.at(0) = '0';
  }
  if (ans != -1) {
    for (size_t i = 1; i < n; i++) {
      if (num.at(i) == 'x') {
        num.at(i) = '0';
      }
    }
    cout << num << endl;
  }else{
    cout << -1 << endl;
  }
  return 0;
}


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

int main()
{


    int64_t k,a,b;
    cin>>k>>a>>b;

    //交換しない方がよい場合
    if(a+2>b||k<(a-1)+2)
        cout<<k+1<<endl;
    else{
        //1回交換してb枚にする、+kから初回1回分を引いたのが残り、それを交換コスト2で割って1回ごとに(b-a)増える。それと余り
        int64_t wk1=b+(k-(a-1)-2)/2*(b-a)+(k-(a-1)-2)%2;
        cout<<wk1<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

int main()
{
  int n;
  cin >> n;
  vector<queue<int>> ques(n);
  rep(i, n) {
    rep(j, n-1) {
      int tmp;
      cin >> tmp;
      ques[i].push(tmp-1);
    }
  }

  int date = 0;
  while (1) {
    int finished = 0;
    set<pair<int, int>> matches;

    for (int i = 0; i < ques.size(); i++) {
      // ques[i] が empty の場合
      if (ques[i].empty()) {
        finished++;
        continue;
      }
      int enemy = ques[i].front();
      if (i == ques[enemy].front()) {
        // 試合する. このタイミングで que から抜くのはまずいはず
        if (i < enemy) {
          matches.insert(make_pair(i, enemy));
        }
      }
    }

    if (finished == n) {
      break;
    }

    if (matches.empty()) {
      cout << "-1" << endl;
      return 0;
    }

    for (auto itr = matches.begin(); itr != matches.end(); ++itr) {
      ques[(*itr).first].pop();
      ques[(*itr).second].pop();
    }
    date++;
  }

  cout << date << endl;

  return 0;
}


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

using namespace std;

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

const double PI=3.14159265358979323846;

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

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

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

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

vector< string > field;

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

    int h, w;
    cin >> h >> w;

    field.resize(h);
    rep (i, h) cin >> field[i];

    int num = 0;
    rep (i, h) rep (j, w) num += field[i][j] == '#';

    auto check = [](int x) {
        int ret = 0;
        while (x)
        {
            ret += x & 1;
            x >>= 1;
        }
        return ret;
    };

    bool ans = false;
    rep (i, 1 << (h + w - 2))
    {
        if (check(i) != h - 1) continue;
        int temp = i;
        int y, x;
        x = y = 0;
        int cnt = field[y][x] == '#';
        rep (j, h + w - 2)
        {
            if ((temp >> j) & 1) ++y;
            else ++x;
            if (field[y][x] == '#') ++cnt;
        }
        if (num == cnt) ans = true;
    }

    cout << (ans ? "Possible\n" : "Impossible\n");
    return 0;
}



Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
 
for i in range(N):
	a.append(a[i] + A[i])
    
for i in range(M):
	b.append(b[i] + B[i])
    
ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47656
import java.util.Scanner;

public class Main {

	/**
	 * Two Rectangles
	 * @param 1 ≦ A ≦ 10^4
	 * @param 1 ≦ B ≦ 10^4
	 * @param 1 ≦ C ≦ 10^4
	 * @param 1 ≦ D ≦ 10^4
	 */
	public static void main(String... args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();
			if (a * b >= c * d) {
				System.out.println(a * b);
			} else {
				System.out.println(c * d);
			}
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };


double x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4;

int main() {
	while ( ~scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x_1, &y_1, &x_2, &y_2, &x_3, &y_3, &x_4, &y_4 ) ) {
		if ( fabs( ( x_2 - x_1 ) * ( x_4 - x_3 ) + ( y_2 - y_1 ) * ( y_4 - y_3 ) ) < EPS ) {
			printf( "YES\n" );
		}
		else {
			printf( "NO\n" );
		}
	}
	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    stack<char>s1;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='B')
        {
            if(!s1.empty())
            {
                s1.pop();
            }
        }
        else
        {
            s1.push(s[i]);
        }
    }
    string ans;
    while(!s1.empty())
    {
        ans+=s1.top();
        s1.pop();
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}







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

int main() {
  string s,t;cin>>s>>t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  //文字列の辞書順比較はs<tで表される
  if(s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main() {
	// your code goes here
	
	map <char,int> mp;
	
	string s;
	
	cin >> s;
	
	for(int i =0;i<4;i++)
		mp[s[i]]++;
	
	
	if(mp.size()==2)
	{
		map<char,int> :: iterator it;
		
		int  f= 0;
		
		for(it = mp.begin();it!=mp.end();it++)
		{
			if(it->second!=2)
			{
				f = 1;
				break;
			}
		}
		
		if(f)
			cout << "No" << endl;
		else 
			cout << "Yes" << endl;
	}
	
	else 
		cout << "No" << endl;
	
	
	return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < k; i++) ans += p[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner scan = new Scanner(System.in);
        int second = scan.nextInt();
        int hour = second /3600;
        int m = second % 3600;
        int minuit = m /60;
        int b = m % 60;
        System.out.printf("%d:%d:%d\n",hour,minuit,b);
    
    }
}

Measured memory_bytes: 26428
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int[] d = new int[n];

    for (int i = 0; i < n; i++) {
      d[i] = sc.nextInt();
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        ans += d[i] * d[j];
      }
    }
    os.println(ans);
  }
}

Measured memory_bytes: 22484
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a[3][3];
	for(int i = 0; i<3; i++) for(int j = 0; j<3; j++) cin>>a[i][j];
	int flag = 0;
	for(int b = -100000; b<=100000; b++)
	{
		int b1 = a[0][0]-b, b2 = a[0][1]-b, b3 = a[0][2]-b;
		int a2 = a[1][0]-b1,a3 = a[2][0]-b1;
		if(a2+b2==a[1][1] && a2+b3==a[1][2] && a3+b2==a[2][1] && a3+b3 == a[2][2]) flag = 1;
		if(flag) break;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    d = sys.stdin.readline().split()

    s_n = str(n)

    flg = True
    while flg:
        s_n = str(n)

        flg_tmp = True
        for di in d:
            if di in s_n:
                flg_tmp = False
                break

        flg = not flg_tmp
        n += 1

    print(n - 1)


if __name__ == '__main__':
    main()


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n;
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    }
    else if(n == 2){
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 384
S = input()
S_list = []
for i in range(len(S)):
    if S[i] == "N":
        S_list.append(0)
    elif S[i] == "W":
        S_list.append(1)
    elif S[i] == "S":
        S_list.append(2)
    elif S[i] == "E":
        S_list.append(3)

route = [0, 0, 0, 0]

for i in S_list:
    route[i] += 1
if route[0] != 0 and route[1] == 0 and route[2] != 0 and route[3] == 0:
    print("Yes")
elif route[0] == 0 and route[1] != 0 and route[2] == 0 and route[3] != 0:
    print("Yes")
elif route[0] != 0 and route[1] != 0 and route[2] != 0 and route[3] != 0:
    print("Yes")
else:
    print("No")
        


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll p,q,r;
cin>>p>>q>>r;
ll ans=infll;
chmin(ans,p+q);
chmin(ans,q+r);
chmin(ans,p+r);
cout<<ans<<endl;
}









Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int n,m,ans,a[200005],b[200005],c[200005],d[200005],p[200005],fa[200005];
int find(int x)
{
    return (fa[x]==x)?x:fa[x]=find(fa[x]);
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]),a[n+1]^=a[i];
    for (int i=1;i<=n;i++)
        scanf("%d",&b[i]),b[n+1]^=b[i];
    for (int i=1;i<=n+1;i++)
        c[i]=a[i],d[i]=b[i];
    sort(a+1,a+n+2),sort(b+1,b+n+2);
    for (int i=1;i<=n+1;i++)
        if (a[i]!=b[i]) {printf("-1\n");return 0;}

    for (int i=1;i<=n+1;i++)
        if (c[i]!=d[i] || i==n+1) p[++m]=c[i],p[++m]=d[i],ans+=(i<=n);
    if (ans==0) {printf("0\n");return 0;}
    sort(p+1,p+m+1),m=unique(p+1,p+m+1)-p-1;

    for (int i=1;i<=m;i++) fa[i]=i;
    for (int i=1;i<=n+1;i++)
        if (c[i]!=d[i])
        {
            c[i]=lower_bound(p+1,p+m+1,c[i])-p,d[i]=lower_bound(p+1,p+m+1,d[i])-p;
            fa[find(c[i])]=find(d[i]);
        }


    /*
    for (int i=1;i<=n+1;i++)
        p[++m]=c[i],p[++m]=d[i];
    sort(p+1,p+m+1),m=unique(p+1,p+m+1)-p-1;

    for (int i=1;i<=m;i++) fa[i]=i;
    for (int i=1;i<=n+1;i++)
        c[i]=lower_bound(p+1,p+m+1,c[i])-p,d[i]=lower_bound(p+1,p+m+1,d[i])-p;
    for (int i=1;i<=n+1;i++)
        if (c[i]!=d[i] || i==n+1)
            fa[find(c[i])]=find(d[i]),ans+=(i<=n);
        else ans--;
    if (ans==0) {printf("0\n");return 0;}
    */
    for (int i=1;i<=m;i++)
        if (find(i)==i) ans++;
    printf("%d\n",ans-1);
    return 0;
}

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

using int64 = long long;

int N, K;

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

   // Kの倍数である数値の個数を数える
   int64 a = 0;
   for (int x = 1; x <=N; x++) {
      if (x % K == 0) {
         a++;
      }
   }

   // 余りがKの半分となる数値の個数を数える
   int64 b = 0;
   for (int x = 1; x <=N; x++) {
      if (x % K == K/2) {
         b++;
      }
   }

   // 全ての要素がKの倍数の場合を足す
   int64 ans = a * a * a;
   // Kが偶数なら余りがK/2の場合も考慮する
   if (K % 2 == 0) {
      // 全ての要素がK/2の場合を足す
      ans += b * b * b;
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.1.9
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lW,0,a.size()){Vout(a[lW]);}
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
 
signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  Vi a(0);
  string s,t;
  cin >> s >> t;
  
  //tate=11,yoko=22
  
  rep(i,0,n){
    if(s[i]==t[i]) a.pb(11);
    else {
      a.pb(22);
      i++;
    }
  }
  //Vout(a);
  
  int ans = 0;
  if(a[0]==11) ans = 3;
  else ans = 6;
  
  rep(i,1,a.size()){
    if(a[i-1]==11&&a[i]==11) ans *= 2;
    if(a[i-1]==11&&a[i]==22) ans *= 2;
    if(a[i-1]==22&&a[i]==11) ans *= 1;
    if(a[i-1]==22&&a[i]==22) ans *= 3;
    ans %= MOD;
  }
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

const int N = 1e5;
const int oo = INT_MAX;
int dp[N + 5];
int h[N + 5];
int main()
{
    dp[1] = 0;
    for (int i = 2; i <= N; i++)
        dp[i] = oo;
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> h[i];

    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= min(n, i + k); j++)
        {
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
        }
    }

    cout << dp[n];

    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

const int MOD = 1e9+7;

const int INF = 1e10;
const int N=1e5+5;
int n;
int parent[N];
int sz[N];
std::vector<int> f[N],b[N];
int m,k;

void makeset(int x){
    
}

void init(){
    for(int i=0;i<n;i++){
        parent[i]=i;
    sz[i]=1;
    }
}

int find (int x){
    if(parent[x]==x) return x;
    return parent[x]=find(parent[x]);
}

void uni(int a, int b){
    //cout<<"IN "<<a<<b<<'\n';
    int x=find(a);
    int y=find(b);
    //cout<<"MAT "<<x<<" "<<y<<'\n';
    if(x!=y){
        if(sz[x]<sz[y])
            swap(x,y);
        parent[y]=x;
      //  cout<<x<<" "<<y<<'\n';
        sz[x]+=sz[y];
      //  cout<<"FUCK "<<sz[x]<<" "<<sz[y]<<'\n';
    }
}

int32_t main()
{
    
    IOS
    
    cin>>n>>m>>k;
    init();
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        f[x].pb(y);
        f[y].pb(x);
        uni(x,y);
        
    }
    for(int i=0;i<k;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        b[x].pb(y);
        b[y].pb(x);
    }
    
    for(int i=0;i<n;i++){
        int ans=sz[find(i)]-1;
    //    cout<<ans<<" "; 
        for(auto x:b[i]){
           // cout<<"X "<<x<<'\n';
            if(find(x)==find(i)){
                ans--;
            }
        }
      //  cout<<ans<<'\n';
        for(auto x:f[i]){
            if(find(x)==find(i)){
                ans--;
            }
        }
        cout<<ans<<' ';
    }
    return 0;
}


Measured memory_bytes: 14452
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BResale solver = new BResale();
        solver.solve(1, in, out);
        out.close();
    }

    static class BResale {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            int[] value = new int[n];
            for (int i = 0; i < n; i++) {
                value[i] = sc.nextInt();
            }
            int[] cost = new int[n];
            for (int i = 0; i < n; i++) {
                cost[i] = sc.nextInt();
            }

            int[][] dp = new int[n + 1][51 * n];
            boolean[][] go = new boolean[n + 1][51 * n];

            go[0][0] = true;

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 51 * n; j++) {
                    if (go[i][j]) {
                        if (!go[i + 1][j]) {
                            dp[i + 1][j] = dp[i][j];
                        } else {
                            if (j - dp[i + 1][j] < j - dp[i][j]) {
                                dp[i + 1][j] = dp[i][j];
                            }
                        }
                        go[i + 1][j] = true;

                        if (!go[i + 1][j + value[i]]) {
                            dp[i + 1][j + value[i]] = dp[i][j] + cost[i];
                        } else {
                            if (j + value[i] - dp[i + 1][j + value[i]] < j + value[i] - dp[i][j] - cost[i]) {
                                dp[i + 1][j + value[i]] = dp[i][j] + cost[i];
                            }
                        }
                        go[i + 1][j + value[i]] = true;
                    }
                }
            }

            int max = 0;
            for (int i = 0; i < 51 * n; i++) {
                if (go[n][i])
                    max = Math.max(max, i - dp[n][i]);
            }
            out.println(max);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

string IntToString(int number)
{
	stringstream ss;
	ss << number;
	return ss.str();
}

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

int main()
{
    int a, b, c;
    ci >> a >> b >> c;

    co << min(c, b / a) << en;
  
    return 0;
}







Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n

dp[1] = abs(h[0] - h[1])

for i in range(2, n):
    dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))

print(dp[-1])


Measured memory_bytes: 13928
#include <iostream>

using namespace std;

int main()
{
  long long x, k, d;
  cin >> x >> k >> d;
  
  long long n = x / d * (x < 0 ? -1 : 1);
  if (n > k) n = k;
  k -= n;
  x += n * d * (x > 0 ? -1 : 1);
  
  k %= 2;
  
  if (k)
  	x += d * (x > 0 ? -1 : 1);
  
  cout << x * (x < 0 ? -1 : 1);
  return 0;
}


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

int main(){
    string com;
    priority_queue<int> PQ;

    while(1){
        cin >> com;
        if(com=="insert"){
            int key; scanf("%d",&key);
            PQ.push(key);
        } else if(com=="extract"){
            printf("%d\n",PQ.top());
            PQ.pop();
        } else if(com=="end"){
            break;
        }
    }
}

Measured memory_bytes: 7048
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n, k;
    cin >> n >> k;
    if (n >= 2 * k - 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)1e7 + 7;
const int MAXN = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)2e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e18;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

bool prime[N];
int cnt[N], mdiv[N], cntm[N];

void solve() {
	int n; cin >> n;
	fill(mdiv, mdiv + N, INF);
	fill(prime, prime + N, true);
	for (int i = 2; i <= n; i++) {
		if (!prime[i])
			continue;
		mdiv[i] = i;
		for (LL j = 1LL * i * i; j < N; j += i) {
			prime[j] = false;
			uin(mdiv[j], i);
		}
	}
	LL ans = 1;
	cnt[1] = 1;
	for (int i = 2; i <= n; i++) {
		if (mdiv[i / mdiv[i]] != mdiv[i]) {
			cntm[i] = 1;
			cnt[i] = 2 * cnt[i / mdiv[i]];
		}
		else {
			cntm[i] = cntm[i / mdiv[i]] + 1;
			cnt[i] = cnt[i / mdiv[i]] / cntm[i] * (cntm[i] + 1);
		}
		ans += 1LL * i * cnt[i];
	}
	cout << ans;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 130572
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int main(){
  ll H,W,x,y;
  cin>>W>>H>>x>>y;

  long double ans=H*W*0.5;

  if(H==y||W==x){
    cout<<fixed<<setprecision(10)<<ans<<" ";
    cout<<0<<endl;
    return 0;
  }

  bool ox=false,oy=false;
  if(H%2==0&&H/2==y) oy=true;
  if(W%2==0&&W/2==x) ox=true;

  cout<<fixed<<setprecision(10)<<ans<<" ";

  if(ox&&oy) cout<<1<<endl;
  else if(ox||oy) cout<<0<<endl;
  else cout<<0<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

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

    cout<<((n+m)*(n+m-1)/2-n*m)<<endl;
    return 0;
}

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

using namespace std;

int n = 10, k;
long long dp[10][10][2];
long long a = 0;


int f(int pos, int last, bool flag) {
    if(pos == n) {
        if(flag) return 1;
        return 0;
    }
    
    long long &ans = dp[pos][last][flag];
    if(ans != -1) return ans;
    ans = 0;

    for (int i = 0; i < 10; ++i) {
        if(abs(i - last) <= 1 or !flag) {
            ans += f(pos + 1, i, flag | i);
        }
    }
    return ans;
}

void r(int pos, int last, bool flag) {
    if(pos == n) return;

    int ans = 0;
    int id = 0;
    for (int i = 0; i < 10; ++i) {
        if(abs(i - last) <= 1 or !flag) {
            if(ans + f(pos + 1, i, flag | i) >= k) {
                id = i;
                break;
            } else ans += f(pos + 1, i, flag | i);
        }
    }
    k -= ans;
    a = a * 10 + id;
    r(pos + 1, id, id | flag);
}


int main() {
    memset(dp, -1, sizeof dp);
    f(0,0,0);
    cin >> k;
    r(0,0,0);
    cout << a << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5+5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


ll a, b, c, d;

void solve()
{
    cin >> a >> b >> c >> d;
    nout(max_3(a*c,b*d,max(a*d,b*c)));
    
}

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

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long i = 0; i < (long)(n); i++)
int main(){
    long n,cost=0,cost1=0,sum=0;
    cin >> n;
    long a[n],b[n];
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n){
        sum += b[i]-a[i];
        if(b[i]-a[i]>0) cost+=(b[i]-a[i]+1)/2;
        else  cost1 += a[i]-b[i];
    }
    if(max(cost1,cost)<=sum) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

struct HitAndBlow
{
    vector<int> cards;

    HitAndBlow(){
        cards = vector<int>(4);
    }

    void board(const HitAndBlow &other) const {
        int hit = 0, blow = 0;
        for (int i = 0; i < cards.size(); i++)
            for (int j = 0; j < cards.size(); j++)
                if (i == j) {
                    if (cards[i] == other.cards[j])
                        hit++;
                } else if (cards[i] == other.cards[j])
                    blow++;
        cout << hit << " " << blow << endl;
    }
};

istream &operator >> (istream &is, HitAndBlow &g)
{
    for (int i = 0; i < g.cards.size(); i++)
        is >> g.cards[i];
    return is;
}

int main()
{
    for (HitAndBlow braker, maker; cin >> braker >> maker;)
        maker.board(braker);

    return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

int main(int argc, char const *argv[]) {

  int a[32] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int b;

  scanf("%d\n", &b);

  printf("%d\n", a[b-1]);

  return 0;
}




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

int main(void) {
    int n, m, zohe[50] = {};
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        zohe[a - 1]++;
        zohe[b - 1]++;
    }
    for (int i = 0; i < n; i++) {
        cout << zohe[i] << endl;
    }
}


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

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

int main(){
    string S;
    cin >> S;
    if(S[0]==S[1]){
        if(S[2]==S[3] && S[0]!=S[2]){
            cout << "Yes";goto end;
        }
    }
    if(S[0]==S[2]){
        if(S[1]==S[3] && S[0]!=S[1]){
            cout << "Yes";goto end;
        }
    }
    if(S[0]==S[3]){
        if(S[1]==S[2]  && S[0]!=S[1]){
            cout << "Yes";goto end;
        }
    }
    if(S[1]==S[2]){
        if(S[0]==S[3]  && S[0]!=S[1]){
            cout << "Yes";goto end;
        }
    }
    if(S[1]==S[3]){
        if(S[0]==S[2] && S[0]!=S[1]){
            cout << "Yes";
            goto end;
        }
    }
    if(S[2]==S[3]){
        if(S[0]==S[1] && S[0]!=S[2]){
            cout << "Yes";
            goto end;
        }
    }
    cout << "No";
    end:
    return 0;
}

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

int main(int argc, char const *argv[]) {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;

    if (k<=a) {
        ans += k;
    }else if (a < k && k <= a+b) {
        ans += a;
    }else if (a+b < k && k <= a+b+c) {
        ans += a;
        ans -= k - (a+b);
    }

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


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int to_0 = 0;
    int to_x = 0;
    for (int i = 0; i < m; i++) {
        int a; cin >> a;
        if (a < x) to_0++;
        if (a > x) to_x++;
    }
    cout << min(to_0, to_x) << endl;
    return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split())

if N == 0:
    print(X)
    exit()

p = list(map(int, input().split()))

i = 0

while(True):
    if not X-i in p:
        print(X-i)
        break
    elif not X+i in p:
        print(X+i)
        break
    i += 1

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  ull n;
  cin>>n;
  ull cnt=1;
  ull p=100;
  for(cnt;cnt<=4000;cnt++){
    p*=1.01;


    if(p>=n) break;

  }
  cout<<cnt;
  return(0);
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<math.h>

int main(){

	int n;
	scanf("%d",&n);
	int S[100000];
	int i;
	for(i=0;i<n;i++){
		scanf("%d",&S[i]);	
	}
	
	int q;
	scanf("%d",&q);
	int T[50000];
	for(i=0;i<q;i++){
		scanf("%d",&T[i]);	
	}
	
	int C=0;
	int key=0;
	int k;
	for(i=0;i<q;i++){
		key=T[i];
		int left=0;
		int right=n-1;
		for(k=0;(double)k<log2((double)n);k++){
			int middle=(right+left)/2;
			if(key==S[middle]){
			C++;
			break;
			}
			else if(key<S[middle]){
				right=middle;
			}
			else if(key>S[middle]){
				left=middle+1;
			}
		}
	}
	
	
	printf("%d\n",C);
	return 0;
}


Measured memory_bytes: 2432