akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;


int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<max(ll(0),c-(a-b));
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	string s; cin >> s;
	int len = s.length();
	int le, ri;
	rep(i, len) {
		if (s[i] == 'A') {
			le = i; break;
		}
	}
	per(i, len) {
		if (s[i] == 'Z') {
			ri = i; break;
		}
	}
	cout << ri - le + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
import fractions
a,b,c,d= map(int,input().split())
count = 0
kou = (c*d) // fractions.gcd(c,d)
#print(kou)
if a % kou == 0:
    hajime = a
else :
    hajime = (kou - a % kou) + a
owari = b - (b % kou)
if a % c == 0:
    chajime = a
else :
    chajime = (c - a % c) + a
cowari = b - (b % c)
if a % d == 0:
    dhajime = a
else :
    dhajime = (d - a % d) + a
dowari = b - (b % d)


kousuu = ((cowari - chajime) // c + 1) + ((dowari - dhajime) // d + 1) - ((owari - hajime) // kou + 1)
sa = b - a + 1
print(sa - (kousuu))
#print(hajime,owari,chajime,cowari,dhajime,dowari,)


Measured memory_bytes: 5076
#include<stdio.h>

/*??????????????¢??°*/
long int diff(long int x,long int y) {
	return y - x;
}

int main(void) {
	long int a, b, n, i, d=-9999999999999;
	scanf("%d", &n);/*n???????????\???*/
	scanf("%d", &a);/*R1?????\???*/
	for (i = 0; i < n-1; i++) {
		scanf("%d", &b);/*R2??\????????\???*/
		if (diff(a,b) > d)/*R1??¨Rt??????????????§???*/
			d = diff(a, b);
		if (a > b)/*R1???????????????*/
			a = b;
	}
	printf("%d\n", d);
	return 0;
}

Measured memory_bytes: 2748
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int add(int x, int y) {
	x += y;
	if (x  >= mod) {
		x -= mod;
	}
	return x;
}
void add_self(int& x, int y) {
	x = add(x, y);
}
int mult(int x, int y) {
	return 1ll * x * y % mod;
}
void mult_self(int& x, int y) {
	x = mult(x, y);
}
int bin_pow(int x, int y) {
	if (y == 0) {
		return 1;
	}
	if (y % 2 == 0) {
		return bin_pow(mult(x, x), y / 2);
	}
	return mult(x, bin_pow(x, y - 1));
}
int inv(int x) {
	return bin_pow(x, mod - 2);
}
const int maxn = 2e5 + 10;
vector<int> fact(maxn), inv_fact(maxn);
int C(int x, int y) {
	if (x < y) {
		return 0;
	}
	return mult(mult(fact[x], inv_fact[y]), inv_fact[x - y]);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	for (int i = 0; i < maxn; ++i) {
		if (i == 0) {
			fact[i] = 1;
		} else {
			fact[i] = mult(fact[i - 1], i);
		}
		inv_fact[i] = inv(fact[i]);
	}
	int n, m, k;
	cin >> n >> m >> k;
	int answer = 0;
	for (int len = 1; len < n; ++len) {
		add_self(answer, mult(mult(n - len, mult(m, m)), len));
	}
	for (int len = 1; len < m; ++len) {
		add_self(answer, mult(mult(m - len, mult(n, n)), len));
	}
	mult_self(answer, C(n * m - 2, k - 2));
	cout << answer << '\n';
}


Measured memory_bytes: 1792
l = [[[0] * 10 for _ in range(3)] for _ in range(4)]
for _ in range(int(input())):
    b, f, r, v = map(int, input().split())
    l[b - 1][f - 1][r - 1] += v

for x in range(4):
    for y in range(3):
        print("", *l[x][y])
    if x != 3:
        print("#" * 20)

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

int main() {
  string S;
  cin >> S;

  int l = stoi(S.substr(0, 2));
  int r = stoi(S.substr(2, 2));

  if (1 <= l && l <= 12) {
    if (1 <= r && r <= 12)
      cout << "AMBIGUOUS" << endl;
    else
      cout << "MMYY" << endl;
  } else {
    if (1 <= r && r <= 12)
      cout << "YYMM" << endl;
    else
      cout << "NA" << endl;
  }

  return 0;
}


Measured memory_bytes: 3620
a, b = map(int, input().split())
s = list(input())
math_list = ['0','1','2','3','4','5','6','7','8','9']
check = 0
for i in range(0,len(s)):
  if 0<=i<=a-1:    
    if s[i] not in math_list:
      print('No')
      check = 1
      break
  if i == a:
    if s[i] != '-':
      print('No')
      check = 1
      break
  if a+1<=i<=a+b:
    if s[i] not in math_list:
      print('No')
      check = 1
      break
if check == 0:
  print('Yes')


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>
#include<tuple>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
 
using namespace std;

int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  int ans=0;

  if(A>=K){
    ans += K;
  }else if(A+B>=K){
    ans += A;
  }else if(A+B+C>=K){
    ans = A - (K-A-B);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,K;
  cin>>N>>K;
  VL A(N);
  rep(i,N) cin>>A[i];
  VL L(N+1),R(N+1);
  rep(i,N) L[i+1]=L[i]+A[i]*(A[i]>0);
  rep(i,N) R[N-1-i]=R[N-i]+A[N-1-i]*(A[N-1-i]>0);
  ll sum=0;
  rep(i,K) sum+=A[i];
  ll ans=0;
  rep(i,N-K+1){
    ll tmp=L[i]+R[i+K];
    if(sum>0) tmp+=sum;
    ans=max(ans,tmp);
    sum=sum-A[i]+A[i+K];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2688
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
using namespace std;
int main(){
    vector<int> w;
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        int tmp_w;
        cin >> tmp_w;
        w.push_back(tmp_w);
    }
    int min = 100;
    for(int i = 1; i < n; ++i){
        int former = 0;
        int latter = 0;;
        for(int j = 0; j < i; ++j){
            former += w[j];
        }
        for(int j = i; j < n; ++j){
            latter += w[j];
        }
        int diff = abs(former - latter);
        if(diff < min){
            min = diff;
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
n, ans = 0, 0
for a in A:
    if a == n+1:
        n += 1
    else:
        ans += 1
if ans == len(A):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 26140
s = input()
ans = 0
Anum = 0
tmp = 0

while tmp < len(s):
    if s[tmp] == 'A':
        Anum += 1
        tmp += 1
    elif s[tmp:tmp+2] == 'BC':
        ans += Anum
        tmp += 2
    else:
        Anum = 0
        tmp += 1

print(ans)

Measured memory_bytes: 3500
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <numeric>    // accumulate
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int N, M, K, A, out = 0;
  cin >> N >> M;
  vector<vector<bool>> fav(M, vector<bool>(N, false));
  for (int i = 0; i < N; i++) {
    cin >> K;
    for (int j = 0; j < K; j++) {
      cin >> A;
      fav[A - 1][i] = true;
    }
  }

  for (auto f : fav) {
    if (find(f.begin(), f.end(), false) == f.end()) out++;
  }
  cout << out << endl;
}


Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
using System.Linq;

namespace template
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int cnt = 0;
            var n = int.Parse(cin.ReadLine);
            var a = cin.ReadIntArray(n);

            while(a.Count(x => x%2 == 0) == n)
            {
                cnt++;
                a = a.Select(x => (int)x/2).ToArray();
            }

            Console.WriteLine(cnt);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) 
                {
                    return inputStream.Dequeue();
                }

                string[] tmp = _stream.ReadLine().Split(_separator);
                
                for (int i = 0; i < tmp.Length; ++i)
                {
                    inputStream.Enqueue(tmp[i]);
                }
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 13524
#include <stdio.h>
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>

using namespace std;

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};
//*****************************************


int n,h,w,ans; 

int main(void)
{
    scanf("%d",&n);
    scanf("%d",&h);
    scanf("%d",&w);

    ans=(n-h+1)*(n-w+1);

    printf("%d",ans);


    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 100000;
int n, l;
int a[MAX_N];
 
int main(){
  cin >> n >> l;
  REP(i, n) cin >> a[i];
 
  int x = n;
  REP(i, n - 1) {
    if(a[i] + a[i + 1] >= l) {
      x = i;
      break;
    }
  }
 
  if(x == n) {
    cout << "Impossible" << endl;
  } else {
    cout << "Possible" << endl;
    REP(i, x) cout << i + 1 << " " << endl;
    REP(i, n - 1 - x) cout << n - 1 - i << " " << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;

int n,arr[50];

int main() {
    scanf("%d",&n);
    
    int idx=0,v=0;
    for(int i=0;i<n;i++) {
        scanf("%d",arr+i);
        if(abs(arr[i])>v) {
            v=abs(arr[i]);
            idx=i;
        }
    }
    if(v==0) {
        puts("0");
        return 0;
    }

    v=arr[idx];
    vector<pii> ans;
    for(int i=0;i<n;i++) if(i!=idx) {
        ans.push_back(pii(idx+1,i+1));
        arr[i] += arr[idx];
    }
    if(v<0) {
        for(int i=n-2;i>=0;i--) if(arr[i] > arr[i+1]) {
            arr[i] += arr[i+1];
            ans.push_back(pii(i+2,i+1));
        }
    } else {
        for(int i=1;i<n;i++) if(arr[i] < arr[i-1]) {
            arr[i] += arr[i-1];
            ans.push_back(pii(i,i+1));
        }
    }
    printf("%lu\n",ans.size());
    for(auto &it:ans)printf("%d %d\n",it.first,it.second);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MAX 2000000

using namespace std;

int n;
int C[10000];

void countingSort(const int *A, int *B, int k) {
    for ( int i = 0; i <= k; ++i ) {
        C[i] = 0;
    }

    for ( int j = 0; j < n; ++j ) {
        C[A[j]]++;

    }

    for ( int i = 1; i <= k; ++i ) {
        C[i] = C[i] + C[i-1];
    }

    for ( int j = n-1;j >= 0; --j ) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
}

int main() {
    cin >> n;
    int A[MAX];
    int B[MAX];
    for ( int i = 0; i < n; ++i ) {
        cin >> A[i];
    }
    int max = A[0];
    for (int i = 1; i < n; ++i ) {
        if ( A[i] > max ) {
            max = A[i];
        }
    }

    countingSort(A,B,max);
    for (int i = 1; i <= n; ++i ) {
        if ( i > 1 ) cout << " ";
        cout << B[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 18752
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int n, k;in2(n, k);
	int a[n];
	for(int i=0;i<n;i++) in(a[i]);
	
	for(int i=k;i<n;i++) {
		if(a[i-k] >= a[i]) cout<<"No"<<en;
		else cout<<"Yes"<<en;
	}
	
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 4460
import copy
a = list(input())
b = list(input())

arr = []
length = len(b)

for i in range(len(a) - len(b) + 1):
  tmp = copy.deepcopy(a)
  formable = True
  for j, bs in enumerate(b):
    if bs == a[i+j] or a[i+j] == "?":
      continue
    formable = False
  if formable == False:
    continue

  for k, bbs in enumerate(b):
    tmp[i+k] = bbs

  for l, sa in enumerate(tmp):
    if sa == "?":
      tmp[l] = "a"
  arr.append("".join(tmp))
nn = sorted(arr)
ans = "UNRESTORABLE" if len(arr) == 0 else nn[0]

print(ans)

Measured memory_bytes: 3572
# coding:utf-8

def main():
    s = input()
    ans = 0
    for i in range(len(s)+1):
        for j in range(i,len(s)+1):
            temp = s[i:j]
            # print(i,j)
            # print(temp)
            if atgc_check(temp) and len(temp) > ans:
                ans = len(temp)
    print(ans)

def atgc_check(sub_s):
    for si in sub_s:
        if not si in ["A","T","G","C"]:
            return False
    return True

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  string s; cin >> s;
  sort(s.begin(), s.end());
  cout << (s[0] == s[1] && s[2] == s[3] && s[1] != s[2] ? "Yes\n" : "No\n");
}

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

int main(){
  long long n;
  cin >> n;
  long long sum = 0;
  long long n_3, n_5, n_15;
  n_3 = n / 3;
  n_5 = n / 5;
  n_15 = n / 15;
  sum += n * (n+1) /2;
  sum -= n_3 *(2 * 3 + (n_3-1)*3) /2;
  sum -= n_5 * (2 * 5 + (n_5-1)*5) /2;
  sum +=  n_15 * (2 * 15 + (n_15 -1) * 15 ) /2;
  cout << sum << endl;
    
}

Measured memory_bytes: 3636
#include <cstdio>
const int N=200005;
int a[N];long long ans=0;
int l[N],r[N],s[N],pos[N],top=0;
int main (){
    int n;scanf ("%d",&n);
    for (int i=1;i<=n;i++) scanf ("%d",&a[i]);
    s[top=1]=0,pos[top]=0;
    for (int i=1;i<=n;i++){
        while (top>0&&s[top]>a[i]) --top;
        l[i]=pos[top]+1;s[++top]=a[i],pos[top]=i;
    }
    s[top=1]=0,pos[top]=n+1;
    for (int i=n;i>=1;i--){
        while (top>0&&s[top]>a[i]) --top;
        r[i]=pos[top]-1;s[++top]=a[i],pos[top]=i;
    }
    for (int i=1;i<=n;i++)
    	ans+=1ll*(r[i]-i+1)*(i-l[i]+1)*a[i];
    printf ("%lld",ans);
    return 0;
}

Measured memory_bytes: 4224
import qualified Data.ByteString.Char8 as BC
import qualified Data.IntMap as M
import Data.Maybe (fromJust)
import Data.List
import Data.Array.IO

main = do
  n <- readLn :: IO Int
  [x, y] <- transpose <$> getInt2DListBC
  parent <- newArray (1, n) 0 :: IO (IOUArray Int Int)
  let pointX = zip [1..n] x
      pointY = zip [1..n] y
      sortedX = sortBy (\x y -> compare (snd x) (snd y)) pointX
      sortedY = sortBy (\x y -> compare (snd x) (snd y)) pointY
      edge = sortBy compEdge $ (makeEdge sortedX) ++ (makeEdge sortedY)
  print =<< greedy parent edge (n-1) 0

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getInt2DListBC :: IO [[Int]]
getInt2DListBC = map (map bsToInt . BC.words) . BC.lines <$> BC.getContents

makeEdge :: [(Int, Int)] -> [(Int, Int, Int)]
makeEdge (_:[]) = []
makeEdge (x:y:ys) = (fst x, fst y, abs $ (snd x) - (snd y)) : makeEdge (y:ys)

compEdge :: (Int, Int, Int) -> (Int, Int, Int) -> Ordering
compEdge (_, _, x) (_, _, y) = compare x y

greedy :: IOUArray Int Int -> [(Int, Int, Int)] -> Int -> Int -> IO Int
greedy parent ((i, j, w):es) n k
  | n == k    = return 0
  | otherwise = do
    pI <- getParent parent i
    pJ <- getParent parent j
    if pI == pJ then greedy parent es n k
                else do
                  writeArray parent pI pJ
                  sum <- greedy parent es n $ k + 1
                  return $ w + sum

getParent :: IOUArray Int Int -> Int -> IO Int
getParent memo i = do
  parent <- readArray memo i
  case parent of
    0 -> return i
    _ -> do
      pp <- getParent memo parent
      writeArray memo i pp
      return pp


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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const int mod = 1e9 + 7;
const int MAXN = 5e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int mx = 0;
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for (auto &c : a) cin >> c;
    for (int i = 0; i < n - 1; i++) mx = max(mx, a[i + 1] - a[i]);
    mx = max(mx, a[0] + k - a[n - 1]);
    cout << k - mx;
    return 0;
}


Measured memory_bytes: 3952
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

ll dp[1000005][2];
int main(){
	string N;
	cin >> N;

	dp[0][0] = 0;
	dp[0][1] = 1;
	for(int i=0; i<N.size(); i++){
		int d = N[i]-'0';
		dp[i+1][0] = dp[i][0] + d;
		if(d > 0) dp[i+1][0] = min(dp[i+1][0], dp[i][1] + 10 - d);

		dp[i+1][1] = dp[i][1] + 9 - d;
		if(d < 9) dp[i+1][1] = min(dp[i+1][1], dp[i][0] + d + 1);


		debug(i, d, dp[i+1][0], dp[i+1][1]);
	}
	cout << dp[N.size()][0] << endl;

	return 0;
}


Measured memory_bytes: 17028
#include <bits/stdc++.h>
#define maxi 300005
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ll long long
#define si(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif
#define gc getchar
#define REP(i,j,n)               for( i=j;i<n;i++)
#define PER(i,j,n)               for( i=n-1;i>=j;i--)
ll mpow(ll a, ll n,ll mod){
	ll ret=1;ll b=a;
	while(n) {
		if(n&1)
			ret=(ret*b)%mod;
		b=(b*b)%mod;
		n>>=1;
	}
	return (ll)ret;
}
ll gcd(ll a, ll b)
{
    if (a == 0 || b == 0)
       return 0;
    if (a == b)
        return a;
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
inline void read(int &x){
	x=0;
	register char c=gc();
	for(;c<'0' || c>'9';c=gc());
	for(;c>='0' && c<='9';c=gc())
		x=(x<<3)+(x<<1)+(c-'0');
}
inline void write(int x){
	register char buffor[35];
	register int i=0;
	do{
		buffor[i++]=(x%10)+'0';
		x/=10;
	} while(x);
	i--;
	while(i>=0) putchar(buffor[i--]);
	putchar('\n');
}
inline int in() { int x; read(x); return x; }
void solve();
int dbg=1;
ll lo[2005][2005],u[2005][2005],l[2005][2005],r[2005][2005];
using namespace std;
int main(){
	int t=1;
	//read(t);
	for(int i=0;i<t;i++){
		//printf("Case #%d:\n",i);
		solve();
	}
	return 0;
}
void solve() {
	ll h,w,i,j,k=0,ma=0;
	string s[2005];
	cin>>h>>w;
	REP(i,0,h)
		cin>>s[i];
	REP(i,0,h){
		k=0;
		REP(j,0,w){
			if(s[i][j]=='.')
				k++;
			else
				k=0;
			l[i][j]=k;
		}
	}
	REP(i,0,h){
		k=0;
		PER(j,0,w){
			if(s[i][j]=='.')
				k++;
			else
				k=0;
			r[i][j]=k;
		}
	}
	REP(i,0,w){
		k=0;
		REP(j,0,h){
			if(s[j][i]=='.')
				k++;
			else
				k=0;
			u[j][i]=k;
		}
	}
	REP(i,0,w){
		k=0;
		PER(j,0,h){
			if(s[j][i]=='.')
				k++;
			else
				k=0;
			lo[j][i]=k;
		}
	}
	REP(i,0,h)
		REP(j,0,w)
			ma=max(ma,l[i][j]+r[i][j]+lo[i][j]+u[i][j]-3);
	cout<<ma<<endl;
}



Measured memory_bytes: 129920
package main

import (
    "fmt"
    // "sort"
)

func main() {
    // var n int
    // fmt.Scan(&n, &x)
    // nums := make([]int,n);
    // m := make(map[int]int)

    var n int
    fmt.Scan(&n)

    s:=0
    top:=0
    c:=-1

    for i := 0; n>0; i++ {
    	top=n%10
		s+=top    
		n/=10;	
		c++
    }

    ans := c*9 + top-1
	
	if ans<s {
		ans=s
	}


	fmt.Println(ans)
}

Measured memory_bytes: 512
import sys
n = int(input())
a = list(map(int, input().split()))
if n%2 == 0:
	dp = [[-10**20 for _ in range(2)] for _ in range(n)]
	dp[0][0] = a[0]
	dp[0][1] = 0
	dp[1][1] = a[1]
	for i in range(1, n):
		if i%2 == 0:
			dp[i][0] = dp[i-2][0] + a[i]
			dp[i][1] = max(dp[i-1][0], dp[i-1][1])
		else:
			dp[i][0] = dp[i-1][0]
			if i > 1:
				dp[i][1] = max(dp[i-2][1] + a[i], dp[i-3][0] + a[i])

else:
	dp = [[-10**20 for _ in range(3)] for _ in range(n)]
	dp[0][0] = a[0]
	dp[0][1] = 0
	dp[1][1] = a[1]
	dp[0][2] = 0
	dp[1][2] = 0
	dp[2][2] = a[2]

	for i in range(1, n):
		if i%2 == 0:
			if i < n-1:
				dp[i][0] = dp[i-2][0] + a[i]
			else:
				dp[i][0] = dp[i-1][0]
			dp[i][1] = max(dp[i-1][1], dp[i-2][0])
			if i > 2:
				dp[i][2] = max(dp[i-2][2] + a[i], dp[i-4][0] + a[i], dp[i-3][1] + a[i])
		else:
			dp[i][0] = dp[i-1][0]
			if i > 1:
				dp[i][1] = max(dp[i-2][0] + a[i], dp[i-2][1] + a[i])
				dp[i][2] = max(dp[i-1][2], dp[i-2][1], dp[i-3][0])

print(max(dp[n-1]))

Measured memory_bytes: 117804
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c, n;
string s;



int main()
{
cin>>a>>b>>c;
  cout<<(c/a)*b<<endl;
return 0;
}


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

int main(){
    int K = 26;
    int D;
    cin >> D;
    vector<ll> C(K);
    for (int i = 0; i < K; i++) cin >> C[i];
    vector<vector<ll>> s(D+1, vector<ll>(K, 0));
    for (int i = 1; i <= D; i++) {
        for (int j = 0; j < K; j++) {
            cin >> s[i][j];
        }
    }
    
    vector<int> ans(D+1, 0);
    
    vector<set<int>> day(K);
    for (int i = 0; i < K; i++) {
        day[i].insert(0);
        day[i].insert(D+1);
    }
    vector<int> cnt(K, 0);
    for (int i = 1; i <= D; i++) {
        int op = 0;
        int s_mx = 0;
        for (int j = 0; j < K; j++) {
            if (s_mx < s[i][j]) {
                s_mx = s[i][j];
                op = j;
            }
        }
        day[op].insert(i);
        ans[i] = op+1;
    }
    
    ll inf = 1e18;
    ll r = 123456789;
    ll mod = 1e9+7;
    int repmax = 300000;
    for (int rep = 0; rep < repmax; rep++) {
        r = r*r%mod;
        int a = r%D+1;
        
        int def = ans[a]-1;
        
        ll pt_max = -inf; 
        ll op = 0;
        day[def].erase(day[def].find(a));
        for (int i = 0; i < K; i++) {
            auto it = day[i].lower_bound(a);
            ll nxt = (*it);
            it--;
            ll pre = (*it);
            ll pt = ((nxt-pre)*(nxt-pre+1)/2 - ((a-pre)*(a-pre+1)/2+(nxt-a)*(nxt-a+1)/2)) * C[i] + s[a][i];
            if (pt > pt_max) {
                pt_max = pt;
                op = i;
            }
        }
        day[op].insert(a);
        ans[a] = op+1;
    }
    
    for (int i = 1; i <= D; i++) cout << ans[i] << endl;
    
    return 0;
}


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

int main ()
{
    int n, m;
    while (cin >> n >> m, (n || m)) {
        vector<pair<int,int> > v(n);
        for (auto &i : v) cin >> i.second >> i.first;
        sort(v.begin(), v.end());

        int i = n-1;
        while (m && i >= 0) {
            if (v[i].second) m--, v[i].second--;
            else i--;
        }

        int res = 0;
        i = 0;
        while (i < v.size() && v[i].second) {
            res += v[i].second * v[i].first;
            i++;
        }

        cout << res << endl;
    }

    return 0;
}

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

signed main(){

  int64_t x;
  cin>>x;

  int64_t dist = 0;
  for(int i=1;;++i){
    dist+=i;
    if(dist>=x){
      cout<<i<<endl;
      return 0;
    }
  }

}

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

vector<ll> dat;
int N;

void update(int k, int a) {
  k += N - 1;
  ll old = dat[k];
  dat[k] = a;
  while (k > 0) {
    k = (k - 1) / 2;
    dat[k] = dat[k * 2 + 1] | dat[k * 2 + 2];
    if ( dat[k * 2 + 1] & old == 0 &&  dat[k * 2 + 2] & old == 0) {
      dat[k] = dat[k] - old;
    }
  }
}

int find(int a, int b, int k, int l, int r) {
  if (r <= a || b <= l) return 0;
  if (a <= l && r <= b) return dat[k];
  else {
    int vl = find(a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = find(a, b, k * 2 + 2, (l + r) / 2, r);
    return vl | vr;
  }
}

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

  cin >> N;
  string S; cin >> S;

  ll Q; cin >> Q;
  ll N_ = N;
  N = 1;
  while (N < N_) N *= 2;
  dat = vector<ll>(2 * N - 1, 0);
  for (ll i = 0; i < N; i++) {
    update(i, 1 << (S[i] - 'a' + 1));
  }

  for (ll i = 0; i < Q; i++) {
    int q;
    cin >> q;
    if (q == 1) {
      int x; char y; cin >> x >> y;
      update(x - 1, 1 << (y - 'a' + 1));
    } else {
      int x, y; cin >> x >> y;
      x--; y--;
      int temp = find(x, y + 1, 0, 0, N);
      int ans = 0;
      for (ll i = 0; i < 30; i++) {
        ans += temp % 2;
        temp /= 2;
      }
      cout << ans << '\n';
    }
  }

  return 0;
}

Measured memory_bytes: 9116
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int N,Q;
vector<pair<pair<int,int>,int> >E;
main()
{
	cin>>N>>Q;
	for(int i=0;i<N;i++)
	{
		int S,T,X;cin>>S>>T>>X;
		S-=X,T-=X;
		E.push_back({{S,T},X});
	}
	sort(E.begin(),E.end());
	int id=0;
	priority_queue<pair<int,int> >P;
	for(int i=0;i<Q;i++)
	{
		int D;cin>>D;
		while(id<N&&E[id].first.first<=D)
		{
			P.push({-E[id].second,E[id].first.second});
			id++;
		}
		while(!P.empty()&&P.top().second<=D)P.pop();
		if(!P.empty())cout<<-P.top().first<<endl;
		else cout<<-1<<endl;
	}
}

Measured memory_bytes: 7920
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MOD = 1e9+7;

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

    string s,t;
    cin >> s >> t;

    bool ok = true;
    int n = s.size();
    rep(i,n){
        if(s[i] != t[i]) ok = false;
    }

    cout << ( ok ? "Yes" : "No" ) << endl;

    return 0;
}


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

int main() {
	int A;	// 整数.
	cin >> A;
	int B;	// 整数.
	cin >> B;

	int answer = 0;
	for (int n = A; n <= B; n++) {
		int l = 1;
		int r = 1;
		while (l * 10 <= n) {
			l *= 10;
		}
		while (l >= r) {
			if ((n % (l * 10) / l) != (n % (r * 10) / r)) {
				break;
			}
			l /= 10;
			r *= 10;
		}
		if (l >= r) {
			continue;
		}
		answer++;
	}
	cout << answer << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define clr clear()
#define ins insert
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define cusmem(x,val) for(auto &i:x) i=val;
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);\
            cin.tie(NULL);\
            cout.tie(NULL);
using namespace std;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef vector<ll> vl;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vpii;
string imp="Impossible\n";

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
clock_t startTime;
double getCurrentTime() {
    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
// const int N=11;
const int N=5e6+5;
ll MOD=1e9+7;
ll n,m,k,i,j;
bool f0,f1,f2;
const int MAXN=2e3;

int main(){
    #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin); 
            freopen("output.txt","w",stdout);
    #endif
    fastio
	cout<<fixed<<setprecision(11);
    int tests=1;    
    // cin>>tests;
    while(tests--){
		int n;	cin>>n;
		int cnt=0;
		for(int i=1;i<=n;i++){
			int x;	cin>>x;
			if((i&1)&&(x&1))	cnt++;
		}
		cout<<cnt;
    }
    return 0;
}



 



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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  vector <int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
    ans += v.at(i);
  }
  sort(v.begin(), v.end());
  if (ans%10 != 0) {
    cout << ans << endl;
  } else {
    for (int i = 0; i < n; i++) {
      if (v.at(i)%10 != 0) {
        ans -= v.at(i);
        cout << ans << endl;
        break;
      }
    }
    if(ans%10 == 0) {
      cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();
        int q = ni();
        int[] a = new int[q];
        int[] b = new int[q];
        for (int i = 0; i < q; i++) {
            a[i] = ni() - 1;
            b[i] = ni() - 1;
        }

        boolean[] can = new boolean[n];
        can[0] = can[1] = true;

        int idx = 0;

        for (int i = 0; i < q; i++) {
            if (a[i] == idx) idx = b[i];
            else if (b[i] == idx) idx = a[i];

            boolean tmp = can[a[i]];
            can[a[i]] = can[b[i]];
            can[b[i]] = tmp;

            if (idx + 1 <= n - 1) can[idx + 1] = true;
            if (idx - 1 >= 0) can[idx - 1] = true;
        }

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

        out.println(ans);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 28632
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 998244353;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N; cin >> N;
    vector<pair<long long, long long>> vp(N);
    for (int i = 0; i < N; i++) {
        long long x, y; cin >> x >> y;
        vp[i] = {x, y};
    }
    int limit = 1;
    for (int i = 0; i < N; i++) {
        limit *= N;
    }
    double sum = 0;
    long long cnt = 0;
    int flag[N];
    int perms[N];
    for (int i = 0; i < limit; i++) {
        int bits = i;
        memset(flag, 0, sizeof(flag));
        memset(perms, 0, sizeof(perms));
        for (int i = 0; i < N; i++) {
            int town = bits % N;
            if (flag[town] == 1) goto END;
            flag[town] = 1;
            perms[i] = town;
            bits /= N;
        }
        cnt++;
        for (int i = 1; i < N; i++) {
            long long tmp = 0;
            tmp += (vp[perms[i]].first - vp[perms[i-1]].first) * (vp[perms[i]].first - vp[perms[i-1]].first);
            tmp += (vp[perms[i]].second - vp[perms[i-1]].second) * (vp[perms[i]].second - vp[perms[i-1]].second);
            sum += sqrt(tmp);
        }
        END: continue;
    }
    printf("%.12f\n", sum/cnt);
}




Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main () {
	int d = 100000;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		d *= 1.05f;
		int a = d % 1000;
		if(a != 0){
			d += 1000;
			d -= a;
		}
	}
	cout << d << endl;
}


Measured memory_bytes: 3004
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    cout << max(A * B, C * D) << endl;

    return 0;
}

Measured memory_bytes: 3604
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.next().split("");
    for(int i = 0;i<s.length;i++){
      if(s[i].equals("1"))s[i] = "9";
      else if(s[i].equals("9"))s[i] = "1";
      System.out.print(s[i]);
    }
  } 
}

Measured memory_bytes: 21332
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
ll in(){ ll x; cin >> x; return x; }
vector<ll> in(size_t n){ vector<ll> v(n); each(x, v) cin >> x; return v; }
/* ]]] */

ll T, n;
ll s[100010], t[100010];

int main(){
  cin >> T >> n;
  rep(i, n) cin >> s[i] >> t[i];
  s[n] = t[n] = inf_ll;
  
  ll ii = 0;
  ll res = 0;
  ll sum = 0;
  rep(i, n){
    while (t[ii] <= s[i] + T) sum += t[ii] - s[ii], ii++, chmax(res, sum);
    if (s[i] <= s[ii] && s[ii] < s[i] + T) chmax(res, sum + s[i] + T - s[ii]);
    sum -= t[i] - s[i];
  }
  
  reverse(s, s + n);
  reverse(t, t + n);
  rep(i, n) s[i] = -s[i];
  rep(i, n) t[i] = -t[i];
  ii = 0;
  sum = 0;
  rep(i, n){
    while (t[ii] <= s[i] + T) sum += t[ii] - s[ii], ii++, chmax(res, sum);
    if (s[i] <= s[ii] && s[ii] < s[i] + T) chmax(res, sum + s[i] + T - s[ii]);
    sum -= t[i] - s[i];
  }

  cout << res << endl;
}

Measured memory_bytes: 4732
#include <iostream>
#include <cmath>

bool isPrime(int x) {

	if (x == 2) {
		return true;
	}
	if (x % 2 == 0) {
		return false;
	}

	for (int i = 3; i <= std::sqrt(x); i += 2) {
		if (x % i == 0) {
			return false;
		}
	}
	return true;
}

int main() {

	int n;
	std::cin >> n;

	int cnt = 0;

	for (int i = 0; i < n; ++i) {
		int m;
		std::cin >> m;
		if (isPrime(m)) {
			++cnt;
		}
	}

	std::cout << cnt << std::endl;

	return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>
#include <stdlib.h>

int main() {
  long n,q,i,j,C;
  char *S;
  scanf("%ld", &n);
  S = (char*)calloc(1000000001,sizeof(char));
  for(i = 0; i < n; i++) { scanf("%ld", &j); S[j]=1;}
  scanf("%ld", &q);
  long T;C = 0;
  for(i = 0; i < q; i++) {
    scanf("%ld",&T);
    if(S[T] == 1) C++;
  }

  printf("%ld\n",C);

  free(S);
  return 0;
}

Measured memory_bytes: 6516
#include<bits/stdc++.h>
#define F(a,b,c,d) for (register int a=b;a<=c;a+=d)
#define FD(a,b,c,d) for (register int a=b;a>=c;a-=d)
using namespace std;
int n,maxn=INT_MAX,s[300100],s1[301010],m;
int main(){
	char ch;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>ch;
		if (ch=='W') s[i]=1;
		else s1[i]=1;
	}
	for (int i=1;i<=n;i++)
	s[i]=s[i-1]+s[i]//,cout<<s[i]<<" "
	;
	///cout<<endl;
	for (int i=n;i>0;i--)
	s1[i]=s1[i+1]+s1[i];
	//for (int i=1;i<=n;i++)
	//cout<<s1[i]<<" ";
	//cout<<endl;
	for (int i=1;i<=n;i++)
	maxn=min(maxn,s[i-1]+s1[i+1]);
	cout<<maxn<<endl;
	return 0;
}



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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int now = 0;
    for (int i=1; i<N; i++) {
        if (S[i] == 'E') now++;
    }
    int ans = now;
    for (int i=1; i<N; i++) {
        int tmp = 0;
        if (S[i-1] == 'W') tmp++;
        if (S[i] == 'E') tmp--;
        now += tmp;
        ans = min(ans, now);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 900
/**
*    author:  souzai32
*    created: 04.08.2020 19:53:05
**/

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

int main() {

    int n;
    string s;
    cin >> n >> s;
    vector<long long int> alphabet(26,1);
    long long int ans=1;

    rep(i,n) alphabet.at(s.at(i)-'a')++;
    rep(i,26){
        ans*=alphabet.at(i);
        ans%=1000000007;
    }

    cout << ans-1 << endl;

    return 0;
}

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

int main()
{
	int a, b, c, count;
	bool flag[100] = {};

	cin >> a >> b >> c;

	flag[a - 1] = true;
	flag[b - 1] = true;
	flag[c - 1] = true;

	for (int i = 0; i < 100; i++) {
		if (flag[i]) {
			count++;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> re;
    int idx = 1;
    int k = 0;
    rep(i,n){
        if(a[i] == idx){
            re.push_back(a[i]);
            idx++;
        }else{
            k++;
        }
    }
    if(re.size()) cout << k << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 2168
# -*- coding: utf-8 -*-
# モジュールのインポート
import sys

# 標準入力を取得
N, M = list(map(int, input().split()))
cakes = []
for n in range(N):
    cake_n = list(map(int, input().split()))
    cakes.append(cake_n)

# 求解処理
ans = -sys.maxsize
element = 3
for bit in range(1 << element):
    sign = [1 for i in range(element)]
    for i in range(element):
        if bit & (1 << i):
            sign[i] *= -1
    cakes = sorted(cakes, key=lambda x: sum(
        [sign[i] * x[i] for i in range(element)]), reverse=True)

    indicator = [0 for i in range(element)]
    for cake in cakes[:M]:
        for i in range(element):
            indicator[i] += cake[i]

    ans = max(ans, sum(map(abs, indicator)))

# 結果出力
print(ans)


Measured memory_bytes: 9332
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
check = 0
for i in range(n):
    tabe = a[i]
    check += b[tabe - 1]
    if i < n -1 :
        if (a[i+1] - a[i]) == 1:
            check += c[a[i]-1]
print(check)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>

using namespace std;

int main(){
    vector<int> n,x;
    int tempn,tempx;
    do{
        cin>>tempn>>tempx;
        n.push_back(tempn);
        x.push_back(tempx);
    }while (tempn!=0 || tempx!=0);
    for (int i=0;i<n.size()-1;i++){
        int cnt=0;
        for (int a=1;a<=n[i];a++){
            for (int b=a+1;b<=n[i];b++){
                int c=x[i]-a-b;
                if (c>b && c<=n[i]){
                    cnt++;
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}



Measured memory_bytes: 3116
#include <stdio.h>
 
int main(void)
{
    int n,i,c_max,c_min;
    long long int c_sum = 0;
    int c[10000];
     
    scanf("%d\n",&n);
     
    for(i=0;i<n;i++){
    scanf("%d",&c[i]);
    }
    c_max = c[0];
    c_min = c[0];
    for(i=1;i<n;i++){
        if(c_max < c[i]){
            c_max = c[i];
        }
        if(c_min > c[i]){
            c_min = c[i];
        }
    }
    for(i=0;i<n;i++){
        c_sum = c_sum + c[i];
    }   
        printf("%d %d %lld\n",c_min,c_max,c_sum);
    return 0;
}

Measured memory_bytes: 636