akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,t,c,a;
    cin >> n >> t;
    int ans = 1e9;
    rep(i,n){
        cin >> c >> a;
        if (a <= t) chmin(ans,c);
    }
    if (ans != 1e9) PRINT(ans);
    else PRINT("TLE");
}





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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (int i = 0; i < H; i++)
    {
        cin >> s[i];
    }

    for(int i = 0; i <= W + 1; i++) cout << "#";
    cout << endl;
    for (int i = 0; i < H; i++)
    {
        cout << "#";
        cout << s[i];
        cout << "#" << endl;
    }
    for(int i = 0; i <= W + 1; i++) cout << "#";
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;
typedef long long ll;

int main(){
    int a, b;
    string s;
    cin >> a >>b >> s;
    string ans="Yes";
    for (int i = 0; i < a; i++)
    {
        if(!(s[i]>='0' && s[i]<='9')) ans = "No";
    }
    if(s[a]!='-') ans = "No";
    for (int i = a+1; i < a+b+1; i++)
    {
        if(!(s[i]>='0' && s[i]<='9')) ans = "No";
    }
    
    cout << ans << endl;
}


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

// Template for atcoder
public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};

    void solve() throws IOException {
        int n = nextInt();
        int[][] mat = new int[n][3];
        for (int i = 0; i < n; i++) {
            mat[i] = nextIntArr(3);
        }
        int[] dp = new int[4];
        Arrays.fill(dp, -1);
        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            int[] nxt = new int[4];
            Arrays.fill(nxt, -1);
            for (int j = 0; j < 4; j++) {
                if (dp[j] < 0) {
                    continue;
                }

                for (int k = 1; k < 4; k++) {
                    if (k != j) {
                        nxt[k] = Math.max(nxt[k], mat[i][k - 1] + dp[j]);
                    }
                }
            }

            dp = nxt;
        }
        int res = Integer.MIN_VALUE;
        for (int v : dp) {
            res = Math.max(res, v);
        }
        outln(res);
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


Measured memory_bytes: 61412
#include <iostream>
#include <cmath>
using namespace std;
const int INF = 1001001001;

int main() {
	int n, k;
	cin >> n >> k;
	int h[100001];
	for (int i = 0; i < n; ++i) cin >> h[i];

	int dp[100001];
	for (int i = 0; i < n; ++i) dp[i] = INF;
	dp[0] = 0;
	for (int i = 0; i < n-1; ++i) {
		for (int j = 1; j <= k && i + j < n; ++j) {
			dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
		}
	}

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

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<ll, ll>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  ll H;
  cin >> N >> H;
  ll a[N], b[N];
  for (int i = 0; i < N; i++) cin >> a[i] >> b[i];

  vector<P> p(N);
  for (int i = 0; i < N; i++) p[i] = P(a[i], -b[i]);
  sort(p.begin(), p.end());

  // 振るのは、一番大きいダメージを与えられる刀のみで良い。投げつけて与えられるダメージが振って与えられる最大ダメージより大きい間はそっちを使ったほうがいい
  vector<ll> v;
  for (int i = N - 2; i >= 0; i--) v.push_back(-p[i].second);
  sort(v.begin(), v.end());

  ll ans = 0;
  for (int i = v.size() - 1; i >= 0; i--) {
    if (p[N-1].first >= v[i]) break;

    H -= v[i];
    ans++;
    if (H <= 0) break;
  }

  // 解答
  if (H <= 0) {
    cout << ans << endl;
  } else {
    // 振る刀も、最後は投げつけた方が良いことに注意
    if (H - (-p[N-1].second) > 0) {
      H -= (-p[N-1].second);
      ans += (H + p[N-1].first - 1) / p[N-1].first;
    }

    cout << ans + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 4472
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, x, y int
	fmt.Scanf("%d %d %d", &n, &x, &y)

	// index is from 1 to n - 1 (do not use 0)
	countForK := make([]int, n)

	for i := 1; i <= n-1; i++ {
		for j := i + 1; j <= n; j++ {
			dNormal := j - i

			dXToI := int(math.Abs(float64(x - i)))
			dYToJ := int(math.Abs(float64(y - j)))
			dShortcut := dXToI + 1 + dYToJ

			k := int(math.Min(float64(dNormal), float64(dShortcut)))

			countForK[k]++
		}
	}

	for k := 1; k <= n-1; k++ {
		fmt.Println(countForK[k])
	}
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int Q = sc.nextInt();
		int[] l = new int[Q];
		int[] r = new int[Q];
		for(int i = 0; i < Q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}
		boolean[] dp = new boolean[100000];
		dp[0] = dp[1] = true;
		int[] likeNo = new int[100000];
		List<Integer> prime = new LinkedList<Integer>();
		for(int i = 2; i < 100000; i++) {
			if(dp[i]) {
				likeNo[i] = likeNo[i - 1];
				continue;
			}
			prime.add(i);
			if(dp[(i + 1) / 2]) {
				likeNo[i] = likeNo[i - 1];
			} else {
				likeNo[i] = likeNo[i - 1] + 1;
			}
			for(int j = i * 2; j < 100000; j += i) {
				dp[j] = true;
			}
		}
		for(int i = 0; i < Q; i++) {
			System.out.println(likeNo[r[i]] - likeNo[l[i] - 1]);
		}
	}
}

Measured memory_bytes: 71816
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#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,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1e9+7;



void solve(){
    int d,t,s;
    cin >> d >> t >> s;
    if (d <= s*t){
        cout << "Yes";
    }
    else cout << "No";
};



int main() {
    int T;
    //cin >> T;
    T = 1;
    while (T--) {
        solve();
        cout << endl;
    }
}




Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>

int main() {
	int rect = 0, lozen = 0, a = 0, b = 0, c = 0;
	while (std::scanf("%d,%d,%d",&a,&b,&c) != EOF) {
		if (a == b) ++lozen;
		if (a * a + b * b == c * c) ++rect;
	}
	std::cout << rect << std::endl << lozen << std::endl;
	return 0;
}


Measured memory_bytes: 3032
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

#define f first
#define s second
#define endl "\n"
#define pb push_back
#define  oo 0x3f3f3f3f
#define limit 1000000007
#define two pair<int,int>
#define mod(x,m) ((x%m+m)%m)
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define fori(x,n) for(int i = x; i < n; i++)
#define forj(y,m) for(int j = y; j < m; j++)
#define fork(z,p) for(int k = z; k < p; k++)
#define fastio std::ios::sync_with_stdio(false)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define input_from_file  freopen("input.txt", "r", stdin);

int main(){
   //input_from_file;
   fastio;
   double w,h,x,y; cin>>w>>h>>x>>y;
   double area = (w*h)/2;
   cout<<area<<" ";
   if(x == w/2 && y == h/2) cout<<1<<endl;
   else cout<<0<<endl;
}


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

int main(){
    int n;
    scanf("%d",&n);
    int arr[n][3];
    for(int i=0;i<n;i++){
        scanf("%d %d %d",&arr[i][0],&arr[i][1],&arr[i][2]);
    }
    long long dp[n][3];
    dp[0][0]=arr[0][0], dp[0][1]=arr[0][1], dp[0][2]=arr[0][2];
    for(int i=1;i<n;i++){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2])+arr[i][0];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2])+arr[i][1];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1])+arr[i][2];
    }
    printf("%lld",max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]));
    return 0;
}

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

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(Re int i = a;i <= b;++i)
#define nfor(i,a,b) for(Re int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};
LL gcd (LL a,LL b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    LL a,b,c,d;
    LL ans=0;
    cin>>a>>b>>c>>d;
    a--;
    LL cc=b/c-a/c;
    LL dd=b/d-a/d;
    LL g=gcd(c,d);
    g=c/g*d;
    LL e=b/g-a/g;
    ans=b-a-cc-dd+e;
    cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int powi(int base, int expt) {
  if (expt == 1) return base;
  if (expt % 2 == 0) {
    int tmp = powi(base, expt / 2);
    return tmp * tmp;
  } else {
    return base * powi(base, expt - 1);
  }
}

int main() {
  int X; cin >> X;
  int ans = 1;
  for (int b = 2; ; b++) {
    if (b > X) break;
    for (int p = 2; ; p++) {
      if (powi(b, p) > X) break;
      ans = max(ans, powi(b, p));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define INF 100000000

bool check(ll a){
  bool flag3 = false;
  bool flag5 = false;
  bool flag7 = false;
  string y = to_string(a);
  rep(i,y.size()){
      if(y[i] == '3') flag3 = true;
      if(y[i] == '5') flag5 = true;
      if(y[i] == '7') flag7 = true;
  }
  if(flag3 && flag5 && flag7) return true;
  else return false;
}


int main(){
  int a;
  cin >> a;
  int count = 0;
  function<ll(ll)>  dfs = [&](ll b){
    if(b <= a){
      if(check(b)) count++;
      //cout << b<< " " <<count << endl;
      ll num3 = dfs(b*10 + 3);
      ll num5 = dfs(b*10 + 5);
      ll num7 = dfs(b*10 + 7);      
    }
    return count;
  };
  cout << dfs(0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w,k;
	cin>>h>>w>>k;
	bitset<9> mask;
	int ans = numeric_limits<int>::max();
	vector<vector<bool> > inp(h,vector<bool>(w));
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char temp;
			cin>>temp;
			inp[i][j]=temp-'0';
		}
	}
	
	//int ans=numeric_limits<int>::max();
	while(true){

		int len = mask.count()+1;
		vector<int> present(len,0);
		vector<int> temp(len,0);
		int counter=mask.count();
		for(int i=0;i<w;i++){
			temp.clear();
			int sum=inp[0][i];
			bool flag=false;
			for(int j=1;j<h;j++){
				if(mask[j-1]){
					if(sum>k){
						flag=true;
						break;
					}
					temp.push_back(sum);
					sum=inp[j][i];
				}
				else{
					sum+=inp[j][i];
				}
			}
			//cout<<"SAJID"<<endl;
			if(sum>k){
				flag=true;
			}
			temp.push_back(sum);
			if(flag){
				counter=numeric_limits<int>::max();
				break;
			}
			//cout<<"Goku"<<endl;
			assert(temp.size()==present.size());
			bool my_flag=false;
			for(int j=0;j<len;j++){
				if(present[j]+temp[j]>k){
					my_flag=true;
				}
			}
			if(my_flag){
				counter++;
				present=temp;
			}
			else{
				for(int j=0;j<len;j++){
					present[j]+=temp[j];
				}
			}
			//cout<<"Gohan"<<endl;
		}
		//cout<<"Wajid"<<endl;
		ans=min(ans,counter);
		if(mask.count()==h-1){
			break;
		}
		mask=mask.to_ulong()+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[2000000], ans, dp[10000000],a[2000000], b[2000000];
string str;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n >> m;
	if (n + m == 15)
		cout<<"+"<<endl;
	else if(n*m==15)
		cout<<"*"<<endl;
	else
		cout<<"x"<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
double p[6],q[6];
int main(){
	rep(i,6) cin>>p[i],p[i]/=100;
	rep(i,6) cin>>q[i],q[i]/=100;
	vector<double> xs;
	rep(i,6){
		if(p[i]==0&&q[i]==0) continue;
		xs.pb(q[i]/(p[i]+q[i]));
	}
	double ans=1;
	for(double x:xs){
		double s=0;
		rep(i,6){
			s+=max(x*p[i],(1-x)*q[i]);
		}
		chmin(ans,s);
	}
	printf("%.12f\n",ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  int N, X, minv = 1000000, a, sum = 0;
  cin >> N >> X;

  for (int i = 0; i < N; i++) {
    cin >> a;
    sum += a;
    minv = min(a, minv);
  }

  printf("%d\n", N + ((X - sum) / minv));
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);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 ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int px = sx;
    int py = sy;
    vector<char> res;

    // 1
    REP(i, ty - sy) { res.push_back('U'); }
    REP(i, tx - sx) { res.push_back('R'); }

    // 2
    REP(i, ty - sy) { res.push_back('D'); }
    REP(i, tx - sx) { res.push_back('L'); }

    // 3
    res.push_back('L');
    REP(i, ty - sy) { res.push_back('U'); }
    res.push_back('U');
    res.push_back('R');
    REP(i, tx - sx) { res.push_back('R'); }
    res.push_back('D');

    // 4
    res.push_back('R');
    REP(i, ty - sy) { res.push_back('D'); }
    res.push_back('D');
    res.push_back('L');
    REP(i, tx - sx) { res.push_back('L'); }
    res.push_back('U');

    REP(i, res.size()) {
        cout << res[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, b, f, r, v;
  cin >> n;

  int house[4][3][10] = {0};

  for(int i = 0; i < n;i++){
    cin >> b >> f >> r >> v;
    house[b-1][f-1][r-1] += v;
  }

  for(int i =0;i < 4;i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 10; k++){
        cout << " " << house[i][j][k];
      }
      cout << endl;
    }
    if(i != 3){
      cout << "####################" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

ll n;
set<ll> st;

void dfs(ll num) {
  if (n < num) return;
  st.insert(num);
  dfs(num * 10 + 7);
  dfs(num * 10 + 5);
  dfs(num * 10 + 3);
}

int main() {
  cin >> n;
  dfs(0);
  int ans = 0;
  for (auto a : st) {
    bool ok1 = false;
    bool ok2 = false;
    bool ok3 = false;
    string s = to_string(a);
    REP(i, s.size()) {
      if (s[i] == '7') ok1 = true;
      if (s[i] == '5') ok2 = true;
      if (s[i] == '3') ok3 = true;
    }
    if (ok1 && ok2 && ok3) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  string s;
  cin >> s;
  int n = sz(s);
  rep(i, n / 2) {
    if (s[i] != s[n - 1 - i]) {
      cout << "No" << endl;
      return;
    }
  }
  rep(i, n / 2) {
    int j = n / 2 - 1 - i;
    if (i == j) break;
    if (s[i] != s[j]) {
      cout << "No" << endl;
      return;
    }
  }
  rep(i, n / 2) {
    int j = n / 2 + 1 + i;
    int k = n - 1 - i;
    if (j == k) break;
    if (s[j] != s[k]) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n,t,e;cin>>n>>t>>e;){
		vi xs(n);
		rep(i,n) cin>>xs[i];
		
		int res=-1;
		rep(i,n)
			if(min(t%xs[i],xs[i]-t%xs[i])<=e){
				res=i+1;
				break;
			}
		cout<<res<<endl;
	}
	
	return 0;
}

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

int arr[105];
int n;

int main()
{
	scanf("%d", &n);
	n *= 2;
	for (int i = 0;i < n;i++) scanf("%d", arr+i);
	sort(arr, arr+n);
	int ans = 0;
	for (int i = 0;i < n;i+=2) ans += arr[i];
	printf("%d\n", ans);
}


Measured memory_bytes: 764
#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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str.
   builtin functions :
   __builtin_popcount(n) : no. of set bits in n.
   __builtin_parity(n) : parity of no. of set bits
   __builtin_clz(n) : no. of leading zeros before 1
   __builtin_ctz(n) : no of zeros from last to first occurrence of 1
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll binlen(ll a)
{
	ll v = 0;
	for(ll i=0;i<61;++i)
	{
		v += (1ll<<i);
		if(a<=v) return i;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	n = n%10;
	string str = "hon";
	if(n <= 1 || n == 6 || n == 8)
		str[0] = 'p';
	else if(n == 3)
		str[0] = 'b';
	cout << str << endl;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N;
	vector<llong> p;

	cin >> N;
	p.resize(N);
	for(int i = 0; i < N; i++)
		cin >> p[i];

	sort(ALL(p), greater<>());
	llong ans = 0;
	for(int i = 1; i <= N; i++){
		if(p[i] <= i){
			ans = i;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
	int r;
	cin >> r;
	int a = 3*r*r;
	cout << a << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {

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

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

    private static void solve() {
        while (true) {
            String s1 = in.nextLine();
            if (!in.hasNextLine() || s1.equals("."))
                break;
            String s2 = in.nextLine();

            Map.Entry<List<String>, List<String>> strings1 = parseStrings(s1);
            Map.Entry<List<String>, List<String>> strings2 = parseStrings(s2);
            List<String> outer1 = strings1.getKey();
            List<String> outer2 = strings2.getKey();
            List<String> inner1 = strings1.getValue();
            List<String> inner2 = strings2.getValue();

            int diff = 0;
            if (outer1.size() == outer2.size() && inner1.size() == inner2.size()) {
                for (int i=0; i < inner1.size(); i++) {
                    if (!inner1.get(i).equals(inner2.get(i))) {
                        diff++;
                        if (diff > 1)
                            break;
                    }
                }
                for (int i=0; i < strings1.getKey().size(); i++) {
                    if (!outer1.get(i).equals(outer2.get(i))) {
                        diff = 2;
                        break;
                    }
                }
            } else
                diff = 2;

            out.println(diff == 0 ? "IDENTICAL" : diff == 1 ? "CLOSE" : "DIFFERENT");
        }
    }

    private static Map.Entry<List<String>, List<String>> parseStrings(String s) {
        List<String> inner = new ArrayList<>();
        List<String> outer = new ArrayList<>();
        char[] cs = s.toCharArray();
        boolean inside = false;
        int beginIndex = 0;
        for (int i=0; i < cs.length; i++) {
            if (cs[i] == '"') {
                inside = !inside;

                if (inside) {
                    outer.add(s.substring(beginIndex, i));
                    beginIndex = i + 1;
                } else {
                    inner.add(s.substring(beginIndex, i));
                    beginIndex = i + 1;
                }
            }
        }

        outer.add(s.substring(beginIndex));

        return new AbstractMap.SimpleEntry<>(outer, inner);
    }
}



Measured memory_bytes: 29296
n=int(input())
q=lambda i:input('%d\n'%i)
i=0
j=n-1
a=q(i)
b=q(j)
while 1:
    if j-i<2:
        q(i)
        q(j)
    k=(j-i)//2+i
    c=q(k)
    if(k-i)%2and a==c or not(k-i)%2and a!=c:
        j=k
    else:
        a=c
        i=k

Measured memory_bytes: 3660
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int K, N;
    cin >> K >> N;
    vector<long long> l;
    vector<long long> delta_l;

    for(int i=0; i<N; ++i){
        long long ai;
        cin >> ai;
        l.push_back(ai);
    }

    long long MAX = 0;
    for(int i=0; i<l.size()-1; ++i){
        long long gap = l[i+1] - l[i];
        if(gap > 0){
            MAX = max(MAX, gap);
            delta_l.push_back(gap);
        }
    }
    
    // delta of N and 0
    delta_l.push_back( abs( (K - l[N-1]) + l[0]) );
    MAX = max(MAX, abs( (K - l[N-1]) + l[0]) );


    long long ans = 0;
    for(int i=0; i<N; ++i){
        ans += delta_l[i];
    }
    ans -= MAX;

    cout << ans << endl;
}


Measured memory_bytes: 4848
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 5006
#define MOD 1000000007
using namespace std;
long long d[MAXN][MAXN];
int n,m;
char s[MAXN];
/*long long ksm(long long a,int m)
{
	if(m==0) return 1;
	long long nex=ksm(a,m/2);
	nex=nex*nex%MOD;
	if(m%2==0) return nex;
	return nex*a%MOD;
}*/
int main()
{
	scanf("%d",&n);
	scanf("%s",s);
	m=strlen(s);
	d[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=n;j++)
		{
			d[i][j]+=d[i-1][j+1]*2;
			d[i][j]+=d[i-1][max(j-1,0)];
			d[i][j]%=MOD;
		}
	printf("%lld",d[n][m]);
}

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

#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

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

void solve() 
{ 
ll a,b;
cin>>a>>b;
cout<<lcm(a,b);
}
 

int main(){


		solve();
		cout<<endl;
	
	

					
}
		

	

		

 



Measured memory_bytes: 3644
# -*- coding:utf-8 -*-


def main(min_limit, max_limit):
    result = []
    i = min_limit

    while(i < max_limit + 1):
        result.append(i)
        i = i * 2
    print(len(result))


if __name__ == "__main__":
    min_limit, max_limit = [int(val) for val in input().split()]
    main(min_limit, max_limit)

Measured memory_bytes: 2940
# -*- coding: utf-8 -*-

import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':

ans_st = [111, 222, 333, 444, 555, 666, 777, 888, 999]
n = int(input().rstrip())
i = 0
while n > ans_st[i]:
	i += 1
print(ans_st[i])


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i < n + 1; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;

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;
}
// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    int k;
    cin >> k;
    REP(i, N)
    cin >> h[i];
    REP(i, 100010)
    {
        dp[i] = INF;
    }
    dp[0] = 0;

    REP(i, N)
    {
        REP1(j, k)
        {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[N - 1] << endl;
}


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

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    int i;
    for(i=0;i<n;i++)cin>>a.at(i);
    for(i=0;i<n;i++)cin>>b.at(i);
    for(i=0;i<n-1;i++)cin>>c.at(i);
    int ans=0;
    ans+=b.at(a.at(0)-1);
    int now = a.at(0)-1;
    int prev;
    for(i=1;i<n;i++)
    {
        prev = now;
        now = a.at(i)-1;
        ans+=b.at(now);
        if(prev+1==now)
        {
            ans+=c.at(prev);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class AFavoriteSound {
public:
	void solve(std::istream& in, std::ostream& out) {
	     int a,b,c;in>>a>>b>>c;
	     out<<min(c,b/a)<<endl;

	}
};


int main() {
	AFavoriteSound solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3112
def test():
    a = list(map(int,input().split()))
    b = 0
    c = max(a)
    a.remove(max(a))
    for i in range(2):
        c = abs(c-max(a))
        b += c
        c = max(a)
        a.remove(max(a))
    print(b)


if __name__ == "__main__":
    test()


Measured memory_bytes: 3060
k=int(input())
if k%2==0 or k%5==0:
  print(-1)
  exit()
  
le=len(str(k))
p=int(''.join(['7']*le))
i=0
s=p%k
while True:
  if s==0:
    print(le+i)
    exit()
  else:
    s+=7*pow(10,le+i,k)
    s%=k
    i+=1
    


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


int main(){
    int n;
    cin >> n;
    string S[50];
    int char_cnt[50][26] = {};
    for(int i = 0; i < n; i++){
        cin >> S[i];
        for(int j = 0; j < S[i].length(); j++){
            char_cnt[i][S[i][j] - 'a']++;
        }
    }
    int ans_cnt[26] = {};
    for(int i = 0; i < 26; i++){
        ans_cnt[i] = 50;
        for(int j = 0; j < n; j++){
            ans_cnt[i] = min(ans_cnt[i], char_cnt[j][i]);
        }
        for(int j = 0; j < ans_cnt[i]; j++){
            cout << char('a' + i);
        }
    }
    cout << endl;
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];
ll B[100005];

ll T[100005];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(i, N)
    {
        cin >> B[i];
    }

    //! n!%MOD
    T[0] = 1;
    FOR(i, N + 1, 1)
    {
        T[i] = T[i - 1] * i;
        T[i] %= MOD;
    }

    sort(A, A + N);
    sort(B, B + N);
    A[N] = INF;
    B[N] = INF;
    ll sum = 1;

    int pi = 0, wi = 0;
    int np = 0, nw = 0;
    while (pi < N || wi < N)
    {
        if (A[pi] < B[wi])
        {
            pi++;
            if (nw > np)
            {
                sum *= nw;
                nw--;
            }
            else
            {
                np++;
            }
        }
        else
        {
            wi++;
            if (np > nw)
            {
                sum *= np;
                np--;
            }
            else
            {
                nw++;
            }
        }
        sum %= MOD;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define Inf 1000000007
using namespace std;
int fun(int *dp,int *arr,int n)
{
    if(n==0)
    {
       return 0; 
    }
    if(n<0)
    return Inf;

    //lookup
    if(dp[n]!=-1)
    return dp[n];

    //rec case
    dp[n]=min(abs(arr[n]-arr[n-1])+fun(dp,arr,n-1),abs(arr[n]-arr[n-2])+fun(dp,arr,n-2));
    return dp[n];
}


int main()
{
    int arr[100005];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>arr[i];
    int dp[100005];
    for(int i=0;i<n+2;i++)
     dp[i]=-1;
    cout<<fun(dp,arr,n-1)<<endl;
    return 0;
}

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

long long N, X, A[209], dp[209][100009], mod = 1000000007;

int main() {
	cin >> N >> X;
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A, A + N);
	reverse(A, A + N);

	dp[0][X] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 100000; j++) {
			if (dp[i][j] == 0) continue;
			dp[i + 1][j%A[i]] += dp[i][j]; dp[i + 1][j%A[i]] %= mod;
			dp[i + 1][j] += dp[i][j] * (N - i - 1); dp[i + 1][j] %= mod;
		}
	}

	long long s = 0;
	for (int i = 0; i <= 100000; i++) { s += 1LL * i*dp[N][i]; s %= mod; }
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 155904
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <utility>

using namespace std;

template <class T>
class FenwickTree {
    size_t n;
    vector<T> tree0, tree1;
    void add(vector<T> &tree, size_t i, T x) {
        while (i <= n) {
            tree[i] += x;
            i += i & -i;
        }
    }
    T query(vector<T> &tree, size_t i) {
        T res=0;
        while (i > 0) {
            res += tree[i];
            i -= i & -i;
        }
        return res;
    }
public:
    FenwickTree(size_t n, T e=0): n(n), tree0(n, e), tree1(n, e) {
        tree0 = vector<T>(n+1, e);
        tree1 = vector<T>(n+1, e);
    }
    void add(size_t l, size_t r, T x) {
        add(tree0, l+1, -x*l);
        add(tree1, l+1, x);
        add(tree0, r+1, x*r);
        add(tree1, r+1, -x);
    }
    T query(size_t l, size_t r) {
        T res=0;
        res += query(tree0, r) + query(tree1, r)*r;
        res -= query(tree0, l) + query(tree1, l)*l;
        return res;
    }
    T query(size_t i) {
        return query(i, i+1);
    }
};

int main() {
    size_t N, M;
    scanf("%zu %zu", &N, &M);

    vector<pair<size_t, size_t>> q;
    for (size_t i=0; i<N; ++i) {
        size_t l, r;
        scanf("%zu %zu", &l, &r);

        q.emplace_back(l, r);
    }

    sort(q.begin(), q.end(), [](
        const pair<size_t, size_t> &lhs, const pair<size_t, size_t> &rhs
    ) {
        return lhs.second-lhs.first < rhs.second-rhs.first;
    });

    FenwickTree<int> tree(M+1);
    for (size_t d=1, i=0; d<=M; ++d) {
        while (i < N && q[i].second-q[i].first < d) {
            tree.add(q[i].first, q[i].second+1, 1);
            ++i;
        }

        int res=N-i;
        for (size_t j=d; j<=M; j+=d)
            res += tree.query(j);

        printf("%d\n", res);
    }

    return 0;
}


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

int main() {
    //freopen("input.txt","r",stdin);
	int N;
	long long K;
	cin >> N >> K;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) 
        cin >> A[i], A[i]--;
	vector<long long> X;
	vector<bool> B(N, false);
	X.push_back(0);
	B[0] = true;
	int NOW = 0;
	while (1) {
		NOW = A[NOW];
		if (B[NOW]) break;
		B[NOW] = true;
		X.push_back(NOW);
	}
    // for(auto i:X)
    //     cout<<i<<" ";
    // cout<<"\n";
    //cout<<NOW<<"\n";
	int P, Q;
    // P is the starting index of the cycle
    // Q is the length of the cycle
	for (int i = 0; i < X.size(); i++) {
		if (X[i] == NOW) {
			P = i;
			break;
		}
	}
    //cout<<P<<"\n";
	Q = (int)X.size() - P;

    //if k occurs before beginning of the cycle
    if (P > K) cout << X[K]+1  << endl;
	else {
        // else after...find the element within
        // the cycle with offset of P
		cout << X[((K - P) % Q) + P]+1  << endl;
	}
}


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

using namespace std;
int main(){
	
	int N=6;
	int x[N],sum=0;
	int cntA=1,cntB=1;
	int cntC=1,cntD=1;
    double pDen=-1.0,Den,s;
	int ansW=-1,ansS=-1,W,S,H;
	
	for(int i=0;i<N;i++){
		cin>>x[i];
	}
	
	//何回Aが入れられるか
	while(cntA*x[0]*100<=x[5]){
		cntA++;
	}cntA--;
	
	//何回Bが入れられるか
	while(cntB*x[1]*100<=x[5]){
		cntB++;
	}cntB--;
	
	//何回Cが入れられるか
	while(cntC*x[2]<=x[5]){
		cntC++;
	}cntC--;
	
	//何回Dが入れられるか
	while(cntD*x[3]<=x[5]){
		cntD++;
	}cntD--;
	//cout<<cntC<<endl;
	
	for(int i=0;i<=cntA;i++){
		for(int j=0;j<=cntB;j++){
			for(int k=0;k<=cntC;k++){
				for(int m=0;m<=cntD;m++){//if((i==0)&&(j==1)&&(k==100)&&(m==0))break;
					if((i!=0)||(j==0)){
						W=(i*x[0]*100+j*x[1]*100+k*x[2]+m*x[3]);
						S=(k*x[2]+m*x[3]);
						Den=(double)S/W;
						H=(i*x[0]+j*x[1])*100;
						s=(double)x[4]/100;
						if((x[5]>=W)&&(Den>pDen)&&((double)(k*x[2]+m*x[3])/H<=(double)x[4]/100)){
							ansW=W;//cout<<i<<" "<<j<<" "<<k<<" "<<m<<endl;
							ansS=S;//cout<<Den<<" "<<S<<" "<<W<<endl;
							pDen=Den;
						}
					}
				}
			}
		}
	}
	
	//1 2 1 2 100 1000
	cout<<ansW<<" "<<ansS<<endl;
}

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

const int MN = 55;
const int MX = 2505;
int nums[MN], a, n;
long long memo[MN][MX][MN];

long long solve(int idx, int val, int hw) {
  if (idx >= n) {
    if(hw)
      return ((val / hw) == a) && (val % hw == 0);
    return 0;
  }
  if (memo[idx][val][hw] != -1) return memo[idx][val][hw];
  long long ans = solve(idx + 1, val, hw) + solve(idx + 1, val + nums[idx], hw + 1);
  return memo[idx][val][hw] = ans;
}

int main() {
  while (cin >> n >> a) {
    for (int i = 0; i < n; i++) cin >> nums[i];
    memset(memo, -1, sizeof memo);
    cout << solve(0, 0, 0) << endl;
  }
}


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

int main()
{   int a[5];
int b[5];

    while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4])
    {
         for(int i=0;i<5;i++)
         {

             b[i]=a[i]%10;
         }
         sort(b,b+5);
         for(int i=0;i<5;i++)
         {

             if(b[i]!=0)

             {b[0]=b[i];
             break;
             }
         }
         int k=0;
         int sum=0;
         for(int i=0;i<5;i++)
         {

             int temp;
             temp=a[i]/10;
             if(a[i]%10>0)
                {
                    a[i]=temp*10+10;
                    k++;

                }

                  sum+=a[i];
         }
         if(k==0)
         {
             cout<<sum<<endl;
         }
         else
         {

             cout<<sum-10+b[0]<<endl;
         }


    }
        return 0;
}


Measured memory_bytes: 256
H = int(input())
bin_str = format(H,"b")
t = len(bin_str)
jud = 0
a = 1
result = 0
for i in range(t):
    if bin_str[i] != "0":
        jud = 1 
        break
        
if jud == 0:
    for i in range(t+1):
        result += a
        a *= 2
else:
    for i in range(t):
        result += a
        a *= 2
print(result)

Measured memory_bytes: 38384
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	v := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&v[i])
	}
	sort.Ints(v)
	ans := float64(v[0])
	for i := 1; i < N; i++ {
		ans = (float64(ans) + float64(v[i])) / 2.0
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
N, M = map(int,input().split())
A = []
B = []
for i in range(M) :
    C, D = map(int,input().split())
    A.append(C)
    B.append(D)
if min(B)-max(A)+1 > 0 :
    print(min(B)-max(A)+1)
else :
    print(0)

Measured memory_bytes: 10996