akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{

    int n;
    int max = 1<<15;

    void solve(){
        Scanner sc = new Scanner(System.in);

        int[] cnt = new int[max+1];
        for(int i=1; i*i<=max; i++){
            cnt[i*i]++;
            for(int j=i; j*j+i*i<=max; j++){
                cnt[i*i+j*j]++;
                for(int k=j; k*k+j*j+i*i<=max; k++){
                    cnt[i*i+j*j+k*k]++;
                    for(int l=k; l*l+k*k+j*j+i*i<=max; l++){
                        cnt[i*i+j*j+k*k+l*l]++;
                    }
                }
            }
        }

        while(true){
            n = sc.nextInt();
            if(n==0) break;
            System.out.println(cnt[n]);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

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

int main()
{
  ll N; cin >> N;
  ll M = N;

  ll sum=0;
  while(M > 0) {
    sum += M % 10;
    M /= 10;
  }

  if (N % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map<int,int> mp;
    for(int i = 0; i < n; i++) {
        mp[a[i]]++;
        mp[a[i]-1]++;
        mp[a[i]+1]++;
    }
    int ans=0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++) {
        ans=max(ans,itr->second);
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 5120
// #include <atcoder/all>
// using namespace atcoder;
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    ll sum = 0;
    auto nxt = [](ll x, ll m) {
        return (x * x) % m;
    };
    vector<ll> a;
    set<ll> s;
    int cnt = 0;
    int num = 0;
    for (int i = 0; i < n; ++i) {
        a.push_back(x);
        s.insert(x);
        sum += x;
        cnt++;        
        x = nxt(x, m);
        if (s.count(x)) {
            num = x;
            break;
        }
    }
    if (cnt == n) {
        cout << sum << '\n';
        return 0;
    }
    ll nokori = n - cnt;
    ll psum = 0;
    ll plen = 0;
    bool flag = false;
    rep(i, a.size()) {
        if (flag) {
            plen++;
            psum += a[i];
        } else {
            if (a[i] == num) {
                flag = true;
                plen++;
                psum += a[i];
            }
        }
    }
    ll block = nokori / plen;
    ll amari = nokori % plen;
    sum += block * psum;
    int cntt = 0;
    flag = false;
    rep(i, a.size()) {
        if (cntt == amari) break;
        if (flag) {
            cntt++;
            sum += a[i];
        } else {
            if (a[i] == num) {
                cntt++;
                sum += a[i];
                flag = true;
            }
        }
    }
    cout << sum << '\n';
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }
    int state = 0;
    int ans = 1;
    for (int i = 1; i < N; ++i)
    {
        switch (state)
        {
        case 1:
            if (A[i] < A[i - 1])
            {
                state = 0;
                ++ans;
                break;
            }
        case 0:
            if (A[i] > A[i - 1])
            {
                state = 1;
            }
            else if (A[i] < A[i - 1])
            {
                state = -1;
            }
            break;
        case -1:
            if (A[i] > A[i - 1])
            {
                state = 0;
                ++ans;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3740
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  xys <- replicateM n $ map read . words <$> getLine
  print $ solve n xys

solve :: Int -> [[Double]] -> Double
solve n xys = sum [ sqrt ((x1 - x2) ^ 2 + (y1 - y2) ^ 2) | [x1, y1] <- xys, [x2, y2] <- xys ]  / (fromIntegral n)

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>

using namespace std;

int main(){
  int L,R;
  cin >> L >> R;
  int l = L % 2019;
  int r = R % 2019;
  if(L + 2019 <= R){
    cout << 0 << endl;
  }else if(l > r){
    cout << 0 << endl;
  }else{
    int min = (l * r) % 2019;
    for(int i = l; i < r; i++){
      for(int j = i + 1; j <= r; j++){
	int tmp = (i * j) % 2019;
	if(tmp < min) min = tmp;
      }
    }
    cout << min << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
 
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
 
#define CINT cpp_int 
 
int main() {
    int n; cin >> n; CINT a, b; 
    CINT REF = pow(CINT(10), 80);
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        if (a + b >= REF) cout << "overflow" << endl;
        else cout << a + b << endl;
    }
    return 0;
}


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

#define ll long long int
bool cheak(int a,int b,int c)
{
	if(a<b&&b<c)
	{
		return true;
	}
	if(a>b&&b>c)
		return true;
	return false;
}

int main()
{
	

	int n;
	cin>>n;
	int ar[n];
	for(int i=0;i<n;i++)
	{
		cin>>ar[i];
	}
	int count=0;
	for(int i=1;i<n-1;i++)
	{
		count+=cheak(ar[i-1],ar[i],ar[i+1]);
	}
	cout<<count<<endl;

	return 0;
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000
#define N 100005
#define pii pair<int,int>
#define vp vector<pair<int,int > >
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define gsz(x) ((int)(x).size())
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))

int main()
{
	fastio;
	ll n,i,j,k;
	cin>>n;
	ll res=0;
	while(n>0)
		{
		if(n%3==0&&n%5==0)
		{
			//cout<<"FizzBuzz"<<endl;
		}
		else if(n%3==0)
		{
			//cout<<"Fizz"<<endl;
		}
		else if(n%5==0)
		{
			//cout<<"Buzz"<<endl;
		}
		else
		{
			res+=n;
		}
		n--;
	}
	cout<<res<<endl;


	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

int main(){
    vvi c(3, vi(3, 0));
    rep(i, 3){
        rep(j, 3){
            cin >> c[i][j];
        }
    }
    rep(i, 3){
        rep(j, 3){
            c[i][j] -= c[2][j];
        }
    }
    bool f = true;
    rep(i, 3){
        rep(j, 3){
            c[i][j] -= c[i][2];
            if(c[i][j]) f = false;
        }
    }
    cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int L[] = new int[N];

    for(int i = 0; i < N; i++){
      L[i] = sc.nextInt();
    }

    Arrays.sort(L);
    int count = 0;
    for(int i = 0; i < N - 2; i++){
      for(int j = i + 1; j < N - 1; j++){
        for(int k = j + 1; k < N; k++){
            if(L[k] < L[i] + L[j]){
              count++;
            }
        }
      }
    }

    System.out.println(count);
  }
}

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

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

    int ans = 0;
    for (int i = 0; i < S.length(); ++i) {
        if (S[i] != T[i]) {
            ++ans;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3916
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  int n, m;
  cin >> n >> m;
  priority_queue<ll> q;
  rep(i, n){
    int a;
    cin >> a;
    q.push(a);
  }

  ll ans = 0;


  for(int i = 0; i < m; ++i){
    ll max_price = q.top();
    max_price /= 2;
    q.pop();
    q.push(max_price);
  }

  while(!q.empty()){
    ans += q.top();
    q.pop();
  }

  cout << ans << endl;


}

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

import sys
sys.setrecursionlimit(300000)


def solve(S: str, T: str):
    ret = 0
    for i in range(len(S)):
        if S[i] != T[i]:
            ret += 1
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


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

int N;
int cont=0;
vector<int> p(8);
vector<int> q(8);
int a,b;
bool aa=false,bb=false;

void My_Permutation(vector<bool> flag,int k,vector<int> P){
  if(k==N){
    cont++;
    bool equal_a=true;
    bool equal_b=true;
    rep(i,N){
      if(p.at(i)!=P.at(i)) equal_a=false;
      if(q.at(i)!=P.at(i)) equal_b=false;
    }

    if(equal_a){
      a=cont;
      aa=true;
    }

    if(equal_b){
      b=cont;
      bb=true;
    }

    if(aa&&bb){
      cout << abs(a-b) << endl;
      exit(0);
    }

    return;

  }
  for(int E=1;E<=N;E++){
    if(flag.at(E-1)){
      continue;
    }else{
      P.push_back(E);
      flag.at(E-1)=true;
      My_Permutation(flag,k+1,P);
      flag.at(E-1)=false;
      P.pop_back();
    }
  }
}

int main(){
  cin >> N;
  rep(i,N) cin >> p.at(i);
  rep(i,N) cin >> q.at(i);
  vector<bool> flag(N);
  vector<int> P(0);
  My_Permutation(flag,0,P);
}

Measured memory_bytes: 256
n, k = list(map(int, input().split()))
s = list(map(int, input().split()))
T = list(input())
ans = 0
for i in range(k):
    T_sub = T[i::k]
    score = 0
    pre = 3
    for t_sub in T_sub:
        if t_sub == pre:
            pre = 3
        else:
            if t_sub == 'r':
                score += s[2]
            elif t_sub == 's':
                score += s[0]
            else:
                score += s[1]
            pre = t_sub
    ans += score
print(ans)


Measured memory_bytes: 4788
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;
    
    vector<P> p(n);  // p[i] : (おいしさ, ネタの種類)
    rep(i, n) {
        ll t, d;
        cin >> t >> d;
        p[i] = make_pair(d, t);
    }
    sort(rall(p));
    
    map<ll, ll> mp;
    priority_queue<ll, vector<ll>, greater<ll>> prQ;  // 小さい要素から順に取り出す
    ll sumD = 0;
    rep(i, k) {
        ll d = p[i].first;
        ll t = p[i].second;
        sumD += d;
        mp[t]++;
        if(mp[t] >= 2) {
            prQ.push(d);
        }
    }
    
    ll x = mp.size();
    ll ans = sumD + x*x;
    
    exrep(i, k, n-1) {
        if(prQ.empty()) {
            break;   
        }
        ll d = p[i].first;
        ll t = p[i].second;
        mp[t]++;
        if(mp[t] >= 2) {
            mp[t]--;
            continue;
        }
        sumD += d - prQ.top();
        prQ.pop();
        x++;
        chmax(ans, sumD + x*x);
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 6140
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int N;
string S;

bool notequal(char a,char b,char c){
    if(a==b||a==c||b==c)return false;
    return true;
}
int main() {
    ios::sync_with_stdio(false);
    string S=in<string>();
    int a,b;
    a=S[0]-'0';a*=10;a+=S[1]-'0';
    b=S[2]-'0';b*=10;b+=S[3]-'0';
    // debug(a);
    // debug(b);
    if(a<=12&&a>=1){
        if(b<=12&&b>=1){
            cout<<"AMBIGUOUS"<<endl;
        }else{
            cout<<"MMYY"<<endl;
        }
    }else{
        if(b<=12&&b>=1){
            cout<<"YYMM"<<endl;
        }else{
            cout<<"NA"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main()
{
    int N;
    std::cin >> N;
    // long long ls[N];
    std::vector<long long> ls(N);
    long long xor_sum = 0;
    for (int i=0; i<N; i++)
    {
        std::cin >> ls[i];
        xor_sum ^= ls[i];
    }
    for (int i=0; i<N; i++)
    {
        std::cout << (xor_sum^ls[i]) << std::endl; 
    }
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s] += 1;
  }
  int num = 0;
  for(auto v : mp) {
    num = max(num, v.second);
  }
  for(auto v : mp) {
    if(v.second == num) cout << v.first << endl;
  }
}

Measured memory_bytes: 25216
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int h,w;
  cin >> h >> w;
  vector<string> a(h);
  for(int i = 0;i < h;i++)cin >> a[i];

  int cnt = 0;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(a[i][j] == '#')cnt++;
    }
  }

  if(cnt != h + w - 1)cout << "Impossible" << endl;
  else cout << "Possible" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *xp, int *yp);

int main(void)
{
	int rope[30];
	int x, y;
	int w, n;
	int i;
	
	scanf("%d %d", &w, &n);
	
	for (i = 0; i < w; i++){
		rope[i] = i + 1;
	}
	
	for (i = 0; i < n; i++){
		scanf("%d%*c%d", &x, &y);
		swap(&rope[x - 1], &rope[y - 1]);
	}
	
	for (i = 0; i < w; i++){
		printf("%d\n", rope[i]);
	}
	
	return (0);
}

void swap(int *xp, int *yp)
{
	int tmp;
	
	tmp = *xp;
	*xp = *yp;
	*yp = tmp;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long int i,j,a,b,k;
	cin>>a>>b>>k;
	if(a>b)
	{
		cout<<0<<endl;
		return 0;
	}
	for(i=1;i<=k && a<=b;i++)
	{
	
		cout<<a<<endl;
		a=a+1;
		
	}
	a--;
	for(i=b-k+1;i<=b && i>=0;i++)
	{
		if(i>a)
		{
			cout<<i<<endl;
		}
	}
	
	
	
		
} 

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(auto &t:a)cin>>t;return i;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


int check(int x,vector<int> &A){
  int n = A.size();
  for(int i=0;i<n;i++) x = x - x%A[i];
  return x;
}


int solve1(vector<int> A){
  int L = 0,R = INF;
  while(L+1<R){
    int M = (L+R)/2;
    check(M,A) != 0? R=M:L=M;
  }
  return R;
}

int solve2(vector<int> A){
  int L = 0,R = INF;
  while(L+1<R){
    int M = (L+R)/2;
    check(M,A) > 2? R=M:L=M;
  }
  return L;
}


void dfs(int idx,int x, vector<int> &A){
  if(idx == (int)A.size()) cout<<x<<endl;
  if(idx == (int)A.size()) return;
  for(int i=0;i<100;i++) if(x == i - i%A[idx]) dfs(idx+1,i,A);
}

signed main(){
  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;
  
  //dfs(0,2,A);
  //reverse(A.begin(),A.end());
  //for(int i=0;i<100;i++) cout<<check(i,A)<<endl;
  
  int a = solve1(A);
  int b = solve2(A);
  if(check(a,A)!=2 || check(b,A)!=2) cout<<-1<<endl;
  else cout<<a<<" "<<b<<endl;
    
  
  return 0;
}


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

int a, b, c, d;

main()
{
    cin >> a >> b >> c >> d;

    if (abs(a - c) <= d) {
        cout << "Yes" << endl;
        return 0;
    } else if (abs(a - b) <= d && abs(b - c) <= d) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define N 26
#define Nil -1

typedef struct {
    int parent;
    int left;
    int right;
} Node;

Node BT[N];
int D[N];
int Deg[N];
int H[N];

void setDepth(int i, int depth) {
    D[i] = depth;
    if (BT[i].left != Nil) setDepth(BT[i].left, depth + 1);
    if (BT[i].right != Nil) setDepth(BT[i].right, depth + 1);
}

int setHeight(int i) {
    int hl, hr;
    hl = hr = 0;
    if (BT[i].left != Nil) hl = setHeight(BT[i].left) + 1;
    if (BT[i].right != Nil) hr = setHeight(BT[i].right) + 1;
    if (hl < hr) {
        return hr;
    } else {
        return hl;
    }
}

int sibling(int i) {
    if (BT[i].parent == Nil) return -1;
    Node parent = BT[BT[i].parent];
    if (parent.left != Nil && parent.left != i) {
        return parent.left;
    }
    else if (parent.right != Nil && parent.right != i) {
        return parent.right;
    }
    else {
        return -1;
    }
}

int setDegree(int i) {
    int c = 0;
    if (BT[i].left != Nil) c++;
    if (BT[i].right != Nil) c++;
    return c;
}

int main () {
    int n;
    scanf("%d", &n);
    for (int i=0; i<n; i++) D[i] = -1;
    for (int i=0; i<n; i++) { BT[i].parent = Nil; }

    for (int i=0; i<n; i++) {
        int v, l, r;
        scanf("%d %d %d", &v, &l, &r);
        BT[v].left = l;
        BT[v].right = r;
        if (Nil != l) { BT[l].parent = v; }
        if (Nil != r) { BT[r].parent = v; }
    }

    int root = -1;
    for (int i=0; i<n; i++) if (BT[i].parent == Nil) root = i;
    setDepth(root, 0);
    for (int i=0; i<n; i++) {
        H[i] = setHeight(i);
        Deg[i] = setDegree(i);
    }
    for (int i=0; i<n; i++) {
        char type[20];
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, BT[i].parent, sibling(i), Deg[i], D[i], H[i]);
        if (root == i) {
            printf("root\n");
        } else if (Deg[i] > 0) {
            printf("internal node\n");
        } else {
            printf("leaf\n");
        }
    }

    return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#define ll long long
#define sz 100105
using namespace std;
ll a[sz] , sum;
ll dp[sz];
ll solve(ll n , ll i){
   if(i<n){
        dp[i] = min(dp[i-2]+(abs(a[i-2] - a[i])),dp[i-1]+(abs(a[i-1] - a[i])));
        solve(n,i+1);
   }
   else return dp[n-1];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i , j , n;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    dp[1] = abs(a[1]-a[0]);
    ll res = solve(n,2);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

struct UnionFind{
    public:
    vector<int> data;
    UnionFind(ll sz){
        data.assign(sz, -1);
    }
    int find(int p){
        if(data[p]<0) return p;
        return data[p]=find(data[p]);
    }
    bool unite(int X, int Y){
        X=find(X), Y=find(Y);
        if(X==Y) return false;
        if(data[X]>data[Y]) swap(X, Y);
        data[X] += data[Y];
        data[Y]=X;
        return true;
    }
    ll size(int k){
        return -data[find(k)];
    }
};

int main() {
	ll N, M;
	cin >> N >> M;
	vector<vector<int>> lang(M);
	for(int i=0; i<N; ++i){
	    int K, L;
	    cin >> K;
	    for(int j=0; j<K; ++j){
	        cin >> L;
	        lang[L-1].push_back(i);
	    }
	}
	UnionFind uf(N);
	for(int i=0; i<M; ++i){
	    for(int j=0; j+1<lang[i].size(); ++j){
	        uf.unite(lang[i][j], lang[i][j+1]);
	    }
	}
	cout << (uf.size(0)==N ? "YES" : "NO") << endl;
	return 0;
}


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

int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  
  bool flg = false;
  
  if (x + r <= W && x - r >= 0 && y + r <= H && y - r >= 0) {
    flg = true;
  }
  
  if (flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
    
}



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

int main(){
    while(true){
        int n,m;
        cin >> n >> m;
        if(!n && !m) break;
        int ans = 0;
        for(int i = 1; i <= n; i++){
            for(int j = i+1; j <= n; j++){
                for(int k = j+1; k <= n; k++){
                    if(i+j+k == m) ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()

    ans = 0
    for i in (25, 10, 5, 1):
        ans += n // i
        n %= i

    print(ans)

if __name__ == '__main__':
    resolve()



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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    void swap(int &, int &);
    if (a > b)
        swap(a, b);
    if (b > c)
        swap(b, c);
    if (a > b)
        swap(a, b);
        
    cout << a << ' ' << b << ' ' << c << endl;
    return 0;
}

void swap(int &x, int &y) {
    int temp = x;
    x = y;
    y = temp;
}


Measured memory_bytes: 3108
def main():
    n = int(input())
    ans = []
    for i in range(1, 12):
        if n <= 26**i:
            n -= 1
            for j in range(i):
                a = n % 26
                ans.append(chr(97+a))
                n = n // 26
            break
        else:
            n -= 26**i
    print(*ans[::-1], sep='')
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 9132
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

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

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

using namespace std;

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

  vector<int> D(n);
  for (int i = 0; i < n; i++) cin >> D.at(i);

  int ans = 0;

  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += D.at(i) * D.at(j);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	var n int
	fmt.Scan(&a, &b, &n)
	m := n / b
	if m >= 1 {
		fmt.Println(a*(m*b-1)/b - a*((m*b-1)/b))
	} else {
		fmt.Println(a*n/b - a*(n/b))
	}
}


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

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    if (ceil(double(n)/2) >= k){
    	cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    cin >> n;
}

Measured memory_bytes: 256
import math
N = int(input())
cnt = 0
for j in range(1, N+1, 2):
    ans = []
    for i in range(1, math.ceil(j**0.5)+1):
        if j%i == 0:
            if j//i == i:
                ans.append(i)
            else:
                ans.append(i)
                ans.append(j//i)
    if len(ans) == 8:
        cnt += 1
    ans = []
print(cnt)

Measured memory_bytes: 3188
n = int(input())
lst = list(map(int, input().split()))
a = lst[0]
A = lst[0]
s = lst[0]
for i in range(1, n):
    a = min(a, lst[i])
    A = max(A, lst[i])
    s += lst[i]
print(a, A, s)


Measured memory_bytes: 6592
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader inp = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(inp, out);
        out.close();
    }

    private static class Solver {
        private void solve(InputReader inp, PrintWriter out) {
            int h = inp.nextInt(), w = inp.nextInt();
            boolean[][] grid = new boolean[h][w];
            for (int i = 0; i < h; i++) {
                char[] row = inp.next().toCharArray();
                for (int j = 0; j < w; j++) {
                    grid[i][j] = row[j] == '.';
                }
            }
            long MOD = 1000000007;
            long[][] dp = new long[h][w];
            dp[0][0] = 1;
            int row = 0, column = 0;
            while (row < h && column < w) {
                int i = 0;
                while (column + i < w && row - i >= 0) {
                    if (grid[row - i][column + i]) {
                        if (row - i - 1 >= 0)  {
                            dp[row - i][column + i] += dp[row - i - 1][column + i];
                        }
                        if (column + i - 1 >= 0) {
                            dp[row - i][column + i] += dp[row - i][column + i - 1];
                        }
                    }
                    dp[row - i][column + i] %= MOD;
                    i++;
                }
                if (row + 1 < h) row++;
                else column++;
            }
            out.print(dp[h-1][w-1]);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 36956
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:X]
q = q[:Y]
r.extend(p)
r.extend(q)
r.sort(reverse=True)
ans = 0
for i in range(X+Y):
    ans += r[i]
print(ans)

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

int main() {
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());

    s < t ? cout << "Yes" : cout << "No";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

string s,t;
vector<ll> f[26];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>s>>t;
	set<char> present;
	For(i,0,s.size()){
		f[s[i]-'a'].pb(i);
		present.insert(s[i]);
	}
	For(i,0,t.size()){
		if(present.find(t[i])==present.end()){
			cout<<-1<<endl;
			return 0;
		}
	}

	ll ans = 0;
	ll prev = -1;
	For(i,0,t.size()){
		vector<ll>& a = f[t[i]-'a'];
		vector<ll>::iterator it = upper_bound(a.begin(),a.end(),prev);
		if(it==a.end()){
			ans += ((s.size()-1)-prev);
			ll index = a[0];
			ans += (index+1);
			prev = index;
			// trace(i,index,prev);
		}else{	
			ll index = *it;
			ans += (index-prev);
			prev = index;
			// trace(i,index,prev);
		}
	}
	cout<<ans<<endl;
	































	
}

Measured memory_bytes: 1736
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(a <= k){
        ans += a;
        k -= a;
        if(b <= k){
            k -= b;
            if(k <= c){
                ans -= k;
            }
        }
    }else{
        ans += k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

long long int T = 1000000000;

int main() {
	long long int a, b;
	cin >> a >> b;
	string c;
	cin >> c;
	c = "+" + c;
	int N = c.size()/4;
	priority_queue<int, vector<int>, less<int> > pq;
	for (int i = 0; i < N; i++) {
		pq.push(c[3+4*i]-'0');
	}
	bool hantei = true;
	long long int p = 0;
	while (!pq.empty()) {
		int t = pq.top(); 
		pq.pop();
		long long int k = 1;
		for (int i = 0; i < t; i++) {
			k *= a;
			if (k > T) {
				hantei = false;
				break;
			}
		}
		p += k;
		if (p > T) {
			hantei = false;
			break;
		}
	}
	if (hantei) {
		p *= b;
		if (p > T) {
			hantei = false;
		}
	}
	if (hantei) {
		cout << p << endl;
	} else {
		cout << "TLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less   
using namespace __gnu_pbds;  
using namespace std;  
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> set1;
ll find(ll a,ll p[])
{
   //cout<<"find "<<a<<endl;
   if(a==p[a])
   return a;
   else return p[a]=find(p[a],p);

}
void join(ll a,ll b,ll p[],ll sz[])
{
   a=find(a,p);
   b=find(b,p);
   if(a!=b)
   {
      if(sz[a]<sz[b])
      swap(a,b);
      sz[a]+=sz[b];
      p[b]=a;
   }
}
ll power(ll a,ll b,ll mod)
{
   ll res=1;
   while(b>0)
   {
      if(b&1)
      res=(res*a)%mod;
      b=b/2;
      a=(a*a)%mod;
   }
   return res;
}
ll inverse(ll x, ll p)
{
   return power(x,p-2,p);
}
ll hash1(ll x,ll y)
{
   return x+y+x*y;
}
ll f[200000]={0};
ll mod=1000000007;
void ini()
{
   f[0]=1;
   for(ll i=1;i<=200000;i++)
   f[i]=(i*f[i-1])%mod;
}
void build(ll tree[],ll v,ll l,ll r,ll dp[])
{
   if(l==r)
      tree[v]=dp[l];
   else
   {
      ll m=(l+r)/2;
      build(tree,2*v,l,m,dp);
      build(tree,2*v+1,m+1,r,dp);
      tree[v]=max(tree[2*v],tree[2*v+1]);
   }
}
ll query(ll tree[],ll v,ll l,ll r,ll tl,ll tr)
{
   if(l==tl && tr==r)
   {
    //  cout<<"max of "<<tl<<" "<<tr<<" "<<tree[v]<<endl;
      return tree[v];
   }
   else
   {
      ll m=(l+r)/2;
      if(tr<=m)
      {
         ll z1= query(tree,2*v,l,m,tl,tr);
     //    cout<<"max of "<<tl<<" "<<tr<<" "<<z1<<endl;
         return z1;
      }
      else if(tl>m)
      {
         ll z2= query(tree,2*v+1,m+1,r,tl,tr);
      //   cout<<"max of "<<tl<<" "<<tr<<" "<<z2<<endl;
         return z2;
      }
      else 
      {
         ll z=query(tree,2*v,l,m,tl,m);
         ll z1=query(tree,2*v+1,m+1,r,m+1,tr);
       //  cout<<"max of "<<tl<<" "<<tr<<" "<<max(z1,z)<<endl;
         return max(z1,z);
      }
      
      
   }
}
void update(ll tree[],ll v,ll l,ll r,ll pos,ll element)
{
   if(l==r && l==pos)
   tree[v]=element;
   else
   {
      ll m=(l+r)/2;
      if(pos<=m)
      update(tree,2*v,l,m,pos,element);
      else
      update(tree,2*v+1,m+1,r,pos,element);
      tree[v]=max(tree[2*v],tree[2*v+1]);
   }
}

ll ncr(ll n,ll r)
{
   ll res=1;
   ll k=f[n];
   ll v=inverse(f[n-r],mod);
   ll u=inverse(f[r],mod);
   ll x=(u*v)%mod;
   k=(k*x)%mod;
   return k;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
  ll n;
  cin>>n;
  ll h[n];
  ll a[n];
  for(ll i=0;i<2;i++)
  {
     for(ll j=0;j<n;j++)
     {
        if(i==0)
        cin>>h[j];
        else
        cin>>a[j];
     }
  }
ll dp[n+1]={0};
dp[0]=0;
ll tree[4*n+1];
build(tree,1,0,n,dp);
for(ll i=0;i<n;i++)
{
   ll s=query(tree,1,0,n,0,h[i]-1);
  // cout<<s<<endl;
   dp[h[i]]=max(dp[h[i]],a[i]+s);
   update(tree,1,0,n,h[i],dp[h[i]]);
}
cout<<query(tree,1,0,n,0,n)<<endl;
return 0;
}


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

bool f[3333][3333];

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  memset(f, false, sizeof(f));
  f[0][0] = true;
  for(int j = 0; j <= F; j++) {
    for(int i = 0; i <= F - j; i++) {
      if (i * 100 > j * E) {
        break;
      }
      if (j >= 100 * A && f[i][j - 100 * A]) {
        f[i][j] = true;
      }
      if (j >= 100 * B && f[i][j - 100 * B]) {
        f[i][j] = true;
      }
      if (i >= C && f[i - C][j]) {
        f[i][j] = true;
      }
      if (i >= D && f[i - D][j]) {
        f[i][j] = true;
      }
    }
  }
  double res = -1;
  int res1 = 0, res2 = 0;
  for(int j = 1; j <= F; j++) {
    for(int i = 0; i <= F - j; i++) {
      if (f[i][j]) {
        if (res < 100.0 * i / (i + j)) {
          res = 100.0 * i / (i + j);
          res1 = i; res2 = i + j;
        }
      }
    }
  }
  cout << res2 << " " << res1 << endl;
  return 0;
}


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

int main() {
string S,T;
  cin >> S >> T;
  
int A,B ;
  cin >> A >> B ;
string U;
  cin >> U;
  
  if(S==U) A--;
  else if (T==U) B--;
  
  cout << A <<" "<< B << endl;  
}


Measured memory_bytes: 256
from collections import deque
inf=10**9


def BFS():
    point=0
    color=[["white" for _ in range(w)] for _ in range(h)]
    D=[[inf for _ in range(w)] for _ in range(h)]

    queue=deque([])
    for i in range(h):
        for j in range(w):
            if A[i][j]=="#":
                queue.append([i,j])
                D[i][j]=0

    while len(queue)>0:
        x,y=queue.popleft()
        for a,b in [[1,0],[-1,0],[0,1],[0,-1]]:
            X,Y=x+a,y+b
            if 0<=X<h and 0<=Y<w:
                if color[X][Y]!="black" and D[X][Y]>D[x][y]+1:
                    color[X][Y]="gray"
                    D[X][Y]=D[x][y]+1
                    point=max(point,D[X][Y])
                    queue.append([X,Y])
        color[x][y]="black"

    return point


h,w=map(int,input().split())
A=[list(input()) for _ in range(h)]
print(BFS())

Measured memory_bytes: 186716
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);

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

    if (a + b <= 16) {
        if (a > 8 or b > 8)
            cout << ":(" << endl;
        else 
            cout << "Yay!" << endl;
    }

    return 0;
}


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

int main(void){
  int n;
  int cnt1 = 0,cnt2 = 0,cnt4 = 0;
  cin >> n;
  for(int i = 0;i < n;++i){
    int a;
    cin >> a;
    if(a % 4 == 0) ++cnt4;
    else if(a % 2 == 1)++cnt1;
    else cnt2++;
  }
  if(cnt1 <= cnt4)puts("Yes");
  else if(cnt2 == 0 && cnt1 <= cnt4 + 1)puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

int N;
string S[200005];
int cnt[60][60];
signed main(){
	cin>>N;
	int ans=0;
	rep(i,N){
		cin>>S[i];
		bool flag=false;
		rep(k,len(S[i]))flag|=S[i][k]=='.';
		if(!flag)S[i].push_back('.');
		while(S[i].back()=='0')S[i].pop_back();
		int j=0;
		for(;j<len(S[i]);j++)if(S[i][j]=='.')break;
		int now=0;
		for(char c:S[i]){
			if(c=='.')continue;
			now=now*10+c-'0';
		}
		rep(k,9-(len(S[i])-j)+1)now*=10;
		int cnt2=0,cnt5=0;
		while(now%2==0){now/=2;cnt2++;}
		while(now%5==0){now/=5;cnt5++;}
		for(int k=max(0ll,18-cnt2);k<60;k++){
			for(int l=max(0ll,18-cnt5);l<60;l++){
				ans+=cnt[k][l];
			}
		}
		cnt[cnt2][cnt5]++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    int N = s.size();
    //vec[i]:=それより右をi文字に抑えることのできる最小のindex
    vector<int> vec;
    vec.pb(N);
    map<char, int> mp;
    rep3(i, N-1, 0){
        mp[s[i]]++;
        if(mp.size() == 26){
            vec.pb(i);
            mp.clear();
        }
    }
    //文字列の最小の長さはn
    int n = vec.size();
    s += alpha;
    //左からi文字目に何を使えるか貪欲に調べる
    int now = 0;
    char ans[n];
    rep(i, n){
        rep(j, 26){
            char x = 'a'+j;
            int k = now;
            while(s[k] != x) k++;
            //残りでn-1-i文字を作れれば良い
            if(k >= vec[n-1-i]){
                ans[i] = x;
                now = k+1;
                break;
            }
        }
    }
    rep(i, n) cout << ans[i];
    cout << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll A,B,C,K; cin>>A>>B>>C>>K;
	cout<<(K%2==1?B-A:A-B);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  string s,ans;
  cin>>s;
  for(int i=0;i<s.size();i=i+2){
    ans.push_back(s[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
int n,m,i,d,p,z;
main(){
  while(std::cin>>n>>m,n){
    int x[11]={};
    for(z=i=0;i++<n;x[p]+=d)std::cin>>d>>p;
    for(i=10;i>=0;z+=i*x[i],--i)x[i]-=d=(x[i]<m?x[i]:m),m-=d;
    std::cout<<z<<'\n';
  }
}

Measured memory_bytes: 3048
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  val Array(r,c) = readLine.split(" ").map(_.toInt)
  val matrix = ArrayBuffer.empty[Array[Int]]
  val row = Array.fill[Int](c+1)(0)

  for( i <- 0 until r) {
    val n = readLine.split(" ").map(_.toInt)
    val a = n :+ n.sum
    matrix += a
    (0 until c).foreach( j=> row(j) += n(j) );row(c) += n.sum
  }
  matrix += row
  matrix.toArray.foreach( row => println(row.mkString(" ")) )
}

Measured memory_bytes: 48396
def dist(arr, n):
	res = 0; su = 0
	for i in range(n):
		res = (res + (arr[i] * i) - su) % mod
		su = (su + arr[i]) % mod

	return res % mod

n,m,k = map(int,input().split())
mod = int(1e9+7)
fact = [1]
for i in range(1,n*m+1):
	fact.append((fact[-1] * i)%mod)

x = []
y = []

for i in range(1,n+1):
	for j in range(1,m+1):
		x.append(i)
		y.append(j)

y.sort()

tot = (dist(x,n*m) + dist(y,n*m))%mod
N = n*m - 2
Need = k-2
num = fact[N]
den = (fact[Need] * fact[N-Need])%mod
ncr = (num * pow(den,mod-2,mod)) % mod
ans = (tot * ncr) % mod
print(ans)

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

typedef long long ll;

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

  ll takahashi=1,aoki=1;
  rep(i,0,N) {
    int T,A; cin >>T >>A;
    ll n=max(ll((takahashi+T-1)/T),ll((aoki+A-1)/A));
    takahashi=n*T;
    aoki=n*A;
  }
  cout<<takahashi+aoki <<endl;
  return 0;
}


Measured memory_bytes: 256
s = gets.to_s.chomp

ATGC = "ATGC".freeze
ans = cnt = 0
s.each_char do |c|
  
  if ATGC.include?(c)
    cnt += 1
  else
    ans = cnt if ans < cnt
    cnt = 0
  end
end

ans = cnt if ans < cnt

puts ans

Measured memory_bytes: 1788