akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define _LIBCPP_DEBUG 0
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(){
///////////////////////////////////////////////////////////
int n,ans=0;
cin >> n;

if(n%2==0){
    ans=n/2-1;
}
else{
    ans=n/2;
}
cout << ans << endl;
//////////////////////////////////////////////////////////
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

vector<vector<int>> G(4);
bool used[4];

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

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

    ll K, A, B;
    cin >> K >> A >> B;

    ll ans = 0;
    if (A >= B)
    {
        cout << K + 1 << endl;
    }
    else
    {
        if (K < A)
        {
            cout << K + 1 << endl;
        }
        else
        {
            if (B - A <= 2)
            {
                cout << K + 1 << endl;
            }
            else
            {
                ans += B;
                K -= (A + 1);

                ll t = 0;
                if (K % 2 == 0)
                {
                    ans += (B - A) * K / 2;
                }
                else
                {
                    ans += (B - A) * (K - 1) / 2 + 1;
                }
                cout << ans << endl;
            }
        }
    }
    //cout << fixed << setprecision(15);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;
int N, x;
int a[2 * MAX_N - 1];

int main(){
	cin >> N >> x;
	if(x == 1 || x == 2 * N - 1){
		cout << "No" << endl;
		return 0;
	}
	for(int i = 0; i < 2 * N - 1; i++) a[i] = i + 1;
	
	if(x < N){
		for(int i = x - 1; i < N - 1; i++) swap(a[i], a[i + 1]);
		for(int i = 0; i < N - 2; i++) swap(a[i], a[i + 1]);
	}else if(x > N){
		for(int i = x - 1; i > N - 1; i--) swap(a[i], a[i - 1]);
		for(int i = 2 * N - 2; i > N; i--) swap(a[i], a[i - 1]);
	}
	
	cout << "Yes" << endl;
	for(int i = 0; i < 2 * N - 1; i++) cout << a[i] << endl;
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  string s;
  cin >> s;
  ll sum = 0, flag = 1, l = s.size();
  if(l == 1){
    cout << s[0] - '0' << endl;
    return 0;
  }
  string t;
  REP(i, l - 1) t.append("9");
  if(s[0] != '9' && s.substr(1, l - 1) == t){
    ll res = s[0] - '0' + 9 * (l - 1);
    cout << res << endl;
    return 0;
  }
  REP(i, l){
    if(flag && s[i] != '9'){
      if(i == 0) sum += s[i] - '0' - 1;
      else sum += 8;
      flag = 0;
    }
    else sum += 9;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  string a,b;
  cin >> a >> b;

  if(a.size() > b.size()) cout <<  "GREATER" << endl;
  else if(a.size() < b.size()) cout <<  "LESS" << endl;
  else{
    if(a>b) cout <<  "GREATER" << endl;
    else if(a<b) cout <<  "LESS" << endl;
    else cout <<  "EQUAL" << endl;
  }
  return 0;
} 

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define N 60
#define ll long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
using namespace std;
ll n,m,s;
vector< vector<pair< ll , pair< ll,ll> > > > adj(N);
ll dis[N][N*N];
ll vis[N][N*N];
priority_queue<pair<ll,pair<ll,ll>> > pq;
ll c[N],d[N];
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m>>s;
    for(int i=0;i< m;i++){
        ll u,v,a,b;
        cin>>u>>v>>a>>b;
        b*=-1ll;
        adj[u].pb({v,{a,b}});
        adj[v].pb({u,{a,b}});
    }
    for(int i=1;i<=n;i++)
        cin>>c[i]>>d[i];
    for(int i=0;i<n;i++)
        d[i+1] *= -1ll;
    for(int i=0;i<N;i++){
        for(int j=0;j<N*N;j++){
            dis[i][j] = -1e18;
        }
    }
    ll h = N*N; h--; 
    s = min(s,h);
    dis[1][s] = 0;
    pq.push({0ll,{1ll,s}});
    while(!pq.empty()){
        ll cur = pq.top().y.x;
        ll coin = pq.top().y.y;
        pq.pop();
        if(vis[cur][coin])continue;
       // cout<<cur<<" "<<coin<<" "<<dis[cur][coin]<<"\n";
        vis[cur][coin] = 1;
        for(auto j: adj[cur]){
            if(coin<j.y.x)continue;
            if(vis[j.x][coin-j.y.x])continue;
            if(dis[j.x][coin-j.y.x]<dis[cur][coin]+j.y.y){
                dis[j.x][coin-j.y.x]=dis[cur][coin]+j.y.y;
                pq.push({dis[j.x][coin-j.y.x],{j.x,coin-j.y.x}});
            }
        }
        if(coin+c[cur]<=h){
            if(dis[cur][coin+c[cur]]<dis[cur][coin]+d[cur]){
                dis[cur][coin+c[cur]]=dis[cur][coin]+d[cur];
                pq.push({dis[cur][coin+c[cur]],{cur,coin+c[cur]}});
            }
        }
    }
    for(int i=2;i<=n;i++){
        ll mi = 1e18;
        for(int j=0;j<N*N;j++)
            mi = min(mi,abs(dis[i][j]));
        cout<<mi<<"\n";
    }
    return 0;
}

Measured memory_bytes: 9256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a%b) : a; }
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
signed main()
{
	int x, y;
	cin >> x >> y;
	cout << x + y / 2;
}

Measured memory_bytes: 256
import heapq
n = int(input())
a_lst = list(map(int, input().split(" ")))

a_lst.sort(reverse=True)


result = 0
heap = []
heapq.heappush(heap,-a_lst[0])

for i in a_lst[1:]:
	now_max = heapq.heappop(heap)
	result += now_max
	heapq.heappush(heap, -i)
	heapq.heappush(heap, -i)

print(-result)

Measured memory_bytes: 31792
#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>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#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>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#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>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

int f(char c){
    if('a'<=c and c<='z')return 26+(c-'a');
    else return (c-'A');
}

char rf(int n){
    if(n<26)return ('A'+n);
    else return ('a'+(n-26));
}

bool solve(){
    ll n,a,b;cin>>n>>a>>b;
    cout<<(abs(a-b)%2==0 ? "Alice" : "Borys")<<endl;
    return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, int s>using va = vector<array<T, s>>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#define rrep(i,a) for(int i=a-1;i>=0;i--)
#define rrep1(i,a) for(int i=a;i;i--)
const ll mod = 1000000007;
#define REP rep
template<class T>using heap = priority_queue<T, vector<T>, greater<T>>;
template<class T>using pque = priority_queue<T, vector<T>, function<T(T, T)>>;
template <class T>
inline void hash_combine(size_t & seed, const T & v) {
	hash<T> hasher;
	seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
namespace std {
	template<typename S, typename T> struct hash<pair<S, T>> {
		inline size_t operator()(const pair<S, T> & v) const {
			size_t seed = 0;
			hash_combine(seed, v.first);
			hash_combine(seed, v.second);
			return seed;
		}
	};
	// Recursive template code derived from Matthieu M.
	template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1>
	struct HashValueImpl{
		static void apply(size_t& seed, Tuple const& tuple){
			HashValueImpl<Tuple, Index - 1>::apply(seed, tuple);
			hash_combine(seed, std::get<Index>(tuple));
		}
	};
	template <class Tuple>
	struct HashValueImpl<Tuple, 0>{
		static void apply(size_t& seed, Tuple const& tuple){
			hash_combine(seed, std::get<0>(tuple));
		}
	};
	template <typename ... TT>
	struct hash<std::tuple<TT...>>{
		size_t operator()(std::tuple<TT...> const& tt) const{
			size_t seed = 0;
			HashValueImpl<std::tuple<TT...> >::apply(seed, tt);
			return seed;
		}
	};
}
template<class T>int id(vector<T> &a, T b) {
	return lower_bound(ALL(a), b) - a.begin();
}
//end of lib
int main() {
	int n, d, x;
	cin >> n >> d >> x;
	vector<vi> p(d, vi(n));
	rep(i, d)rep(j, n)cin >> p[i][j];
	rep(i, d - 1) {
		vi dp(x + 1, x);
		rep(j, n) {
			for (int k = p[i][j]; k <= x; k++)cmax(dp[k], dp[k - p[i][j]] + p[i + 1][j] - p[i][j]);
		}
		x = dp.back();
	}
	cout << x << endl;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a) for(int i = 0; i < a; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int n; cin>>n;
    if(n%2==0) cout<<n<<endl;
    else cout<<n*2<<endl;
}


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

/* combinatorics template */

const int mod = 1e9 + 7;

void add_self(int &x, int y) {
  x += y;
  if (x >= mod)
    x -= mod;
}

void sub_self(int &x, int y) {
  x -= y;
  if (x < 0)
    x += mod;
}

int add(int x, int y) {
  x += y;
  if (x >= mod)
    x -= mod;
  return x;
}

int sub(int x, int y) {
  x -= y;
  if (x < 0)
    x += mod;
  return x;
}

int powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for( ; b; b >>= 1){
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res % mod;
}

int mult(int x, int y) {
  return (1LL * x * y) % mod;
}

int divide(int x, int y) {
  return mult(x, powmod(y, mod - 2));
}

/* end of combinatorics template */

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &a[i]);
  vector<int> pref(n + 1, 1);
  for (int i = 2; i <= n; ++i)
    pref[i] = add(pref[i - 1], divide(1, i));
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    add_self(ans, mult(pref[i + 1], a[i]));
    add_self(ans, mult(pref[n - i], a[i]));
    sub_self(ans, a[i]);
  }
  for (int i = 1; i <= n; ++i)
    ans = mult(ans, i);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		if(n == 1)
			System.out.println("Hello World");
		else 
			System.out.println(sc.nextInt() + sc.nextInt());
	}
}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


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

int main(){
    string A,B,C;
    cin >> A >> B >> C;

    if( A[A.size()-1]==B[0] && B[B.size()-1]==C[0] ){
            cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    while(true){
      int a = scanner.nextInt();
      char x = scanner.next().charAt(0);
      int b = scanner.nextInt();
      if(x == '?') break;
      switch(x){
        case '+':
          System.out.println(a + b);
          break;
        case '-':
          System.out.println(a - b);
          break;
        case '*':
          System.out.println(a * b);
          break;
        case '/':
          System.out.println(a / b);
          break;
        default:
          break;
        }
      }
  }
}

Measured memory_bytes: 26252
n = int(input())
nums = [int(i) for i in input().split()]

m = 10 ** 10
for num1 in range(1, max(nums)+1):
    tmp = 0
    for num2 in nums:
        tmp += (num1 - num2) ** 2
    m = min(m, tmp)
print(m)


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

int main(){
    ll n;
    cin >> n;
    ll ans = n*(n+1)*(n+2)/6;
    ll u, v;
    rep(i, n-1) {
        
        cin >> u >> v;
        if (u>v) swap(u, v);
        ans -= (u)*(n-v+1);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 1e6 + 44;
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9 + 44;

string s;

int d;

long long dp[10100][105];

long long go (int pos = 0, bool sp = 1, int m = 0) {
	if (pos == (int) s.size()) return !m;
	int l = 0, r = 9;
	if (sp) {
		long long res = 0;
		r = s[pos] - '0';
		while (l < r) {
			res += go (pos + 1, 0, (m + l) % d);
			res %= mod;
			++l;
		}
		res += go (pos + 1, 1, (m + r) % d);
		res %= mod;
		return res;
	}
	long long &res = dp[s.size() - pos][m];
	if (res != -1) return res;
	res = 0;
	while (l <= r) {
		res += go (pos + 1, 0, (m + l) % d);
		res %= mod;
		++l;
	}
	return res;
}

int main () {
	boost;
	for (int i = 0 ; i <= 10099 ; ++ i) {
		for (int j = 0 ; j < 104 ; ++ j) {
			dp[i][j] = -1;
		}
	}
	cin >> s >> d;
	cout << (go() - 1 + mod) % mod;
}

Measured memory_bytes: 9472
n,k = map(int, input().split())

d = list(map(int, input().split()))
a = []
for i in range(10):
  if i not in d:
    a.append(str(i))
ans = n
while True:
  b = str(ans)
  if all([i in a for i in b]):
    break
  ans += 1
print(ans)

Measured memory_bytes: 3060
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
import collections
n = ii()
A = iil()
d = collections.Counter(A)
fst = 0
sec = 0
for k,v in d.items():
    if v == 1:
        continue
    elif v < 4:
        if k > fst:
            sec = fst
            fst = k
        elif k > sec:
            sec = k
    else:
        if k > fst:
            fst = k
            sec = k
        elif k > sec:
            sec = k
print(fst*sec)

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int A, B, C;
  cin >> A >> B >> C;
  cout << min(C, B/A) <<endl;
}


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

int main() {
    int H, W;

    while(1) {
        cin >> H >> W;
        if(H == 0 && W == 0)break;

        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                if((i + j) % 2 == 0){
                    cout << "#";
                } else {
                    cout << ".";
                }
            } 
            cout << "\n";
        }
        cout << endl;
    }

    return 0;
}


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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

long d[50][50][50];

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

    int n;
    cin >> n;
    n *= 2;
    vector<vector<char>> a(n, vector<char>(n));
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < n; j++) {
            a[i][j] = s[j] == '1';
        }
    }
    for (int len = 0; len < n; len += 2) {
        for (int l = 0; l < n; l++) {
            for (int x = 0; x <= len; x++) {
                if (len == 0) {
                    d[len][l][x] = 1;
                    continue;
                }
                for (int q = 0; q < x; q++) {
                    for (int w = x + 1; w <= len; w++) {
                        if (a[(l + q) % n][(l + w) % n]) {
                            for (int qq = q; qq < x; qq++) {
                                for (int ww = x + 1; ww <= w; ww++) {
                                    d[len][l][x] +=
                                            d[qq][l][q] *
                                            d[len - ww][(l + ww) % n][w - ww] *
                                            d[ww - qq - 2][(l + qq + 1) % n][x - qq - 1];
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    long res = 0;
    for (int i = 1; i < n; i++) {
        if (a[0][i]) {
            res += d[n - 2][(i + 1) % n][n - i - 1];
        }
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
#include<unordered_map>
using namespace std;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const int mod=998244353;
#define ll long long

int main(){
    ll n;
    cin>>n;
    vector<ll>d(n);
    vector<ll>a(n);
    rep(i,n){
        cin>>d[i];
        if(d[0]!=0){
            cout<<0<<endl;
            return 0;
        }
        if(i!=0&&d[i]==0){
            cout<<0<<endl;
            return 0;
        }
        a[d[i]]++;
    }
    sort(d.begin(),d.end());
    ll ans=1;
    for(int i=1;i<=d[n-1];i++){
        ll k=a[i-1];
        ll l=a[i];
        while(l){
            ans*=k;
            if(ans>=mod){
                ans%=mod;
            }
            l--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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; }
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main(){
	string s;
	cin >> s;
	deque<char> dq;
	int n = s.size();
	rep(i, n) dq.push_back(s[i]);
	bool rev = false;
	int q;
	cin >> q;
	rep(qqq, q) {
		int k;
		cin >> k;
		if (k == 1) rev ^= true;
		else {
			int x; char c;
			cin >> x >> c;
			if (rev) x = 3 - x;
			if (x == 1) dq.push_front(c);
			else dq.push_back(c);
		}
	}
	if (rev) {
		while (!dq.empty()) {
			cout << dq.back();
			dq.pop_back();
		}
	}
	else {
		while (!dq.empty()) {
			cout << dq.front();
			dq.pop_front();
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3948
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;
int gcd(int a, int b)
{
    if(b) return gcd(b,a%b);
    return a;
}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1e9 + 7;

int n,k,dp[1 << 17],pd[1 << 17],f;

int32_t main(){_
    //freopen("in","r",stdin);
	cin >> n >> k;
	dp[0] = 1;
	for(int i = 1;i <= n;i++)
	{
		int x;
		cin >> x;
		f = 0;
		for(int j = 0;j <= k;j++)
		{
			f += dp[j];
			f %= mod;
			if(j - x - 1 >= 0){
				f -= dp[j - x - 1];
				f += mod;
				f %= mod;
			}
			pd[j] = f;
		}
		for(int j = 0;j <= k;j++)
		{
			dp[j] = pd[j];
		}
	}
	rc(dp[k]);
}

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

using namespace std;

typedef pair< int, int> pii;
typedef pair< int, pii> piii;

int M, T, P, R;

int main() {
	while (1) {
		cin >> M >> T >> P >> R; if (M==0 && T==0 && P==0 && R==0) break;
		
		vector<piii> pv(T);
		vector< vector<int> > end(T, vector<int>(P, 0) );
		for (int i = 0; i < T; i++) pv[i] = make_pair(0, make_pair(0, i + 1) );
		for (int i = 0; i < R; i++) {
			int m, t, p, j; cin >> m >> t >> p >> j;
			if (end[t-1][p-1] > 0) continue;
			if (m > M) continue;
			if (j==0) {
				pv[t-1].first++;
				pv[t-1].second.first -= m;
				end[t-1][p-1] = (-1)*end[t-1][p-1];
			} else {
				end[t-1][p-1]--;
			}
		}

		for (int i = 0; i < T; i++) {
			for (int j = 0; j < P; j++) {
				if (end[i][j] <= 0) continue;
				pv[i].second.first -= 20 * end[i][j];
			}
		}

		sort(pv.begin(), pv.end());
		for (int i = T-1; i >= 0; i--) {
			if (i > 0 && pv[i].first == pv[i-1].first && pv[i].second.first == pv[i-1].second.first) {
				cout << pv[i].second.second << "=";
			} else {
				cout << pv[i].second.second;
				if (i > 0) cout << ",";
			}
		}
		cout << endl;
	}	

	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define repLL(i,a,b) for(LL i=(LL)a;i<(LL)b;i++)
#define perLL(i,a,b) for(LL i=(LL)a;i>(LL)b;i--)
#define debug5(a,b,c,d,e) cerr<<#a<<": "<<a<<" "<<#b<<": "<<b<<" "<<#c<<": "<<c<<" "<<#d<<": "<<d<<" "<<#e<<": "<<e<<endl;
#define debug4(a,b,c,d)  cerr<<#a<<": "<<a<<" "<<#b<<": "<<b<<" "<<#c<<": "<<c<<" "<<#d<<": "<<d<<endl;
#define debug3(a,b,c) cerr<<#a<<": "<<a<<" "<<#b<<": "<<b<<" "<<#c<<": "<<c<<endl;
#define debug2(a,b) cerr<<#a<<": "<<a<<" "<<#b<<": "<<b<<endl;
#define debug(a) cerr<<#a<<": "<<a<<endl;
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<typename T>
void dbg(T a)
{
      #ifdef LOCAL
            cerr<<a<<"\n";
      #endif
}

template<typename T, typename ...Arg>
void dbg(T a,Arg ...arg)
{
      #ifdef LOCAL
            cerr<<a<<" ";
            dbg(arg...);
      #endif
}

const int maxn=(1e6)+7;
const int inf=(1e9)+7;
const LL LLinf=(1e18)+7;
const LD eps=1e-9;
const LL mod=1e9+7;

// ***************************** CODE ***************************** //

VPII wek[maxn];
bool vis[maxn];
LL odl[maxn];
bool f = 0;

void dfs(int x)
{
	vis[x] = 1;
	for(auto s : wek[x])
	{
		if(vis[s.fi] == 0)
		{
			odl[s.fi] = odl[x] + s.se;
			dfs(s.fi);
		}
		else
			if(odl[s.fi] != odl[x] + s.se)
				f = 1;
	}
}


int main()
{
      _upgrade
	int n, m;
	cin>>n>>m;
	while(m--)
	{
		int a, b, c;
		cin>>a>>b>>c;
		wek[a].pb({b, c});
		wek[b].pb({a, -c});
	}
	for(int i = 1; i <= n;i++)
		if(vis[i] == 0)
			dfs(i);
	if(f)
		cout<<"No";
	else
		cout<<"Yes";
      return 0;
}


Measured memory_bytes: 35200
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
//typedef complex<long double> com;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k;
	cin >> n >> k;
	vector <ld> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z];
	}
	ll ans = 0;
	for (int z=0;z<k;z++){
		ans += arr[z];
	}
	ll maxi = ans;
	for (int z=k;z<n;z++){
		ans += arr[z];
		ans -= arr[z-k];
		maxi = max(ans,maxi);
	}
	cout << setprecision(60) << ld(maxi+(k))/ld(2) << endl;
} 
 


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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


bool judge(int a, int b, int c) {
    if ((a > b && b > c) || (a < b && b < c)) return true;
    return false;
}

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

    int n;
    cin >> n;

    vector<int> p(n, 0);
    REPinit(i, 0, n) cin >> p[i];

    int ans = 0;
    REPinit(i, 1, n - 1) {
        if (judge(p[i - 1], p[i], p[i + 1])) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

ll dp[1000][1000] = {};
int ma[1000][1000] = {};
int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> m(h);
  REP(i, h)
  {
    cin >> m[i];
  }

  REP(i, h)
  {
    REP(j, w)
    {
      if (m[i][j] == '#')
      {
        ma[i][j] = 1;
      }
    }
  }

  dp[0][0] = 1;

  REP(i, h)
  {
    REP(j, w)
    {
      if (ma[i][j] == 1)
        continue;
      if (i != 0)
      {
        dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
      }
      if (j != 0)
      {
        dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
      }
    }
  }
  cout << dp[h - 1][w - 1] << endl;
}


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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

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

  int n;

  cin >> n;

  vector<int> arr(n);

  for(int &x: arr)
    cin >> x;

  for(int i = 0; i < n; i++) {
    if(arr[i] == 1)
        continue;
    if(i == 0 || (arr[i] > arr[i - 1])) {
        arr[i]--;
    }
  }

  bool ok = true;
  for(int i = 1; i < n; i++) {
    ok &= (arr[i] >= arr[i - 1]);
  }

  cout << (ok ? "Yes" : "No") << endl;

}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        if (str.equals("AAA") || str.equals("BBB")) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


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

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

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int p, q, r;
    cin >> p >> q >> r;
    int sum = p + q + r;
    int mx = max({p, q, r});
    sum -= mx;
    cout << sum;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>

#pragma GCC optimize("O3")

using namespace std;
using ll = long long;
using ull = unsigned long long;

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repd(i, n) for(ll i = (n) - 1; i >= 0; --i)
#define FOR(i, a, b) for(ll i = a; i <= ll(b); ++i)
#define FORD(i, a, b) for(ll i = a; i >= ll(b); --i)
#define loop while(true)
#define asort(array, size) std::sort(array, array + size)
#define cauto const auto&
#define bit(n) (1LL << (n))

int main()
{
    int N;
    cin >> N;
    auto c = new char[N];
    rep(i, N) {
        cin >> c[i];
    }
    int count = 0;
    rep(l, N) {
        if (c[l] == 'W') {
            bool find = false;
            FORD(r, N - 1, l + 1) {
                if (c[r] == 'R') {
                    c[l] = 'R';
                    c[r] = 'W';
                    ++count;
                    find = true;
                    break;
                }
            }
            if (!find) break;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3788
#include<iostream>
#include<map>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n][3];
	int d,b,c;
	cin>>a[0][0]>>a[0][1]>>a[0][2];
	for ( int i=1;i<n;i++){
		cin>>d>>b>>c;
		a[i][0]=d+ max(a[i-1][1],a[i-1][2]);
		a[i][1]=b+ max(a[i-1][0],a[i-1][2]);
		a[i][2]=c+ max(a[i-1][1],a[i-1][0]);
	}
	int k= max(a[n-1][0], max(a[n-1][1],a[n-1][2]));
	cout<<k<<endl;	
}

Measured memory_bytes: 4716
#include<iostream>

using namespace std;



int main(){
  int x,y;
  cin>>x>>y;
  switch(x){
      case(4):
      case(6):
      case(9):
      case(11):x=2;break;
      case(2):x=3;break;
    default:x=1;break;
  }
  switch(y){
      case(4):
      case(6):
      case(9):
      case(11):y=2;break;
      case(2):y=3;break;
    default:y=1;break;
  }
  cout<<(x==y?"Yes":"No")<<endl;
  return 0;
  
}  


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

typedef long double ld;
typedef pair<ld, ld> pld;

#define fi first
#define se second

const int MAXN = 500005;

int T[MAXN], V[MAXN];
deque<pld> d;

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

	cin >> N >> L;
	for(int i = 0; i < N; i++) cin >> T[i] >> V[i];

	cout << fixed;
	cout.precision(20);
	pld ep = make_pair(0.0L, 0.0L);
	for(int i = 0; i < N; i++) {
		d.push_front(make_pair(V[i], (ld) V[i] * T[i]));
		ep.fi = L;
		ep.se += (ld) V[i] * T[i];
		cout << ep.se / ep.fi << "\n";
		if(i == N - 1) break;
		while(d.size() > 1 && d[0].se / d[0].fi < d[1].se / d[1].fi) {
			d[1].fi += d[0].fi;
			d[1].se += d[0].se;
			d.pop_front();
		}
		while(!d.empty() && ep.fi - d.back().fi > L - V[i + 1]) {
			ep.fi -= d.back().fi;
			ep.se -= d.back().se;
			d.pop_back();
		}
		if(!d.empty()) {
			ld dse = d.back().se * (ep.fi - L + V[i + 1]) / d.back().fi;
			d.back().fi -= ep.fi - L + V[i + 1];
			ep.se -= dse;
			d.back().se -= dse;
			ep.fi = L - V[i + 1];
		}
	}
	return 0;
}


Measured memory_bytes: 35772
#include <iostream>
 
using namespace std;
 
long long num[256];
int main(){
	char A[200001];
	cin >> A;
 
	int i;
	for (i=0; A[i] != 0; i++) {
		num[A[i]]++;
	}
	long long len = i;
 
	long long max = len * (len - 1) / 2 + 1;
	for (int j = 0; j < 256; j++) {
		if (num[j] == 0) continue;
		// num C 2
		max -= (num[j] * (num[j]-1) / 2);
	}
 
	cout << max << endl;
 
	return 0;
}

Measured memory_bytes: 384
n,k = map(int,input().split())
p = pow(10,9)+7
li = [1]*(n+2)

counter = 0
k = min(k,n-1)

for a in range(1,n+1):
    li[a] = a*li[a-1]%p

def comb(a,b):
    if b<1:
        return 1
    return li[a]*pow(li[b],p-2,p)*pow(li[a-b],p-2,p)


for i in range(k+1):
    counter += comb(n,i)*comb(n-1,i)%p
    #nCi*  (n-1)Cn-i-1


    #n人をn-iのぐるーぷに分ける

print(counter%p)

Measured memory_bytes: 42604
#include <bits/stdc++.h>
using namespace std;
const int dir[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
const int INF = 1e9;

int h, w, k;
int x1, x2, y2;
vector<vector<char>> MP;
vector<vector<int>> dis;

bool outside(int x, int y) {
	return x < 0 or x >= h or y < 0 or y >= w;
}

bool bad(int x, int y, int nd) {
	return MP[x][y] == '@' or dis[x][y] < nd;
}

void bfs(int y1) {
	queue<pair<int, int>> que;
	que.push({x1, y1});
	dis[x1][y1] = 0;
	while (!que.empty()) {
		int x = que.front().first;
		int y = que.front().second;
		que.pop();
		for (int i = 0; i < 4; i++) {
			int nx = x, ny = y;
			int nd = dis[x][y] + 1;
			for (int j = 1; j <= k; j++) {
				nx += dir[i][0];
				ny += dir[i][1];
				if (outside(nx, ny) or bad(nx, ny, nd))
					break;
				if (dis[nx][ny] > nd) {
					que.push({nx, ny});
					dis[nx][ny] = nd;
				}
			}
		}
	}
}

int main() {
	int y1;
	cin >> h >> w >> k >> x1 >> y1 >> x2 >> y2;
	--x1, --y1, --x2, --y2;
	MP.resize(h, vector<char>(w));
	dis.resize(h, vector<int>(w));
	for (int i = 0; i < h; i++) 
		for (int j = 0; j < w; j++)
			cin >> MP[i][j], dis[i][j] = INF;
	bfs(y1);
	cout << (dis[x2][y2] == INF ? -1 : dis[x2][y2]);
}

Measured memory_bytes: 12008
n = int(input())
a = list(map(int, input().split()))
rui = [0] * n
cnt = 0
if a[0] > 0:
    rui[0] = a[0]
else:
    rui[0] = 1
    cnt += abs(a[0]) + 1
for i in range(1, n):
    tmp = rui[i - 1] + a[i]
    if tmp == 0:
        if rui[i - 1] > 0:
            rui[i] = tmp - 1
            cnt += 1
        else:
            rui[i] = tmp + 1
            cnt += 1
    else:
        if rui[i - 1] > 0 and tmp > 0:
            rui[i] = -1
            cnt += abs(tmp) + 1
        elif rui[i - 1] < 0 and tmp < 0:
            rui[i] = 1
            cnt += abs(tmp) + 1
        else:
            rui[i] = tmp

cnt1 = 0
if a[0] < 0:
    rui[0] = a[0]
else:
    rui[0] = -1
    cnt1 += abs(a[0]) + 1
for i in range(1, n):
    tmp = rui[i - 1] + a[i]
    if tmp == 0:
        if rui[i - 1] > 0:
            rui[i] = tmp - 1
            cnt1 += 1
        else:
            rui[i] = tmp + 1
            cnt1 += 1
    else:
        if rui[i - 1] > 0 and tmp > 0:
            rui[i] = -1
            cnt1 += abs(tmp) + 1
        elif rui[i - 1] < 0 and tmp < 0:
            rui[i] = 1
            cnt1 += abs(tmp) + 1
        else:
            rui[i] = tmp

print(min(cnt, cnt1))

Measured memory_bytes: 14332
#include<bits/stdc++.h>
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 15000
using namespace std;

template <typename T>
void print(T x){cout<<x<<"\n";}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<"\n";}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<"\n";}

int mincost(int jumps[],int n)
{
    vector<int> dp(n,0);

    dp[1]=abs(jumps[1]-jumps[0]);
    for(int i=2;i<n;i++) dp[i] = min(abs(jumps[i] - jumps[i - 1]) + dp[i - 1], abs(jumps[i] - jumps[i - 2]) + dp[i - 2]);

    return dp[n-1];
}

int main()
{
    io;
    ll test_case;
    //cin>>test_case;
    test_case=1;
    while(test_case--)
    {
        ll n;
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++) cin>>arr[i];
        cout<<mincost(arr,n)<<"\n";
    }   
}

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

using namespace std;
using ll = long long;

int main() {
    int k,a,b;
    cin>>k>>a>>b;
    for(int i = a;i <= b;++i) {
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        
        int N = stdIn.nextInt();
        int A = stdIn.nextInt();
        int answer = N*N-A;
        
        System.out.print(answer);
               
    }
    
}


Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,K,h,c=0;
    cin>>N>>K;
    for(int i=0;i<N;++i){
        cin>>h;
        if(h>=K)++c;
    }
    cout<<c<<endl;
    
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << (x) << endl;
#define T long long
#define mat vector<vector<T>>
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define cld complex<long double>
using namespace std;

int main(){
	fast_io();
	int n;cin >> n;
	vector<ll> v(n);
	ll s = 0;
	cu(i,0,n){cin >> v[i];s += v[i];}
	ll ans = -1;
	for(ll m = s - n * (n - 1); m <= s; ++m){
		ll cnt = 0;	
		cu(i,0,n){
			cnt += (v[i] + 1 + m)/(n + 1); 
		}
		if(cnt <= m){
			ans = m;
			break;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
# ここから入力
from itertools import combinations_with_replacement
from itertools import accumulate
n, m, q = map(int, input().split())
a = []
for i in range(q):
    a.append(list(map(int, input().split())))
# ここまで入力
# 重複組合せ
x = 0
for i in combinations_with_replacement(range(1, m + 1), n):
    ans = []
    for j in a:
        if i[j[1] - 1] - i[j[0] - 1] == j[2]:
            ans.append(j[3])
    if x < sum(ans):
        x = sum(ans)
print(x)



Measured memory_bytes: 9076
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

long long N, M;
vector<long long> DP;

int main() {
	cin >> N >> M;
	DP.resize(N,0);
	for (long long m = 0; m < M; m++) {
		long long a, b;
		cin >> a >> b;
		a--; b--;
		DP[min(a, b)]++;
		DP[max(a, b)]--;
	}
	for (long long n = 1; n < N; n++)DP[n] += DP[n - 1];
	for (long long n = 0; n < N; n++) {
		if (DP[n] & 1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

int A, B, C;

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

	cin >> A >> B >> C;
	
	int ans = B;
	if(C > 0) {
		if(C > (A + B))     ans += (A + B + 1);
		else				ans += C;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;


		BigDecimal delta = new BigDecimal("0.0000001");
		BigDecimal bn = new BigDecimal(n);

		for (int i = 1; i < n; i++) {

			BigDecimal sub = bn.divide(new BigDecimal(i).add(delta),MathContext.DECIMAL128);
			count += sub.intValue();
		}
		System.out.println(count);

	}
}


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

int main() {
  int a, b, c;
  cin >> a  >> b >> c;
  int plan1 = a * b;
  int plan2 = c;
  if (plan1 <= plan2) {
    cout << plan1;
  }else{
  	cout << plan2;
  }
}

Measured memory_bytes: 3644