akhauriyash/Code-Regression huggingface dataset:
///                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 1e5 + 100, M = 998244353,  P = 6151, SQ = 1300, lg = 6;
typedef pair <int, int> pii;
int aa[N], bb[N], lena, lenb, len, k;

int32_t main() {
	use_fast;
	int a, b, x, y, l, r, ans, ll, rr;
	cin >> a >> b;
	x = a, y = b;
    while(a)
		aa[++lena] = a & 1, a /= 2;
    while(b)
		bb[++lenb] = b & 1, b /= 2;
    for(int i = max(lena,lenb); i; i--) {
        if(aa[i] != bb[i]){
			len=i;
			break;
		}
        x -= 1ll * aa[i] << (i - 1);
        y -= 1ll * bb[i] << (i - 1);
    }
    for(int i = len - 1; i; i--) {
		if(bb[i]) {
			k = i; 
			break;
		}
	}
    l = x, r = (1ll << (len - 1)) + (1ll << k) - 1;
    ll = (1ll << (len - 1)) + x, rr = (1ll << len) - 1;
    if(ll > r)
		ans = r - l + 1 + rr - ll + 1;
    else 
		ans = rr - l + 1;
    cout << ans << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04
5- ...
*/

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int a;
  int b;
   cin >>a>>b;
  if((a%2 !=0) &&(b%2 !=0)) {
    cout <<"Odd" << endl;
  }
  else {
cout << "Even" << endl;
  }
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  //atcoder
  string s;cin>>s;
  if(s[2]==s[3] && s[4]==s[5])cout<<"Yes";
  else cout<<"No";
  return 0;
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p.at(i);

  sort(p.begin(), p.end());

  int ans=0;
  rep(i, k) ans+=p.at(i);

  cout << ans;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	int width;//?????????????????????
	int height;//????????????????????????
	//????????????????????¨???????????¢??°
	void printData(int crowd[][]){
		for(int i = 0;i <height;i++){
			for(int j = 0;j < width;j++){
				if(j < width-1){
					System.out.print(crowd[j][i]+" ");					
				}else{
					System.out.print(crowd[j][i]);						
				}
			}
			System.out.println();
		}	
	}
	//?????¨??????????????????????¬?????????????????????????????????????
	void calcCrowd(int crowd[][]){
		for(int i = 0;i <height;i++){
			for(int j = 0;j < width;j++){
				for(int k = width-1;k >= 0;k--){
					if(crowd[k][i] == 0 && crowd[j][i] == -1 && k < j){
						crowd[j][i] = j-k;
					}
				}
			}
		}		
	}
	void doIt(){
		Scanner sc = new Scanner(System.in);
		this.height = sc.nextInt();
		this.width = sc.nextInt();
		String c[] = new String[height];
		int crowd[][] = new int[width][height];
		for(int i = 0; i < height;i++){
			c[i] = sc.next();
		}
		for(int i = 0;i <height;i++){
			for(int j = 0;j < width;j++){
				if(c[i].charAt(j) == 'c'){
					crowd[j][i] = 0;
				}else{
					crowd[j][i] = -1;	
				}
			}
		}
		calcCrowd(crowd);
		printData(crowd);
	}
	public static void main(String[] args) {
		new Main().doIt();
	}

}

Measured memory_bytes: 33316
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

struct kraw
{
    ll a, w;
};

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector< vector<kraw> > T(n);
    for (int i = 0; i < n - 1; ++i)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        T[a].push_back({b, c});
        T[b].push_back({a, c});
    }
    ll q, k;
    cin >> q >> k;
    --k;
    vector<ll> odl(n, -1);
    odl[k] = 0;
    stack<int> S;
    S.push(k);
    while (!S.empty())
    {
        int akt = S.top();
        S.pop();
        for (int i = 0; i < T[akt].size(); ++i)
        {
            if (odl[T[akt][i].a] == -1)
            {
                odl[T[akt][i].a] = odl[akt] + T[akt][i].w;
                S.push(T[akt][i].a);
            }
        }
    }
    for (int i = 0; i < q; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        cout << odl[a] + odl[b] << endl;
    }
    return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

int m[1009];

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

	int N, X; cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> m[i];
		X -= m[i];
	}
	int ans = N;
	sort(m, m + N);
	cout << ans + X / m[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 100100
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

ll n, W, w[MAXN], v[MAXN], dp[102][MAXN];
ll infi = 1e9;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n >> W;
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= W; j++){
            if(i == 0){
                if(w[0] <= j) dp[i][j] = v[0];
                continue;
            }
            dp[i][j] = dp[i - 1][j];
            if(w[i] > j) continue;
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
        }
    }
    cout << dp[n - 1][W];
}

Measured memory_bytes: 80128
#include<iostream>
using namespace std;
int n,a[3][103],x,s;
int main(){
cin>>n;
for(int i=1;i<=2;i++)
for(int j=1;j<=n;j++)
cin>>x,a[i][j]=a[i][j-1]+x;
for(int i=1;i<=n;i++)
s=max(s,a[1][i]+a[2][n]-a[2][i-1]);
cout<<s<<endl;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 5 * 1e5 + 10;
typedef pair<long long, long long> P;
bool comp(P &p1, P &p2){
    return p1.second < p2.second;
}
struct BIT{
    vector<long long> num;
    int N;
    BIT(int n){
        N = n;
        num.resize(N + 1, 0);
    }
    long long sum(long long t){
        long long res = 0;
        while(t > 0){
            res += num[t];
            t -= t & -t;
        }
        return res;
    }
    void add(int ind, long long t){
        while(ind <= N){
            num[ind] += t;
            ind += ind & -ind;
        }
    }
};
int main(){
    int N, Q;
    cin >> N >> Q;
    BIT BIT(N);
    vector<long long> c(N);
    map<long long, P> m;
    map<P, long long> ans;
    for(int i = 0; i < N; i++) {
        cin >> c[i];
    }
    vector<P> qu(Q);
    for(int i = 0; i < Q; i++){
        long long l, r;
        cin >> l >> r;
        m[i] = P(l, r);
        qu[i] = P(l, r);
    }
    sort(qu.begin(), qu.end(), comp);
    vector<long long> num(500010, -1);
    int ind = 0;
    for(int i = 0; i < N; i++){
        if(ind == Q) break;
        if(num[c[i]] != -1){
            BIT.add(num[c[i]], -1);
            num[c[i]] = i + 1;
            BIT.add(num[c[i]], 1);
        }
        else{
            num[c[i]] = i + 1;
            BIT.add(num[c[i]], 1);
        }
        while(i + 1 == qu[ind].second){
            long long temp = BIT.sum(i + 1) - BIT.sum(qu[ind].first - 1);
            ans[qu[ind]] = temp;
            ind++;
            if(ind == Q) break;
        }
    }
    for(auto v:m){
        cout << ans[v.second] << endl;
    }
}

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

int main(void){
    int N,M; cin >> N >> M;
    vector<int> city(N);

    for(int i=0; i<M; i++){
        int a,b; cin >> a >> b;
        a--; b--;
        city[a]++; city[b]++;
    }

    for(int i=0; i<N; i++){
        cout << city[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int min=1000000;
    int max=-1000000;
    long sum=0L;
    for(int i=0;i<a;i++){
      int b=sc.nextInt();
      if(min>b) min=b;
      if(max<b) max=b;
      sum+=b;
    }
    System.out.println(min+" "+max+" "+sum);
  }
}



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


class Main {
    static final int N=200000;
    static final long MOD=1000000007;
    static long[] fact;
    static long[] invfact;
    static void initialize() {
	fact = new long[N];
	invfact = new long[N];
	fact[0] = invfact[0] = 1;
	for (int i = 1; i < N; ++i) {
	    fact[i] = (i * fact[i - 1]) % MOD;
	    invfact[i] = powerMod(fact[i], MOD - 2);
	}
    }
    static long powerMod(long x, long exponent) {
	long prod = 1;
	for (int i = 63; i >= 0; --i) {
	    prod = (prod * prod) % MOD;
	    if ((exponent & 1L << i) != 0) {
		prod = (prod * x) % MOD;
	    }
	}
	return prod;
    }
    static long comb(int x, int y) {
	if (x < 0) {
	    return 0;
	}
	if (y < 0 || y > x) {
	    return 0;
	}
	long r= (fact[x] * powerMod((fact[x - y] * fact[y]) % MOD, MOD - 2)) % MOD;
	return r;
    }
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int h=sc.nextInt();
        int w=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();
        initialize();
        long ans=0;
        for(int i=0;i<h-a;++i){
            long tmp=comb(b-1+i,i);
            tmp=tmp*comb(h-1-i+w-b-1,w-b-1);
            ans=(ans+tmp)%MOD;
        }
        out.println(ans);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------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: 25428
#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

void solve()
{
	int n;
	cin >> n;
	n = n % 10;
	if(n == 2 ||n == 4 ||n == 5 || n == 7 || n == 9) cout << "hon";
	else if(n == 0 || n == 1 || n == 6 || n  == 8) cout  << "pon";
	else cout << "bon";
}

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



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

using namespace std;

int main(){
	#ifdef EVAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int N;
	cin >> N;
	vector <int> v(N);
	for(int i = 0; i < N; i++){
		cin >> v[i];
	}
	int ans = 0;
	for(int i = 1; i < N - 1; i++){
		int a[] = {v[i - 1],v[i],v[i + 1]};
		sort(a,a + 3);
		if(v[i] == a[1]){
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp ": "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(__typeof(a)i=(a);i<=(b);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define db(something)   cerr<<#something<<" - "<<something<<"\n";         
int main()
{
  
   Ezio
   /*Variables*/
   /*Code*/
   ll  n;
   cin>>n;
   string  s;
   while(n>0){
     --n;
     s+=((n%26)+'a');
     n/=26;
   }
   r(s);
   cout<<s<<endl;
   return 0;
}
    

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

typedef long long ll;

struct UnionFind
{
    vector<int> par;

    UnionFind(int n): par(n){
        for(int i = 0;i < n;++i){
            par.at(i) = i;
        }
    }

    int root(int x){
        if(par.at(x) == x){
            return x;
        }else{
            return par.at(x) = root(par.at(x));
        }
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }else{
            par.at(rx) = ry;
        }
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n,m,i;
    cin >> n >> m;

    vector<int> p(n);

    for(i = 0;i < n;++i){
        cin >> p.at(i);
    }

    UnionFind tree(n);

    for(i = 0;i < m;++i){
        int x,y;
        cin >> x >> y;
        tree.unite(x-1,y-1);
    }

    int ans = 0;
    for(i = 0;i < n;++i){
        if(tree.same(i,p.at(i)-1)){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

#define QSIZE 100000

struct _q{
  char n[11];
  int  t;
} q[QSIZE];
int qs=0,qe=0;

void enqueue(struct _q *ptq){
  q[qe].t=ptq->t;
  strncpy(q[qe].n,ptq->n,10);
  qe++; if (qe==QSIZE) qe=0;
  return;
}

struct _q *dequeue(){
  int qc=qs;
  if (qs==qe) return NULL;
  qs++; if (qs==QSIZE) qs=0;
  return &q[qc];
}

int main(){
  int N,Q,t=0;
  struct _q tq, *ptq;
  scanf("%d %d\n",&N,&Q);
  while(scanf("%s %d\n",tq.n,&tq.t) != EOF){
    if(tq.t>Q){
      t+=Q; tq.t-=Q;
      enqueue(&tq);
    }
    else{
      t+=tq.t;
      printf("%s %d\n",tq.n, t);
    }
  }

  ptq = &tq;
  while ((ptq=dequeue()) != NULL) {
    if(ptq->t>Q){
      t+=Q;
      ptq->t-=Q;
      enqueue(ptq);
    }
    else{
      t+=ptq->t;
      printf("%s %d\n",ptq->n, t);
    }
  }
  return 0;
}

Measured memory_bytes: 2176
import itertools

N, K = map(int, input().split())
A = list(map(int, input().split()))

mn = 1e12

for v in itertools.product([0,1], repeat=N-1):
    h = A[0]
    p = 0
    if sum(v) < K - 1:
        continue
    for i, vv in enumerate(v):
        if vv == 1:
            p += max(h - A[i+1] + 1, 0)
            h = max(A[i+1], h + 1)
        else:
            h = max(A[i+1], h)
    mn = min(mn, p)

print(mn)

Measured memory_bytes: 41840
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  int n,q;
  cin>>n>>q;
  vector<queue<int> > s(n);
  for(int i=0;i<q;i++){
    int t,a;
    cin>>t>>a;
    if(t==0){
      int x;
      cin>>x;
      s[a].emplace(x);
    }
    if(t==1) if(!s[a].empty()) cout<<s[a].front()<<endl;
    if(t==2) if(!s[a].empty()) s[a].pop();
  }
  return 0;
}



Measured memory_bytes: 4232
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
  int N = nextInt();
  ArrayList<Integer> list = nextIntArray();
  int[] count = new int[N];
  for(int i = 0; i < N; i++){
    count[list.get(i) - 1] = i + 1;
  }
      String[] output = new String[N];
      for(int i = 0; i < N; i++){
        output[i] = String.valueOf(count[i]);
      }
  myout(myconv(output, 8));
	}
	//Method addition frame start



	//Method addition frame end
}


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

int A[100];
int B[100];
vector <int> adj[100];
vector <pair<int,int>> red,blue;
bool visited[100];

bool dfs(int a)
{
    visited[a] = true;
    for(auto b : adj[a])
    {
        if(B[b]==-1 || visited[B[b]]==false && dfs(B[b]))
        {
            A[a] = b;
            B[b] = a;
            return true;
        }
    }
    return false;
}

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

    int n,a,b;

    cin >> n;

    for(int i=0;i<n;i++)
    {
        cin >> a >> b;
        red.push_back(make_pair(a,b));
    }

    for(int i=0;i<n;i++)
    {
        cin >> a >> b;
        blue.push_back(make_pair(a,b));
    }

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(red[i].first < blue[j].first && red[i].second < blue[j].second)
            {
                adj[i].push_back(j);
            }
        }
    }

    int res = 0;
    memset(A,-1,sizeof(A));
    memset(B,-1,sizeof(B));

    for(int i=0;i<n;i++)
    {
        if(A[i]==-1)
        {
            memset(visited,false,sizeof(visited));
            if(dfs(i))
            {
                res++;
            }
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
	double x1,x2,y1,y2,c;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	c=sqrt(pow((x2-x1),2)+pow((y2-y1),2));
	printf("%.8lf\n",c);
	return 0;
}

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

using namespace std;

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    int res = 1 << 29;
    for (int i = 0; i < (1 << (h - 1)); i++) {
        int rc = 0;
        for (int j = 0; j < h - 1; j++) {
            if ((i & (1 << j)) > 0) {
                rc++;
            }
        }

        int r = 0;
        bool ok = true;
        vector<int> c(rc + 1, 0);
        for (int j = 0; j < w; j++) {
            vector<int> c_next(rc + 1, 0);
            for (int l = 0, m = 0; l < h; l++) {
                if (s[l][j] == '1') {
                    c_next[m]++;
                }

                if ((i & (1 << l)) > 0) {
                    m++;
                }
            }

            int pat = 0;
            for (int l = 0; l < rc + 1; l++) {
                if (c_next[l] > k) {
                    pat = 2;
                } else if (c[l] + c_next[l] > k) {
                    pat = 1;
                }
            }

            if (pat == 0) {
                for (int l = 0; l < rc + 1; l++) {
                    c[l] += c_next[l];
                }
            } else if (pat == 1) {
                c = c_next;
                r++;
            } else {
                ok = false;
                break;
            }
        }

        if (ok) {
            res = min(res, r + rc);
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int L[6],v[5];
LL f[50*5+1][1<<5];
int sa[5];
int main()
{
	int n=gi(),C=gi(),i,k,s;LL g=0,sum=0;
	for (i=0;i<n;i++) L[i]=gi(),sa[i]=i;
	sort(L,L+n);
	if (L[--n]>=C) return puts("1"),0;
	do {
		for (i=0;i<n;i++) v[i]=L[sa[i]];
		memset(f,0,sizeof(f));
		f[L[n]*n-1][0]=1;
		for (i=0;i<C*n;i++)
			for (k=i;k<=C*n;k++)
				for (s=0;s<1<<n;s++)
					if (!(s>>(i%n)&1))
						f[min(max(i+v[i%n]*n,k),C*n)][s|1<<(i%n)]+=f[k][s];
		sum+=f[C*n][(1<<n)-1];
		g++;
	} while (next_permutation(sa,sa+n));
	while (n--) g*=C;
	printf("%.12lf\n",(double)sum/g);
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
MOD = 10**9+7
dp = [-1]*(n+1)
dp[0] = dp[1] = 1

for x in a:
    dp[x] = 0

for i in range(2, n+1):
    if dp[i] == 0:
        continue
    dp[i] = (dp[i-1]+dp[i-2]) % MOD

print(dp[n])

Measured memory_bytes: 7824
import java.io.*;
import java.util.*;
/**
 * Main
 */
public class Main {
       static int mod  = 1000000007;
        static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] args) {
       MyScanner ms  = new MyScanner();
        String s = ms.nextLine();
        if(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5))
            pw.println("Yes");
        else
            pw.println("No");
    pw.flush();

    }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: 22740
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;

typedef long long ll;
const ll mod=1e9+7;
const ll MAXN=1e5+10;
const ll INF=0x7fffffff;

int main()//所有的循环已改正 
{
	int a[MAXN]={0};
	int n;
	cin>>n;
	int mn=INF,mx=-INF;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		a[x]++; 
		mn=mn<x?mn:x;
		mx=mx>x?mx:x;
	}
	int ans=a[mn]+a[mn+1];
	for(int i=mn+1;i<=mx;i++){
		int sum=a[i-1]+a[i]+a[i+1];
		if(sum>ans){
			ans=sum;
		}
	}
	cout<<ans<<endl;
	return 0;
}	 


Measured memory_bytes: 640
/*

にっこにっこにー♪
あなたのハートににこにこにー♪
笑顔届ける矢澤にこにこー♪
にこにーって覚えてラブにこー♪


*/
#include<stdio.h>
#include<string.h>
typedef unsigned long long ull;
const ull B = 1e9+7;
char s[1111111];
int len;
ull a[1111111];
ull h[1111111];
ull Bh[1111111];
int main(void) {
    int res = -1;
     int i,al,bl;
  scanf("%s", s);
  len = strlen(s);
  Bh[0] = 1;
 
   for (i = 0; i < len; i++) {
     h[i+1] = h[i]*B + s[i];
     Bh[i+1] = Bh[i]*B;
   }
 
   for (i = 1; i*3 < len; i++) {
     if ((len - i*3)%2 != 0 || len - i*3 <= 0) continue;
     al = i;
     bl = (len - i*3)/2;
     if (h[al] == h[al+bl + al]-h[al+bl]*Bh[al] &&
         h[al+bl + al]-h[al+bl]*Bh[al] == h[al*2+bl*2+al]-h[al*2+bl*2]*Bh[al] &&
         h[al+bl]-h[al]*Bh[bl] == h[al*2+bl + bl]-h[al*2+bl]*Bh[bl]) {
       if (res == -1 || res > al+bl) {
         res = al+bl;
       }
     }
      }
 
      if (res < 0) {
        puts("mitomerarenaiWA");
      } else {
        printf("Love ");
        for (int i = 0; i < res; i++) {
          printf("%c", s[i]);
        }
        puts("!");
      }
      return 0;
}


Measured memory_bytes: 19320
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(b%a?b-a:a+b)<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll a[100000];
ll o[51];
ll dp[51][2];
int n;
ll k;

ll f(int i, bool b)
{
    if (i < 0)
        return 0;

    if (dp[i][b] != -1)
        return dp[i][b];

    ll sol = 0;
    if (b)
    {
        sol = max(sol, (1ll << i) * o[i] + f(i - 1, true));
        sol = max(sol, (1ll << i) * (n - o[i]) + f(i - 1, true));
    }
    else
    {
        if (k & (1ll << i))
            sol = max(sol, (1ll << i) * (n - o[i]) + f(i - 1, false));
        sol = max(sol, (1ll << i) * o[i] + f(i - 1, k & (1ll << i)));
    }
    return dp[i][b] = sol;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        for (int j = 0; j <= 50; ++j)
            if (a[i] & (1ll << j))
                o[j]++;
    }
    memset(dp, -1, sizeof dp);
    cout << f(50, false);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
#define watch(x) cout << "["<<(#x) << " is " << (x) << "]" << endl
void watchVecI(vector<int>a){
	for(int i = 0; i < a.size(); ++i){
		cout << a[i] << " ";
	}
	cout << endl;
}
void watchVecS(vector<string>a){
	for(int i = 0; i < a.size(); ++i){
		cout << a[i] << " ";
	}
	cout << endl;
}
void watchVecC(vector<char>a){
	for(int i = 0; i < a.size(); ++i){
		cout << a[i];
	}
	cout << endl;
}
long double binets(double n){
	long double first = (1+sqrt(5.0))/2.0;
	long double second = (1-sqrt(5.0))/2.0;
	long double third = pow(first,n)-pow(second,n);
	return (third/sqrt(5.0));
}


void solve(){
  int n;
  cin >> n;
  int k;
  cin >> k;
  vector<int>a(n);
  for(int i =0 ; i < n; ++i){
    cin >> a[i];
  }
  int ans = 0;
  sort(a.begin(), a.end());
  for(int i =0 ; i < k; ++i){
    ans += a[i];
  }
  cout << ans;
}

int main(){
//	freopen("I_P.txt", "r", stdin);
    int t = 1;
//    cin >> t;
    while(t--){
        solve();
    }
	return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string S; cin >> S;
    int cnt = 0, mr = 0;
    REP(i,3) {
        if (S[i] == 'R') cnt++;
        else cnt = 0;
        mr = max(mr,cnt);
    }
    OUT(mr)

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main(void){
   int s;
   cin >> s;
   int t,o;
   t = s % 100;
   o = s / 100;
   if(0 < t && t < 13 &&  0 < o && o < 13){
       cout << "AMBIGUOUS" << endl;
   }else if(0 < o && o < 13){
       cout << "MMYY" << endl;
   }else if(0 < t && t < 13){
       cout << "YYMM" << endl;
   }else{
       cout << "NA" << endl;
   }
 return 0;
}



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

int main(){
  
  int a,b;
  cin >> a >> b;
  int cnt = 0;
  int n =a;
  
  
  for(int i = a; i < b+1; i++){
     if((n/10000==n%10)&&(n/1000%10)==(n/10%10))
       cnt ++;
     n++;
  }
     
    cout << cnt << endl;

}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメa
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)*/

//ここから書き始める
template<class T> ll gcd_2(T a , T b){
	T A = max(a,b); //大きいほう
	T B = min(a,b);//小さいほう
	T c =-1;
	T ans = 1 ;
	while(c!=0){
		c = A % B;
		if(c==0){//Bが最大公約数
			ans = B;
			break;
		}
		else{//B大公約数ではないので，AをBに，BをCにしてもう一度
			A = B; 
			B = c; 
		}
	}
	return ans;//cが最大公約数 
}
int main(){
	ll n ; cin >> n;
	vector<ll> a(n);
	rep(i,n) cin>>a[i];
	//get gcd
	ll gcd = a[0];
	for(int i = 1 ; i < n ; i ++){
		chmin(gcd, gcd_2(gcd,a[i]));
	}
	cout<<gcd<<endl;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,t,a,b,m,i;
    vector<pair<ll,ll>>x;
    cin>>n>>t;
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        x.push_back({a,b});
    }
    sort(x.begin(),x.end());
    for(i=0;i<x.size();i++)
    {
        if(x[i].second<=t)
        {
            cout<<x[i].first<<endl;
            return 0;
        }
    }
    cout<<"TLE"<<endl;
}




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

using namespace std;

const int mod = 1e9 + 7;

int C(int ,int);
int quick_pow(int ,int);

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int ans = quick_pow(2, n) - 1;
	ans = (1ll * ans - C(n, a) - C(n, b) + mod + mod) % mod;
	cout << ans << endl;
	return 0;
}

int C(int x, int y){
	int sum1 = 1, sum2 = 1;
	for(int i = x; i >= x - y + 1; --i)
		sum1 = 1ll * sum1 * i % mod;
	for(int i = 1; i <= y; ++i)
		sum2 = 1ll * sum2 * i % mod;
	return 1ll * sum1 * quick_pow(sum2, mod - 2) % mod;
}

int quick_pow(int x, int y){
	int sum = 1;
	for(; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) sum = 1ll * sum * x % mod;
	return sum;
}


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

vector<ll> enum_div(ll n){
    vector<ll> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vector<ll> d = enum_div(m);
    ll ans = 0;
    for(auto a : d){
        if(n*a <= m){
            ans = a;
        }
        else break;
    }
    cout<<ans<<endl;

}

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

int main(){
    int h,m,s;
    
    cin >> s;
    h=s/3600;
    m=(s%3600)/60;
    s=(s%3600)%60;
    
    cout<<h<<":"<<m<<":"<<s<<endl;
    
    return 0;
}


Measured memory_bytes: 3100
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if A < B:
  A_P = A + V * T
  B_P = B + W * T
  if A_P >= B_P:
    print("YES")
  else:
    print("NO")
else:
  A_P = A - V * T
  B_P = B - W * T
  if A_P <= B_P:
    print("YES")
  else:
    print("NO")

Measured memory_bytes: 61664
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,a;cin>>n>>a;
    n%=500;
    if(a>=n)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
use v5.18; # strict say state
use warnings;

chomp (my ($n, $m) = split / /, <STDIN>);
my @x;
for my $i (0..$m-1) {
  my ($l1, $l2) = split ' ', <STDIN>;
  $x[$i][0] = $l2;
  $x[$i][1] = $l1;
}
@x = sort {$a->[0] <=> $b->[0]} @x;
my $ans = 0;
my $cur = 0;
for my $i (0..$m-1) {
  next if $cur > $x[$i][1];
  $ans++;
  $cur = $x[$i][0];
}
say $ans;

Measured memory_bytes: 34176
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a-c <= d && c-a <= d){
        cout << "Yes";
    }else if((a-b <= d && b-a <= d) && (b-c <= d && c-b  <= d)){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
  int i,N,T,c[1000],t[1000],min;
  scanf("%d%d",&N,&T);
  for(i=0;i<N;i++)scanf("%d%d",&c[i],&t[i]);
  for(i=0;i<N;i++){
    min=i;
    if(t[i]<=T)break;
  }
  if(i==N){
    printf("TLE\n");
    return 0;
  }
  for(;i<N;i++)
    if(c[min]>c[i]&&t[i]<=T)min=i;
  printf("%d\n",c[min]);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>

using namespace std;

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

	string s;
	cin >> s;

	if (s[0] != s[1] && s[0] != s[2] && s[1] != s[2]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

// ModInt
// region
class ModInt(x: Long) {

    companion object {
        //const val MOD = 1000000007L
        const val MOD = 998244353L
    }

    val x = (x % MOD + MOD) % MOD

    operator fun plus(other: ModInt): ModInt {
        return ModInt(x + other.x)
    }

    operator fun minus(other: ModInt): ModInt {
        return ModInt(x - other.x)
    }

    operator fun times(other: ModInt): ModInt {
        return ModInt(x * other.x)
    }

    operator fun div(other: ModInt): ModInt {
        return this * other.inv()
    }

    fun pow(exp: Long): ModInt {
        if (exp == 0L) return ModInt(1L)
        var a = pow(exp shr 1)
        a *= a
        if (exp and 1L == 0L) return a
        return this * a
    }

    fun inv(): ModInt {
        return this.pow(MOD - 2)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as ModInt

        if (x != other.x) return false

        return true
    }

    override fun hashCode(): Int {
        return x.hashCode()
    }

    override fun toString(): String {
        return "$x"
    }

}

val fac = mutableListOf<ModInt>()
val invfac = mutableListOf<ModInt>()

fun fact(n: Long, b: Boolean): ModInt {
    if (fac.count() == 0) {
        fac.add(ModInt(1))
        invfac.add(ModInt(1))
    }
    while (fac.count() <= n) {
        fac.add(fac.last() * ModInt(fac.count().toLong()))
        invfac.add(fac.last().inv())
    }
    return if (b) {
        fac[n.toInt()]
    } else {
        invfac[n.toInt()]
    }
}

fun comb(n: Long, k: Long): ModInt {
    return fact(n, true) * fact(k, false) * fact(n - k, false)
}

fun comb2(n: Long, k: Long): ModInt {
    var ans = ModInt(1)
    for (i in 0 until k) {
        ans = ans * ModInt(n - i) / ModInt(k - i)
    }
    return ans
}
// endregion

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val k = sc.nextInt()
    if (n > k) {
        println(0)
        return
    }
    var ans = ModInt(2).pow(k - 1L)
    var c = ModInt(1)
    for (i in 0 until n - 1) {
        ans -= c
        c *= ModInt(k - 1L - i) / ModInt(i + 1L)
    }
    println(ans)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 52376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << 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 trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

int dp[3005][3005];

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int a[n + 1];
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for(int len = 1; len <= n; len++) {
		for(int i = 1; i + len - 1 <= n; i++) {
			if(len == 1) {
				dp[i][i] = a[i];
			}
			else {
				int j = i + len - 1;
				dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
			}
		}
	}
	cout << dp[1][n];

	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a, b;
  cin >> a >> b;
  for (ll i = 1; i < 1000000; i++) {
    ll fa = i * 8 / 100;
    ll fb = i / 10;
    if (fa == a && fb == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

int main() {
  int n,m,c;
  int cnt = 0;
  int tmpSum = 0;
  
  cin >> n >> m >> c;
  
  vector<int> vecB(m);
  vector<int> vec(m);
  
  for(int i = 0; i < m; i++) cin >> vecB.at(i);
  
  for(int i = 0; i < n; i++){
    tmpSum = 0;
    for(int k = 0; k < m; k++) cin >> vec.at(k);  // 1行セット  
    // 計算
    for(int j = 0; j < m; j++){
      tmpSum += vec.at(j) * vecB.at(j);
    }
    tmpSum += c;
    if(tmpSum > 0) cnt++;
  }
  
  cout << cnt;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long a, b, c, min, max;
    cin >> a >> b >> c;

    min = a;
    if (min > b) min = b;
    if (min > c) min = c;

    max = a;
    if (max < b) max = b;
    if (max < c) max = c;
    
    cout << min << " " << max << endl;

    return 0;
}



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

int main() {
    int64_t N, M;
    cin >> N >> M;
    vector<vector<int64_t>> connect(N);
    for (int64_t i = 0; i < M; i++) {
        int64_t A, B;
        cin >> A >> B;
        A--; B--;
        connect[A].push_back(B);
        connect[B].push_back(A);
    }

    enum {
        BLACK, WHITE, UNDEFINED
    };
    vector<int64_t> color(N, UNDEFINED);

    stack<int64_t> st;
    color[0] = BLACK;
    st.push(0);
    while (!st.empty()) {
        int64_t top = st.top();
        st.pop();

        int64_t next_color = (color[top] == BLACK ? WHITE : BLACK);

        for (int64_t next_node : connect[top]) {
            if (color[next_node] == UNDEFINED) {
                //塗られていなかったら塗る
                color[next_node] = next_color;
                st.push(next_node);
            } else if (color[next_node] != next_color) {
                //矛盾する-> 2部グラフにならない
                //全辺が張れる
                cout << N * (N - 1) / 2 - M << endl;
                return 0;
            }
        }
    }

    int64_t black_num = 0;
    for (int64_t i = 0; i < N; i++) {
        black_num += (color[i] == BLACK);
    }

    cout << black_num * (N - black_num) - M << endl;
}

Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

vi t(21);

int main(void){
    int n; cin >> n;
    fill(ALL(t), -1);

    while(n --){
        int a, v; cin >> a >> v;
        t[a] = v;
    }
    vi::iterator res = max_element(ALL(t));

    cout << res - t.begin() << " " << *res << endl;

    return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
int main(void){
        int a,b,c,i,yakusu;
        scanf("%d %d %d",&a,&b,&c);
        i = a;
        yakusu = 0;
        while(a <= i && i <= b){
                if(c % i == 0)
                        yakusu++;
                i++;
        }
        printf("%d\n",yakusu);
        return 0;
}


Measured memory_bytes: 2104
def main():
    x = int(input())
    if 400 <= x < 600:
        print(8)
    elif x < 800:
        print(7)
    elif x < 1000:
        print(6)
    elif x < 1200:
        print(5)
    elif x < 1400:
        print(4)
    elif x < 1600:
        print(3)
    elif x < 1800:
        print(2)
    elif x < 2000:
        print(1)     
         
if __name__ == '__main__':
    main()

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

int main() {
	// your code goes here
	int r,g,b,n;
	cin>>r>>g>>b>>n;
	int cnt=0;
	for(int i=0;i<=3000;i++){
		for(int j=0;j<=3000;j++){
			int tot=i*r+j*g;
			if(n>=tot && (n-tot)%b==0)
				cnt++;
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256