akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class ADDCCFinals {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int x = Math.min(4, s.nextInt()), y = Math.min(4, s.nextInt());
            int res = (4 - x) * 100000 + (4 - y) * 100000;
            if (x == 1 && y == 1)
                res += 400000;
            w.println(res);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, w[110];

    cin >> n;

    REP(i, n)
    cin >> w[i];

    int res = 1e9;
    for (int i = 1; i < n; i++)
    {
        int a = 0;
        int b = 0;
        REP(j, n)
        {
            if (j + 1 <= i)
                a += w[j];
            else
                b += w[j];
        }

        res = min(res, abs(a - b));
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


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

    vector<pair<int,int>> e[n];

    rep(i,n-1){
        int a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        pair<int,int> p;
        p.first = b;
        p.second = c;
        e[a].push_back(p);
        p.first = a;
        e[b].push_back(p);
    }

    int ans[n];
    rep(i,n){
        ans[i] = -1;
    }

    queue<int> que;
    que.push(0);
    ans[0] = 0;

    while(!que.empty()){
        int x = que.front();
        que.pop();
        rep(i,e[x].size()){
            if(ans[e[x][i].first]==-1){
                ans[e[x][i].first] = (ans[x]+e[x][i].second) % 2;
                que.push(e[x][i].first);
            }
        }
    }

    rep(i,n){
        cout << ans[i] << endl;
    }

    return 0;
}
 
 


Measured memory_bytes: 6784
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
void solve()
{
    int n;
    cin>>n;
    int ans=0;
    rep1(i,n){
        int x;
        cin>>x;
        if((i&1)&&(x&1)) ans++;
    }
    pr(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

const int X_MAX = 35;
const int Y_MAX = 3005;

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    bool x[X_MAX], y[Y_MAX];
    for (ll i = 0; i <= X_MAX; i++) x[i] = false;
    for (ll i = 0; i <= Y_MAX; i++) y[i] = false;
    int tw, water = 0, sugar = 0;
    int a_max = f / (100 * a), b_max = f / (100 * b), c_max = f / c, d_max = f / d;
    for (ll i = 0; i <= a_max; i++) {
        x[i * a] = true;
        for (ll j = 0; j <= b_max; j++) {
            x[j * b] = true;
            tw = i * a + j * b;
            if (100 * tw <= f) x[tw] = true;
        }
    }
    for (int i = 0; i <= c_max; i++) {
        y[i * c] = true;
        for (int j = 0; j <= d_max; j++) {
            y[j * d] = true;
            tw = i * c + j * d;
            if (tw <= f) y[tw] = true;
        }
    }
    double conc, maxc = -1, conc_lim = (double)(100 * e) / (100 + e);
    for (ll i = 0; i <= X_MAX; i++) {
        if (!x[i]) continue;
        for (ll j = 0; j <= Y_MAX; j++) {
            if (y[j] && 100 * i + j <= f) {
                conc = (double)(100 * j) / (100 * i + j);
                if (conc <= conc_lim && conc == (maxc = max(maxc, conc))) {
                    water = 100 * i;
                    sugar = j;
                }
            }
        }
    }
    cout << water + sugar << ' ' << sugar << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>

using namespace std;


vector<int> value; // ノードの値を持つ配列
int N;             // 葉の数

void update(int i, int x) {
	i += N - 1;
	value[i] = x;
	while (i > 0) {
		i = (i - 1) / 2;
		value[i] = max(value[i * 2 + 1],
			value[i * 2 + 2]);
	}
}

int query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return 0;
	if (a <= l && r <= b)
		return value[k];
	else {
		int c1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
		int c2 = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return max(c1, c2);
	}
}

int binary_search(int left, int right, int key, int pivot) {
	while (right-left >= 2) {
		int mid = left + (right - left) / 2; // 区間の真ん中
		int val = query(mid, pivot, 0, 0, N);
		if (val > key) {
			left = mid;
		}
		else right = mid;
	}
	return left;
}

int binary_search2(int left, int right, int key, int pivot) {
	while (right - left >= 2) {
		int mid = left + (right - left) / 2; // 区間の真ん中
		int val = query(pivot,mid, 0, 0, N);
		if (val > key) right = mid;
		else left = mid;
	}
	return left;
}

int main() {
	int n;
	cin >> n;
	N = 1;
	while (N < n) N *= 2; // 葉の数を計算（n以上の最小の2冪数）
	value = vector<int>(2 * N - 1, 0);
	vector<int> p;
	for (int i = 0; i < n; ++i) {
		int pi;
		cin >> pi;
		update(i, pi);
		p.push_back(pi);
	}
	int64_t sum = 0;
	for (int i = 0; i < n; ++i) {
		int val = p[i];
		int lp1, lp2;
		int rp1, rp2;

		int left1 = query(0, i, 0, 0, N);
		if (left1 < val) {
			lp1 = lp2 = -1;
		}
		else {
			int pos = binary_search(0, i, val, i);
			lp1 = pos;
			int left2 = query(0, lp1, 0, 0, N);
			if (left2 < val) {
				lp2 = -1;
			}
			else {
				int pos2 = binary_search(0, lp1, val, lp1);
				lp2 = pos2;
			}
		}

		int right1 = query(i+1,N, 0, 0, N);
		if (right1 < val) {
			rp1 = rp2 = -1;
		}
		else {
			int pos = binary_search2(i+1, N, val, i+1);
			rp1 = pos;
			int right2 = query(rp1+1, N, 0, 0, N);
			if (right2 < val) {
				rp2 = -1;
			}
			else {
				int pos2 = binary_search2(rp1+1, N, val, rp1+1);
				rp2 = pos2;
			}
		}
		int64_t lval = val;
		//cout << i << " " << lp1 << " " << lp2 << " " << rp1 << " " << rp2 << endl;
		if (lp1 != -1) {
			int64_t lpad, rpad;
			int left = (lp2 != -1) ? lp2 : -1;
			int right = (rp1 != -1) ? rp1 : n;
			lpad = lp1 - left;
			rpad = right - i;
			sum += val * lpad*rpad;
		}
		if (rp1 != -1) {
			int64_t lpad, rpad;
			int left = (lp1 != -1) ? lp1 : -1;
			int right = (rp2 != -1) ? rp2 : n;
			lpad = i - left;
			rpad = right - rp1;
			sum += val * lpad*rpad;
		}
	}
	cout << sum << endl;
	return 0;
}


/*
int main() {
	int n;
	vector<int> s;
	for (int i = 0; i < (1 << n); ++i) {
		int si;
		cin >> si;
		s.push_back(si);
	}
	sort(s.rbegin(), s.rend());
	int last = -1;
	for (int i = 0; i < s.size(); ++i) {
		int si = s[i];
		if (last == si) {

		}
	}
	return 0;
}
*/

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

int main(){

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

    cout << a*b-(b+a-1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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 N;

//DPテーブル
vector<ll> dp(100010);

int main() {
    int n;
    cin>>n;
    string ans;
    if(n%10==3) {ans="bon";}
    else if(n%10==0 || n%10==1 || n%10==6 || n%10==8) {ans="pon";}
    else {ans="hon";}
    cout << ans << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> a(n);
  rep(i,n) {
    ll x;
    int y;
    cin >> x >> y;
    a.at(i)=make_pair(x,-1*y);
  }
  sort(a.begin(),a.end());
  int cnt=0;
  int i=0;
  ll ans=0;
  ll z;
  int v,w;
  while(cnt<m) {
    tie(z,v)=a.at(i);
    w=-1*v;
    ans+=z*w;
    cnt+=w;
    i++;
  }
  if(cnt>m) ans -= z*(cnt-m);
  cout << ans << endl;
}

Measured memory_bytes: 1792
import math

A,B,H,M = map(int,input().split())

th1 = (H + M/60)*math.pi/6
th2 = M*math.pi/30

RS2 = (B*math.sin(th2) - A*math.sin(th1))**2
RC2 = (B*math.cos(th2) - A*math.cos(th1))**2
R2 = RS2 + RC2
print(R2**(1/2))

Measured memory_bytes: 9148
using System;
using System.Linq;
using System.Text;

namespace ABC158d
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            var Q = int.Parse(Console.ReadLine());

            StringBuilder sb1 = new StringBuilder(S.Length + Q);
            StringBuilder sb2 = new StringBuilder(S.Length + Q);
            
            bool rule = true;
            for (int i = 0; i < Q; i++)
            {
                var q = Console.ReadLine().Split(' ');
                if (q[0] == "1")
                {
                    rule = !rule;
                }
                else if(q[0] == "2")
                {
                    if(q[1] == "1")
                    {
                        if (rule)
                        {
                            sb2.Append(q[2]);
                        }
                        else
                        {
                            sb1.Append(q[2]);
                        }

                    }
                    else if (q[1] == "2")
                    {
                        if (rule)
                        {
                            sb1.Append(q[2]);
                        }
                        else
                        { 
                            sb2.Append(q[2]);
                        }
                    }
                }
            }
            string result;
            if (rule)
            {
                result = string.Join("", sb2.ToString().Reverse())
                    + S + sb1.ToString();
            }
            else
            {
                result = string.Join("", sb1.ToString().Reverse())
                    + string.Join("", S.Reverse()) + sb2.ToString();
            }
            Console.WriteLine(result);
        }
    }
}


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


int main() { 
  int n,k,ans=0;
  cin>>n>>k;
  vector<int> h(n);
  rep(i,n){cin>>h[i];if(h[i]>=k){ans++;}}
  cout<<ans<<endl;
  

}

Measured memory_bytes: 640
n=int(input())
A=[0]*3
for i in map(int,input().split()):
    A[i-1]+=1
dp=[[[0]*(n+2)for _ in range(n+2)]for __ in range(n+2)]
for i in range(A[2]+1):
    for j in range(n-A[0]-i+1):
        for k in range(n-i-j+1):
            if i+j+k!=0:
                dp[i][j][k]=(dp[i-1][j+1][k]*i+dp[i][j-1][k+1]*j+dp[i][j][k-1]*k+n)/(i+j+k)
i,j,k=A
print(dp[k][j][i])

Measured memory_bytes: 508936
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
#include <math.h>
//#include <vector>
//#include <unordered_map>
#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    string s;
    cin >> s;
    int tmp;
    int ans=1000;
    for(int i=0; i<s.size()-2; i++){
        tmp=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        tmp=abs(tmp-753);
        if(tmp<ans){
            ans=tmp;
        }
    }
    cout << ans << endl;

    return 0;
}

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

class MainClass
{
    static readonly long mod = 998244353;
    static void Main()
    {
        var NS = ReadLine().Split().Select(int.Parse).ToArray();
        int N = NS[0];
        int S = NS[1];
        var A = ReadLine().Split().Select(int.Parse).ToArray();

        var dp = new long[N+1][];
        for (int i = 0; i < N+1; i++)
        {
            dp[i] = new long[S + 1];
            
        }

        dp[0][0] = 1;

        for (int i = 0; i < N; i++)
        {
            for (int j = S; j >=0; j--)
            {
                dp[i + 1][j] = dp[i][j] * 2;
                dp[i + 1][j] %= mod;
                int k = j + A[i];

                if (dp[i][j] == 0 || k > S) continue;
                dp[i + 1][k] += dp[i][j];
                dp[i + 1][k] %= mod;

            }
        }
        WriteLine(dp[N][S]);
    }
}


Measured memory_bytes: 99952
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a/__gcd(a, b))*b; }

void solve()
{
    ll n;
    cin >> n;
    ll l = 1;
    rep(i, n){
        ll x; cin >> x;
        l = lcm(l, x);
    }cout << l << " ";
}
int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

void solve(string s, char c, int n){
    if((int)s.size()==n){
        cout << s << endl;
        return;
    }
    char ad = 'a';
    while((int)ad<=(int)c+1){
        solve(s+(char)ad,(char)(max(ad,c)),n);
        ad+=1;
    }
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s = "a";
    solve(s,'a',n);
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll h, w;
char b[1000][1000];
ll dp[1001][1001];

int main() {
    cin >> h >> w;
    rep(i,h) rep(j,w) cin >> b[i][j];
    dp[0][0] = 1;
    rep(i,h) {
        rep(j,w) {
            if (b[i][j] == '#') continue;
            if (i != 0) dp[i][j] += dp[i-1][j];
            if (j != 0) dp[i][j] += dp[i][j-1];
            dp[i][j] %= MOD;
        }
    }
    cout << dp[h-1][w-1] << endl;
}



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

using namespace std;

int main() {

	string S;
	string T;

	cin >> S;
	cin >> T;
	int res = 0;

	for (int i = 0; i < 3; ++i) {
		if (S[i] == T[i]) ++res;
		else continue;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
//#include <unordered_map>
//#include <unordered_set>
#include <iterator>
#include <cmath>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define ins insert
#define iter ::iterator
#define upb upper_bound
#define lwb lower_bound
#define INF32 10e9
#define INF64 10e18

#define sz(v) v.size()
#define aloc(i, a, n) i *a = new i[n]
#define print(a) if(DEBUG) cout << a << endl;
#define print2(a,b) if(DEBUG) cout << a << ' ' << b << endl;
#define print3(a,b,c) if(DEBUG) cout << a << ' ' << b << ' ' << c << endl;
#define print4(a,b,c,d) if(DEBUG) cout << a << ' ' << b << ' ' << c << ' ' << d << endl;


#define for0(i,a) for(ll i = 0; i < a; i++)
#define fori(i,a,b) for(ll i = a; i < b; ++i)
#define rfor0(i,a) for(ll i = a; i >= 0; --i)
#define rfor(i,a,b) for(ll i = a; i >= b; --i)

#define DEBUG true
//##############################################################################

void solve(){
	string s;
	cin >> s;
	if(s[3] == s[2] && s[4] == s[5])
		cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main(){
	int Q = 1;
	//cin >> Q;
	for0(q,Q) solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
void ii(ll &x){ cin >> x; }
void is(string &x){ cin >> x; }
void oi(ll x){ cout << x << " "; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }

ll INF = 1e9+7;

ll modinv(ll a, ll m){
    ll b=m,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b; swap(a,b);
        u-=t*v; swap(u,v);
    }
    u%=m;
    if(u<0){ u+=m; }
    return u;
}

ll modpow(ll a, ll n, ll m){
    ll ret=1;
    while(n>0){
        if(n&1){ ret=ret*a%m; }
        a=a*a%m;
        n>>=1;
    }
    return ret;
}

ll modC(ll n, ll k){
    ll a=n;
    ll b=1;
    REP(i,1,k){
        a*=(n-i);
        a%=INF;
        b*=(i+1);
        b%=INF;
    }
    return (a*modinv(b, INF))%INF;
}

int main(){
    ll n, a, b;
    ii(n), ii(a), ii(b);
    ll ans=(modpow(2,n,INF)-1-modC(n,a)-modC(n,b));
    ans+=INF*10;
    ans%=INF;
    oie(ans);
    return 0;
}

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

int main() {
  int N;
  int64_t r0=2,r1=1,R=1;
  cin >> N;
  for(int i=0;i<N-1;i++){
    if(N==1){
      break;
    }
    R=r0+r1;
    r0=r1;
    r1=R;
  }
  cout << R << endl;    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;
using P = pair<int, int>;

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

    int H, W; cin >> H >> W;
    vector<string> s(H);
    for (int i = 0; i < H; i++) cin >> s[i];

    vector<vector<int>> check(H, vector<int>(W, -1));
    check[0][0] = s[0][0] == '.' ? 0 : 1;
    queue<P> que;
    que.push(P(0, 0));
    while (!que.empty()) {
        P now = que.front(); que.pop();
        int i = now.first;
        int j = now.second;
        if (i+1 < H) {
            int value = check[i][j];
            if (s[i][j] == '.' && s[i+1][j] == '#')
                value++;
            if (check[i+1][j] < 0) {
                check[i+1][j] = value;
                que.push(P(i+1, j));
            }
            else check[i+1][j] = min(check[i+1][j], value);
        }
        if (j+1 < W) {
            int value = check[i][j];
            if (s[i][j] == '.' && s[i][j+1] == '#')
                value++;
            if (check[i][j+1] < 0) {
                check[i][j+1] = value;
                que.push(P(i, j+1));
            }
            else check[i][j+1] = min(check[i][j+1], value);
        }
    }
    cout << check[H-1][W-1] << "\n";
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main(int argc, char const *argv[]) {
  unsigned long long X, Y;
  cin >> X >> Y;
  int ans = 0;
  while (X <= Y) {
    ans++;
    X = 2 * X;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <fstream>
#include <set>
#include <stack>
#include <queue>
#include <list>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
// // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    int64 a,b,n;
    cin >> a >> b >> n;
    int64 x;
    int64 rs;
    if (n >= b){
        x = b - 1;
    }
    else{
        x = n;
    }
    rs = ((a * x) / b) -a * (x / b);
    ctn(rs);
    return 0;
}


Measured memory_bytes: 3632
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(list(dict.fromkeys(ans)))
    if(ans[-1]==n):
        ans = ans[:-1]
    return ans

n = int(input())
ans = ''
for i in range(1, 99):
    if(n <= 26**i):
        n-=1
        for i in range(i):
            ans+=(chr(ord('a')+n%26))
            n//=26
        break
    else:
        n-=26**i
ans = ans[::-1]
print(ans)

Measured memory_bytes: 61780
#include <stdio.h>

int main(void)
{
	int a,b,c,d,e;
	scanf("%d",&d);
	for(e=0;d>e;e++){
		scanf("%d %d %d",&a,&b,&c);
		if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==b*b+a*a)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

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

int main(){
    vector<int> s(3,0);
    for(int i = 0; i < 3; i++) cin >> s[i];
    sort(s.begin(), s.end(), greater<int>());

    cout << s[0]*10 + s[1] + s[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <memory>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;

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

    queue<unsigned int> lunq;

    int cnt = K;
    unsigned int lun = 0;
    for(auto i = 1; i <= 9; i++) {lunq.push(i);}
    while (true)
    {
        lun = lunq.front();
        lunq.pop();

        cnt--;
        if (cnt <= 0) break;
        if (lun % 10 != 0) {lunq.push((10 * lun)+(lun%10)-1);}
        lunq.push((10 * lun)+(lun%10));
        if (lun % 10 != 9) {lunq.push((10 * lun)+(lun%10)+1);}
    }

    cout << lun << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a < b && b < c){
			System.out.printf("Yes\n");
		}else{
			System.out.printf("No\n");
		}
	}
}


Measured memory_bytes: 26308
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  if(v<w)cout << "NO" << endl;
  else if((v-w)*t>=abs(a-b))cout << "YES" << endl;
  else cout << "NO" << endl;
}
  


Measured memory_bytes: 3588
#include <cstdio>
#include <vector>

int testcase_ends() {
  size_t n;
  int m;
  scanf("%zu %d", &n, &m);

  if (n == 0 && m == 0) return 1;

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);

  size_t target_i = n;
  int min_time = 2000;
  int min_diff = 2000;
  for (size_t i = 0; i < n; ++i) {
    int time = (min_time/a[i]+1) * a[i];
    if (time > m) time = m / a[i] * a[i];
    if (min_time > time || (min_time == time && min_diff > a[i])) {
      target_i = i+1;
      min_time = time;
      min_diff = a[i];
    } else if (min_time == time && min_diff == a[i]) {
      target_i = n;
    }
  }
  printf("%zu\n", target_i);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2584
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
using namespace std;
using ll = long long;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

ll dp[500010] = {};

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}
  void init(int n) { par.assign(n, -1); }

  int root(int x) {
    if (par[x] < 0)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return;
    if (par[x] > par[y])
      swap(x, y);
    par[x] += par[y];
    par[y] = x;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { return -par[root(x)]; }
};

signed main() {
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  int l=0;
  int r = n;
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    l = max(l, a);
    r = min(r, b);
  }
  cout << max(0, r - l+1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,q;cin>>n>>q;
  vector<ll> A(n+3),up_sum(n+3),kisu_sum(n+3);
  up_sum[0] = 0;
  REPS(i,n){
    cin>>A[i];
  }
  reps(i,n){
    up_sum[i] = up_sum[i-1] + A[i];
  }
  kisu_sum[n+1] = 0;
  kisu_sum[n+2] = 0;
  REPS(i,n){
    if(i%2 == 1){
      kisu_sum[i] = kisu_sum[i+2] + A[i];
    }
  }

  rep(t_, q){
    ll x;cin>>x;
    ll ok = n+10;
    ll ng = 0;
    while(ok-ng >= 2){
      ll mid = (ok+ng)/2;
      if(2*mid+1 > n || abs(A[mid+1] - x) < abs(A[2*mid+1] - x)){
        ok = mid;
      }else{
        ng = mid;
      }
    }
    cout<<up_sum[ok] + kisu_sum[2*ok + 1]<<endl;
  }

  return 0;
}

Measured memory_bytes: 4096
from queue import Queue
w, h = 0, 0

def bfs(x, y, data):
    que = Queue()
    que.put((x, y))

    while not que.empty():
        x, y = que.get()
        if data[x][y] == 0:
            continue

        data[x][y] = 0
        for dx in range(-1, 2):
            for dy in range(-1, 2):
                sx, sy = x + dx, y + dy
                if sx < 0 or sx >= h or sy < 0 or sy >= w:
                    continue
                que.put((sx, sy))
    return data


while True:
    w, h = map(int, input().split())
    if w == h == 0:
        break

    data = []
    for i in range(h):
        data.append(list(map(int, input().split())))

    ans = 0
    for x in range(h):
        for y in range(w):
            if data[x][y] > 0:
                ans += 1
                data = bfs(x, y, data)
    print (ans)


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

int main(void){
  int n;
  char s[10] = {};
  int i, j, k;

  scanf("%d", &n);

  for(i = 0; i < 3; i++){
    s[i] = (n/((int) pow(10, (double) i)))%10 + '0';
    if(s[i] == '1'){
      s[i] = '9';
    }else if(s[i] == '9'){
      s[i] = '1';
    }
  }

  n = (s[2] - '0')*100 + (s[1] - '0')*10 + (s[0] - '0');

  printf("%d\n", n);

  return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.util.regex.*;
 
public class Main {
	
	public static void main(String[]  args) {
		System.out.println(countTakahashi(scanInt(), scanInt()));
	}
	
	private static int countTakahashi(int a, int b) {
		return a - ((b < a) ? 1 : 0);
	}
 
	
	private static final Scanner SC = new Scanner(System.in);
 
	private static int scanInt() {
		return SC.nextInt();
	}
 
	private static  String scanString() {
		return SC.next();
	}
}

Measured memory_bytes: 21204
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    let m: i32 = read();
    println!("{}", if m == n { "Yes" } else { "No" });
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
def slove():
    import sys
    input = sys.stdin.readline
    n, m, x, y = list(map(int, input().rstrip('\n').split()))
    xl = list(map(int, input().rstrip('\n').split()))
    xl.sort()
    yl = list(map(int, input().rstrip('\n').split()))
    yl.sort()
    for i in range(x + 1, y + 1):
        if xl[-1] < i <= yl[0]:
            print("No War")
            exit()
    print("War")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;

static class P
{
    static void Main()
    {
        var nw = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nw[0];
        var w = nw[1];
        long[] price = new long[w + 1];
        for (int i = 0; i < n; i++)
        {
            var wv = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int j = price.Length - wv[0] - 1; j >= 0; j--) price[j + wv[0]] = Max(price[j + wv[0]], price[j] + wv[1]);
        }
        Console.WriteLine(price.Max());
    }
}


Measured memory_bytes: 13920
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();
        char[] sArray = s.toCharArray();
        int passStudent = 0;
        int passStrudentAbroad = 0;
        for (int i = 0; i < n; i++) {
            String ans = "No";
            if (sArray[i] == 'a' && a + b > passStudent) {
                passStudent++;
                ans = "Yes";
            } else if (sArray[i] == 'b' && a + b > passStudent && passStrudentAbroad < b) {
                passStudent++;
                passStrudentAbroad++;
                ans = "Yes";
            }
            System.out.println(ans);
        }
    }

}

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

int main(){
    ll n,l;
    cin>>n>>l;
    ll mini=1e9;
    ll sum=0;
    ll atai;
    rep(i,n){
        sum+=l+i;
        if(mini>abs(l+i)){
            mini=abs(l+i);
            atai=l+i;
        }
    }
    cout<<sum-atai<<endl;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final PrintStream so = System.out;
    static final Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        int N = ni();
        int[] V = new int[N];
        int[] C = new int[N];
        for (int i = 0; i < N; i++) {
            V[i] = ni();
        }
        for (int i = 0; i < N; i++) {
            C[i] = ni();
        }
        
        int ans = 0;
        for (int i = 0; i < N; i++) {
            ans += Math.max(0, V[i] - C[i]);
        }
        so.println(ans);
    }
    
    static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
        
       
    static int ni() {
        return sc.nextInt();
    }
    
    static long nl() {
        return sc.nextLong();
    }

    static char[] nsToChars() {
        return sc.next().toCharArray();
    }
}


Measured memory_bytes: 23636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

typedef long long LL;

#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)

#define MAX  600000
#define LIM  100000000
const LL MOD = 1000000007;
const int INF = 2147483647/2;
const LL LINF = 9223372036854775807/3;

int ucmpii(const void *a, const void *b){return(*(int*)a==*(int*)b?0:(*(int*)a>*(int*)b?1:-1));}
int dcmpii(const void *a, const void *b){return(*(int*)a==*(int*)b?0:(*(int*)a<*(int*)b?1:-1));}

int ucmpll(const void *a, const void *b){return(*(LL*)a==*(LL*)b?0:(*(LL*)a>*(LL*)b?1:-1));}
int dcmpll(const void *a, const void *b){return(*(LL*)a==*(LL*)b?0:(*(LL*)a<*(LL*)b?1:-1));}

void SORT(int*a, int n){qsort(a,n,sizeof(int),ucmpii);}
void SORTR(int*a, int n){qsort(a,n,sizeof(int),dcmpii);}
void LSORT(LL*a, int n){qsort(a,n,sizeof(LL),ucmpll);}
void LSORTR(LL*a, int n){qsort(a,n,sizeof(LL),dcmpll);}

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






int main(){
  
  int H,W,M;
  scanf("%d%d%d",&H,&W,&M);

  int hcnt[MAX]={0}, wcnt[MAX]={0};
  int hset[MAX]={0}, wset[MAX]={0};

  REP(i,M){
    int h,w;
    scanf("%d%d",&h,&w);
    h--;w--;
    hcnt[h]++;
    wcnt[w]++;
    hset[i] = h;
    wset[i] = w;
  }

  int hmax=0, wmax=0, bmax=0;

  REP(i,H) hmax = max(hmax,hcnt[i]);
  REP(i,W) wmax = max(wmax,wcnt[i]);
  REP(i,M) bmax = max(bmax,hcnt[hset[i]]+wcnt[wset[i]]);

  LL bmcnt=0,hmcnt=0,wmcnt=0;

  REP(i,H){
    if(hmax==hcnt[i]) hmcnt++;
  }
  REP(i,W){
    if(wmax==wcnt[i]) wmcnt++;
  }
  REP(i,M){
    if(bmax==hcnt[hset[i]]+wcnt[wset[i]]) bmcnt++;
  }

  int ans = hmax+wmax;

  if(bmax == hmax+wmax){
    if(bmcnt == hmcnt*wmcnt){
      ans--;
    }
  }

  printf("%d\n",ans);

}

Measured memory_bytes: 11108
#include<stdio.h>

int main(){
        int h, w, a, b;
        scanf("%d %d %d %d", &h, &w, &a, &b);
        for(int i=0; i<h; i++){
                for(int j=0; j<w; j++) printf("%d", (i<b)^(j<a));
                puts("");
        }
        return 0;
}


Measured memory_bytes: 1152
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

/*int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

struct BIT{
    vector<int> dat;
    int sz;
    BIT(int n){
        for(sz=1;sz<n;sz *= 2);
        dat.resize(++sz);
    }
    int q(int n){
        int ret = 0;
        for(int i=n;i>0;i-=i&-i)ret +=dat[i];//和の計算　iから最後の１のbit(i&-i 多分＆はビット積)を減算
        for(int i=n;i<sz;i+=i&-i) dat[i]++;//値の加算　iから最後mの１のbitを加算
        return ret;
    }
};

int main(){
    string s;
    cin >> s;
    int n=s.size();
    int a[n+1],m=0,p;
    a[0]=0;
    rep(i,n){
        if(s[i]=='A'||s[i]=='G'||s[i]=='C'||s[i]=='T'){
            a[i+1]=a[i]+1;
        }else{
            a[i+1]=0;
        }
       
        if(m<a[i+1]){
            m=a[i+1];
            p=i+1;
        }
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	LL t1, t2, a1, a2, b1, b2;
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	if(a1 > b1) { swap(a1, b1); swap(a2, b2); }
	
	LL x = (a1 * t1 + a2 * t2) - (b1 * t1 + b2 * t2);
	LL y = (b1 - a1) * t1;
	
	if(x == 0) { cout << "infinity" << endl; }
	if(x <  0) { cout << 0 << endl; }
	if(x >  0) { cout << (y / x * 2 + (y % x == 0 ? 0 : 1)) << endl; }
	
	return 0;
}


Measured memory_bytes: 256