akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		int nico = Integer.parseInt(sc.nextLine());
		
		for (int i = 0; i < nico; i++) {
			String[] params = sc.nextLine().split(" ");

			double x0 = Double.parseDouble(params[0]);
			double y0 = Double.parseDouble(params[1]);
			double r0 = Double.parseDouble(params[2]);
			double x1 = Double.parseDouble(params[3]);
			double y1 = Double.parseDouble(params[4]);
			double r1 = Double.parseDouble(params[5]);
			
			double d = Math.sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1));
			
			if (d > (r0 + r1)) {
				System.out.println("0");
			} else if (r0 > r1) {
				if ((d + r1) >= r0) {
					System.out.println("1");
				} else {
					System.out.println("2");
				}
			} else {
				if ((d + r0) >= r1) {
					System.out.println("1");
				} else {
					System.out.println("-2");
				}
			}
		}
	}
}

Measured memory_bytes: 25928
a, b = map(int, input().split())
m, n = a, b
c = 0

while n != 0:
    c = m % n
    m = n
    n = c

li = [1]
for i in range(2, int(m ** 0.5)+1):
    while m % i == 0:
        m //= i
        li.append(i)
li.append(m)

print(len(set(li)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
ll q[4], n, vs = linf, vd = linf;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  FOR(i, 0, 4) cin >> q[i];
  cin >> n;
  FOR(i, 0, 3) mins(vs, q[i] * (1ll<<(2-i)));
  FOR(i, 0, 4) mins(vd, q[i] * (1ll<<(3-i)));
  ll ans = 0;
  if(n%2) ans += vs;
  ans += n/2 * vd;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a;
int main()
{
    cin>>a;
    if(a==0)puts("0");
    else{
        ll ans=2*((a)/11);
        a%=11;
        if(a>6)ans++;
        if(a>0)ans++;
        printf("%lld\n",ans);
    }
}


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

#define ll long long

int main() {
    int n,ans = 0;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(i%2==1)ans++;
    }
    cout << fixed << setprecision(10) << (double)ans/n << endl;
}

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


int main() {
    int n;
    cin >> n;
    vector<pair<int, int> > tasks;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        tasks.emplace_back(b, a);
    }

    sort(tasks.begin(), tasks.end());
    bool flag = true;
    int sum = 0;

    for (auto v : tasks) {
        sum += v.second;
        if (sum > v.first) {
            flag = false;
            break;
        }
    }
    cout << (flag ? "Yes" : "No") << endl; 
    return 0;
}

Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int contest1 = 0;
        int contest2 = 0;
        int contest3 = 0;
        for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            if (p <= a) {
                contest1++;
            } else if (p > a && p <= b) {
                contest2++;
            } else if (p > b) {
                contest3++;
            }
        }
        int min = Math.min(contest1, contest2);
        System.out.println(Math.min(min, contest3));
    }

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define pb push_back
int mod=1e9+7;
int gcd (int a, int b) {
   while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll fast(ll a,ll n){
	a%=mod;
	ll res=1;
	while(n>0){
		if(n&1)res=res*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return res;
}
int digit_sum(int a){
	int sum=0;
	while(a){
		sum+=a%10;
		a/=10;
	}
	return sum;
}
	// vector<int> v;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	int a[n];
	f(i,n){
		cin>>a[i];
	}
	int dp[n];
	dp[0]=0;
	for(int i=1;i<n;i++)dp[i]=INT_MAX;
	// memset(dp,, sizeof dp);
	for(int i=1;i<n;i++){
		for(int j=1;j<=k;j++){
			if(i-j>=0)dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}



Measured memory_bytes: 4428
s=input()
i=0
n=len(s)

while i<n:
  if s[i:i+10]=="dreamerase":
    i+=5
  elif s[i:i+7]=="dreamer":
    i+=7
  elif s[i:i+5]=="dream":
    i+=5
  elif s[i:i+6]=="eraser":
    i+=6
  elif s[i:i+5]=="erase":
    i+=5
  else:
    break
print("YES" if i==n else "NO")

Measured memory_bytes: 68676
//In The Name Of The God

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define F first
#define S second
#define X first.first
#define Y first .second
#define A second.first
#define B second.second
#define mp make_pair
#define pb push_back
#define pf push_front
#define P push
#define pob pop_back
#define pof pop_front
#define PO pop
#define rep(i,j,k) for(int i = j ; i <= k ; ++ i)
#define rrep(i,j,k) for(int i = j ; i>=k ; --i)
#define FR(i,j,k) for(int i = j ; i < k ; ++ i )
#define rFR(i,j,k) for(int i = j ; i > k ; -- i )
#define lb(x) x&-x;
#define SZ size()
#define LB lower_bound
#define UB upper_bound
#define IT iterator
#define RIT reverse_iterator
#define E end()
#define BE begin()
#define RE rend()
#define RBE rbegin()
#define UN unsigned

typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll ;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<int,pll> pipl;
typedef pair<pll,int> ppli ;
typedef pair<pll,pll> plpl ;
typedef pair<ll,pii> lpip;
typedef pair<pii,ll> lppi;
typedef pair<pii,pii> lppp;
typedef pair<ll,pll> lpipl;
typedef pair<pll,ll> lppli ;
typedef pair<pll,pll> lplpl ;
typedef vector<int> vi ;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii > stpi;
typedef set<pll> stpl;
typedef vi::IT vit;
typedef vl::IT vlt;
typedef vpi::IT vpit;
typedef vpl::IT vplt;
typedef sti::IT stit;
typedef stl::IT stlt;
typedef stpi::IT stpit;
typedef stpl::IT stplt;
typedef vpi::RIT rvpit;
typedef vpl::RIT rvplt;
typedef sti::RIT rstit;
typedef stl::RIT rstlt;
typedef stpi::RIT rstpit;
typedef stpl::RIT rstplt;

const int MAXN = 500000;
const int SUPERN = 5000000;
const int MD = 1e9+7;
//......Variables........
string s1,s2,s3,re;
//......Funcs............

//......Code.............
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>s1>>s2>>s3;
    re.pb((char)(s1[0]-'a'+'A'));
    re.pb((char)(s2[0]-'a'+'A'));
    re.pb((char)(s3[0]-'a'+'A'));
    cout<<re;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a, b, c, d, e;
int main() {
	while (true) {
		cin >> a; if (a == 0)break;
		cin >> b >> c >> d >> e;
		int H = 0, I = 0;
		for (int i = 0; i <= e; i++) {
			int Y = c*i; if (Y > b)break;
			int P = (b - Y) / d;
			if (i + P < a)break;
			H = i, I = P;
		}
		if (H == 0)cout << "NA" << endl;
		else { cout << H << ' ' << I << endl; }
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
String S = sc.next();
String T = sc.next();
boolean answer=true;
int length=S.length();
ArrayList<Character> list = new ArrayList<Character>();
for(int i=0;i<length;i++){
char s=S.charAt(i);
char t=T.charAt(i);
  if(t!=s){
    S = S.replaceAll(String.valueOf(s), "0");
    S = S.replaceAll(String.valueOf(t), String.valueOf(s));
    S = S.replaceAll("0", String.valueOf(t));
    if(list.contains(t)){
      break;
    }else{
      list.add(t);
    }

  }
}




if(S.equals(T)){
  System.out.println("Yes");
}else{
  System.out.println("No");
}
}
}


Measured memory_bytes: 59828
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        while (true) {
            int n = Integer.parseInt(reader.readLine());
            if (n == 0) {
                break;
            }
            int sum = 0;
            while (true) {
                n = n / 5;
                if (n == 0) {
                    break;
                }
                sum += n;
            }
            out.println(sum);
        }
    }
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;
void fff()
{
	ll n;
	cin >> n;
	ll cur = 26;
	string ans = "";
	n--;
	while(n>=0)
	{
		cur = n%26;
		ans += char('a'+cur);
		n/=26;
		n--;
	}	
	reverse(all(ans));
	cout<<ans<<ln;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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


    int a, b, n;
    
    while(cin >> a >> b >> n) {
        int x[1000], y[1000], dp[1000][1000];
	if(!a && !b) break;
	rep(i, n) {
		cin >> x[i] >> y[i];
		x[i]--; y[i]--;
	}

	Fill(dp, -1);
	rep(i, n) dp[x[i]][y[i]] = 0;

	int t = 1;
	rep(i, a) {
		if(dp[i][0] == 0) t = 0;
		dp[i][0] = t;
	}

	t = 1;
	rep(i, b) {
		if(dp[0][i] == 0) t = 0;
		dp[0][i] = t;
	}

	rep(i, a) {
		rep(j, b) {
			if(dp[i][j] == -1) {
				dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			}
		}
	}

	// rep(i, a) {
	// 	rep(j, b) cout << dp[i][j] << " ";
	// 	cout << endl;
	// }

	cout << dp[a - 1][b - 1] << endl;
    }
	return 0;
}



Measured memory_bytes: 10912
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define zero(x) (((x)>0?(x):-(x))<eps)
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int>PII;
typedef pair<int,string>PIS;
const double eps=1e-9;
const double pi=acos(-1.0);
const int inf=1e9+7;
const int INF=0x3f3f3f3f;
//LL powmod(LL a,LL b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int a[100010];
LL p[100010];
int main(){
//    freopen("in.in","r",stdin);
//    freopen("out.out",";w",stdout);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    p[0]=0;
    for(int i=1;i<=n;i++) p[i]=p[i-1]+a[i];
    for(int i=n;i>=1;i--){
        if(a[i]>p[i-1]*2){
            cout<<n-i+1<<endl;
            break;
        }
    }
    return 0;
}


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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<double,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

string v = "aiueo";

int solve(){
    int n;
    cin >> n;
    if(n == 0) return 1;
    vector<string> s(n), code(n);
    int l = 0;
    for(int i=0;i<n;i++){
        cin >> s[i];
        code[i].push_back(s[i].front());
        for(int j=1;j<int(s[i].size());j++){
            if(v.find(s[i][j-1]) != v.npos){
                code[i].push_back(s[i][j]);
            }
        }
        l = max(l, int(code[i].size()));
    }
    set<string> st;
    for(int k=1;k<=l;k++){
        st.clear();
        for(int i=0;i<n;i++){
            st.insert(code[i].substr(0,min(int(code[i].size()),k)));
        }
        if(st.size() == n){
            cout << k << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

int main(){
    // solve();
    while(solve()==0);
    // int t; cin >> t; for(;t>0;t--) solve();
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
	cin>>n;
	ll x,y;
	ll inf = 1e18;
	pair<ll,ll> ans[4];
	for(int i=0;i<4;i++)
	ans[i]={-inf,inf};
	for(int i=0;i<n;i++){
		cin>>x>>y;
		ans[0].first=max(ans[0].first,x+y);
		ans[0].second=min(ans[0].second,x+y);
		
		ans[1].first=max(ans[1].first,-x+y);
		ans[1].second=min(ans[1].second,-x+y);
		
		
		ans[2].first=max(ans[2].first,x-y);
		ans[2].second=min(ans[2].second,x-y);
		
		
		ans[3].first=max(ans[3].first,-x-y);
		ans[3].second=min(ans[3].second,-x-y);
	}
	ll final = ans[0].first-ans[0].second;
	final = max(final ,ans[1].first-ans[1].second);
	final = max(final ,ans[2].first-ans[2].second);
	final = max(final ,ans[3].first-ans[3].second);
	cout<<final;
	return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

struct union_find {
    int n;
    vi d;
    union_find() {}
    union_find(int n_): n(n_), d(n, -1) {}
    int root(int v) {
        if (d[v] < 0) {
            return v;
        }
        return d[v] = root(d[v]);
    }
    int size(int v) {
        return -d[root(v)];
    }
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return false;
        }
        if (size(x) < size(y)) {
            swap(x, y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    }
};

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if ( n == 0 ) { break; }
        vvi edges(m);
        rep (i, m) {
            int a, b, cost;
            cin >> a >> b >> cost;
            edges[i] = {cost, a, b};
        }
        sort(all(edges));

        int ans = 0;
        union_find uf(n);
        rep (i, m) {
            if ( uf.unite(edges[i][1], edges[i][2]) ) {
                ans += edges[i][0];
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3220
N = int(input())
a = []
list = []
a = input().split()

for i in range(N):
  list.append(int(a[i]))

cost = []
cost.append(abs(list[0]-list[1]))
if N > 2:
  cost.append(abs(list[0]-list[2]))
if N > 2:
  for i in range(3,N):
    cost.append(min(cost[i-3]+abs(list[i-2]-list[i]),cost[i-2]+abs(list[i-1]-list[i])))
  print(cost[-1])
else:
  print(cost[-1])

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        long n = sc.nextLong();
        long total = pow(10, n);
        long one = pow(9, n);
        long both = pow(8, n);
        long res = (total - (2 * one - both) % mod) % mod;
        if (res < 0) res += mod;
        out.println(res);
        out.close();
    }

    static long[] fac;
    static long mod = (long) 1e9 + 7;

    static void initFac(long n) {
        fac = new long[(int)n + 1];
        fac[0] = 1;
        for (int i = 1; i <= n; i++) {
            fac[i] = (fac[i - 1]  * i) % mod;
        }
    }



    static long nck(int n, int k) {
        if (n < k)
            return 0;
        long den = inv((int) (fac[k] * fac[n - k] % mod));
        return fac[n] * den % mod;
    }

    static long pow(long b, long e) {
        long ans = 1;
        while (e > 0) {
            if (e % 2 == 1)
                ans = ans * b % mod;
            e >>= 1;
            b = b * b % mod;
        }
        return ans;
    }

    static long inv(long x) {
        return pow(x, mod - 2);
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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


    }

}

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

using namespace std;
 
int main() {
  int n;
  cin >> n;
  const int MAX = 60;
  vector<vector<int>> cnt(MAX, vector<int>(MAX));
  for (int i = 0; i < n; i++) {
    long double x;
    cin >> x;
    long long y = (long long) (x * 1e9 + 0.5);
    int a = 0, b = 0;
    while (y % 2 == 0) {
      y /= 2;
      a += 1;
    }
    while (y % 5 == 0) {
      y /= 5;
      b += 1;
    }
    cnt[a][b] += 1;
  }
  long long ans = 0;
  for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX; j++) {
      for (int ii = 0; ii < MAX; ii++) {
        for (int jj = 0; jj < MAX; jj++) {
          if (i + ii >= 18 && j + jj >= 18) {
            if (i == ii && j == jj) {
              ans += (long long) cnt[i][j] * (cnt[i][j] - 1);
            } else {
              ans += (long long) cnt[i][j] * cnt[ii][jj];
            }
          }
        }
      }
    }
  }
  cout << ans/2 << '\n';
  return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
#define INF 1000000000
struct edge { int to, cost; };
typedef pair<int, int> P;
int V;
vector<edge> G[100];
int d[100][100];
int news[100];
void dijkstra(int s,int d[]) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
int n,k;
bool solve(){
    scanf("%d%d",&n,&k);
    if(n == 0 && k == 0)
        return false;
    V = n;

    REP(i,n)
        G[i].clear();
    REP(i,n)
        REP(j,n)
            d[i][j] = INF * (i != j);

    int ne = 0;
    REP(i,n)
        news[i] = 0;
    REP(i,k){
        int g;
        scanf("%d",&g);
        if(g){
            int c,d,e;
            scanf("%d%d%d",&c,&d,&e);
            ne++;
            G[c - 1].pb((edge){d - 1,e});
            G[d - 1].pb((edge){c - 1,e});
        }else{
            int a,b;
            scanf("%d%d",&a,&b);
            a--;b--;
            if(ne > news[a] && ne == news[b])
                swap(a,b);

            if(ne > news[a]){
                dijkstra(a,(int*)(d + a));
                news[a] = ne;
            }
            printf("%d\n",d[a][b] < INF ? d[a][b] : -1);
        }
    }
    return true;
}

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

Measured memory_bytes: 3288
#include<iostream>
using namespace std;
int main()
{

     int r;
     string s;//SUN, MON, TUE, WED, THU, FRI, or SAT
     cin>>s;

     if(s=="SUN"){
        r=7;
     }
     else if(s=="MON"){
        r=6;
     }

    else if(s=="TUE"){
        r=5;
     }
     else if(s=="WED"){
        r=4;
     }
     else if(s=="THU"){
        r=3;
     }
     else if(s=="FRI"){
        r=2;
     }
     else if(s=="SAT"){
        r=1;
     }

     cout<<r<<endl;



    return 0;
}

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

using namespace std;
using ll = long long;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++)cin >> A.at(i);

    ll res = 0;
    for(int i=1; i<N; i++){
        if(A.at(i) < A.at(i-1)){
            res += A.at(i-1) - A.at(i);
            A.at(i) = A.at(i-1);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 4788
S = map(int, raw_input().split())
A = S[0]
B = S[1]
C = S[2]
X = S[3]
Y = S[4]

if X > Y:
    A = S[1]
    B = S[0]
    X = S[4]
    Y = S[3]

totals = []
for i in range(Y + 1):
    total = 0
    total += C * 2 * i
    if i < X:
        total += A * (X - i)
    if i < Y:
        total += B * (Y - i)

    totals.append(total)

print(sorted(totals)[0])


Measured memory_bytes: 8964
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np



def main():
	n=int(input())
	w=[input().rstrip().decode('utf-8') for _ in range(n)]
	
	now=w[0][-1]
	
	ans="Yes"
	
	wset=set(w)
	if len(wset)!=n:
		ans="No"
		
	for i in range(1,n):
		if now!=w[i][0]:

			ans="No"
		now=w[i][-1]

	
	print(ans)
	




if __name__ == "__main__":
	main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int a,b,c;
    cin >> a >>b >>c;
    cout << min({a+b,a+c,b+c}) << '\n';
    return 0;
}


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

int main() {
	int n, m, Q;
	cin >> n >> m >> Q;
	vector<int> l(m), r(m), p(Q), q(Q);
	rep(i, m) {
		cin >> l[i] >> r[i];
		l[i]--; r[i]--;
	}
	rep(i, Q){
		cin >> p[i] >> q[i];
		p[i]--; q[i]--;
	}
	vector<vector<int>> v(n, vector<int>(n));
	rep(i, m) {
		v[l[i]][r[i]]++;
	}
	rep(i, n) {
		rep(j, n-1) {
			v[i][j+1] += v[i][j];
		}
	}
	rep(j, n) {
		for(int i = n-1; i > 0; i--) {
			v[i-1][j] += v[i][j];
		}
	}
	rep(i, Q) {
		printf("%d\n", v[p[i]][q[i]]);
	}
	return 0;
}

Measured memory_bytes: 4224
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
#ifdef AIM
#include <sys/resource.h>
#endif
using namespace std;

#define all(a) a.begin(), a.end()
using li = long long;
using ld = long double;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
  freopen("/home/alexandero/CLionProjects/ACM/input.txt", "r", stdin);
  //freopen("/home/alexandero/CLionProjects/ACM/output.txt", "w", stdout);
//freopen("out.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif

#ifdef AIM
  const rlim_t kStackSize = 256 * 1024 * 1024;
  struct rlimit rl;
  int result;

  result = getrlimit(RLIMIT_STACK, &rl);
  if (result == 0) {
    if (rl.rlim_cur < kStackSize) {
      rl.rlim_cur = kStackSize;
      result = setrlimit(RLIMIT_STACK, &rl);
      if (result != 0) {
        fprintf(stderr, "setrlimit returned result = %d\n", result);
      }
    }
  }
#endif

  start = clock();
  int t = 1;
#ifndef AIM
  cout.sync_with_stdio(0);
  cin.tie(0);
#endif
  cout.precision(20);
  cout << fixed;
  //cin >> t;
  precalc();
  while (t--) {
    solve(true);
  }
  cout.flush();

#ifdef AIM1
  while (true) {
    solve(false);
  }
#endif

#ifdef AIM
  cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif
  return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
  if (!w)
    return 1 % mod;
  if (w & 1)
    return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template<typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

template<typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}

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

void precalc() {

}

//#define int li
//const li mod = 1000000007;
//const int mod = 998244353;
//using ull = unsigned long long;


void solve(__attribute__((unused)) bool read) {
  int n, m, len;
  cin >> n >> m >> len;
  int x, y;
  cin >> x >> y;
  --x; --y;
  string s[2];
  cin >> s[0] >> s[1];
  map<char, int> index;
  string vals = "LRUD";
  for (int i = 0; i < 4; ++i) {
    index[vals[i]] = i;
  }
  vector<int> positions = {y, y, x, x};
  vector<int> need = {-1, m, -1, n};
  for (int i = 0; i < len; ++i) {
    auto ind = index[s[0][i]];
    if (ind % 2 == 0) {
      --positions[ind];
    } else {
      ++positions[ind];
    }
    for (int j = 0; j < 4; ++j) {
      if (positions[j] == need[j]) {
        cout << "NO\n";
        return;
      }
    }
    ind = index[s[1][i]];
    ind ^= 1;
    if (ind % 2 == 0) {
      positions[ind] = min(positions[ind] + 1, need[ind ^ 1] - 1);
    } else {
      positions[ind] = max(0, positions[ind] - 1);
    }
  }
  cout << "YES\n";
}

Measured memory_bytes: 920
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

static const int MMAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1 << 29);

int main(){
    int n,m;
    int C[MMAX+1];
    int T[NMAX+1];
    
    cin >> n >> m;
    
    for(int i=1;i<=m;i++){
        cin >> C[i];
    }
    
    for(int i=0;i<=NMAX;i++) T[i] = INFTY;
    T[0] = 0;
    for(int i=1;i<=m;i++){
        for(int j=0;j+C[i]<=n;j++){
            T[j+C[i]] = min(T[j+C[i]],T[j]+1);
        }
    }
    
    cout << T[n] << endl;

    return 0;
}



Measured memory_bytes: 3308
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<long long>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  cout<<a[n-1]-a[0]<<endl;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N, x;
  cin >> N >> x;
  int M = 2 * N -1;
  if(x == 1 || x == M){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
    x--;

    vector<int> used(M);
    vector<int> ans(M);

    int now = 0;
    if(x != 1){
      used[x-2] = 1;
      used[x+1] = 1;
      used[x] = 1;
      used[x-1] = 1;
      for(int i = 0; i < M; i++){
        if(i == N-2){
          ans[i] = x-2;
          
        }else if(i == N-1){
          ans[i] = x+1;
          
        }else if(i == N){
          ans[i] = x;
          
        }else if(i == N+1){
          ans[i] = x-1;
          
        }else{
          while(used[now] == 1){
            now++;
          }
          ans[i] = now;
          used[now] = 1;
        }
      }
    }else{
      used[x+1] = 1;
      used[x] = 1;
      used[x-1] = 1;
      if(x+2 < M){
        used[x+2] = 1;
      }
      for(int i = 0; i < M; i++){
        if(i == N-2){
          ans[i] = x+1;
          
        }else if(i == N-1){
          ans[i] = x;
          
        }else if(i == N){
          ans[i] = x-1;
          
        }else if(i == N+1){
          ans[i] = x+2;
          
        }else{
          while(used[now] == 1){
            now++;
          }
          ans[i] = now;
          used[now] = 1;
        }
      }
    }

    for(int i = 0; i < M; i++){
      cout << ans[i] +1 << endl;
    }


  }


  return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MAXX 1000000000000000000

int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int a,b,c;
	cin >> c >> b >> a;
	b--;
	if(a/c > b/c)
	{
		cout<<"OK";
	}
	else
	{
		cout << "NG";
	}	
	return 0;
}

Measured memory_bytes: 3644
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main()
{

	int d, n;
	cin >> d >> n;
	LL i = 0;
	LL c = 0;
	while (i < n) {
		c++;
		if (d == 0 && c % 100 != 0) i++;
		if (d == 1 && c % 100 == 0 && c % 10000 != 0) i++;
		if (d == 2 && c % 10000 == 0 && c % 1000000 != 0) i++;
	}
	cout << c << endl;
	return 0;
}



Measured memory_bytes: 256
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = int(1e9)

def f(x):
    count = 0
    for a in A:
        count += int((a-1)/x)
    return count <= K

while r-l > 1:
    x = int((r+l)/2)
    if f(x):
        r = x
    else:
        l = x
print(r)

Measured memory_bytes: 31048
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long A,B,C,K,sum=0;
    cin>>A>>B>>C>>K;
    if(A>=K){
        cout << K ;
        return 0;
    }
    else
    {
        K-=A;
        sum+=A;
    }
    if(B>=K){
        cout << sum ;
        return 0;
    }
    else{
        K-=B;
    }
    if(C>=K){
        cout << sum-K ;
        return 0;
    }
    else{
        K-=C;
        sum-=K;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3620
program main
      implicit none
      integer(8) :: a, b, c, k, l, cnt

      read *, a, b, c, k
     
      if ( k > (a+b) ) then
        cnt = a - ( k-a-b )
      else 
        if ( k < a ) then 
          cnt = k
        else
          cnt = a
        end if
      end if

      print *, cnt

end program main


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

using namespace std;

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    ll A, B, N;
    cin >> A >> B >> N;
    if (N >= B)
    {
        cout << int(floor(A * 1.0 * (B - 1) / B)) << "\n";
    }
    else
    {
        cout << int(floor(A * 1.0 * N / B)) << "\n";
    }
    return 0;
}

Measured memory_bytes: 3700
#include<cstdio>
using namespace std;
const int maxn=200005,TT=998244353;
int n,m,K;long long ans,fct[maxn],ifct[maxn];
long long pw(long long x,long long y){
	long long ret=1,w=x%TT;
	while(1){
		if(y&1) ret=ret*w%TT;
		if(!(y>>=1)) return ret;
		w=w*w%TT;
	}
}
int main(){
	scanf("%d%d%d",&n,&m,&K);
	for (int i=fct[0]=1;i<=n;i++) fct[i]=fct[i-1]*i%TT;
	ifct[n]=pw(fct[n],TT-2);
	for (int i=n;i;i--) ifct[i-1]=ifct[i]*i%TT;
	for (int i=0;i<=K;i++)
	ans+=fct[n-1]*ifct[i]%TT*ifct[n-1-i]%TT*pw(m-1,n-1-i)%TT*m%TT;
	printf("%lld\n",ans%TT);
	return 0;
}

Measured memory_bytes: 4800
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N,i;
    cin >> N >> i;
    cout << N-i+1 << endl;
    
    
    return 0;
}




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

#define _CRT_SECURE_NO_WARNINGS

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

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

	set<int> st;
	for (int i = 0; i < 3; i++) {
		int t;
		cin >> t;
		st.insert(t);
	}

	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 3004
#define INF 1e9+7

using namespace std;

ll n,m,mod=1e9+7;
char ar[N][N];
ll dp[N][N];

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

    cin >> n >> m;

    rep(i,1,n+1)
    {
        rep(j,1,m+1)
        {
            cin >> ar[i][j];
        }
    }

    rep(i,1,n+1)
    {
        rep(j,1,m+1)
        {
            if(ar[i][j] == '#')
                dp[i][j]=  0;
            else if(i == 1 && j== 1)
                dp[i][j]=1;
            else
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        }
    }

    cout << dp[n][m];

    return 0;
}



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

const int M = 1e9+7;

int main() {
	int h , w , i , j , k , l;
	cin >> h >> w;
	int dp[h+1][w+1];
	string s[h+1];
	for(i=1;i<=h;i++) {
	    cin >> s[i];
	    s[i] = '@'+ s[i];
	}
	for(i=0;i<=h;i++) for(j=0;j<=w;j++) dp[i][j] = 0;
	for(i=1;i<=h;i++) {
	    for(j=1;j<=w;j++) {
	        if(i == 1 and j == 1) {
	            dp[i][j] = 1;
	            continue;
	        }
	        if(s[i][j] == '#') continue;
	        dp[i][j] = ( (dp[i-1][j] % M) + (dp[i][j-1] % M) ) % M;
	    }
	}
	cout << dp[h][w];
	return 0;
}

Measured memory_bytes: 5120
x, n = map(int, input().split())
if n > 0:
  p = sorted(list(map(int, input().split())))
  if not x in p:
    print(x)
  else:
    ans = 0
    m = 1000
    for i in range(0, 102):
      if not i in p:
        d = abs(x-i)
        if d < m:
          m = d
          ans = i
    print(ans)
else:
  print(x)

Measured memory_bytes: 9136
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

long long powmod(lint a,lint b){
  return b?powmod(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;
}

int main(void){
    lint N;
    lint div2=powmod(2,MOD-2);
    cin >> N;
    lint A[N];
    lint Amod[N];
    rep(i,N){
        cin >> A[i];
        Amod[i]=A[i]%MOD;
    }
    lint ans=0;
    lint sum=0;
    lint minus=0;
    rep(i,N) sum=(sum+Amod[i]*(N-1))%MOD;
    lint bitcount[60]={};
    rep(i,N){
        rep(j,60) if(A[i]&1LL<<j) bitcount[j]++;
    }
    rep(i,60){
        lint bito=(1LL<<i)%MOD;
        minus=(minus+((bito*((bitcount[i]*(bitcount[i]-1))%MOD))%MOD))%MOD;
    }
    sum-=minus;
    if(sum<0) sum+=MOD;
    cout << sum << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <algorithm>
using namespace std;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int INFTY = (1<<21);
static const int MAX = 100;

int n, M[MAX][MAX];

int prim(){
    int u,minv;
    int d[MAX],p[MAX], color[MAX];
    
    for(int i = 0; i < n; i++){
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }
    d[0] = 0;
    
    while(1){
        minv = INFTY;
        u = -1;
        for(int i = 0; i < n; i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1)break;
        color[u] = BLACK;
        for(int v = 0; v < n; v++){
            if(color[v] != BLACK && M[u][v] != INFTY){
                if(d[v] > M[u][v]){
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for(int i = 0; i < n; i++)if(p[i] != -1)sum += M[i][p[i]];
                return sum;
    }   

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            int e; cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }
    cout << prim() << endl;
    
    return 0;
}




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

int main() {
  long long k;
  cin >> k;
  
  int ans = 1;
  long long now = 7;
  for(int i = 0; i < k+1; i++){
    now %= k;
    if(now == 0){
      cout << ans << endl;
      return 0;
    }
    now = now*10 + 7;
    ans++;
  }
  
  cout << -1 << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int H1, M1, H2, M2, K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;
	int T = (H2 - H1) * 60 + M2 - M1;
	cout << T - K << endl;
	return 0;
}

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

ans = []
while len(b) > 0:
    ind = -1
    for i in range(len(b)):
        if b[i] == i + 1:
            ind = i
    if ind == -1:
        break
    else:
        ans.append(b.pop(ind))
    
if ind == -1:
    print(-1)
else:
    print(*ans[::-1], sep='\n')

Measured memory_bytes: 38512