akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  while(cin >> n) {
    printf("3C%02d\n",n % 39 == 0 ? 39 : n%39 );
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

bool compare_brue(pair<int, int> a, pair<int, int> b) {
    if(a.first == b.first){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
bool compare_red(pair<int, int> a, pair<int, int> b) {
    if(a.second == b.second){
        return a.first < b.first;
    }else{
        return a.second > b.second;
    }
}
int main(){
    int N;
    cin >> N;
    int a, b, c, d;

    vector<pair<int, int>> red;
    vector<pair<int, int>> brue;
    for(int i = 0; i < N; i++){
        cin >> a >> b;
        red.push_back(make_pair(a, b));
    }
    for(int i = 0; i < N; i++){
        cin >> c >> d;
        brue.push_back(make_pair(c, d));
    }

    sort(brue.begin(), brue.end(), compare_brue);
    sort(red.begin(), red.end(), compare_red);
    //cout << "sorted\n";
    //for(int i = 0; i < N; i++)cout << brue[i].first << endl;
    //cout << red[0].second << endl;

    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < red.size(); j++){
            if(red[j].first < brue[i].first && red[j].second < brue[i].second){
                ans++;
                red.erase(red.begin() + j);
                break;
            }
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
program peaks
  implicit none
  integer :: n, m, h(100000) = 0, a, b, i, x = 0
  logical :: g(100000) = .true.
  read(*,*) n, m
  read(*,*) h(1:n)
  do i = 1, m
    read(*,*) a, b
    if (h(a) <= h(b)) g(a) = .false.
    if (h(b) <= h(a)) g(b) = .false.
  end do
  do i = 1, n
    if (g(i)) x = x+1
  end do
  write(*,'(i0)') x
end program peaks

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int f(int x, int y, int z, string s) {
  int idx = 0;

  for (; idx < s.size(); idx++) {
    if ((int)(s[idx] - '0') == x) break;
  }
  if (idx++ == s.size()) return 0;

  for (; idx < s.size(); idx++) {
    if ((int)(s[idx] - '0') == y) break;
  }
  if (idx++ == s.size()) return 0;

  for (; idx < s.size(); idx++) {
    if ((int)(s[idx] - '0') == z) break;
  }
  if (idx++ == s.size()) return 0;

  return 1;
}

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

  int ans = 0;
  rep(i, 10) rep(j, 10) rep(k, 10) ans += f(i, j, k, s);

  cout << ans << endl;
}


Measured memory_bytes: 384
using System;
using System.Linq;

namespace AtCoderTutorial
{
    public class AtCoder175
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] bars = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToArray();

            int total = 0;
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    if (bars[j] == bars[i])
                    {
                        continue;
                    }

                    for (int k = j + 1; k < N; k++)
                    {
                        if (bars[k] == bars[i] || bars[k] == bars[j])
                        {
                            continue;
                        }

                        if (bars[i] + bars[j] > bars[k] &&
                            bars[j] + bars[k] > bars[i] &&
                            bars[k] + bars[i] > bars[j])
                        {
                            total++;
                        }
                    }
                }
            }

            Console.WriteLine(total);
        }
    }
}

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

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

	vector<int> p(m);
	vector<string> s(m);
	for(int i=0; i<m; i++){
		cin >> p[i] >> s[i];
	}

	vector<int> memo(n+1);
	vector<int> memo_pnl(n+1);

	ac = 0;
	pnl = 0;
	for(int i=0; i<m; i++){
		if(memo[p[i]]==0){
			if(s[i]=="WA"){
				memo_pnl[p[i]] += 1;
			}else{
				memo[p[i]] = 1;
				ac += 1;
			}
		}
	}
	for(int i=1; i<=n; i++){
		if(memo[i]==1){
			pnl += memo_pnl[i];
		}
	}
	cout << ac << " " << pnl << endl;
	return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

//struct Monoid{
//	using T = _underlying_set_; //モノイドの台集合の型
//	T operator()(const T &a, const T &b) { return _a_op_b_; } //二項演算
//	static constexpr T identity() { return _identity_element_; } //単位元
//};


struct RMQ{
	using T = int; //モノイドの台集合の型
	T operator()(const T &a, const T &b) { return min(a,b); } //二項演算
	static constexpr T identity() { return INT_MAX; } //単位元
};

struct RSQ{
	using T = int; //モノイドの台集合の型
	T operator()(const T &a, const T &b) { return a + b; } //二項演算
	static constexpr T identity() { return 0; } //単位元
};

template<class Monoid>
class SegTree{ //SegTree<Monoid> seg(n);
	private:
		using T = typename Monoid::T; //台集合の型をエイリアス
		Monoid op; //演算の関数オブジェクト
		const int n; //列の長さ
		vector<T> t; //内部二分木

		void prop_to(int i) { //ノードiに伝搬
			t[i] = op(t[2 * i], t[2 * i + 1]);
		}

	public:
		SegTree(int n) : n(n), t(4 * n, op.identity()) {} //単位元で埋める初期化
		SegTree(const vector<T> &v) : n(v.size()), t(2 * n){ //配列を用いて初期化
			copy(begin(v), end(v), begin(t) + n);
			for(int i = n - 1; i > -0; i--) prop_to(i);
		}

		void set(int i, const T &x){
			t[i += n] = x; 
			while(i >>= 1) prop_to(i);
		}

		void add(int i, const T &x){
			set(i, get(i) + x);
		}

		T get(int i) { return t[i + n]; } //列のi番目を返す

		T query(int l, int r){ // 1-index
			T accl = op.identity(), accr = op.identity();
			for(l += n, r += n; l < r; l >>= 1, r >>= 1){
				if(l & 1) accl = op(accl, t[l++]);
				if(r & 1) accr = op(t[r-1], accr);
			}
			return op(accl, accr);
		}
};

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

	SegTree<RSQ> seg(n);
	rep(i,q){
		int com;
		cin >> com;
		if(com){
			int l, r;
			cin >> l >> r;
			cout << seg.query(l + 1,r + 2) << endl;
		}else{
			int p, x;
			cin >> p >> x;
			seg.add(p + 1,x);
		}
	}
}



Measured memory_bytes: 4380
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<": "<<a<<endl;
#else
#define tr(a)    
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int N,P;
	cin>>N>>P;
	int odd=0;
	int even=0;
	rep(i,0,N){
		int temp;
		cin>>temp;
		if(temp%2==0)even++;
		else odd++;
	}
	if(P==1 and odd==0){
		cout<<0;
		return;
	}
	else if(odd==0){
		cout<<(1LL<<even);
	}
	else{
		cout<<(1LL<<even)*(1LL<<(odd-1));
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#
# 179B
#
n = input()
n = int(n)
s = ''
for i in range(n):
    t = input()
    t = t.replace(' ','')
    t = list(t)
    if t[0]==t[1]:
        s = s+'1'
    else:
        s = s+'0'

if '111' in s:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9172
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class SimpleKnapsack {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long w = in.nextLong();

            long[] weights = new long[n];
            long[] values = new long[n];

            // i番目 | 選んだ個数 | 残 weight
            long[][][] dp = new long[n + 1][n + 1][3 * n + 1];
            for (int i = 0; i < n; i++) {
                weights[i] = Long.parseLong(in.next());
                ;
                values[i] = Long.parseLong(in.next());
                ;
            }

            for (int i = 0; i < n; i++) {
                long diff = weights[i] - weights[0];
                for (int j = 0; j < n; j++) {
                    for (int k = 0; k <= 3 * n; k++) {
                        if (k - diff < 0) {
                            dp[i + 1][j + 1][k] = dp[i][j + 1][k];
                        } else {
                            dp[i + 1][j + 1][k] = Math.max(dp[i][j + 1][k], dp[i][j][(int) (k - diff)] + values[i]);
                        }
                    }
                }
            }
            long result = 0;
            for (int i = 0; i <= n; i++) {
                long zan = w - i * weights[0];
                if (zan >= 0) {
                    result = Math.max(result, dp[n][i][(int) Math.min(3 * n, zan)]);
                }
            }

            out.println(result);

        }

    }
}



Measured memory_bytes: 67692
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  int n = in();
  int m = in();
  vector<pair<int,char>> order(m);
  foreach(i,order){
    i.first = in()-1;
    in(i.second);
  }

  string ans = "-1";

  rep(i,1000){
    string str = to_string(i);
    if(str.size()!=n)continue;
    bool flag = true;
    foreach(j,order){
      if(str[j.first]!=j.second){
        flag = false;
        break;
      }
    }
    if(flag){
      ans = str;
      break;
    }
  }
  cout << ans << endl;


  return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

ll gcd(ll a, ll b) {
    if (a < b) {
        return gcd(b, a);
    }
    ll c = a % b;
    while (c != 0) {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    cin >> n;
    vl a(n + 10);

    IPT(a, n)
    sum = 0;
    map<ll, ll> counts;

    NREP() {
        tmp = a[i];
        sum += tmp;
        if (counts.count(tmp) == 0) {
            counts[tmp] = 1;
        } else {
            counts[tmp]++;
        }
    }

    cin >> q;
    REP(i, 0, q) {
        cin >> b >> c;

        ll cnt = counts[b];
        ll dec = b * cnt;
        ll inc = c * cnt;
        sum -= dec;
        sum += inc;

        counts[b] = 0;

        if (counts.count(c) == 0) {
            counts[c] = cnt;
        } else {
            counts[c] += cnt;
        }
        MSG(sum)
    }
}


Measured memory_bytes: 10112
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;

void solve(){
  ll n,k;
  cin>>n>>k;
  cout<<min(n%k,k-n%k);
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
while true
        input = STDIN.gets.split(' ')
        h = input[0].to_i
        w = input[1].to_i

        break if (h == 0 && w == 0)

        h.times {|i|
                w.times {|j|
                        if (i == 0 || i == (h-1)) ||
                                (j == 0 || j == (w-1))
                        print "#"
                        else
                                print "."
                        end
                }
                print "\n"
        }
        print "\n"

end

Measured memory_bytes: 6100
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
Int n,m;
Int check(Int k){
  m=(n/k)-1;
  if(m<=0) return 0;
  return (n/m)==(n%m);  
}

signed main(){
  cin>>n;  

  set<Int> ms; 
  for(Int k=1;k*k<=n;k++){
    if(n%k!=0) continue;
    if(check(k)) ms.emplace(m);
    if(check(n/k)) ms.emplace(m);
  }
  
  Int ans=0;
  for(Int x:ms) ans+=x;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//bool cmp(pair<int, int>a, pair<int, int>b){if(a.first==b.first) return a.second > b.second;  else return a.first<b.first;   }
//bool valid(int i, int j){ return 0 <= i&&i < n && 0 <= j&&j < m; }
#define ll long long
#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define Scan(a) scanf ("%I64d", &a)
#define scan(a) scanf ("%d", &a)
#define fi first
#define se second
#define siz 10

const ll INF = (1ll<<62);
const ll mod = 1e9+7;
typedef pair<int,int> pii;
typedef pair<int,pii > pip;
typedef pair< pair<int ,int> , pair<int ,int > > ppp;
vector<tuple<int,int,int> >tup;

double dp[3005];

int main(){
    ios_base::sync_with_stdio(0);

//      freopen("katryoshka.in","r",stdin);
     //freopen("output.txt","w",stdout);
    //memset(dist, MEMSET_INF, sizeof dist);
   //memset(dp_memo, -1, sizeof dp_memo);

   dp[0]=1;
   int n; cin>>n;
   for(int i=1;i<=n;i++){
    double p; cin>>p;

    for(int j=i;j>=0;j--){
        if(j==0){
            dp[j]= (dp[j]*(1.0-p));
        }
        else
            dp[j]=(dp[j-1]*p)+(dp[j]*(1-p));


    }
   }

  double ans=0.0;
  for(int i=0;i<=n;i++){
    int t=n-i;
    if(i>t){
//     cout<<i<<' '<<t<<' '<<dp[i]<<endl;
      ans+=dp[i];
    }
  }

  cout<<fixed<<setprecision(12)<<ans;

     return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int mini = INT_MAX;
  vector<int> L(n+1,0), R(n+1,0);
  for(int i=n-1;i>=0;--i) {
    if( s[i] == 'E' ) ++L[i];
    else ++R[i];
  }
  for(int i=n-2;i>=0;--i) {
    L[i] += L[i+1];
    R[i] += R[i+1];
  }
  int l=0,r=0;
  rep(i,n) {
    // L -> E
    // R -> W
    mini = min(mini,r+L[i+1]);//E
    if( s[i] == 'E' ) ++l;
    else ++r;
  }
  cout << mini << endl;
  compute();
  return 0;
}


Measured memory_bytes: 3076
/*Ankon Ghosh
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
///#include <ext/pb_ds/detail/standard_policies.hpp>*/
///using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define inf 1e16
#define MAX 100005
#define mod 998244353
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) printf("Case %lld: ",i)
#define setpre(number) cout<<fixed<<setprecision(10)<<number<<endl
#define pf(a) printf("%lld ",a)
#define pff(a,b) printf("%lld %lld\n",a,b)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll i=x;i<=y;i++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p make_pair
#define ff first
#define ss second
#define p_b push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define output freopen("output.txt","w",stdout)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp1;
vector<pair<ll,ll> >vpp,vp1;
vector<ll>v,v1,v2,fin;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb,mb1;
ll a,b,c,n,d,e,f,ta,sum=0,cnt=0,m,l,req,sz,maxi,k;
priority_queue<ll>pq;
ll solve()
{
    ///cout<<"ankon"<<endl;
    while(!pq.empty())
    {
        ///cout<<pq.size()<<endl;
        if(pq.size()==1) return pq.top();
        else
        {
            ll x=pq.top();
            pq.pop();
            ll y=pq.top();
            pq.pop();
            ll rem=x%y;
           /// cout<<x<<" "<<y<<" "<<rem<<endl;
            if(rem==1) return 1;
            if(rem==0LL)
            {
                pq.push(y);
            }
            else
            {
                pq.push(y);
                pq.push(rem);
            }
        }
    }
}
int main()
{
    fast;
    cin>>n;
    FOR(i,n)
    {
        cin>>a;
        pq.push(a);
    }
    ll ans=solve();
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4280
fun main(args: Array<String>) {
    val (a,b) = readLine()!!.split(" ").map{ it.toLong() }

    fun gcd(a: Long, b: Long): Long {
        return if (a==1L || b== 1L) 1L
        else if (b == 0L) a
        else if (a < b) gcd(a, b % a)
        else gcd(b, a % b)
    }

    println(a*b/gcd(a,b))
}


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

int main() {
    int x;
    cin >> x;
    if(x>=400&&x<=599)cout << 8 <<endl;
    if(x>=600&&x<=799)cout << 7 <<endl;
    if(x>=800&&x<=999)cout << 6 <<endl;
    if(x>=1000&&x<=1199)cout << 5 <<endl;
    if(x>=1200&&x<=1399)cout << 4 <<endl;
    if(x>=1400&&x<=1599)cout << 3 <<endl;
    if(x>=1600&&x<=1799)cout << 2 <<endl;
    if(x>=1800&&x<=1999)cout << 1 <<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int A,B,C,cmp[3],ans;
  cin>>cmp[0]>>cmp[1]>>cmp[2];
  sort(cmp,cmp+3);
  A=cmp[0];B=cmp[1];C=cmp[2];
  ans+=(C-A)/2;
  A+=((C-A)/2)*2;
  ans+=(C-B)/2;
  B+=((C-B)/2)*2;
  map<int,int> mp;
  mp[A]++,mp[B]++,mp[C]++;
  if(A==B&&B==C){}
    else{
  if(A==B)ans++;
      else ans+=2;
    }
  cout<<ans<<endl;

}

Measured memory_bytes: 256
require 'pp'

n, m = gets.split.map(&:to_i)
s_m = []
c_m = []
m.times do |i|
    s, c = gets.split.map(&:to_i)
    s_m[i] = s
    c_m[i] = c
end 

range = if n == 1
    (0..9)
elsif n == 2
    (10..99)
else
    (100..999)
end

ans = range.find {|x|
    tmp = x
    digits = []
    while tmp > 0
        digits.push(tmp % 10)
        tmp = tmp / 10
    end
    if digits.empty?
        digits << 0
    end

    digits.reverse!
    #pp digits

    m.times.all? {|i|
        digits[s_m[i] - 1] == c_m[i]
    }
}

if ans
    puts ans
else
    puts -1
end


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

int cnt[10000005] ;

int main(){

	int n ;
	cin >> n ;
	
	for(int i = 1 ; i <= n ; i++){
		for(int j = i ; j <= n ; j += i)
			cnt[j]++ ;
	}

	LL ans = 0LL ;

	for(LL i = 1 ; i <= n; i++){
		ans += i * (LL)(cnt[i]) ;
	}
	cout << ans << endl ;

	return 0;
}

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

int main(){
    int N;

    cin>>N;

    int sum=0;

    vector<int> a(N);

    for(auto &x:a){
        cin>>x;
        sum+=x;
    }


    double ave = (double)(sum)/N;

    int ans=0;

    for(int i=1;i<N;++i){
        if(abs(a[i]-ave)<abs(a[ans]-ave)){
            ans=i;
            
        }
    }





cout<<ans<<endl;


}

Measured memory_bytes: 256
s = input()
k = int(input())

len_s =  len(s)
L = []
m = 0
for i in range(1, k+1):
    for j in range(len_s-i+1):
        if s[j:j+i] not in L:
            L.append(s[j:j+i])


L.sort()
print(L[k-1])


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

string num;

int main(void){
  while(cin >> num){
    for(int i = num.length(); i > 1; i--){
      for(int j = 0; j < i - 1; j++){
        int sum = (num[j] - '0') + (num[j+1] - '0');
        int sub = sum - 10;
        if(sub >= 0){
          num[j] = sub + '0';
        }else{
          num[j] = sum + '0';
        }
      }
    }
    cout << num[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 1172
import math
N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

  
table = factorization(N)

if N == 1:
  print(0)
else:
  ans = 0
  for a,b in table:
    cand = int(math.sqrt(2*b))
    cnt = 0
    for i in range(max(0,cand-10),cand+10):
      if 2*b >= i*(i+1):
        cnt=i
      else:
        break
    ans += cnt
  print(ans)

Measured memory_bytes: 63580
typedef long long ll;
/*
id: sadykhzadeh -> Azer_Sadykhzadeh
Programming Language: C++
*/
#define qq2(x,y) cout << (#x) << " = " << (x) << '\t' << (#y) << " = " << (y) << endl
#define qq(x) cout << (#x) << " = " << (x) << endl
#define elif else if
#define pb push_back
#define ins insert
#define pow2(x) ((x)*(x))
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define rus_lang setlocale(LC_ALL , "Russian")
#define F_READ ios_base::sync_with_stdio(false);cin.tie(0)
#define MOD 1000000007
#define COUT(x) return cout << x << endl, 0;
#define stop return 0
using namespace std;

#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#define endl "\n"

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

string s;

int main(){
    ll n;
    vector <ll> a;
    cin >> n;
    a.resize(n); ll cnt = 0;
    for(ll i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end());
    return cout << abs(a[n/2]-a[n/2-1]), 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k,s; cin >> n >> k >> s;
	int t=s+1;
	if(s==1e9)t-=2;
	for(int i=0;i<k;i++){
		cout << s << endl;
	}
	for(int i=k;i<n;i++){
		cout << t << endl;
	}
}

Measured memory_bytes: 1408
n, avg = map(int, input().split())
a = list(map(int, input().split()))
mxsm = sum(a) + 5

dp = [[0] * mxsm for _ in range(n + 5)]

dp[0][0] = 1
rs = 0
for x in a:
    dp2 = [[it for it in lin] for lin in dp]
    for i in range(1, n + 1):
        for j in range(x, mxsm + 1):
            if dp[i - 1][j - x]:
                dp2[i][j] += dp[i - 1][j - x]
    dp = dp2

for i in range(1, n + 1):
    if len(dp[i]) > avg * i:
        rs += dp[i][avg * i]

print(rs)



Measured memory_bytes: 5492
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(A > 0 && C > 0) {
        C -= B;
        if (C <= 0) break;
        A -= D;
    }
    if (A <= 0) {
        cout << "No" << endl;
    } else{
        cout << "Yes" << endl;
    }



    return 0;
}


Measured memory_bytes: 3640
(defun f (a b c)
  (cond ((char= a b c) 0)
        ((char= a b) 1)
        ((char= b c) 1)
        ((char= a c) 1)
        (t 2)))
(let* ((n (read))
       (a (read-line))
       (b (read-line))
       (c (read-line)))
  (princ (loop :for k :from 0 :upto (1- n) :sum (f (aref a k) (aref b k) (aref c k)))))


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

int bubbleSort(int A[],int N){
  int sw = 0;
  bool flag = 1;
  for (int i = 0;flag;i++){
    flag = 0;
    for(int j = N -1;j >= i+1 ; j--){
      if (A[j] < A[j-1]){
        swap(A[j],A[j-1]);
        flag = 1;
        sw++;
      }
    }
  }
  return sw;
}

int main(){
  int A[100],N,sw;
  cin >> N;
  for ( int i =0;i<N;i++) cin>>A[i];
  sw = bubbleSort(A,N);

  for (int i =0;i<N;i++){
    if(i) cout <<" ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}

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

int main() {
	vector<int> A(3);
	REP(i,3) cin >> A.at(i);
	sort(A.begin(), A.end());
	cout << A.at(2) - A.at(0) << endl;
}

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

int main(int argc, const char * argv[]) {
    int n;
    int cnt, cur, max, num;
    
    //初期化
    max = 0;
    num = 1;
    
    //入力
    cin >> n;
    

    for (int i = 1; i <= n; i++) {
        //初期化
        cur = i;
        cnt = 0;
        while (cur % 2 == 0) {
            cur /= 2;
            cnt++;
        }
        if (cnt > max) {
            max = cnt;
            num = i;
        }
    }
    
    //出力
    cout << num << endl;
    
    return 0;
}


Measured memory_bytes: 256
h, w = map(int,input().split())
a = []
flag = True
for i in range(h):
    aa = list(input().rstrip())
    a.append(aa)
for i in range(h):
    for j in range(w):
        if a[i][j]=='.': continue
        aa = ['','','','']
        if i!=0: aa[0] = a[i-1][j]
        if i+1!=h: aa[1] = a[i+1][j]
        if j!=0: aa[2] = a[i][j-1]
        if j+1!=w: aa[3] = a[i][j+1]
        if a[i][j] not  in aa:
            flag = False
            break
print('Yes' if flag else 'No')

Measured memory_bytes: 3064
n,m = map(int,input().split())
plist=[]
slist=[]
isAc_list = [False for _ in range(n+1)]
penalty_list = [0 for _ in range(n+1)]
for i in range(m):
  inputs = input().split()
  plist.append(int(inputs[0]))
  slist.append(inputs[1])

correct = 0
penalty = 0
for problem,result in zip(plist,slist):
  if isAc_list[problem]:
    continue
  elif result == 'AC':
    isAc_list[problem] = True
    correct+=1
    penalty+=penalty_list[problem]
  else:
    penalty_list[problem]+=1
print(correct,penalty)


Measured memory_bytes: 14980
def all_nine_check(num):
    for i in range(1, len(num)):
        if num[i] == '9':
            pass
        else:
            return False
    return True

n = input()
if all_nine_check(n):
    ans = int(n[0]) + 9 * (len(n) - 1)
else:
    ans = int(n[0]) - 1 + 9 * (len(n) - 1)
print(ans)

Measured memory_bytes: 3060
import math
import itertools
import statistics
#import numpy as np
#import collections
n = int(input())
d, x = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(int(input()))

total = 0
for i in range(n):
    total += d//a[i]
    if d%a[i]!=0:
        total += 1
        
total += x

print(total)

Measured memory_bytes: 5148
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int32_t main()
{
   IOS

    int TESTS=1;
   // cin >> TESTS;
    while (TESTS--)
    {
        ll n,m;
        cin >> n >> m;
        vi v(m);
        rep(i,0,m)
        {
            cin>> v[i];
        }
        rep(i,0,m)
        {
           n=n- v[i];
        }
        if(n>=0)
        {
          cout<< n << endl;
        }
        else
        {
            cout<< "-1"<< endl;
        }





    }
    return 0;
}


Measured memory_bytes: 3672
import sys
sys.setrecursionlimit(500000)

n, q = map(int, input().split())
ab = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
add = [0]*n
for _ in range(q):
    pp, xx = map(int, input().split())
    add[pp-1] += xx


def dfs(v, p, value):
    value += add[v]
    ans[v] = value
    for c in ab[v]:
        if c == p:
            continue
        dfs(c, v, value)


ans = [0]*n
dfs(0, -1, 0)
print(*ans)


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


int main(int argc, const char * argv[]) {
    int w, h, x, y, r;
    
    cin >> w >> h >> x >> y >> r;
    
    if(x + r > w || x - r < 0 || y + r > h || y - r < 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <list>
#include <stack>
#include <climits>
#include <unordered_set>
#define m7 1000000007
#define m9 1000000009
#define ll long long
#define pii pair<int,int>
#define F first
#define S second

using namespace std;
int main()
{
	int n,w;
	cin >> n>>w;
	map<int, ll> M;
	vector<int> wt(n+1),vl(n+1);
	M[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> wt[i] >> vl[i];
	}
	for (int i = 1; i <= n; i++) {
		map<int, ll> T = M;
		for (auto it : M) {
			if (it.first + wt[i] > w)
				continue;
			if (T.find(it.first + wt[i]) == T.end()) {
				T[it.first + wt[i]] = it.second + vl[i];
			}
			else {
				int y = it.first + wt[i];
				T[y] = max(T[y], it.second + vl[i]);
			}
		}
		M = T;
	}
	ll maxi = 0;
	for (auto it : M) {
		if (it.second > maxi) maxi = it.second;
	}
	cout << maxi;
	return 0;
}

Measured memory_bytes: 12800
#nの約数列挙
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass #sortされていない


def main():
    N, M = map(int, input().split())
    ass = divisor(M)
    ass.sort()
    ans = 1
    for a in ass:
        if a <= (M // N):
            ass = a
        else:
            print(ass)
            exit()
    print(ass)

if __name__ == "__main__":
    main()

Measured memory_bytes: 63988
#include<stdio.h>
int main(){
  char a;
  while(1){
    scanf("%c",&a);
    if(a=='\n') break;
    if('a'<=a && a<='z'){
      a-=32;
    }else if('A'<=a&&a<='Z'){
      a+=32;
    }
    printf("%c",a);
  }
  
  printf("\n");

  return 0;
}



Measured memory_bytes: 2108
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
  int A[3];
  cin >> A[0] >> A[1] >> A[2];
  sort(A,A+3);

  int d1 = A[2]-A[1], d2 = A[2]-A[0];
  if (d1%2 == 0 && d2%2 == 0) {
    cout << d1/2 + d2/2 << endl;
  } else if (d1%2 == 1 && d2%2 == 1) {
    cout << (d1-1)/2 + (d2-1)/2 + 1 << endl;
  } else {
    if (d1%2 == 0) {
      cout << d1/2 + (d2+1)/2 + 1 << endl;
    } else {
      cout << (d1+1)/2 + d2/2 + 1 << endl;
    }
  }
}


Measured memory_bytes: 888
#include <stdio.h>
#define Max 100000
#define Min 50000

int BinarySearch(int );

int n,S[Max],T[Min];

int main()
{
  int i,q,a,sum=0;

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(i=0;i<q;i++)
    {
      scanf("%d",&T[i]);
    }

  for(i=0;i<q;i++)
    {
      a = BinarySearch(T[i]);

      if(a == T[i]) sum++;
    }

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

  return 0;
}

int BinarySearch(int key)
{
  int left = 0;
  int right = n;
  int mid;
  while (left < right)
    {
      mid = (left + right) / 2;
      if (S[mid] == key) return S[mid];
      else if (key < S[mid])  right = mid;
      else left = mid + 1;  
    }
  return -1;
}

Measured memory_bytes: 1180
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int in;
	string a, b;
	vector<char> output;

	cin >> in >> a >> b;

	for (int i = 0; i < a.length(); i++)
	{
		output.push_back(a[i]);
		output.push_back(b[i]);
	}

	for (char x: output)
		cout << x;
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).bigin(), (a).end())
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

ll cal2(ll x) { return (x + 1) / 2 % 2; }

ll cal(ll x) {
  if (x % 2 == 1)
    return cal2(x);
  else
    return cal2(x + 1) ^ (x + 1);
}

int main() {
  ll a, b;
  cin >> a >> b;
  cout << (cal(a - 1) ^ cal(b)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
    ll a,b,c,d; cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d});
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3604
from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def bfs(field, d, sx, sy, gx, gy):
    queue = deque([(sx, sy)])
    d[sx][sy] += 1
    
    while queue:
        x, y = queue.popleft()
        if (x, y) == (gx, gy):
            return d[x][y]

        dx = [1, 0, -1, 0]
        dy = [0, 1, 0, -1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            
            # field内かつ障害物じゃないかつ未訪問なら追加
            if (0 <= nx <= gx and 0 <= ny <= gy
                and field[nx][ny] != "#" 
                and d[nx][ny] == -1):
                d[nx][ny] = d[x][y] + 1
                queue.append((nx, ny))

def main():
    H,W = map(int, readline().split())
    s = [readline() for i in range(H)]

    #スタートからの距離(-1は未訪問)
    d = [[-1]*W for i in range(H)]

    min_path = bfs(s, d, 0, 0, H-1, W-1)
    if min_path is not None:
        min_path += 1
    else:
        print(-1)
        exit()

    black = 0
    for line in s:
        black += line.count("#")

    ans = H * W - min_path - black
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  
  ll a, p;
  I(a);
  I(p);
  P((a * 3 + p) / 2);

}


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

a, p = [1], [1]
for i in range(N):
        a.append(a[i] * 2 + 3)
        p.append(p[i] * 2 + 1)

def f(N, X):
        if N == 0:
                return 0 if X <= 0 else 1
        elif X <= 1 + a[N-1]:
                return f(N-1, X-1)
        else:
                return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
ll N, M;

vector<pair<ll,ll>> get_primes(ll n)
{
    vector<pair<ll,ll>> primes;
    for (int i = 2; i * i <= n; ++i) {
        if (n % i) {
            continue;
        }
        int num = 0;
        while (n % i == 0) {
            ++num;
            n /= i;
        }
        primes.push_back(make_pair(i, num));
    }
    if (n > 1) {
        primes.push_back(make_pair(n, 1));
    }
    return primes;
}

// Combination
const ll COMB_MAX = 1e6;
ll fac[COMB_MAX], finv[COMB_MAX], inv[COMB_MAX];
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < COMB_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(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    COMinit();
    cin >> N >> M;
    auto vec = get_primes(M);

    ll res = 1;
    for (auto pa : vec) {
        ll num = pa.second;
        ll tmp = COM(num + N - 1, N - 1);
        res = (res * tmp) % MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 23808
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e16;
typedef long long ll;

int main(){
  int N; cin >> N;
  string ans = "No";

  for (int i = 1; i < 10; i++){
    if (N % i == 0){
      if (N / i <= 9){
        ans = "Yes";
      }
    }
  }

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


Measured memory_bytes: 256