akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i,y;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>y;
  ll a = -1;
  ll b = -1;
  ll c = -1;
  rep(i,n+1)rep(j,n-i+1)rep(k,n-i-j+1){
    if(10000*i+5000*j+1000*k==y and i+j+k==n) {
      a=i;b=j;c=k;
      break;
    }
  }
  cout<<a<<" "<<b<<" "<<c<<endl;

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO                       \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define mem(a, x) memset(a, x, sizeof(a))
#define per(x, a, b) for (int x = a; x <= b; x++)
#define rep(x, a, b) for (int x = a; x >= b; x--)

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
const double eps = 1e-8;

int main() {
#ifdef LOCAL_IM0QIANQIAN
    freopen("test.in", "r", stdin);
//    freopen("test.out", "w", stdout);
#else
    IO;
#endif // LOCAL_IM0QIANQIAN

    string s;
    while (cin >> s) {
        stack<char> sk;
        int len = s.length();
        int ans = 0;
        for (int i = 0; i < len; i++) {
            if (!sk.empty()) {
                int top = sk.top();
                if (s[i] != top) {
                    ans += 2;
                    sk.pop();
                } else {
                    sk.push(s[i]);
                }
            } else {
                sk.push(s[i]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 512
n = int(input())
d = [0]*13
for i in map(int,input().split()):
  if i == 0:
    print(0)
    exit()
  d[i] += 1
t = [0]*25
t[0] = t[-1] = 1
c = 0
for i,j in enumerate(d):
  if j >=3:
    print(0)
    exit()
  elif j == 0:
    continue
  elif j == 2:
    t[i] = t[24-i] = 1
  else:
    if c == 0:
      t[i] = 1
    else:
      t[24-i] = 1
    c = 1-c
m = 24
ans = 24
for i in t:
  m += 1
  if i:
    ans = min(ans,m)
    m = 0
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;
const int d[12] = {1, 6, 6*6, 6*6*6, 6*6*6*6, 6*6*6*6*6, 6*6*6*6*6*6, 9, 9*9, 9\
*9*9, 9*9*9*9, 9*9*9*9*9};

int main()
{
  int N;
  int dp[110000];
  int res=0;
  cin >> N;

  rep(i,N) dp[i] = INF;
  dp[0]=0;

  FOR(i,1,N){
    int mincnt = INF;
    rep(j,12){
      int idx = i-d[j];
      if(idx>=0) {
        mincnt = min(dp[idx]+1, mincnt);
      }
      dp[i] = mincnt;
    }
  }

  cout << dp[N] << endl;
}

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


int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  ll num=0;
  rep(i,n) {
    cin >> a[i];
    num^=a[i];
  }
  rep(i,n) {
    b[i]=a[i]^num;
  }
  rep(i,n) cout << b[i] << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 6360
#include <stdio.h>

int main(void) {
  int i, j, k, a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if((a && b && !c) || (!a && !b && c)) printf("Open\n");
  else printf("Close\n");
  return 0;
}


Measured memory_bytes: 2596
import numpy as np
X, N = map(int, input().split())
p_list = set([int(i) for i in input().split()])
set_all = set(np.arange(-201, 201))
ex_list = set_all-p_list
ex_list = list(ex_list)
diff_list = [np.abs(i-X) for i in ex_list]
min_index = np.argmin(diff_list)
print(ex_list[min_index])

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

long long n;
vector<long long> a, id;
vector<vector<long long>> dp;

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) id.push_back(i);
  sort(id.begin(), id.end(), [&](int l, int r) {
    if (a[l] != a[r]) return a[l] > a[r];
    return l < r;
  });
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  dp.assign(n + 1, vector<long long>(n + 1, -1));
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= i + 1; ++j)
      if (dp[i][j] >= 0) {
        long long now = dp[i][j];
        // left
        if (j != i + 1)
          dp[i + 1][j + 1] =
              max(dp[i + 1][j + 1], now + a[id[i]] * abs(id[i] - j));
        // right
        dp[i + 1][j] =
            max(dp[i + 1][j], now + a[id[i]] * abs(n - 1 - (i - j) - id[i]));
      }
  }
  for (int i = 0; i <= n; ++i) res = max(res, dp[n][i]);
  return res;
}

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

using namespace std;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


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

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    string T; cin >> T;
    REP(i, SZ(T)) {
        if (T[i] == '?') T[i] = 'D';
    }

    cout << T << endl;

    return 0;
}


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

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static class Node {
        private List<Node> children;
        private int parent;
        private int longestPath;

        public Node() {
            this.parent = -1;
            this.children = new ArrayList<>();
            this.longestPath = -1;
        }

        public void addChild(Node child) {
            this.children.add(child);
        }

        private int longestPath() {
            if (this.longestPath != -1) {
                return this.longestPath;
            }
            int ret = 0;
            for (Node child : this.children) {
                ret = Math.max(ret, child.longestPath() + 1);
            }
            this.longestPath = ret;
            return ret;
        }
    }

    private static void solve() {
        int n = in.nextInt();
        int m = in.nextInt();
        Node[] nodes = new Node[n];
        for (int i = 0; i < n; i++) {
            nodes[i] = new Node();
        }

        for (int i = 0; i < m; i++) {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;

            nodes[x].addChild(nodes[y]);
        }

        int ans = 0;
        for (Node node : nodes) {
            ans = Math.max(node.longestPath(), ans);
        }
        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 54116
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    ll n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    if(n%2 == 0){
        map<int,int> mii;
        set<int> si;
        for(auto u :v){
            mii[u]++;
            si.insert(u);
        }
        if(si.size() != n/2){
            cout << 0 << endl;
            return 0;
        }
        for(auto u : mii){
            if(u.first%2 == 0 || u.second !=2){
                cout << 0 << endl;
                return 0;
            }
        }
        //cout << (1 << (n/2))%MOD << endl;
        ll ans = 1;
        rep(i,n/2){
            ans *= 2;
            ans %= MOD;
        }
        cout << ans << endl;
    }else{
        map<int,int> mii;
        set<int> si;
        for(auto u :v){
            mii[u]++;
            si.insert(u);
        }
        if(si.size() != (n+1)/2){
            cout << 0 << endl;
            return 0;
        }
        if(mii[0] != 1){
            cout << 0 << endl;
            return 0;
        }
        for(auto u : mii){
            if(u.first != 0){
                if(u.first%2 != 0 || u.second != 2){
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
        //cout << (1 << ((n-1)/2))%MOD << endl;
        ll ans = 1;
        rep(i,(n-1)/2){
            ans *= 2;
            ans %= MOD;
        }
        cout << ans << endl;
    }
    return 0;
}

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

const int MAXN = 101;

int cn[26];

string s[MAXN];
string ans[MAXN];;

void y() {
    cout << "Yes\n";
    exit(0);
}


int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= m; j++)
            if (i * (m - j) + (n - i) * j == k) y();

    cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>bool chmax(T &a, const T &b) { if (a<=b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<=a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int h,w;
    cin>>h>>w;
    auto vec=make_vec<int>(h,w);
    rep(i,h) rep(j,w) cin>>vec[i][j];
    rep(i,h) rep(j,w) {
        int b;
        cin>>b;
        vec[i][j]-=b;
    }
    
    const int d=6400;
    auto dp=make_vec<bool>(85,85,13001);
    dp[0][0][vec[0][0]+d]=true;
    dp[0][0][-vec[0][0]+d]=true;
    
    rep(i,h) rep(j,w) rep(k,12900) {
        if(dp[i][j][k]) {
            if(i+1<h) {
                dp[i+1][j][max(0,min(13000,k+vec[i+1][j]))]=true;
                dp[i+1][j][max(0,min(13000,k-vec[i+1][j]))]=true;
            }
            if(j+1<w) {
                dp[i][j+1][max(0,min(13000,k+vec[i][j+1]))]=true;
                dp[i][j+1][max(0,min(13000,k-vec[i][j+1]))]=true;
            }
        }
    }

    FOR(k,0+d,6400+d) {
        if(dp[h-1][w-1][k]) {
            cout<<k-d<<endl;
            return 0;
        }
    }
    
}


Measured memory_bytes: 12288
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n, c, k, arr[100005], range, capa=0, bus=0;
    cin >> n >> c >> k;
    for(int i=1; i<=n; i++){
        cin >> arr[i];
    }
    sort(arr+1, arr+n+1);
    range=arr[1]+k;
    capa++;
    bus++;
    for(int i=2; i<=n; i++){
        if(arr[i]<=range && capa<c) {
            capa++;
        }
        else{
            range=arr[i]+k;
            capa=1;
            bus++;
        }
    }
    cout << bus << endl;
    return 0;
}

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

using namespace std;

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

    vector<string> s(n);
    for (auto&e:s) cin >>e;
    sort(s.begin(),s.end());

    for (int i=0;i<n;i++) cout <<s[i];
    cout <<endl;

    return 0;
}


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

string st;

int main()
{
    cin>>st;
    for(int i = 0 ; i < st.size()-2 ; i++ )
        if( st[i] == st[i+2] )
        {
            printf("%d %d\n", i+1, i+3);
            return 0;
        }
    for(int i = 0 ; i < st.size()-1 ; i++ )
        if(st[i] == st[i+1] )
        {
            printf("%d %d\n", i+1, i+2);
            return 0;
        }
    printf("-1 -1\n");
    return 0;
}


Measured memory_bytes: 512
s=input()
n=len(s)
for i in range(1,n//2):
  if s[0:n//2-i]==s[n//2-i:n-2*i]:
    print(n-2*i)
    break
  #print(s[0:n//2-i],s[n//2-i:n-2*i])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
static const long long INF = 1000000;
using p = pair<int,int>;
struct trio{
    int first;
    int second;
    int third;
};
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> vec(n+1);
    vector<int> ans(n+1,0);
    ans[0] = 1;
    vec[0] = 0;
    rep(i,n){
        int h;
        cin >> h;
        vec[i+1] = h;
    }
    rep(i,m){
        int h1,h2;
        cin >> h1 >> h2;
        if (vec[h1] == vec[h2]){
            ans[h1] = 1;
            ans[h2] = 1;
        }
        else if(vec[h1] > vec[h2]){
            ans [h2] = 1;
        }
        else {
            ans [h1] = 1;
        }
    }
    int a = 0;
    rep(i,n+1){
        if (ans[i] == 0){
            a++;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 4020
#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>;
const int INF = 1000000001;

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

int main() {
  string s;
  cin >> s;
  vector<int> a(s.size() + 1, 0);

  for(int i = 0; i < s.size(); ++i){
    if(s[i] == '<'){
      a[i+1] = a[i] + 1;
    }
  }
  for(int i = s.size()-1; i >= 0; --i){
    if(s[i] == '>' && a[i+1] >= a[i]){
      a[i] = a[i+1] + 1;
    }
  }

  ll ans = 0;
  rep(i, s.size()+1){
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2820
import java.util.Scanner

object Main extends App  {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val m = sc.nextInt

  val xs = List.fill(n)((sc.nextLong, sc.nextLong))
  val cs = List.fill(m)((sc.nextLong, sc.nextLong))

  val resl = xs.map(xP => cs.map(distance(xP, _)).zipWithIndex.min._2 + 1)

  resl.foreach(println)

  def distance(aPair: (Long,Long), xPair:(Long,Long)) : Long ={
    Math.abs(aPair._1 - xPair._1)  + Math.abs(aPair._2 - xPair._2)
  }
}


Measured memory_bytes: 25780
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
// fflush(stdout); to flush after every print ;,use \n in interactive prob;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll int n,t[100],i=0,ans=0,p;
string s[100],x;
cin>>n;
for(i=0;i<n;i++)
{
 cin>>s[i]>>t[i];
}
cin>>x;
for(i=0;i<n;i++)
{
    if(s[i]==x)
    {
        p=i;
        break;
    }
}
for(i=p+1;i<n;i++)
{
    ans=ans+t[i];
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100010;
bool f[46][N];
inline void update(int &x,int y){
	if(y<x) x = y;
}
int h[N],now;
int K;
int main(){
	scanf("%d",&K);
	int p = 1,ans = 1e9;
	f[0][0] = true;
	int cnt = 0;
	int tmp;
	for(int i = 0;i<46;i++){
		now++;
		for(int j = 0;j<K;j++) if(f[i][j]){
			tmp = j;
			while(h[tmp]!=now){
				f[i][tmp] = true;
				h[tmp] = now;
				tmp = tmp*10%K;
			}
		}
		for(int j = 0;j<K;j++)if(f[i][j]){
			for(int k = 0;k<10;k++){
				if(i+k<46) f[i+k][(j*10+k)%K] = true;
			}
		}
	}
	for(int i =1;i<46;i++) if(f[i][0]) ans =min(ans,i);
	//memcpy(f,g,sizeof(f));
	
	printf("%d\n",ans);
}

Measured memory_bytes: 5120
using System;
using System.Linq;
class program{
  static void Main(){
    int[] nk = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    int[] p = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    Array.Sort(p);
    int[] a = new int[nk[1]];
 	Array.Copy(p,0 , a, 0, nk[1]);
    Console.Write(a.Sum());
  }
}

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

int N, M;
int X[100100];
vector<int> d;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, M) cin >> X[i];
    if (N>=M) {
        cout << 0 << endl;
        exit(0);
    }
    sort(X, X+M);
    rep(i, M-1) d.pb(X[i+1]-X[i]);
    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());
    int sub = 0;
    rep(i, N-1) sub += d[i];
    cout << X[M-1]-X[0]-sub << endl;
}

Measured memory_bytes: 2168
import sys
readline = sys.stdin.readline

N = int(readline())
S = readline().rstrip()

# dp[i][j] = i文字目からとj文字目からとで最長の長さ
# S[i] != S[j] ならdp[i][j] = 0
# S[i] == S[j] ならdp[i][j] = dp[i + 1][j + 1] + 1

dp = [[0] * (N + 1) for i in range(N + 1)]

ans = 0
for i in range(N - 1, -1, -1):
  for j in range(N - 1, i, -1):
    if S[i] == S[j]:
      dp[i][j] = dp[i + 1][j + 1] + 1
      ans = max(ans, min(dp[i][j], j - i))
print(ans)

Measured memory_bytes: 270148
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10**9 + 7
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def combMod(n, r, p):
    numer = 1
    denom = 1
    for i in range(1, r+1):
        numer = numer * (n-r+i) % p
        denom = denom * i % p
    return numer * pow(denom, p-2, p) % p

def resolve():
    n, k = LI()

    if n >= k:
        ans = combMod(n - 1, k - 1, MOD)
    else:
        ans = 0

    print(ans)

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 6816
#include <cstdio>
int main() {
	int n;
	scanf("%d", &n);
	int s[n + 1];
	for (int i = 0; i < n; i++) scanf("%d", &s[i]);
	int q;
	scanf("%d", &q);
	int t[q];
	for (int i = 0; i < q; i++) scanf("%d", &t[i]);
	/* 在集合t中搜索同时出现在集合s中的元素数量 */
	int cnt = 0;
	for (int i = 0; i < q; i++) {
		s[n] = t[i]; //哨兵 
		int j = 0;
		while (s[j] != t[i]) j++;
		if (j != n) cnt++;
	} 
	printf("%d\n", cnt);
	return 0;
} 


Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
const int N=15;

int h,w,k,ans; char s[N][N];

int c[N][N];
void dfs(int a) {
	if(a==h+w+1) {
		int cnt=0;
		for(int i=1;i<=h;i++)
			for(int j=1;j<=w;j++)
				cnt+=(s[i][j]=='#'&&!c[i][j]);
		ans+=(cnt==k);
		return;
	}
	dfs(a+1);
	if(a<=w) {
		int tmp[15];
		for(int i=1;i<=h;i++)
			tmp[i]=c[i][a],c[i][a]=1;
		dfs(a+1);
		for(int i=1;i<=h;i++)
			c[i][a]=tmp[i];
	} else {
		int tmp[15];
		for(int i=1;i<=w;i++)
			tmp[i]=c[a-w][i],c[a-w][i]=1;
		dfs(a+1);
		for(int i=1;i<=w;i++)
			c[a-w][i]=tmp[i];
	}
}

int main() {
	scanf("%d%d%d",&h,&w,&k);
	for(int i=1;i<=h;i++) scanf("%s",s[i]+1);
	dfs(1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


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




int main() {

    int k; cin >> k;
    int ans = 0;
    for (int a = 1; a <= k; ++a) {
        for (int b = 1; b <= k; ++b) {
            for (int c = 1; c <= k; ++c) {
                ans += gcd(a, gcd(b, c));
            }
        }
    }
    out(ans);


    return 0;
}






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

using namespace std;

using Int = long long;
using P = pair<int, int>;

const long long MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;


int main() {
  int N;
  cin >> N;
  map<int, int> m;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    m[A]++;
  }
  vector<Int> v;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    if (itr->second >= 2) v.push_back(itr->first);
    if (itr->second >= 4) v.push_back(itr->first);
  }
  sort(v.begin(), v.end(), greater<int>());
  if (v.size() < 2) cout << 0 << endl;
  else cout << v[0] * v[1] << endl;
}

Measured memory_bytes: 4992
n,m,x = map(int,input().split())
books = []
cost = []
min_cost = -1
for _ in range(n):
  ca = [int(x) for x in input().split()]
  cost.append(ca[0])
  books.append(ca[1:])
pset = 2**n
for i in range(1,pset):
  indexes = []
  index = 0
  while i!=0:
    if i&1 == 1:
      indexes.append(index)
    index+=1
    i = i//2
  tot_cost = cost[indexes[0]]
  skill = books[indexes[0]].copy()
  for idx in indexes[1:]:
    tot_cost += cost[idx]
    for j in range(m):
      skill[j] += books[idx][j]
  satisfied = True
  for j in range(m):
    if skill[j] < x:
      satisfied = False
      break
  if satisfied:
    if min_cost==-1:
      min_cost = tot_cost
    else:
      min_cost = min(min_cost,tot_cost)
print(min_cost)

Measured memory_bytes: 9260
from math import sqrt, fabs


class Circle:
    def __init__(self, x, y, r):
        self.x = x
        self.y = y
        self.r = r
        self.eps = 1e-8

    def contain(self, x, y):
        d2 = (self.x - x) ** 2 + (self.y - y) ** 2
        return d2 <= self.r ** 2 + self.eps

    def intersect(self, other):
        eps = self.eps

        if self.r > other.r:
            x1, y1, R = self.x, self.y, self.r
            x2, y2, r = other.x, other.y, other.r
        else:
            x1, y1, R = other.x, other.y, other.r
            x2, y2, r = self.x, self.y, self.r
        d = sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

        # d = 0 and R = r
        if fabs(d) < eps and fabs(R - r) < eps:
            return '相同', None

        # d == R - r
        if fabs(d - (R - r)) < eps:
            x3 = (R * x2 - r * x1) / (R - r)
            y3 = (R * y2 - r * y1) / (R - r)
            return '內切', [(x3, y3)]

        # d == R + r
        if fabs(d - (R + r)) < eps:
            x3 = (R * x1 + r * x2) / (R + r)
            y3 = (R * y1 + r * y2) / (R + r)
            return '外切', [(x3, y3)]

        # d < R - r
        if d < R - r - eps:
            return '內離', None

        # d > R + R
        if d > R + r + eps:
            return '外離', None

        # R - r < d < R + r
        a = (R ** 2 - r ** 2 + d ** 2) / (2 * d)
        h = sqrt(R ** 2 - a ** 2)
        cx = x1 + a * (x2 - x1) / d
        cy = y1 + a * (y2 - y1) / d
        x3 = cx + h * (y2 - y1) / d
        y3 = cy - h * (x2 - x1) / d
        x4 = cx - h * (y2 - y1) / d
        y4 = cy + h * (x2 - x1) / d
        return '相交', [(x3, y3), (x4, y4)]


N, K = map(int, input().split())
X, Y, C = [], [], []
for _ in range(N):
    x, y, c = map(int, input().split())
    X.append(x)
    Y.append(y)
    C.append(c)


def check(t):
    circles = [Circle(x, y, t / c) for x, y, c in zip(X, Y, C)]

    cands = []
    for i in range(N):
        cands.append((X[i], Y[i]))
        for j in range(i + 1, N):
            kind, points = circles[i].intersect(circles[j])
            if kind in ['相交', '內切', '外切']:
                cands.extend(points)

    for (x, y) in cands:
        cnt = sum(1 for circle in circles if circle.contain(x, y))
        if cnt >= K:
            return True

    return False


# 0 0 0 1 1 1
lb, ub = 0, 1e9
for _ in range(100):
    mid = (lb + ub) / 2
    if check(mid):
        ub = mid
    else:
        lb = mid
print(ub)


Measured memory_bytes: 81332
from sys import stdin
from itertools import accumulate

def solve():
    file_input = stdin
    
    N = int(file_input.readline())
    G = tuple(tuple(map(int, line.split())) for line in file_input)
    
    # accumulated rows
    ar = ((0,) + tuple(accumulate(line)) for line in G)
    
    # accumulated columns
    ac = ((0,) + tuple(accumulate(line)) for line in zip(*G))
    ac_1 = next(ac)
    ac = tuple(zip(*ac))
    
    ans = 0
    for i, t1 in enumerate(zip(G, ar, ac, ac_1)):
        G_i, ar_i, ac_i, ac_1i = t1
        ar_ii = ar_i[i]
        for j, t2 in enumerate(zip(G[i:], ar_i[i+1:], ac[i+1:], ac_1[i+1:]), start=i):
            G_j, ar_ij, ac_j, ac_1j = t2
            if ar_ij - ar_ii > ans:
                ans = ar_ij - ar_ii
                
            if i == j:
                continue
            
            col_max = ac_1j - ac_1i
            
            for ac_jk, ac_ik, G_ik, G_jk in zip(ac_j, ac_i, G_i[1:], G_j[1:]):
                col = ac_jk - ac_ik
                
                if col_max > 0:
                    c_ans = col_max + col
                    if c_ans > ans:
                        ans = c_ans
                else:
                    if col > ans:
                        ans = col
                
                t_col_max = col_max + G_ik + G_jk
                if t_col_max > col:
                    col_max = t_col_max
                else:
                    col_max = col
    print(ans)

solve()


Measured memory_bytes: 13028
#include <cstdio>
#include <cmath>
#define ll long long
using namespace std;
int main(){
    ll n,k;
    scanf("%lld",&n);
    k=ceil(sqrt(n));
    while(k){
        if(n%k==0){
            printf("%lld",k-1+n/k-1);
            return 0;
        }
        k--;
    }
    return 0;
}


Measured memory_bytes: 2216
#include<stdio.h>

int main()
{
    long long int a,b;
    int c,v;
    char g;
    scanf("%d %c %d",&a,&g,&b);
    if(g=='+'){
        printf("%d\n",a+b);
    }
    else if(g=='-'){
        printf("%d\n",a-b);
    }
    return 0;
}


Measured memory_bytes: 128
n,a,b = (int(i) for i in input().split())
s = input()
kokunai = 0
kaigai = 0
for i in range(n):
  if s[i] == 'c': print('No')
  elif s[i] == 'a':
    if kokunai+kaigai < a+b:
     print('Yes')
     kokunai += 1
    else: print('No')
  else:
    if kokunai+kaigai < a+b and kaigai <b:
      print('Yes')
      kaigai += 1
    else:print('No')
      

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;

int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N, T; cin >> N >> T;
    vector<int> cost;
    REP(i, N) {
        int c, t; cin >> c >> t;
        if (t <= T) cost.push_back(c);
    }
    if(cost.empty()) cout << "TLE" << endl;
    else {
        sort(cost.begin(), cost.end());
        cout << cost[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int i = 2;
    int count = 0;
    List<Integer> prime = new ArrayList<>();
    while (count < N) {
      int tmp = 5*i + 1;
      if (isPrime(tmp)) {
        prime.add(tmp);
        count++;
      }
      i++;
    }
    for (i=0;i<N;i++) {
      System.out.print(prime.get(i));
      if (i!=N-1) {
        System.out.print(" ");
      }
    }
  }

  private static boolean isPrime(int a) {
    if (a == 1) {
      return false;
    }
    if (a == 2 || a == 3) {
      return true;
    }
    for (int i=2; i*i<=a; i++) {
      if (a % i == 0) {
        return false;
      }
    }
    return true;
  }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);
#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

const int N = 2e3 + 50;
const int mod = 998244353 ;

int main(){
    io();

    int s, w;
    cin >> s >> w;
    if(s > w)
        cout << "safe";
    else
        cout << "unsafe";    

}



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

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

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

typedef long long ll;

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

    int X, Y, A, B, C;

    cin >> X >> Y >> A >> B >> C;

    vector<ll> p(A);
    vector<ll> q(B);
    vector<ll> r(C);

    for(int i = 0; i < A; i++) {
        cin >> p[i];
    }

    for(int i = 0; i < B; i++) {
        cin >> q[i];
    }

    for(int i = 0; i < C; i++) {
        cin >> r[i];
    }

    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());

    ll a = X - 1;
    ll b = Y - 1;

    ll z = 0;

    while(a >= 0 || b >= 0) {
        if(a >= 0 && b >= 0) {
            //cerr << p[a] << q[b] << endl;
            if(p[a] > q[b]) {
                if(q[b] < r[z]) {
                    q[b] = r[z];
                    b--;
                    z++;
                } else {
                    break;
                }
            } else {
                if(p[a] < r[z]) {
                    p[a] = r[z];
                    a--;
                    z++;
                } else {
                    break;
                }
            }
        } else if(a >= 0) {
            if(p[a] < r[z]) {
                p[a] = r[z];
                a--;
                z++;
            } else {
                break;
            }
        } else if(b >= 0) {
            if(q[b] < r[z]) {
                q[b] = r[z];
                b--;
                z++;
            } else {
                break;
            }
        }
        if(z >= C) {
            break;
        }
    }

    ll count = 0;

    for(int i = 0; i < X; i++) {
        count += p[i];
    }
    for(int i = 0; i < Y; i++) {
        count += q[i];
    }

    cout << count << endl;
}

Measured memory_bytes: 2560
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

const MOD: usize = 1_000_000_007;

#[fastout]
fn solve() {
    input!{
        a: usize, b: usize, c: usize,
    }

    let flag = (a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5);
    if flag {
        println!("YES");
    } else {
        println!("NO");
    }
    
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9+5;
const int MOD=1e9+7;

int main(){
    int n;
    cin>>n;
    vector<double>dp(n+1);
    dp[0]=1;
    for(int coin=0;coin<n;coin++){
        double p_head;
        cin>>p_head;
        for(int i=coin+1;i>=0;i--){
            dp[i]=(i==0?0:dp[i-1]*p_head)+dp[i]*(1-p_head);
        }
    }
    double answer=0;
    for(int heads=0;heads<=n;heads++){
        int tails=n-heads;
        if(heads>tails){
            answer+=dp[heads];
        }
    }
    printf("%.10lf",answer);
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
vs = gets.split.map(&:to_i)

vs1 = []
vs2 = []
vs.length.times{|x|
    vs1.push(vs[x]) if x % 2 == 0
    vs2.push(vs[x]) if x % 2 != 0
}

vs1_h = Hash.new(0)
vs2_h = Hash.new(0)

vs.length.times{|x|
    vs1_h[vs[x]] = vs1_h[vs[x]] + 1 if x % 2 == 0
    vs2_h[vs[x]] = vs2_h[vs[x]] + 1 if x % 2 != 0
}

n1,n2 = vs1_h.sort_by{|_,v| v}.reverse
m1,m2 = vs2_h.sort_by{|_,v| v}.reverse

n1f,n1b = n1
m1f,m1b = m1

n2f,n2b = n2
m2f,m2b = m2

v1_count = 0
v2_count = 0

if (n2 == nil) && (m2 == nil)
    if n1f == m1f
        ans = vs.length / 2
    else
        ans = 0
    end
elsif (n2 != nil) && (m2 == nil)
    if n1f == m1f
        ans = vs.length / 2 - n2b
    else
        ans = vs.length / 2 - n1b
    end
elsif (n2 == nil) && (m2 != nil)
    if n1f == m1f
        ans = vs.length / 2 - m2b
    else
        ans = vs.length / 2 - m1b
    end
else
    if n1f == m1f
        ans = vs.length - [n1b+m2b,n2b+m1b].max
    else
        ans = vs.length - m1b - n1b
    end
end

puts ans


Measured memory_bytes: 21644
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=998244353;
map<int,int> mii;

int vis[200050];
int main()
{
    //ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 2011

using namespace std;

const int MOD = (int)1e9 + 7;

int n, m, ans;
int s[N],t[N];
int cnt[N][N];
int pre[N][N];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n >> m;
	for(int i=0; i<n; i++) cin >> s[i];
	for(int i=0; i<m; i++) cin >> t[i];
	for(int i=0; i<n; i++) {
		for(int j=0; j<m; j++) {
			if(s[i] == t[j]) {
	          	if(i > 0 and j > 0) cnt[i][j] = cnt[i-1][j-1];
				cnt[i][j] = (cnt[i][j] + 1) % MOD;
				ans = (ans + cnt[i][j]) % MOD;
			}
			if(j > 0) cnt[i][j] = (cnt[i][j-1] + cnt[i][j]) % MOD;
		}
		if(i == 0) continue;
		for(int j=0; j<m; j++) cnt[i][j] = (cnt[i][j] + cnt[i-1][j]) % MOD;
	}
	ans = (ans + 1) % MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 32640
N=int(input())
A=list(map(int,input().split()))
A.sort()

B=[A[0]]
for i in range(1,N):
  B.append(B[-1]+A[i])
#print(A)
#print(B)

left=0
for left in range(N-2,-1,-1):
  if B[left]*2>=A[left+1]:
    pass
  else:
    break
else:
  left=-1

num=N-left-1
#print(left)
print(num)

#cnt=0
#for i in range(num,N-1):
#  if A[num]

Measured memory_bytes: 14320
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for (int i=1;i<=n;i++)
#define REP(i,a,b) for (int i=a;i<=b;i++)
 
#define pb push_back
 
typedef long long ll;

const int inf=0x3f3f3f3f;
const int N=10000+10;

int h,w;
int n;
int a[N];
int g[101][101];
int main() {
 
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	//freopen("in.txt","r",stdin);
	cin>>h>>w;
	cin>>n;
	FOR(i,n) cin>>a[i];
	int x=1,y=0;
	int dir=1;
	int p=1;
	FOR(i,h*w) {
		if (dir==1) {
			if (y!=w) {
				y++;
			} else {
				x++;
				dir=0;
			}
		} else if (dir==0) {
			if (y!=1) {
				y--;
			} else {
				x++;
				dir=1;
			}
		}
		if (a[p]) g[x][y]=p,a[p]--;
		else g[x][y]=p+1,a[++p]--;
	}
	FOR(i,h) {
		FOR(j,w) cout<<g[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
/*input
3 101
*/
#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 int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

void solve(){
  int x,y;cin >> x >> y;
  int ans = 0;
  if(x+y == 2)ans = 4;
  if(x < 4)ans += 4-x;
  if(y < 4)ans += 4-y;
  cout << ans*100000;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int n; cin>>n;
	for(int i = 1000; i < 100000; i+=1000){
		if(i >= n){
			cout<<i-n<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    long double N=double(n);
    long double d=0.0000000000000;
    cout<<fixed;
    cout<<setprecision(12);
    for(int i=1; i<=n; i++){
        int cur=i;
        long double s=1.0/N;
        while(cur<k){
            s/=2;
            cur*=2;
        }
        d+=s;
    }
    
    cout<<d-1e-10<<endl;
}

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

int main() {
	string S;
	cin >> S;
	string ss="";
	for (int i=S.length()-1; i>=0; i--){
	    ss+=S[i];
	    if (ss=="resare") ss="";
	    else if (ss=="esare") ss="";
	    else if (ss=="maerd") ss="";
	    else if (ss=="remaerd") ss="";
	}
	if (ss=="") cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    string ans = c >= a && c <= a + b ? "YES" : "NO";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
const int inf=1145141919ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int a,b,c,d;
int p[114514],q[114514];
int gcd(int x,int y){
	if(x<y)
		swap(x,y);
	int z=x%y;
	if(z==0)
		return y;
	return gcd(y,z);
}
signed main(){
	int i,j;
	cin>>a>>b;
	for(i=0;i<a;i++)
		cin>>p[i];
	int ans=p[0],ma=p[0];
	for(i=1;i<a;i++){
		ans=gcd(ans,p[i]);
		ma=max(ma,p[i]);
	}
	if(b>ma||b%ans)
		cout<<"IMPOSSIBLE"<<endl;
	else
		cout<<"POSSIBLE"<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int K = 0;
    vector<int> nums(100002);
    int d[N];
    for(int i = 0;i < N;i++){
        cin >> d[i];
        nums[d[i]]++;
    }
    for(int i = 1;i <= 100001;i++){
        nums[i] += nums[i - 1];
    }
    
    for(int i = 1;i <= 100000;i++){
        if(nums[i] == N / 2){
            K++;
        }
    }
    cout << K << endl;
}


Measured memory_bytes: 1024
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    ll n,k,q,ans=0;
	cin >> n >> k >> q;
	ll a[q+1],b[n+1];
	for(int i=1;i<=q;i++){
		cin >> a[i];
	}
	for(int i=1;i<=n;i++){
		b[i]=0;
	}

	for(int i=1;i<=q;i++){
		b[a[i]]++;
	}

	for(int i=1;i<=n;i++){
		if((k-q+b[i])<=0){
			cout << "No" << endl;	
		}
		else{
			cout << "Yes" << endl;	
		}
		// con = 0;
		// rep(j,q){
		// 	if(a[j]!=i+1){
		// 		con++;
		// 	}
		// }
		// //cout << k-con << endl;
		// if((k-con)<=0){
		// 	cout << "No" << endl;	
		// }
		// else{
		// 	cout << "Yes" << endl;	
		// }
	}
}

Measured memory_bytes: 2176
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  cin >> K;
  int a, b, c;
  a = 1;
  b = 1;
  c = 1;
  int p, q, r, x, sum;
  sum = 0;
  
  for(a = 1; a <= K; a++){
    for(b = 1; b <= K; b++){
      for(c = 1; c <= K; c++){
        p = a;
        q = b;
        r = c;
        
        while(p != 0 && q != 0){
          if(p >= q){
            p = p % q;
          }
          else
            q = q % p;
        }
        if(p == 0)
          x = q;
        else
          x = p;
        
        while(x != 0 && r != 0){
         if(x >= r){
            x = x % r;
         }
         else
            r = r % x;
        }
        if(x == 0)
          sum += r;
        else
          sum += x;
        }
      }
    }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int num = scan.nextInt();
    int[] n = new int[num];

    for (int i = 0; i < num; i++){
      int s = scan.nextInt();
      n[s - 1] = i;
    }
    for(int i = 0; i < num; i++){
      System.out.print(n[i] + 1 + " ");

    }
  }
}


Measured memory_bytes: 63252