akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

pair<pair<int,int>, pair<int, int>> E[200001];
int H[100001];
int P[100001][17];
int D[100001], RD[100001];

int oya(int A, int B) {
	if (B == 0) return A;
	int k = 31 - __builtin_clz(B);
	return oya(P[A][k], B - (1 << k));
}
void dfs(int A, int prev, int rd, int d) {
	RD[A] = rd;
	D[A] = d;
	P[A][0] = prev;
	int mae = prev;
	rep(i, 16) {
		P[A][i + 1] = P[mae][i];
		mae = P[A][i + 1];
	}
	for (int i = H[A]; i; i = E[i].first.second) {
		if (E[i].first.first != prev) dfs(E[i].first.first, A, rd + E[i].second.first, d + 1);
	}
}

pair<int, int> QE[300001];
int QH[100001];
int CD[100001], CN[100001];
void dfs2(int A, int C) {
	int tmp;
	for (int i = QH[A]; i; i = tmp) {
		tmp = QE[i].second;
		QE[i].second = CN[QE[i].first];
		QE[i].first = CD[QE[i].first];
	}
	for (int i = H[A]; i; i = E[i].first.second) {
		if (E[i].first.first != C) {
			CD[E[i].second.second] += E[i].second.first;
			CN[E[i].second.second]++;
			dfs2(E[i].first.first, A);
			CD[E[i].second.second] -= E[i].second.first;
			CN[E[i].second.second]--;
		}
	}
}


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

	
	int N, Q;
	cin >> N >> Q;
	for (int i = 1; i < N + N - 1; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		E[i] = mp(mp(b, H[a]), mp(d, c));
		H[a] = i++;
		E[i] = mp(mp(a, H[b]), mp(d, c));
		H[b] = i;
	}

	dfs(1, 0, 0, 0);

	int motoD[100000], y[100000];
	rep(i, Q) {
		int x, u, v;
		cin >> x >> y[i] >> u >> v;

		if (D[u] > D[v]) swap(u, v);
		int sa = D[v] - D[u];

		int u2 = u;
		int v2 = oya(v, sa);
		int lca = u;
		if (u2 != v2) {
			for (int k = 16; k >= 0; k--) {
				if (P[u2][k] != P[v2][k]) {
					u2 = P[u2][k];
					v2 = P[v2][k];
				}
			}
			lca = P[u2][0];
		}
		motoD[i] = RD[u] + RD[v] - RD[lca] * 2;
		QE[i * 3 + 1] = mp(x, QH[u]);
		QH[u] = i * 3 + 1;
		QE[i * 3 + 2] = mp(x, QH[v]);
		QH[v] = i * 3 + 2;
		QE[i * 3 + 3] = mp(x, QH[lca]);
		QH[lca] = i * 3 + 3;
	}

	dfs2(1, 0);

	rep(i, Q) {
		motoD[i] -= QE[i * 3 + 1].first + QE[i * 3 + 2].first - 2 * QE[i * 3 + 3].first;
		motoD[i] += (QE[i * 3 + 1].second + QE[i * 3 + 2].second - 2 * QE[i * 3 + 3].second) * y[i];
		co(motoD[i]);
	}

	Would you please return 0;
}

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

const long long MOD = 1000000007;
long long pow(int x, int n);

signed main() {
    int n;
    long long ans;
    cin >> n;

    ans = (pow(10, n) - pow(9, n) - pow(9, n) + pow(8, n)) % MOD;

    cout << (ans + MOD) % MOD << endl; 

    return (0);
}

long long pow(int x, int n) {
    long long ans = 1;

    for ( int i = 0; i < n; i++ ) {
        ans = ans * x;

        ans = ans % MOD;
    }

    return (ans);
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
long long arr[105],n,sum,cap[105][105],maxflow,pre[105];

queue <pair<long long, long long> > q;
vector<long long> adj[105];
const long long inf = 1e18;
long long bfs(){
	while(!q.empty())q.pop();
	pre[0]=-2;
	q.push({0ll,inf});
	while(!q.empty()){
		long long cur  = q.front().fi;
		long long flow = q.front().se;
		q.pop();
		for(auto v: adj[cur]){
			// cout<<v<<' '<<cur<<' '<<cap[cur][v]<<endl;
			if(pre[v]==-1&&cap[cur][v]>0){
				pre[v]=cur;
				long long newflow = min(flow,cap[cur][v]);
				if(v==n+1)return newflow;
				q.push({v,newflow});
			}
		}
	}
	return 0;
}
int main(){
	cin>>n;
	for(long long i =1;i<=n;i++){
		cin>>arr[i];
		
		if(arr[i]>=0){
			adj[i].pb(n+1);
			adj[n+1].pb(i);
			cap[i][n+1]+=arr[i];
			sum+=arr[i];
		}
		if(arr[i]<0){
			adj[i].pb(0);
			adj[0].pb(i);
			cap[0][i]-=arr[i];
		}
		for(int j =2*i;j<=n;j+=i){
			adj[i].pb(j);
			adj[j].pb(i);
			cap[i][j]= inf;
		}
	}
	while(1){
		memset(pre,-1,sizeof(pre));
		long long add =bfs();
		if(add==0)break;
		maxflow+=add;
		long long cur = n+1;
		while(cur!=0){
			long long prev = pre[cur];
			cap[prev][cur]-=add;
			cap[cur][prev]+=add;
			cur=prev;
		}
	}
	// cout<<maxflow<<endl;
	cout<<sum-maxflow<<endl;

}

Measured memory_bytes: 3688
S = input()
f = int(S[0]+S[1])
b = int(S[2]+S[3])

def judge(int):
    if 1 <= int <= 12:
        return 0
    else:
        return 1
ref = [judge(f), judge(b)]

if ref == [1, 1]:
    print("NA")
elif ref == [0, 1]:
    print("MMYY")
elif ref == [1, 0]:
    print("YYMM")
else:
    print("AMBIGUOUS")


Measured memory_bytes: 8920
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
int f(int a){
	if(a==0)
		return 0;
	return 1+2*f(a/2);
}
int32_t main() 
{ 
	int h;
	cin>>h;
	cout<<f(h);
} 


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

vector<int> zero_one_breadth_first_search(int root, vector<set<pair<int, bool> > > const & g) {
    int n = g.size();
    vector<int> dist(n, INT_MAX);
    deque<pair<int, int> > que;
    dist[root] = 0;
    que.emplace_back(root, dist[root]);
    while (not que.empty()) {
        int i, dist_i; tie(i, dist_i) = que.front(); que.pop_front();
        if (dist[i] < dist_i) continue;
        for (auto edge : g[i]) {
            int j; bool cost; tie(j, cost) = edge;
            if (dist[i] + cost < dist[j]) {
                dist[j] = dist[i] + cost;
                if (cost) {
                    que.emplace_back(j, dist[j]);
                } else {
                    que.emplace_front(j, dist[j]);
                }
            }
        }
    }
    return dist;
}

int main() {
    // input
    int k; scanf("%d", &k);
    // solve
    vector<set<pair<int, bool> > > g(k);
    REP (n, k) {
        g[n].emplace(n * 10 % k, 0);
        g[n].emplace((n + 1) % k, 1);
    }
    int result = zero_one_breadth_first_search(1, g)[0] + 1;
    // output
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 15104
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CMultiplication3 {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int A;
        string B;
        cin >> A >> B;

        int b = 0;
        bool hasP = false;
        int num = 0;
        for (auto c : B) {
            if (c == '.') {
                hasP = true;
            } else {
                if (hasP) num++;
                b = 10 * b + (c - '0');
            }
        }

        int points = 1;
        REP(i, num) points *= 10;
        cout << A * b / points << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CMultiplication3 solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3548
#include<stdio.h>
#include<string.h>

int a[60],n,sum;
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    for(int i=1; i<n; i++)
    {
        for(int j=i+1; j<=n; j++)
            sum += a[i]*a[j];
    }
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A + B + C == 17){
    cout << "YES" << endl;
  }
  
  else {
    cout << "NO" << endl;
  }

}
  
  
  

Measured memory_bytes: 768
//============================================================================
// Name        : abc131_c.cpp
// Author      : abb
// Version     :
// Copyright   : [My copyright notice]
// Description : Hello World in C++, Ansi-style
//============================================================================

/*
 C - Anti-Division

 実行時間制限: 2 sec / メモリ制限: 1024 MB

 配点 : 300 点

 問題文
 整数 A, B, C, D が与えられます。A 以上 B 以下の整数のうち、C でも D でも割り切れないものの個数を求めてください。

 制約

 ・1 <= A <= B <= 10^{18}
 ・1 <= C, D <= 10^9
 ・入力はすべて整数である
 */

#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

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

ll GCD(ll a, ll b) {
	return (b == 0) ? a : GCD(b, a % b);
}

ll LCM(ll a, ll b) {
	return a * b / GCD(a, b);
}

/**
 * エントリポイント．
 * @return 0.
 */
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll a, b, c, d, l;
	cin >> a >> b >> c >> d;

	l = LCM(c, d);

	// 区間 [a, b] を考えるので，区間 [1, b] と区間 [1, a-1] に分けて，c あるいは d で割り切れるものの個数を考える
	ll count_1b = b / c + b / d - b / l;
	--a;
	ll count_1a = a / c + a / d - a / l;

	cout << ((b - a) - (count_1b - count_1a)) << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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 inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    int n, m, x;
    in3(n, m, x);
    int a[m];
    rep(i, m) in(a[i]);
    int tmp = lower_bound(a, a + m, x) - a;
    int ans = min(tmp, m - tmp);
    out(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int a,b;
    cin>>a>>b;
    cout<<(a+b+1)/2<<endl;
    return 0;
}

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

int cnt[2];

int main() {
    int n, p; cin >> n >> p;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]%2]++;
    }
    if (cnt[1] > 0) {
        cout << (long long) pow(2LL, n-1) << endl;
    } else {
        if (p == 0) cout << (long long) pow(2LL, n) << endl;
        else cout << 0 << endl;
    }
    return 0;
}

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

void solve(long long N)
{
    N %= 10;
    string ans;
    if (N == 3)
        ans = "bon";
    else if (N == 0 or N == 1 or N == 6 or N == 8)
        ans = "pon";
    else
        ans = "hon";
    cout << ans << endl;
}

signed main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3688
#include "bits/stdc++.h"
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;

    char vec[70][70];
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++){
            cin >> vec[i][j];
        }
    }

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++){
            int res = 0;
            if (vec[i][j] == '.') {
                for (int k = -1; k <= 1; k++){
                    for (int l = -1; l <= 1; l++) {
                        if (vec[i + k][j + l] == '#') {
                            res++;
                        }
                    }
                }
                vec[i][j] = '0' + res;
            }
        }
    }

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++){
            cout << vec[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Fri Mar 20 16:17:15 JST 2020
 **/

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

signed main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    REP(i, n - 1) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    vector<int> depth(n);
    vector<vector<int>> ds(n, vector<int>(2, -1e9));
    auto dfs1 = [&](auto f, Int v, Int prv) -> void {
        for (Int s : g[v]) {
            if (s == prv) continue;
            f(f, s, v);
            ds[v].push_back(depth[s] + 1);
        }
        sort(ds[v].rbegin(), ds[v].rend());
        while (ds[v].size() > 2) ds[v].pop_back();
        depth[v] = max(0, ds[v][0]);
    };
    dfs1(dfs1, 0, -1);

    vector<int> mas(n + 1, -1);
    auto dfs2 = [&](auto f, Int v, Int prv) -> void {
        vector<int> cans(3, -1e9);
        if (prv != -1) {
            int tmp = (ds[prv][0] == depth[v] + 1 ? ds[prv][1] : ds[prv][0]) + 1;
            if (prv == 0) {
                tmp = max(1, tmp);
            } else {
                assert(tmp > 0);
            }
            cans.push_back(tmp);
            ds[v].push_back(tmp);
            sort(ds[v].rbegin(), ds[v].rend());
            ds[v].pop_back();
        }
        for (Int s : g[v]) {
            if (s == prv) continue;
            cans.push_back(depth[s] + 1);
            f(f, s, v);
        }
        sort(cans.rbegin(), cans.rend());
        if (cans[0] >= 0) chmax(mas[cans[0]], cans[0] + cans[2]);
    };
    dfs2(dfs2, 0, -1);

    for (int i = n - 1; i >= 0; i--) {
        mas[i] = max(mas[i], mas[i + 1]);
    }
    REP(k, 1, n + 1) {
        if (k == 1 || k == 2) {
            cout << 1;
        } else {
            cout << (mas[k / 2 + 1] >= k ? 0 : 1);
        }
    }
    cout << endl;
}



Measured memory_bytes: 32560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){    
  ll K, A, B;
  cin >> K >> A >> B;
  if(A%K == 0 || B%K == 0) cout << "OK" << endl;
  else if(A/K == B/K) cout << "NG" << endl;
  else cout << "OK" << endl;
  
}


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

int main(){
    int H,W,K;
    cin >> H >> W >> K ;
    char C[H][W];
    rep(i,H){
        rep(j,W){
            cin >> C[i][j] ;
        }
    }
    int ans=0,c;
    int blackH,blackW;
    rep(blackH,1<<H){
        rep(blackW,1<<W){
            c=0;
            rep(i,H){
                rep(j,W){
                    if(((1<<i)&blackH) and ((1<<j)&blackW) and C[i][j]=='#')
                    c++;
                }
            }
            if(c==K) ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;
public class Main{
	
	public void solve(){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		System.out.println(x*x*x);
		
	}
	
	public static void main(String[]args){
		Main obj =new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17164
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const  int mod = 1000000007;
void add(ll& a, ll b)
{
    a+=b;
    while(a>=mod)
        a-=mod;
    while(a<0)
        a+=mod;
    
}

int main()
{
	ll n,k; cin>>n>>k;
	if(n>=k)
	{
		n = n%k;
	}
	if(!n)
	{
		cout<<0<<endl;
	}
	else
	{
		if(n>k/2)
			cout<<abs(k-n)<<endl;
		else
			cout<<n<<endl;
	}
	
  	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n, a, b := nextInt(), nextInt(), nextInt()
	if a > b {
		fmt.Println(0)
		return
	}
	if n-2 < 0 {
		if a == b {
			fmt.Println(1)
		} else {
			fmt.Println(0)
		}
		return
	}

	ans := int64(n-2)*(int64(b-a)) + 1
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<iostream>
#include<set>
#define FOR(i,a,b) for(int i=(a);i<(b);++i) 
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int col(int x){
  if(x%2 == 0) return x/2;
  else return 3*x + 1;
}

int main(){
  int s; cin>>s;
  set<int> se;

  int cnt = 1;
  while(se.find(s) == se.end()){
    se.insert(s);
    s = col(s);
    ++cnt;
  }

  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
string s[105], t[106];
signed main() {
	int n, m;
	cin >> n; rep(i, n)cin >> s[i];
	cin >> m; rep(i, m)cin >> t[i];
	int ans = 0;
	rep(i, n) {
		int cnt = 0;
		rep(j, n)if (s[i] == s[j])cnt++;
		rep(j, m)if (s[i] == t[j])cnt--;
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

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

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

using namespace std;

int main(){
	string s; cin>>s;
	if(s.length()<26){
		char c='a';
		rep(i,s.length()) if(s[i]==c) c++, i=-1;
		s+=c;
		cout<<s<<'\n';
	}
	else{
		string t=s;
		if(next_permutation(t.begin(),t.end())){
			while(t.substr(0,t.length()-1)>s) t=t.substr(0,t.length()-1);
			cout<<t<<'\n';
		}
		else{
			cout<<"-1\n";
		}
	}
	return 0;
}


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

int main(){
    int n,a=0,b=0,c=0,ans=0;
    cin >> n;
    string s,pin;
    cin >> s;
    /*
    rep(i,n-2){
        for(int j=i+1;j<n-1;j++){
            for(int l=j+1;l<n;l++){
               a=s[i]-48;
               b=s[j]-48;
               c=s[l]-48;
               v[100*a+10*c+b]++;
            //    cout << 100*a+10*b+c << endl;
            }
        }
    }
    ans = count(v.begin(),v.end(),0);
    cout << 1000-ans<<endl;
    */
    rep(i,1000){
        if(i<10) pin = "00" +to_string(i);
        else if(i<100) pin = "0"+to_string(i);
        else pin = to_string(i);
        // cout << pin[0] <<pin[1]<<pin[2]<< endl;
        int f=0;
        rep(j,n){
            if(s[j] == pin[f]) f++;
            if(f==3) break;
        }
        if(f==3) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3716
import numpy as np
import bisect

N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A = [0] + A
B = [0] + B

A = np.array(A, dtype=np.int64)
B = np.array(B, dtype=np.int64)

SA = np.cumsum(A)
SB = np.cumsum(B)

ans = 0
for i in range(N+1):
    if(SA[i] > K): break
    id = bisect.bisect_right(SB, K-SA[i])
    ans = max(ans, i + id-1)

print(ans)


Measured memory_bytes: 58464
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

#include <iomanip>

int main() {
	double a, b;
	cin >> a >> b;
	cout << std::setprecision(16) <<  a * b / 3.305785 << endl;
	return 0;
}

Measured memory_bytes: 1280
import sys
sys.setrecursionlimit(10000000)
G = None
ans = None

def dfs(v, parent_c=-1, parent_id=-1):
    global G, ans
    k = 1
    for i in range(len(G[v])):
        edge_id, to = G[v][i]['edge_id'], G[v][i]['to']
        if to == parent_id: continue
        if k == parent_c: k+=1
        ans[edge_id] = k
        k += 1
        dfs(to, parent_c=ans[edge_id], parent_id=v)

def main():
    global G, ans
    N = int(input())
    G = [[] for _ in range(N)]
    ans = [0 for _ in range(N-1)]
    for edge_id in range(N-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append({'to': b, 'edge_id': edge_id})
        G[b].append({'to': a, 'edge_id': edge_id})
    
    dfs(0)
    print(max(ans))
    for a in ans:
        print(a)

main()

Measured memory_bytes: 149020
#pragma GCC optimize("trapv")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;
const int maxn = 5005, mod = 998244353;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<ld> a(n);
	for(auto &i : a) cin >> i, i = (i+1)/2;
	ld r = 0, s = 0;
	for(int i = 0; i < n; i++) {
		s += a[i] - (i-k>=0?a[i-k]:0);
		r = max(r, s);
	}
	cout << fixed << setprecision(15) << r;
}


Measured memory_bytes: 3456
#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()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    int n, m; cin >> n >> m;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    vector<vector<int>> v(n);
    rep(i, m){
        int a, b; cin >> a >> b;
        a--; b--;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        bool f = true;
        for(int j = 0; j < v[i].size(); j++){
            if(h[i] <= h[v[i][j]]){
                f = false;
            }
        }
        if(f)ans++;
    }    
    cout << ans << endl;
    system("pause");
}

Measured memory_bytes: 9376
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int i, j, k;
    int n, t, m;
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && a != c) {
        puts("Yes");
    }
    else if(a == c && a != b) {
        puts("Yes");
    }
    else if(b == c && b != a) {
        puts("Yes");
    }
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	int n, k;
	ll ans = INF;
	int c[100000];

	cin >> n >> k;

	rep(i, 0, n) {
		cin >> c[i];
	}


	rep(i, 0, n - k + 1) {
		ll sub=min(abs(c[i]) + abs(c[i + k - 1] - c[i]), abs(c[i + k - 1]) + abs(c[i] - c[i + k - 1]));
		ans = min(sub, ans);
	}

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

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll n; cin >> n; vl coo(n+2); coo[0] = 0; coo[n+1] = 0; 
  vl dis(n); ll dissum = 0;
  
  rep(i,n) cin >> coo[i+1];
  
  rep(i,n){
    dis[i] = min(abs(coo[i+2] - coo[i+1]) + abs(coo[i+1] - coo[i]),
                 abs(coo[i+2] - coo[i]));
    }
  
  rep(i,n+1){
    dissum += abs(coo[i+1] - coo[i]);
  }
  
  rep(i,n) cout << dissum - (abs(coo[i+2] - coo[i+1])+
                             abs(coo[i+1] - coo[i])) + dis[i] 
    << endl;
  
  

  
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

int main()
{
    ll n,a,b;cin >>n>>a>>b;
    ll s=0,g=0;
    string k;cin >>k;
    rep(i,n){
        bool flg=true;
        if(s>=a+b)flg=false;
        if(k[i]=='b'){
            g++;
            if(g>b)flg=false;
        }
        if(k[i]=='c')flg=false;
        if(flg){
            s++;puts("Yes");
        }
        else puts("No");
    }
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define PP pair<P,int>
#define fi first
#define se second
#define INF (1LL<<50)
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
int d[201][201];
signed main(){
    for(int i=0;i<201;i++){
        for(int j=0;j<201;j++)d[i][j]=INF;
        d[i][i]=0;
    }
    int n,m,r;
    cin>>n>>m>>r;
    vi vec;
    for(int i=0;i<r;i++){
        int t;
        cin>>t;
        t--;
        vec.pb(t);
    }
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        if(d[a][b]>c)d[a][b]=d[b][a]=c;
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    sort(all(vec));
    int ans=INF;
    do{
        int cnt=0;
        for(int i=1;i<r;i++){
            cnt+=d[vec[i-1]][vec[i]];
        }
        ans=min(ans,cnt);
    }while(next_permutation(all(vec)));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int n;
ll a,b,c,d;

int main() {
	scanf("%d%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	ll l=c*(n-1),r=d*(n-1);
	ll diff=a-b;
	bool flag=false;
	for (int i=0;i<n-1;i++) {//printf("l:%lld r:%lld\n",l,r);
		if (l<=diff&&diff<=r) {
			flag=true;
			break;
		}
		l-=(c+d);
		r-=(c+d);
	}
	if (flag) printf("YES\n");
	else printf("NO\n");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int isPrime(int *);

int main()
{
  int n,i,count=0;
  int *x;

  scanf("%d",&n);
  x=(int *)malloc(n*sizeof(int));

  for(i=0; i<=n-1; i++)
    {
      scanf("%d",&x[i]);
    }

  for(i=0; i<=n-1; i++)
    {
      if(isPrime(&x[i])==1)
	{
	  count++;
	}
    }

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

  return 0;
}

int isPrime(int *x)
{
  int i=3;
  
  if(*x==2) return 1;
  if(*x<2 ||(int)*x%2==0) return 0;

  while(i<=pow(*x,0.5))
    {
      if((int)*x%i==0)
	{
	  return 0;
	}
      i=i+2;
    }

  return 1;
}



Measured memory_bytes: 2100
import math

S = int(input())
if S <= 10**9:
  print("{} {} {} {} {} {}".format(0,0,10**9,1,10**9-S,1))
else:
  print("{} {} {} {} {} {}".format(0,0,10**9,1,(10**9)*math.ceil(S/(10**9))-S,math.ceil(S/(10**9))))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define pii pair<int, int> 
#define pll pair<long , long>
#define all(a) a.begin(), a.end()
#define int long long
#define ll long long
#define mod 998244353
//#define int long long
#define loop(i,a,b) for(int i=a;i<b;i++)
#define bloop(i,a,b) for(int i=a;i>=b;i--)

int max(int a, int b) { return (a > b)? a : b; } 
using namespace std;

ll funct(int n)
{
    if(n<=1) return 0;
    else return (n*(n-1))/2;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int t=1,ca=1;
   //cin>>t;
   while(ca<=t)
   {
      ca+=1;
      int n,total=0;
      cin>>n;
      int a[n];
      vector<pair<int, int>> vect,add,sub;
      //map<int , int > umap,mp;
      set<int>s;
      ll umap[200005]={0};
      for(int i=0;i<n;i++) {cin>>a[i];umap[a[i]]++;s.insert(a[i]);}
      for(int i=0;i<n;i++)
      {
          //cout<<x.first<<" "<<x.second<<endl;
          //mp[x.first]=funct(x.second);
          //cout<<umap[a[i]]<<" ";
          add.push_back(make_pair(a[i],funct(umap[a[i]])));
          sub.push_back(make_pair(a[i],funct(umap[a[i]]-1)));
          //sub[x.first]=funct(x.second-1);
          
      }
      set<int>:: iterator itr;
      for(itr=s.begin();itr!=s.end();itr++)
      total+=funct(umap[*itr]);
      //cout<<endl;
      if(total==0 || s.size()==n)
      {
          for(int i=0;i<n;i++)
          cout<<0<<endl;
      }
      else 
      {
          //cout<<total<<endl;
          for(int i=0;i<n;i++)
          {
              cout<<total+sub[i].second-add[i].second<<endl;
          }
      }
   }
    return 0;
}

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

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

    int n;
    cin >> n;

    bool ans = true;
    vector<int> t(n), x(n), y(n);
    REP(i, n) {
        cin >> t[i] >> x[i] >> y[i];
        if (t[i] % 2 != (x[i] + y[i]) % 2)
            ans = false;
        if (t[i] < x[i] + y[i])
            ans = false;
    }

    if (ans) {
        REP(i, n - 1) {
            if (t[i + 1] - t[i] < abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]))
                ans = false;
        }
    }

    if (ans) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 1408
n = int(input())
d = [-1]*(n+1)
adjacent_list = [[] for _ in range(n+1)]
for _ in range(n):
    edge = list(map(int,input().split()))
    if len(edge) >= 3:
        adjacent_list[edge[0]].extend(edge[2:])

from collections import deque

que = deque()
que.append(1)
d[1] = 0
while len(que) != 0:
    v = que.popleft()
    for nv in adjacent_list[v]:
        if d[nv] == -1:
            d[nv] = d[v] + 1
        else:
            continue
        que.append(nv)

for i,dist in enumerate(d):
    if i == 0:
        continue
    print(i,dist)


Measured memory_bytes: 6040
#include "bits/stdc++.h"
using namespace std; 
vector<int> to[2505];
vector<int> rto[2505];
bool reachabeleFrom1[2505];
bool reachabeleToN[2505];
bool OK[2505];
const int INF = 1001001001;

void dfs(int v) {
	if (reachabeleFrom1[v]) {
		return;
	}
	reachabeleFrom1[v] = true;
	for (int u:to[v]) {
		dfs(u);
	}
}

void rdfs(int v) {
	if (reachabeleToN[v]) {
		return;
	}
	reachabeleToN[v] = true;
	for (int u : rto[v]) {
		rdfs(u);
	}
}



int main() {
	int N, M, P;
	cin >> N >> M >> P;
	vector<tuple<int, int, int>> edges;
	for (int i = 0;i<M;++i) {
		int A, B, C;
		cin >> A >> B >> C;
		--A;
		--B;
		C -= P;
		C = -C;  
		edges.emplace_back(A,B,C);
		to[A].push_back(B);
		rto[B].push_back(A);
	}
	dfs(0);
	rdfs(N - 1);
	for (int n = 0;n<N;++n) {
		OK[n] = reachabeleFrom1[n]&reachabeleToN[n];
	}
	//べるまんふぉーど
	{
		vector<int>d(N, INF);
		d[0] = 0;
		bool upd = true;
		int step = 0;
		while (upd) {
			upd = false;
			for (int i = 0;i<M;++i) {
				int a, b, c;
				tie(a, b, c) = edges[i];
				if (!OK[a]) {
					continue;
				}
				if (!OK[b]) {
					continue;
				}
				int newD = d[a] + c;
				if (newD < d[b]) {
					upd = true;
					d[b] = newD;
				}
			}
			step++;
			if (step > N) {
				cout << "-1"<<endl;
				return 0;
			}
		}
		int ans = -d[N - 1];
		ans = max(ans,0);
		cout << ans <<endl;
	}
	return 0;
} 

Measured memory_bytes: 4056
// SeeAlso: https://atcoder.jp/contests/abc144/tasks/abc145_c

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

double sum;
int n;
int x[8], y[8];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void length() {
    rep(i, n) {
        for(int j=i+1; j<n;j++) {
            sum += dist(i, j);
        }
    }
    return;
}

int rec(int s) {
    if(s>1) {
        return s * rec(s-1);
    }
    return s;
}

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

    rep(i, n) {
        cin >> x[i] >> y[i];
    }

    double ans = 0.0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) ans += dist(i, j) * 2 / n;
    }
    print(ans);
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = 0;
  for(int i = 0; i < 3; i++) {
    if(s.at(i) == '1') {
      n++;
    }
  }
  cout << n << endl;
}

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

count = 0
for i in range(0, n-1):
    if count == 0:
        a.append(b[i])
        a.append(b[i])
        count = count +1
    elif b[i] > b[i-1]:
        a.append(b[i])
    elif b[i] < b[i-1]:
        del a[i]
        a.append(b[i])
        a.append(b[i])
    elif b[i] == b[i-1]:
        a.append(b[i])
print(sum(a))

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int n,m,i,j,k,t,count=0;
    int food[40]={0};
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%d",&k);
    for(j=0;j<k;j++){
            scanf("%d",&t);
            food[t]++;
        }
    }
        for(i=0;i<=m;i++){
            if(food[i]==n)
                count++;
        }
        printf("%d\n",count);
        return 0;

}


Measured memory_bytes: 1728
N, *T = map(int, open(0).read().split())
d_t, d_x, d_y = 0, 0, 0
for t, x, y in zip(T[::3], T[1::3], T[2::3]):
    dist = abs(d_x - x) + abs(d_y - y)
    if t - d_t - dist < 0 or (t - d_t - dist) % 2:
        print("No")
        break
    d_t, d_x, d_y = t, x, y
else:
    print("Yes")


Measured memory_bytes: 26632
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;
const int mod=1e9+7;

int n,x[10],y[10];

double dist(int i, int j){
    double dx = x[i]-x[j];
    double dy = y[i]-y[j];
    return sqrt(dx*dx+dy*dy);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
     
    cin >> n;
    rep(i,0,n) cin >> x[i] >> y[i];
    double ans = 0.0;
    rep(i,0,n) rep(j,i,n){
        ans+=dist(i,j)*2/n;
    }

    cout << ans << endl;
 } 

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

const int MOD = 1000000007;

// vector<vector<int>> data(3, vector<int>(4));

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll ans = a * c;
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);

  printf("%lld", ans);
}


Measured memory_bytes: 3772
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <cassert>

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

int main()
{
	int n,h,w;
	scanf("%d",&n);
	scanf("%d",&h);
	scanf("%d",&w);
	printf("%d\n",(n-h+1)*(n-w+1));
	return 0;
}


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

int main(){
    int A,B,M;
    cin >> A >> B >> M;
    vector<int> fridge(A);
    vector<int> oven(B);
    vector<pair<int,int> > ticket(M);
    vector<int> price(M);
    rep(i,A){
        cin >> fridge[i];
    }
    rep(i,B){
        cin >> oven[i];
    }
    rep(i,M){
        cin >> ticket[i].first >> ticket[i].second >> price[i];
    }
    int ans = 10000000;
    rep(i,M){
        ans = min(ans, fridge[ticket[i].first - 1] + oven[ticket[i].second - 1] - price[i]);
    }
    sort(all(fridge));
    sort(all(oven));
    ans = min(ans, fridge[0] + oven[0]);
    cout << ans << endl;
}


Measured memory_bytes: 2176
def call(n):
    result = ''
    for i in range(1, n + 1):
        x = i
        if x % 3 == 0:
            result += ' ' + str(i)
        else:
            while True:
                if int(x % 10) == 3:
                    result += ' ' + str(i)
                    break
    
                if int(x / 10) > 0:
                    x = int(x / 10)
                else:
                    break
    print(result)

call(int(input()))


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

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

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = 0;
    for (int j = 0; j < M; j++){
      int x;
      cin >> x;
      dp[x]=-1;
    }

    // 初期条件
    dp[0] = 1;

    // ループ
    for (int i = 1; i <= N; ++i) {
      if(i==1){
        if(dp[1]==-1) dp[1]=0;
        else dp[1]=1;
        continue;
      }
      if(dp[i]==-1) continue;
      if(dp[i-1]==-1 && dp[i-2]==-1){
        dp[N]==0;
        break;
      }
      else if(dp[i-1]==-1 && dp[i-2]!=-1){
        dp[i]=dp[i-2];
      }
      else if(dp[i-1]!=-1 && dp[i-2]==-1){
        dp[i]=dp[i-1];
      }
      else{
      dp[i]=(dp[i - 1]+dp[i-2])%1000000007;
      }
    }

    // 答え
    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<string, string> P;
const ll MOD = 1000000007LL;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << max(A * 10 + B + C, max(B * 10 + A + C, C * 10 + A + B)) << endl;
}

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

int main() {
 int N ;
 cin >> N ;
 int ans = 0;
 vector<int> vec(N);
  for (int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  for (int i=0;i<N;i++){
   for (int j=i+1;j<N;j++){
   //  cout << vec.at(i)*vec.at(j) <<endl;
     ans += vec.at(i)*vec.at(j);
   }
  }
  cout << ans ;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int c[3][3];
    int a[3], b[3];
    int i, j, k;
    int ans=0;

    for(i=0; i<3; i++){
        for(j=0; j<3; j++){
            scanf("%d", &c[i][j]);
        }
    }

    for(i=-100; i<=100; i++){
        a[0] = i;
        ans=0;
        for(j=0; j<3; j++){
            b[j] = c[0][j] -a[0];
        }
        for(j=1; j<3; j++){
            a[j] = c[j][0] -b[0];
        }
        for(j=1; j<3; j++){
            for(k=1; k<3; k++){
                if(c[j][k]!= a[j]+b[k]){
                    ans =1;
                }
            }
        }
        if(ans==0){
            break;
        }
    }
    if(ans==0){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

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

char reverce(char chr) {
	char res;
	if(chr=='.') res='#';
	else res='.';
	return res;
}

int main() {
	int h,w;
	
	while(1) {
		cin >> h >> w;
		char c,ic='#';
		if (h==0 && w==0) break;
		for (int j=0;j<h;j++){
			ic = reverce(ic);
			c = ic;
			for (int i=0;i<w;i++){
				c = reverce(c); 
				cout << c;
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
splitBy _ [] = []
splitBy a x =
  let s = takeWhile (/= a) x
      x'= dropWhile (/= a) x
  in
    if x' == []
    then [s]
    else s:(splitBy a $ drop 1 x')

to_m s =
  let [h,m] = map read $ splitBy ':' s :: [Int]
  in
    h*60 + m

ans' _ (_:[]) = []
ans' t ([_,_,t1,s1]:x@[t2,s2,_,_]:xs) =
  let m1 = to_m t1
      m2 = to_m t2
      st = unwords $ [s1, (show (m2-m1))]
      nx = ans' t (x:xs)
  in
    if (m2 - m1) >= t 
    then st:nx
    else nx

ans [] = []
ans ([n,t]:x) =
  let n' = read n :: Int
      t' = read t :: Int
      d  = take n' x
      r  = drop n' x
  in
    (ans' t' d):(ans r)

pr x = do
  print $ length x
  mapM_ putStrLn x

main = do
  c <- getContents
  let i = map words $ lines c
      o = ans i
  mapM_ pr o



Measured memory_bytes: 4064
N, A, B = map(int, input().split())

if (B-A) % 2 == 0:
    ans = (B-A+2)//2-1
else:
    if min(A-1, N-B) == A-1:
        ans = B-1
        plus=A
        B -= A
        A = 1
    else:
        ans = N-A
        plus=N-B+1
        A += N-B+1
        B = N
    if A != B:
        ans = (B-A+2)//2-1+plus

print(ans)


Measured memory_bytes: 9140
list=[int(input()) for j in range(6)]

x=[list[0],list[1],list[2],list[3]]
y=sorted(x)
sum=0
for i in range(1,4):
    sum+=int(y[i])
    
if list[4]>list[5]:
    sum+=int(list[4])
else:
    sum+=int(list[5])
print(sum)


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

signed main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 3){
		if(s[i] == 'R') ans++;
	}
	if(ans >= 1){
		if(s[1] == 'S') {
			cout << 1 << endl;
		}
		else {
			cout << ans << endl;
		}
	}
	else {
		cout << ans << endl;
	}
}


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

const int LIM = 3e4 + 1;

vector<int> Solve(int n) {
	if(n == 3) {
		return {2, 5, 63};
	}
	vector<int> M3, M2;
	for(int i = 3; i < LIM; i += 3) {
		if(i % 2 != 0) {
			M3.push_back(i);
		}
	}
	for(int i = 2; i < LIM; i += 2) {
		M2.push_back(i);
	}
	/* cerr << M2.size() + M3.size() << endl;
	cerr << M2.size() << ", " << M3.size() << endl;
	int sum = accumulate(M2.begin(), M2.end(), 0);
	cerr << "D: " << sum << endl; */
	vector<int> ans;
	int of3 = min(n - ((n % 2) == 0 ? 2 : 3), (int)M3.size());
	ans.insert(ans.begin(), M3.begin(), M3.begin() + of3);
	n -= of3;
	int iter = 0;
	while(n > 1) {
		ans.push_back(M2[iter++]), n--;
	}
	int sum = accumulate(M2.begin(), M2.begin() + iter, 0);
	// cerr << sum % 3 << endl;
	while(iter < M2.size()) {
		if((sum + M2[iter]) % 3 == 0) {
			ans.push_back(M2[iter]), n--;
			break;
		} else {
			iter++;
		}
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	auto ans = Solve(n);
	sort(ans.begin(), ans.end());
	if(ans.size() > 3) {
		int g = ans[0];
		for(int i = 1; i < ans.size(); i++) {
			g = __gcd(g, ans[i]);
		}
		assert(g == 1);
		assert(ans.size() == n);
		ans.resize(unique(ans.begin(), ans.end()) - ans.begin());
		assert(ans.size() == n);
		int sum = accumulate(ans.begin(), ans.end(), 0);
		for(int x: ans) {
			assert(x >= 1 and x < LIM);
			assert((x % 2) == (sum % 2) || (x % 3) == (sum % 3));
		}
	}
	for(int x: ans) {
		cout << x << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 640