akhauriyash/Code-Regression huggingface dataset:
from collections import deque

h, w = map(int, input().split())
mapping = [0]*h
#入力の受け取り
for i in range(h):
    mapping[i] = input()

#壁の検出
wall = 0
yet = [[False]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        if mapping[i][j] == "#":
            yet[i][j] = True
            wall += 1

depth = [[0]*w for i in range(h)]

not_yet = deque([[0, 0]])
yet[0][0] = True

#本番   
while len(not_yet) > 0:
    key = not_yet.popleft()
    a, b = key[0], key[1]
        
    if a != 0 and not yet[a-1][b]:
        not_yet.append([a-1, b])
        yet[a-1][b] = True
        depth[a-1][b] = depth[a][b]+1
            
    if a != h-1 and not yet[a+1][b]:
        not_yet.append([a+1, b])
        yet[a+1][b] = True
        depth[a+1][b] = depth[a][b]+1
            
    if b != 0 and not yet[a][b-1]:
        not_yet.append([a, b-1])
        yet[a][b-1] = True
        depth[a][b-1] = depth[a][b]+1
            
    if b != w-1 and not yet[a][b+1]:
        not_yet.append([a, b+1])
        yet[a][b+1] = True
        depth[a][b+1] = depth[a][b]+1
if depth[h-1][w-1]:
  print(h*w-depth[h-1][w-1]-1-wall)
else:
  print(-1)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {
  string S;
  cin >> S;
  for( int i = 0; i < S.size(); i++ ){
    if( S.at(i) == '?' ) S.at(i) = 'D';
  }
  cout << S << endl;
}

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

int main(){
	int N, ans = 0; cin >> N;
	int a[N];
	for(int i=0; i<N; i++){
		char c; cin >> c;
		a[i] = c - '0';
	}
	for(int i=0; i<=9; i++){
		for(int j=0; j<=9; j++){
			for(int k=0; k<=9; k++){
				int now = 0, f = 0;
				while(1){
					if(now >= N){ f = 1; break;}
					if(a[now] == i) break;
					now++;
				}
				now++;
				while(1){
					if(now >= N){ f = 1; break;}
					if(a[now] == j) break;
					now++;
				}
				now++;
				while(1){
					if(now >= N){ f = 1; break;}
					if(a[now] == k) break;
					now++;
				}
				if(!f) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

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

    int ans[N];
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        ans[tmp-1] = i + 1;
    }

    for (int i = 0; i < N; i++) {
        if (i < N - 1) {
            cout << ans[i] << " ";
        } else{
            cout << ans[i] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
  public static void main(String args[]) {
	Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int M = sc.nextInt();
    
    if (N == M) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d) {
    cout << "Yes" << endl;
  }
  else if (abs(a - b) <= d && abs(b - c) <= d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

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

int main(){
    int n; cin >> n;
    set<string> s;
    rep(i, n){
        string ss; cin >> ss;
        s.insert(ss);
    }
    if(s.size()==3) out("Three");
    else out("Four");
}

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

int main() {
  int N,K;
  cin >> N >> K;
  double ans;
  for (int i = 1; i <= N; ++i){
    int wk = 1;
    int now = i;
    while (now < K) {
      now *= 2;
      wk *= 2;      
    }
    ans += (double)(1.0)/wk / N;     
  }
  printf("%.12f\n", ans);
  //cout << ans / N << endl;
  return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    int n,t;cin >> n >> t;
    int a[n];
    rep(i,n)cin >> a[i];
    int time = 0;
    int ans = 0;
    rep(i,n){
        ans += min(t,a[i] - time);
        time = a[i];
    }
    ans += t;
    cout << ans << endl;
    //cout << time << endl;
    return 0;
}

Measured memory_bytes: 1792
n = gets.to_i
x = gets.chomp.chars
pc = x.count("1")

ur = []
lr = []
ut = 1
lt = -1
rl = x[0].to_i
ru = x[0].to_i

n.times do |i|
  ut %= pc + 1
  ur.unshift(ut)
  ut <<= 1
  if i > 0
    t = x[i]
    ru <<= 1
    ru += t.to_i
    ru %= pc + 1
    if pc - 1 > 0
      rl <<= 1
      rl += t.to_i
      rl %= pc - 1
    end
  end

  if pc - 1 > 0
    lt %= pc - 1
    lr.unshift(lt)
    lt <<= 1
  end
end

n.times do |i|
  res = 1
  if x[i] == "0"
    t = (ur[i] + ru) % (pc + 1)
  elsif pc - 1 == 0
    puts "0"
    next
  else
    t = (lr[i] + rl) % (pc - 1)
  end
    
  while t > 0
    t %= ("%b" % [t]).count("1")
    res += 1
  end
  puts res
end


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

using namespace std;

int main() {
  cin.sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<list<int>> v(N);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      int a;
      cin >> a;
      v[i].push_back(a);
    }
  }
  int ans = 1e9;
  for (int i = M; i > 0; --i) {
    unordered_map<int, int> mp;
    for (int j = 0; j < N; ++j) {
      mp[v[j].front()]++;
    }
    int pre = 0, rem = 0;
    for (auto p : mp) {
      if (p.second > pre) {
        rem = p.first;
        pre = p.second;
      }
    }
    for (int j = 0; j < N; ++j) {
      v[j].remove_if([=](const int &x) { return x == rem; });
    }
    ans = min(ans, pre);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int count = 0, length, i;
  string S, T;
  
  cin >> S >> T;
  length = S.length();
  for(i=0; i<length; i++){
    if(S.at(i) != T.at(i))count++;
  }
  cout << count << endl;
  
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	int a,b;cin>>a>>b;
	cout<<a*b<<" "<<2*(a+b)<<endl;
	return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define pb push_back             
#define se second                
#define fi first  
#define be begin()
#define en end()
#define all(v) v.be, v.en
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }
template<typename... T> void po(T... args) { ((cout << args << " "), ...); cout<<""; }

 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
     int test=1;
     //cin>>test;
     for(int tt=1; tt<=test; tt++){
       ll n,k;
       cin>>n>>k;
       ll a[n],ans=0;
       for(ll i=0; i<n; i++){
           cin>>a[i];
           //ans+=a[i];
       }
       sort(a,a+n);
       for(ll i=0; i<k; i++){
           ans+=a[i];
       }
       pp(ans);

     //cout<<"Case #"<<tt<<": ";  
     }
 
    return 0;
}

Measured memory_bytes: 3660
/*
   Created by Rahul Goel.
*/
/*******************************************************************************/
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
/*******************************************************************************/
using namespace std;
using ll = long long;
using ld = long double;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
/*
.-.. . -. -.- .- / .. ... / .-.. --- ...- . -.-.--
 */
/* For PBDS */
/*Two new methods X.order_of_key() and X.find_by_order()*/
/*
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*******************************************************************************/
ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1LL; }
template<typename T, typename... Args>
T mod_prod(T a, Args... args) { return (a*mod_prod(args...))%mod; }
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/

/*
    Code begins after this.
*/


ll solve(){
    ll n;
    cin >> n;
        
    ll ans = 0;
    for(ll i=1; i<=n; i++){
        ll m = n/i;
        ans += i*m*(m+1)/2;
    }

    cout << ans << endl;

    return 0;
}


signed main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}

/*******************************************************************************/
// Remeber - In a custom comparator cmp(a, b) a==b must always return to false.



Measured memory_bytes: 3664
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(ll itr=mp.begin();itr!=mp.end();itr -++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll a, b, q;
    cin >> a >> b >> q;

    vector<ll> s(a), t(b);
    rep(i, a)cin >> s[i];
    rep(i, b)cin >> t[i];
    
    sort(ALL(s));
    sort(ALL(t));

    rep(i, q){
        ll x;
        cin >> x;

        ll r_s, r_t, l_s, l_t;
        r_s = r_t = l_s = l_t = -1; 

        //神社の距離
        auto p_s = lower_bound(ALL(s), x);
        if(p_s != s.end()){
            r_s = *p_s - x;

            if(p_s - s.begin() > 0){
                l_s = x - s[p_s - s.begin() - 1];
            }
            else if(x == *p_s)l_s = 0;
        }
        else {
            l_s = x - s.back();
        }

        //寺の距離
        auto p_t = lower_bound(ALL(t), x);
        if(p_t != t.end()){
            r_t = *p_t - x;

            if(p_t - t.begin() > 0){
                l_t = x - t[p_t - t.begin() - 1];
            }
            else if(x == *p_t)l_t = 0;
        }
        else {
            l_t = x - t.back();
        }

        ll ans = LINF;
        //神社，寺共に東の方へ
        if(r_s > -1 && r_t > -1)ans = max(r_s, r_t);
        //神社は東，寺は西
        if(r_s > -1 && l_t > -1)ans = min(ans, r_s + l_t + min(r_s, l_t));
        //神社は西，寺は東
        if(l_s > -1 && r_t > -1)ans = min(ans, l_s + r_t + min(l_s, r_t));
        //神社，寺共に西へ
        if(l_s > -1 && l_t > -1)ans = min(ans, max(l_s, l_t));

        cout << ans << endl;
    }
}

Measured memory_bytes: 4816
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>s;i--)
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
ll MOD = 998244353;

ll D[100001] = {};
ll d[100001] = {};
ll Pow(ll n, ll p) {
	if (p == 0)return 1;
	if (p == 1)return n;
	ll t = Pow(n, p / 2);
	if (p & 1) return (t * t % MOD) * n % MOD;
	else return t * t % MOD;
}
int main() {
	ll n; cin >> n;
	ll maxV = 0;
	rep(i, 0, n) {
		cin >> D[i];
		d[D[i]]++;
		maxV = max(D[i], maxV);
	}


	if (d[0] != 1 || D[0] != 0) {
		cout << 0 << endl;
		return 0;
	}

	ll ans = 1;
	repe(i, 2, maxV) {
		if (d[i] == 0) {
			cout << 0 << endl;
			return 0;
		}

		ans = (ans * Pow(d[i-1],d[i])) % MOD;
	}

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


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

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    ll a, b, c;
    cin >> a >> b >> c;
    cout << (c - a - b >= 0 && 4 * a * b < (c - a - b) * (c - a - b) ? "Yes"
                                                                     : "No")
         << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] strp = Console.ReadLine().Split(' ');
        int[] p = Array.ConvertAll(strp, int.Parse);
        int ans = 0;
        for(int i = 1; i < n - 1; i++)
        {
            if(p[i - 1] < p[i] && p[i] < p[i + 1] || p[i - 1] > p[i] && p[i] > p[i + 1])
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){

    string s;
    cin>>s;
    for(int i=0;i<s.size();i+=2){
        if(i+1>=s.size()||s[0]!='h'||s[1]!='i'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}



Measured memory_bytes: 3132
#include <iostream>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <ctype.h>

const int INF =100000000;

using namespace std;

int main(){

  while(1){

    int n;

    cin >> n;

    if(n == 0){
      break;
    }else{
    for(int i = 0;i < n;i++){

      int a,b,c;

      cin >> a >> b >> c;

      if(a == 100 || b == 100 || c == 100){
	cout << "A" << endl;
      }else if(a + b >= 180){
	cout << "A" << endl;
      }else if(a+b+c >= 240){
	cout << "A" << endl;
      }else if(a+b+c >= 210){
	cout << "B" << endl;
      }else if(a+b+c >= 150 && b >= 80){
	cout << "B" << endl;
      }else if(a+b+c >= 150 && a >= 80){
	cout << "B" << endl;
      }else{
	cout << "C" << endl;
      }
    }
    }
  }
}


Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
    return 0;
}

Measured memory_bytes: 3620
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;

    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans = min(a,k);
    k -= min(a,k);
    if(k)
    {
    	k -= min(b,k);
    	if(k)
    	{
    		ans -= min(c,k);
    		k = 0;
    	}
    }
    cout<<ans;
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int K, N;
	cin >> K >> N;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	int mx = 0;
	for (int i = 0; i < N - 1; i++) {
		mx = max(mx, A[i + 1] - A[i]);
	}

	mx = max(mx, K + A[0] - A[N - 1]);

	cout << K - mx << endl;
}

Measured memory_bytes: 1792
// Problem : B - Substring
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

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

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  lcm(x, y)   ((x) * (y) / __gcd(x, y))
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

string s,t; 

int check(string x){
    int cnt = 0,sz = t.size();
    rep(i,0,sz){
        cnt += (x[i]!=t[i]);
    }
    return cnt;
}

void solve(){
    cin >> s >> t;
    
    int sz = s.size()-t.size()+1,len = t.size();
    
    int ans = (int)t.size();
    rep(i,0,sz){
        string temp = s.substr(i,len);
        ans = min(ans , check(temp));
    }
    
    cout << ans;
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
int main() {
    while (true) {
        int n; cin >> n;
        if (n == 0) break;
        bool g[26][26] = {};
        bool used[26] = {};
        int d[26] = {}; // relative degree
        repeat (i,n) {
            string s; cin >> s;
            int x = s.front() - 'a';
            int y = s.back()  - 'a';
            used[x] = true;
            used[y] = true;
            g[x][y] = true;
            d[x] += 1;
            d[y] -= 1;
        }
        repeat (k,26) { // warshall floyd
            repeat (i,26) {
                repeat (j,26) {
                    if (g[i][k] and g[k][j]) g[i][j] = true;
                }
            }
        }
        bool ans = true;
        repeat (i,26) {
            if (d[i] != 0) ans = false; // eulerlian cycle
        }
        repeat (i,26) if (used[i]) {
            repeat (j,26) if (used[j]) {
                if (not g[i][j]) {
                    ans = false; // not connected
                }
            }
        }
        cout << (ans ? "OK" : "NG") << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
N = int(input())
A = [int(a) for a in input().split()]
c = N-1
A.sort()
num = A[0]^A[c]
pre_num = A[c]
B = [A[0],A[c],num]
while len(B) < N:
    box = num
    num = num^pre_num
    pre_num = box
    B.append(num)
B.sort()
if A == B:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14212
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int table[256];

void init_table(){
  int idx = 0;
  for(int i=0;i<=9;i++){
    table[ i + '0'] = idx;
    idx++;
  }
  for(int i='A';i<='Z';i++){
    table[i] = idx;
    idx++;
  }
  for(int i='a';i<='z';i++){
    table[i] = idx;
    idx++;
  }
}

int fast_pow(int x, int n){
  int res = 1;
  while(n > 0) {
    if (n & 1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}

int conv(int type,const string& num){
  int res = 0;
  for(int i=num.size()-1,j=0;i>=0;i--,j++){
    res += table[num[i]] * fast_pow(type,j);
  }
  return res;
}

int main(){
  init_table();

  int total_initial_subsets;
  while(~scanf("%d",&total_initial_subsets)){
    int freq[4];
    memset(freq,0,sizeof(freq));
      
    int nim = 0;
    for(int subset_idx=0;subset_idx < total_initial_subsets;subset_idx++){
      int type;
      string num;
      cin >> type >> num;

      int pile = conv(type,num);
      
      nim ^= pile;
    }
    printf("%s\n",nim == 0 ? "lose" : "win");
  }
}

Measured memory_bytes: 1224
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;

char s[205];
int ans;

bool check(int i)
{
    for(int j = 0; j<(1+i/2); j++)
        if(s[j] != s[j+1+i/2]) return false;
    return true;
}
void solve()
{
    for(int i = 1; i<strlen(s) - 1; i++)
        if((i+1)%2==0 && check(i) == true) ans = i + 1;
    printf("%d\n", ans);
}

int main()
{
    scanf("%s", s);
    solve();
    return 0;
}


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

using namespace std;

#define ll long long

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

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

    int ans = 0;
    while (a > 0) {
        ans++;
        a /= b;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <cmath>
#include <climits>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;

int n, t=0, ans=0;
const int MAX_N = 100000;
pair<int, int> robo[MAX_N];

int main(){
    cin >> n;
    //vector<robop> robo(n);
    int p1, p2;
    for(int i=0;i<n;i++){
        cin >> p1;
        cin >> p2;
        robo[i].first = p1 + p2;
        robo[i].second = p1 - p2; 
    }

    sort(robo, robo+n);
    //cout << "-" << endl;
    for(int i=0;i<n;i++){
        int start = robo[i].second;
        //cout << start << " " << t << " ";
        if(start < 0) start=0;
        //cout << start << " " << t <<endl;
        if(t <= start && start != 0){
            t=robo[i].first;
            ans++;
        }
        else if(start==0 && ans==0){
            t=robo[i].first;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define Int int64_t
 
using namespace std;
 
int main() {
	int N;
	cin >> N;
	vector<int> a(N), b(N);
	vector<pair<int, int>> bx(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }
	for (int i = 0; i < N; ++i) {
		cin >> b[i];
		bx[i] = { b[i], i };
	}

	sort(bx.begin(), bx.end());
	vector<int> c(N);
	set<pair<int, int>> st;
	st.emplace( 0, 0 );
	for (int i = 0; i < N; ++i) {
		c[i] = a[bx[i].second];
		st.emplace( -c[i], i );
	}

	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		auto itx = st.lower_bound({ -c[i], 0 });
		auto px = *itx;
		int vx = px.first, idx = px.second;
		st.erase(itx);

		if (-vx <= bx[i].first) { continue; }
		++cnt;

		auto ity = st.lower_bound({ -bx[i].first, 0 });
		auto py = *ity;
		int vy = py.first, idy = py.second;
		if (vy == 0) {
			cout << "No" << endl;
			return 0;
		}
		st.erase(ity);
		swap(c[idx], c[idy]);
		st.emplace( vx, idy );
	}
	cout << (cnt <= N - 2 ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
    
  int main(){

    
        lint H,W;
        cin>>H>>W;
        queue <tuple<lint,lint,lint>> que;
        char a[H][W];
        rep(i,H){
            rep(j,W){
                cin>>a[i][j];
                if(a[i][j]=='#')que.emplace(i,j,0);
            }
        }
        vector<lint> x{0,0,1,-1};
        vector<lint> y{1,-1,0,0};
        lint ans1=0;
        while(!que.empty()){
            lint xx,yy,ans;
            tie(yy,xx,ans)=que.front();
            ans1=max(ans1,ans);
            que.pop();
            rep(i,4){
                if((xx+x[i])<0||(xx+x[i])>(W-1)||(yy+y[i])<0||(yy+y[i])>(H-1)) continue;
                if(a[yy+y[i]][xx+x[i]]=='.'){que.emplace(yy+y[i],xx+x[i],ans+1);
                    a[yy+y[i]][xx+x[i]]='#';
                }
            }

        }
        cout<<ans1;
    }
     
  


Measured memory_bytes: 25396
#include <cassert>
#include <iostream>
#include <functional>
#include <iomanip>
#include <set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <deque>
#include <algorithm>
#include  <cstring>
#include <string>
#include <cmath> 
using namespace std;
typedef long long LL;
const int MAX = 210000;
const LL base = 1e9 + 7;


struct Node {
	int x, y, w;
};

double dp[301][301][301];
int za[301];
int zt[4];
void solve() {

	double result = 0;
	int n;

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> za[i];
		zt[za[i]]++;
	}

	dp[0][0][0] = 0;

	for (int k = 0; k <= zt[3]; ++k) {
		for (int j = 0; j <= zt[2] + zt[3]; ++j) {
			for (int i = 0; i <= n; ++i) {
				int cc = i + j + k;
				if (cc == 0) continue;
				if (cc > n) continue;
				double tt = 0;
				if (i > 0) {
					tt += double(i) / n * dp[i - 1][j][k];
				}
				if (j > 0) {
					tt += double(j) / n * dp[i+1][j - 1][k];
				}
				if (k > 0) {
					tt += double(k) / n * dp[i][j+1 ][k - 1];
				}
				dp[i][j][k] = (1 + tt) * n / cc;
			}
		}
	}
	result = dp[zt[1]][zt[2]][zt[3]];
	cout<<setprecision(12) << result << endl;

}

int main() {
	const int inId = 0;
	const int outId = 0;
	if (inId>0) {
		cerr << "redirect stdin to input " << inId << endl;
		string s = "input";
		s += to_string(inId);
		s += ".txt";
		auto r = freopen(s.c_str(), "r", stdin);	
		if (r == nullptr) {
			cerr<< "invalid input file "<< s;
		}
	}
	if (outId>0) {
		cerr << "redirect stdout to stdout " << outId << endl;
		string s = "stdout";
		s += to_string(outId);
		s += ".txt";
		auto r = freopen(s.c_str(), "w", stdout);
		if (r == nullptr) {
			cerr<< "invalid output file "<< s;
		}		
	}
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // close sync between cout and printf
	cout.precision(10);
	solve();
}
 

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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define space ' '
#ifdef ONLINE_JUDGE
#define enter '\n'
#else
#define enter std::endl
#endif
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << enter
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << enter
using std::make_pair;

template < typename T >
inline T read( )
{
 T x = 0;
 char ch = gc( );
 bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int N = 204001, mod = 1e9 + 7;
 char c[ 5 ];
 void Fakemain( )
 {
  cin >> c;
  int lst = -1, ans = 0;
  For( i, 0, 2 )
  {
   if( c[ i ] == 'S' )
   {
    if( lst != i - 1 )
     ans = std::max( ans, i - lst - 1 );
    lst = i;
   }
  }
  ans = std::max( 3 - lst - 1, ans ); 
  cout << ans;
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanString() (s string) {
	sc.Scan()
	return sc.Text()
}

func main() {
	inputs := scanString()
	if inputs[0] == inputs[1] && inputs[1] == inputs[2] {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  int n = s.size();
  vector<ll> v(26);
  REP(i, n) v[s[i]-'a']++;
  REP(i, 26){
    if(!v[i]){
      cout << (char)(i+'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

//マクロ
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999

/*
 * 
 */

//ABC079
int main() {
    string ABCD;
    cin >> ABCD;
    int ans;
    int n = ABCD.size() - 1;
    for (int bit = 0; bit < (1<<n); ++bit){
        int res = ABCD[0] - '0';
        REP(i, n){
            if (bit & (1<<i)){
                res += ABCD[i+1] - '0';
            }
            else{
                res -= ABCD[i+1] - '0';
            }
        }
        if (res == 7){
            ans = bit;
            break;
        }
    }
    
    cout << ABCD[0];
    REP(i,n){
        if (ans & (1<<i)){
            cout << "+";
        }
        else{
            cout << "-";
        }
        cout << ABCD[i+1];
    }cout << "=7" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const ll INF=1e9;
const double PI=acos(-1);
const int MAX=200010;


map<ll,int> prime_factor(ll n) {
    map<ll,int> res;
    repr(i,2,sqrt(n)+1) {
        while (n%i==0) {
            ++res[i];
            n/=i;
        }
    }
    if(n!=1) ++res[n];
    return res;
}

ll fac[MAX], finv[MAX], inv[MAX];

void cmbInit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}


ll cmb(int n, int k){
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

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

    ll n,m;
    cin >> n >> m;
    cmbInit();
    map<ll,int> pf=prime_factor(m); 
    ll ans=1; 
    repitr(itr,pf) ans=(ans*cmb(n-1+itr->second,n-1))%MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = 2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;

class Point
{
public:
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) {}

  Point operator+(Point p)
  {
    return Point(x + p.x, y + p.y);
  }
  Point operator-(Point p)
  {
    return Point(x - p.x, y - p.y);
  }
  Point operator*(double a)
  {
    return Point(a * x, a * y);
  }
  Point operator/(double a)
  {
    return Point(x / a, y / a);
  }

  double abs()
  {
    return sqrt(norm());
  }
  double norm()
  {
    return x * x + y * y;
  }

  bool operator<(const Point &p) const
  {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator==(const Point &p) const
  {
    return equals(x, p.x) && equals(y, p.y);
  }

  void print()
  {
    printf("%.10f %.10f\n", x, y);
  }
};

typedef Point Vector;

double dot(Vector a, Vector b)
{
  return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b)
{
  return a.x * b.y - a.y * b.x;
}

struct Segment
{
  Point p1, p2;
};

typedef Segment Line;

class Circle
{
public:
  Point c;
  double r;
  Circle(Point c = Point(), double r = 0) : c(c), r(r) {}
};

typedef vector<Point> Polygon;

Point projection(Line l, Point p)
{
  return l.p1 + (l.p2 - l.p1) * (dot(p - l.p1, l.p2 - l.p1) / (l.p2 - l.p1).norm());
}

Point reflection(Line l, Point p)
{
  Point x = projection(l, p);
  return p + (x - p) * 2;
}

int ccw(Point p0, Point p1, Point p2)
{
  Vector a = p1 - p0, b = p2 - p0;
  if (cross(a, b) > EPS)
  {
    return COUNTER_CLOCKWISE;
  }
  if (cross(a, b) < -EPS)
  {
    return CLOCKWISE;
  }
  if (dot(a, b) < -EPS)
  {
    return ONLINE_BACK;
  }
  if (a.norm() < b.norm())
  {
    return ONLINE_FRONT;
  }
  return ON_SEGMENT;
}

bool is_parallel(Line l1, Line l2)
{
  Vector a = l1.p2 - l1.p1, b = l2.p2 - l2.p1;
  return equals(cross(a, b), 0);
}

bool is_orthogonal(Line l1, Line l2)
{
  Vector a = l1.p2 - l1.p1, b = l2.p2 - l2.p1;
  return equals(dot(a, b), 0);
}

bool intersect(Segment s1, Segment s2)
{
  Point p0 = s1.p1, p1 = s1.p2, p2 = s2.p1, p3 = s2.p2;
  return (ccw(p0, p1, p2) * ccw(p0, p1, p3) <= 0) && (ccw(p2, p3, p0) * ccw(p2, p3, p1) <= 0);
}

int main()
{
  int q;
  cin >> q;
  vector<bool> ans;
  rep(i, q)
  {
    double x0, y0, x1, y1, x2, y2, x3, y3;
    cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    Segment s1 = {Point{x0, y0}, Point{x1, y1}}, s2 = {Point{x2, y2}, Point{x3, y3}};
    ans.push_back(intersect(s1, s2));
  }
  rep(i, q) cout << ans.at(i) << endl;
}


Measured memory_bytes: 3264
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
  int A,B,C; cin >> A >> B >> C;
  if ( A == B ) cout <<C << endl;
  if ( B == C ) cout <<A << endl;
  if ( C == A ) cout <<B << endl;  
  return 0;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    val c = LongArray(n + 1)
    c[0] = 0L
    for (i in 1 .. n) {
        c[i] = a[i-1] + c[i - 1]
    }

    var cum = 0L
    var opNum1 = 0L
    // case (1, -1, 1, -1)
    var shouldItBe = mapOf(
        1 to 1L,
        0 to -1L
    )
    (1..n).forEach {
        val expect = shouldItBe[it % 2]!!
        val actual = c[it] + cum
        val sameOp = expect * actual > 0
        if (!sameOp) {
            val diff = expect - actual
            opNum1 += Math.abs(diff)
            cum += diff
        }
    }

    var opNum2 = 0L
    cum = 0L
    shouldItBe = mapOf(
            1 to -1L,
            0 to 1L
    )
    (1..n).forEach {
        val expect = shouldItBe[it % 2]!!
        val actual = c[it] + cum
        val sameOp = expect * actual > 0
        if (!sameOp) {
            val diff = expect - actual
            opNum2 += Math.abs(diff)
            cum += diff
        }
    }

    println(Math.min(opNum1, opNum2))
}

Measured memory_bytes: 57988
import java.util.*;
import java.math.*;
public class Main
{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		BigInteger l=scan.nextBigInteger();
		BigInteger r=scan.nextBigInteger();
		BigInteger sum=l;
		int cnt=0;
		cnt++;
		while(sum.compareTo(r)!=1){
		    sum=sum.multiply(BigInteger.valueOf(2));
		    //System.out.println(sum);
		    cnt++;
		}
		System.out.println(cnt-1);
	}
}


Measured memory_bytes: 35908
import heapq
N, M = map(int, input().split())
A = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(A)

for i in range(M):
        tmp = int(heapq.heappop(A) / 2)
        heapq.heappush(A, tmp)

print(sum(A) * -1)

Measured memory_bytes: 72216
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
namespace mp = boost::multiprecision;
using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll r,g,b,n;
  ll ans=0;
  cin>>r>>g>>b>>n;
  for(ll i=0;i<=(n/r)+1;i++){
    for(ll j=0;j<=(n/g)+1;j++){
      if(n-i*r-j*g>=0&&(n-i*r-j*g)%b==0){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main()
{
	string n, t;
	int cnt;
	while (cin >> t)
	{
		if (t[0] == '-')
		{
			//cout << n << endl;
			break;
		}
		
		if (isdigit(t[0]))
		{
			cnt = atoi(t.c_str());
			
			for (int i = 0; i < cnt; i++)
			{
				int h;
				cin >> t;
				h = atoi(t.c_str());
				
				string sl = n.substr(0, h);
				string sr = n.substr(h);
				n = sr + sl;
			}
			
			cout << n << endl;
		}
		else
		{
			//if (!n.empty())
				
			n = t;
			continue;
		}
	}
	
	return 0;
	
}

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

ll sol (ll n) {
    ll x = 26 ;
    while(x<n) x*=26 ;
    return x/26 ;

}

int main() {

    ll n , i ;
    cin >> n ;
    string s  ;
    for (i = 'a' ; i<='z' ; i++) {
        s.pb(i) ;
    }
    string ans ;
    while(n) {
        ll l = n%26 ;
        l-- ;
        if (l==-1) l = 25 , n-- ;
        n/=26 ;
        ans.pb(s[l]) ;
    }
    reverse(ans.begin(),ans.end()) ;
    cout << ans << endl ;
    return 0 ;
}


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

dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp[l][r]: 左l個右r個取ったところからの前-後max
for i in range(n):
	dp[i][n-1-i] = a[i]
for x in range(n-2, -1, -1):
	for y in range(x+1):
		l, r = y, x-y
		dp[l][r] = max(-dp[l+1][r] + a[l], -dp[l][r+1] + a[-(r+1)])

print(dp[0][0])

Measured memory_bytes: 121692
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    double n; cin >> n;
    double r = (n+1)/1.08;
    double k = n / 1.08;
    double l = ceil(k);
    if(r > l) cout << l << endl;
    else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll a;
	cin>>a;
	ll ans = a+a*a+a*a*a;
	cout<<ans;


    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int n,a,b,c,l[8],f[8];
int dfs(int x)
{
    int i,aa=0,bb=0,cc=0,ans=0,d[4]={0};
    if(x==n)
	{
        for(i=0;i<n;i++)
		{
            if(f[i]==0)
			{
                aa+=l[i];
                d[0]++;
            }
            else if(f[i]==1)
			{
                bb+=l[i];
                d[1]++;
            }
            else if(f[i]==2)
			{
                cc+=l[i];
                d[2]++;
            }
        }
        ans+=abs(a-aa);
        ans+=abs(bb-b);
        ans+=abs(cc-c);
        for(i=0;i<3;i++)
		{
            if(d[i]==0)
                return 10000;
            else
                ans+=10*(d[i]-1);
        }
        return ans;
    }
    ans=10000;
    for(i=0;i<4;i++)
	{
        f[x]=i;
        ans=min(ans,dfs(x+1));
    }
    return ans;
}
int main()
{
	int i;
	scanf("%d %d %d %d",&n,&a,&b,&c);
    for(i=0;i<n;i++)
        scanf("%d",&l[i]);
    printf("%d",dfs(0));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n;
char s[310][310];
inline bool check () {
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if (s[i][j] != s[j][i]) return false;
	return true;
}
int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf ("%s", s[i] + 1);
	int ans = 0;
	for (int t = 1; t <= n; t++) {
		if (check ()) ans += n;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				s[i][j - 1] = s[i][j];
		for (int i = 1; i <= n; i++) s[i][n] = s[i][0];
	}
	printf ("%d\n", ans);
	return 0;
} 

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 20 20:51:22 2019

@author: Owner
"""

import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*M
Y = [0]*M
for m in range(M):
    P[m], Y[m] = map(int, input().split())
    
all(nstr.count(c) for c in '753')
"""


x = [0]*3
x[:] = map(int, input().split())

x.sort(reverse = False)
print(int(1/2 * x[0]*x[1]))


Measured memory_bytes: 25128