akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

//#pragma GCC target("avx2")
//#pragma GCC optimization("unroll-loops")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa

const int N=2e5; 
const ll MOD=1e9+7;
int tv[10],zr=N-1,mk=N-2,erk=N-3;
struct oper{
	char type;
	int i,j,k;
	oper(){}
	oper(char _type,int _i,int _j,int _k){
		type=_type;
		i=_i;
		j=_j;
		k=_k;
	}
};
vector<oper> ans;
void add(int a,int b,int c){
	ans.ad({'+',c,b,a});
}
void harc(int a,int b,int c){
	ans.ad({'<',c,b,a});
}
void plant(int ind){
	harc(tv[0],0,zr);
	harc(tv[1],1,zr);
	add(tv[2],tv[0],tv[1]);
	harc(ind,tv[2],zr);
}
void sum(int ind,int arr[],int l,int r){
	add(ind,arr[l],zr);
	FORT(i,l+1,r){
		add(ind,arr[i],ind);
	}
}
void multp2(int ind,int pw){
	FOR(i,pw){
		add(ind,ind,ind);
	}
}
int cnt=3;
int ba[70],bb[70];
int pa[70],pb[70];
void represent(int ind,int* bn,int* pw){
	int bsch=cnt++;
	FORD(i,32){
		pw[i]=cnt++;
		plant(pw[i]);
		multp2(pw[i],i);
		sum(bsch,pw,i,31);
		harc(pw[i],ind,bsch);
		multp2(pw[i],i);
		bn[i]=cnt++;
		harc(bn[i],pw[i],zr);
	}
}
int main(){
	srng;
	fastio;
	FOR(i,10){
		tv[i]=N-i-4;
	}
	plant(mk);
	add(erk,mk,mk);
	add(0,0,mk);
	add(1,1,mk);
	represent(0,ba,pa);
	represent(1,bb,pb);
	FOR(i,32){
		FOR(j,32){
			add(tv[0],ba[i],bb[j]);
			harc(tv[0],tv[0],mk);
			multp2(tv[0],i+j);
			add(2,2,tv[0]);
		}
	}
	cout<<ans.size()<<endl;
	FOR(i,ans.size()){
		cout<<ans[i].type<<" "<<ans[i].i<<" "<<ans[i].j<<" "<<ans[i].k<<endl;
	}
	return 0;
}	


Measured memory_bytes: 4232
/*
 * a.cc:
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
#include<iomanip>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main(){
  int a,b;
  cin>>a>>b;
  cout<<fixed<<setprecision(5);
  cout<<a/b<<" "<<a%b<<" "<<(double)a/b<<endl;
  return 0;

}



Measured memory_bytes: 3260
//Program.cpp
//Author : Aaryan Srivastava 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#define pb push_back
#define popb pop_back
#define ull unsigned long long  
#define beg begin
#define mp make_pair
#define pii pair<int, int>
#define piii pair<pii,int>
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second 
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using ll = long long;
#define int ll
const int N = 1e5 + 5 ;
const int mod = 1e9 + 5 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace std;
#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#define AaryanS 0 
#endif

#define debug(x) mycout << #x << " "  << x << endl ;

void solve()
{
	int n,k ;
	cin >> n >> k;
	int dp[n+1] , arr[n+1];
	rep(i,n)
	 cin >> arr[i] ;
	dp[n-1] = 0 ; 
	repD(i,n-2,0){
		int res = inf ;
		for(int j = 1; j <= k && i+j <= n-1 ; j++)
			res = min(abs(arr[i] - arr[i+j]) + dp[i+j],res) ;
		dp[i] = res ;
	}
	cout << dp[0] << endl ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
   // cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case " << t << ":\n" ;
        solve();
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    
    println!("{}", if a == b && b == c {"Yes"} else {"No"});
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pll pair<ll,ll>
#define sc(x) scanf("%lld",&x)

int main(){
	io;
	map<ll,ll>m;
	vector<ll>v;
	v.push_back(0);
	m[0]=0;
	for(ll i=1;i<=200;i++){
		ll val=i*i*i*i*i;
		m[val]=i;
		m[-val]=-i;
		v.push_back(val);
		v.push_back(-val);
	}
	
	sort(v.begin(),v.end());
	ll x;
	cin>>x;
	ll n=v.size();
	for(ll i=0;i<n;i++){
		ll val=x+v[i],val1=v[i]-x;
		if(m.find(val)!=m.end()){
			ll a=m[v[i]],b=m[val];
			//cout<<v[i]<<" "<<val<<endl;
			if((v[i]-val)==x){
				cout<<a<<" "<<b;
			}else{
				cout<<b<<" "<<a;
			}
			break;
		}if(m.find(val1)!=m.end()){
			ll a=m[v[i]],b=m[val1];
			//cout<<v[i]<<" "<<val<<endl;
			if((v[i]-val1)==x){
				cout<<a<<" "<<b;
			}else{
				cout<<b<<" "<<a;
			}
			break;
		}
	}
	
	return 0;
}
	
	


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define AC(x,t) accumulate(ALL(x),t)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string S;
    cin >> S;
    string copy = S;
    reverse( ALL( copy ) );
    cout << ( S == copy ? "Yes" : "No" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

int main() {
  string a, b;

  cin >> a >> b;

  string ans = "NO";
  if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) ans = "YES";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

int dp[50][500][500];

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

    int N, A, B;
    cin >> N >> A >> B;
    vector<int> a(N), b(N), c(N);
    for(int i = 0; i < N; ++i)  cin >> a[i] >> b[i] >> c[i];
    for(int i = 0; i <= N; ++i){
        for(int j = 0; j <= 400; ++j){
            for(int k = 0; k <= 400; ++k){
                dp[i][j][k] = INF;
            }
        }
    }
    dp[0][0][0] = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j <= 400; ++j){
            for(int k = 0; k <= 400; ++k){
                if(dp[i][j][k] == INF)  continue;
                chmin(dp[i + 1][j][k], dp[i][j][k]);
                chmin(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
            }
        }
    }
    int ans = INF;
    for(int i = 1; i <= 400; ++i){
        for(int j = 1; j <= 400; ++j){
            if(dp[N][i][j] == INF)  continue;
            int g = gcd(i, j);
            if(i / g == A && j / g == B)    chmin(ans, dp[N][i][j]);
        }
    }
    if(ans == INF)  ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 35852
#include <bits/stdc++.h>
#define pi pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,a,b) for(int i = a ; i <= b;i++)
#define ld long double
using namespace std;
void debug(int x){
    cerr<<x<<endl;
}
void debug(vector<int> v){
    for(int i = 0 ; i<v.size(); i++) cerr<<v[i]<<" ";
    cerr<<"\n";
}
void debug(int *A, int N){
    for(int i = 0 ; i < N;i++) cerr<<A[i]<<" ";
    cerr<<endl;
}
void debug(int *A, int i, int j){
    for(int k = i;k<=j;k++) cerr<<A[k]<<" ";
    cerr<<endl;
}
void scan(vector<int> &h,int N){
    for(int i = 0 ; i < N;i++){
        scanf("%d",&h[i]);
    }
}







ld dp[3001][3001] = {0.00};
int main(){
    int N;
    cin>>N;
    vector<ld> p(N+1);
    for(int i = 1; i <=N ; i++) cin>>p[i];
    //dp[i][j] is the probability of getting i heads upto position j  where i<=j (1 indexed)
    dp[0][1] = 1 - p[1]; dp[1][1] = p[1];
    for(int i = 2; i<=N;i++){
        for(int j = 0 ; j <=i; j++){
            dp[j][i] = ((j==0)?0:(dp[j-1][i-1]*p[i])) + dp[j][i-1]*(1-p[i]);  
        }
    }
    ld ans = 0;
    for(int j = 1 + N/2; j<=N;j++){
         ans = ans + (dp[j][N]);
    }
    printf("%.10Lf\n",ans);
}

Measured memory_bytes: 139648
#include <iostream>

using namespace std;

int main() {
    int x1, x2, x3, x4;
    int y1, y2, y3, y4;
    int dx, dy;

    cin >> x1 >> y1 >> x2 >> y2;

    dx = x2 - x1;
    dy = y2 - y1;

    x3 = x2 - dy;
    y3 = y2 + dx;

    dx = x3 - x2;
    dy = y3 - y2;

    x4 = x3 - dy;
    y4 = y3 + dx;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
  
int main(){
    int i,j,t,data[10];
      
    for(i=0;i<10;i++)
    {
        scanf("%d",&data[i]);
    }
      
    for(i=0;i<9;i++)
    {
        for(j=0;j<9-i;j++)
        {
            if(data[j]<data[j+1])
            {
                t=data[j];
                data[j]=data[j+1];
                data[j+1]=t;
            }
        }
    }
    for(i=0;i<3;i++)
    {
        printf("%d\n",data[i]);
    }
  
    return 0;
}

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

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

int Gcd(int a, int b, int c){
	return gcd(gcd(a,b),c);
}
int main(){
	long long int k, sum;
	sum=0;
	cin >> k;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int n=1;n<=k;n++){
				sum+=Gcd(i,j,n);
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3620
using System;
class Program
{
    static void Main(string[] args)
    {
        	string a = Console.ReadLine();
            string b = Console.ReadLine();
      		string c = b.Substring(0, b.Length-1);
            if (a.Length + 1 == b.Length && a.Equals(c) )
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
    }
}

Measured memory_bytes: 25884
#include <math.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <ostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _lcint;
#define REP(i, n) for (_lcint i = 0; i < n; i++)
#define FOR(i, a, b) for (_lcint i = (_lcint)(a); i < (_lcint)(b); i++)
#define FORREV(i, a, b) for (_lcint i = (_lcint)(b)-1; i >= (_lcint)(a); i--)
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)  \
  cout << #v << ": "; \
  REP(i, v.size()) cout << " " << v[i] << endl;

#define ALL(a) (a).begin(), (a).end()
#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// permutation
ll mPn(ll m, ll n) {
  ll a = 1;
  REP(i, n) { a *= m - i; }
  return a;
}

// excrametion
ll exc(ll m) {
  ll a = 1;
  FOR(i, 1, m) { a *= i + 1; }
  return a;
}

// combination
ll mCn(ll m, ll n) {
  ll a = 1, b = 1;
  REP(i, n) {
    a *= m - i;
    b *= n - i;
  }
  return a / b;
}

int main() {
  int N;
  int K;
  char S[100001];
  int g[100000];

  cin >> N >> K;
  scanf("%s", S);

  int group = 1;
  {
    g[0] = 0;

    FOR(i, 1, N) {
      if (S[i] != S[i - 1]) {
        g[group] = i;
        group++;
      }
    }
  }

  int result = 1;

  REP(i, group) {
    int k = K * 2;
    if (S[g[i]] == '0') {
      if (i == 0) {
        k--;
      } else
        continue;
    }

    int p = i + k + 1;
    int r = g[p];
    if (p > group - 1) {
      r = N;
    }
    // cout << g[i] << ":" << r - g[i] << endl;
    result = max(result, r - g[i]);
  }

  cout << result << endl;

  return 0;
}


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

long long N, M;
long long numarr[100005];
long long flagarr[100005];
long long X[100005];
long long Y[100005];

int main(){
	cin >> N >> M;
	for(long long i = 0; i < M; i++){
		cin >> X[i] >> Y[i];
		X[i]--;Y[i]--;
	}
	for(long long i = 0; i < N; i++){
		numarr[i] = 1;
	}
	flagarr[0] = true;


	for(long long i = 0; i < M; i++){
		if(flagarr[X[i]]){
			if(numarr[X[i]] == 1){
				flagarr[X[i]] = false;
			}
			flagarr[Y[i]] = true;
		}
		numarr[X[i]]--;
		numarr[Y[i]]++;
	}


	long long ans = 0;
	for(long long i = 0; i < N; i++){
		if(flagarr[i])
			ans++;
	}
	cout << ans << endl;

}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
//using lint = long long;

struct P
{
    int x, y;

    bool operator<(const P &a)const{
              return y>a.y;
    }

};


//vector<P> v[100100];
vector<int> v;
//bitset<4001000> b;
int a,c,i,b,n,m,k,d;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int o[111111];
int l[111111];
//int z1[1000100],z2[1000100];
int j[1];
int e[1];

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long x,y,mod=1000000007,mod2=1000000009,mod3=2017;
long long z;
double pi=3.14159265;
P u[1];
//stack<int> s;

//set<long long> s;
queue<int> q;

//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<long long,int> p;
//list<int> l;

string r;
//char r[1100222],r1[1101000];
//deque<int> de;
//srand((int)time(NULL));


bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}


int main()
{
    cin>>r;
    if(r[r.size()-1]=='1'||r[0]=='0')
    {
        puts("-1");
        return 0;
    }
    for(int i=0,j=(int)r.size()-2;i<j;i++,j--)
    {
        if(r[i]!=r[j])
        {
            puts("-1");
            return 0;
        }
    }
    n=r.size()/2-1;
    for(int i=n;i>0;i--)
    {


        /*if(r[i]>r[i-1])
    {
        puts("-1");
        return 0;
    }*/
    if(r[i]=='1'&&m==0) m=i+1;

    }
    if(!m) m=1;
    //printf("@@%d",m);
    printf("%d %d\n",m+1,m);
    for(int i=m+1;i<r.size();i++)
        printf("%d %d\n",m+1,i+1);
    for(int i=m;i>1;i--)
    {
        for(int j=i-2;j>=0;j--)
        {
            printf("%d %d\n",i,j+1);
            if(r[j]=='1')
            {
                i=j+2;
                break;
            }
        }
    }
}


Measured memory_bytes: 1664
let s, b, m = Array.fold_left (fun (s, b, m) x -> (s + abs x, b <> (x < 0), min m (abs x))) (0, false, 1000000000) (Array.init (read_int()) (fun _ -> Scanf.scanf " %d" (fun i -> i))) in print_int (s + if b then -2 * m else 0)


Measured memory_bytes: 6660
#include <iostream>
#include <string>
#include <vector>
// #include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define RFOR(i, j, k) for(int i=j ; i>=k ; i--)
#define REP(i, j) FOR(i, 0, j)
#define RREP(i, j) RFOR(i, j, 0)
#define PI 3.1415926535897932384626433832795
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int N; cin >> N;
    string s; cin >> s;
    vi a(N), b(N);

    int l = 0, r = 0, p = 0;
    int lm = 0, lr = 0;
    REP(i, N) {

        if (s[i] == '(') l++;
        else r++;
        a[i] = l - r;
        b[i] = r - l;
        lm = min(lm, a[i]);
        lr = min(lm, b[i]);
    }

//    if (a[N-1] < 0) lm -= a[N-1];
    lm = min(lm, 0);
    lr = min(lr, 0);

    int add_left1 = max(0, r-l)-lm;
    int add_left2 = max(0, l-r)-lm;
    int add_left = min(add_left1, add_left2);
    // cout << add_left1 << " " << add_left2 << " " << lm  << endl;
    REP(i, add_left) cout << '(';
    cout << s;
    REP(i, add_left+l-r) cout << ')';
    cout << 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 REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
ll fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}
string to_bin_string(int n){
    stringstream ss;
    ss << bitset<20>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
map<int, int> cnt;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<char> num(k);
    rep(i,k)cin >> num[i];

    while(1){
        bool ok = true;
        stringstream ss;
        ss << n;
        string s = ss.str();
        rep(i,s.size())rep(j,k)if(s[i] == num[j]){
            ok = false;
            break;
        }
        if(ok)break;
        n++;
    }
    cout << n << endl;
    return 0;
} 

Measured memory_bytes: 256
from heapq import heappush,heappop
n,m=map(int,input().split())
a=[[[i-1,0]]for i in range(n+1)]
a[0]=[]
for i in range(m):
    l,r,c=map(int,input().split())
    a[l].append([r,c])
q=[float("INF")]*(n+1)
q[1]=0
c=[]
heappush(c,[0,1])
while c:
    s,t=heappop(c)
    if t==n:
        print(s)
        break
    for i,j in a[t]:
        if q[i]>s+j:
            q[i]=s+j
            heappush(c,[s+j,i])
else:
    print(-1)

Measured memory_bytes: 50448
def check(A: list, B: list, start: (int, int)) -> bool:
    B_len = len(B)
    for b_pos_y, a_pos_y in enumerate(range(start[0], start[0]+B_len)):
        for b_pos_x, a_pos_x in enumerate(range(start[1], start[1]+B_len)):
            #print(f'{A[a_pos_y][a_pos_x]=} {B[b_pos_y][b_pos_x]=}')
            if A[a_pos_y][a_pos_x] != B[b_pos_y][b_pos_x]:
                return False
    return True



N, M = map(int, input().split())
A = [[[] for _ in range(N)] for _ in range(N)]
B = [[[] for _ in range(M)] for _ in range(M)]

for i in range(N):
    A[i] = list(input())

for i in range(M):
    B[i] = list(input())

scope = N - M + 1

possible = False
for i in range(scope):
    for j in range(scope):
        if check(A, B, (i, j)) == True:
            possible = True
            break

if possible:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3316
import java.util.*;

public class Main {
    public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int A = sc.nextInt();
      int B = sc.nextInt();
      
      if((N * A) >= B){
          System.out.println(B);
      } else {
          System.out.println((N * A));
      }
      sc.close();
    }
}


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

const ll mod = 1e9 + 7;

ll dp[101010][13];

int main() {
    string s;
    cin >> s;

    ll a = 0;

    string tmp = s;
    reverse(tmp.begin(), tmp.end());

    int n = tmp.size();
    ll b = 1;
    dp[0][0] = 1;
    rep(i, tmp.size()) {
        int ch;
        if (tmp[i] == '?') ch = -1;
        else ch = tmp[i] - '0';
        for (int j=0; j<10; ++j) {
            if (ch != -1 and ch != j) continue;
            for (int k=0; k<13; ++k) {
                int tmpj = j * b;
                dp[i+1][(tmpj + k) % 13] += dp[i][k];
                dp[i+1][(tmpj + k) % 13] %= mod;
            }
        }
        b *= 10;
        b %= 13;
    }

    cout << dp[n][5] % mod << endl;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	vector<pair<int,int>> v;
	for(int i=0;i<m;i++){
		int a, b; cin >> a >> b;
		v.push_back({b,a});
	}
	sort(v.begin(), v.end());
	int ans = 1;
	int r = v[0].first;
	for(int i=1;i<m;i++){
		if(v[i].second<r){
			continue;
		}else{
			ans++;
			r = v[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var N = IO.RLong;

            if (N % 2 == 1)
            {
                WriteLine(0);
                return;
            }

            long ans = 0;
            long mod = 10;
            for (int i = 0; i < 100; i++)
            {
                if (N / mod == 0) break;
                ans += N / mod;
                mod *= 5;
            }
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 17392
N = int(input())
A = [int(i) for i in input().split()]
cnt =0
for i in range(N):
	minj = i
	for j in range(i,N):
		if A[j]<A[minj]:
			minj = j
	if minj != i:
		cnt += 1
	v = A[i]
	A[i] = A[minj]
	A[minj] = v

print(" ".join(map(str,A)))
print(cnt)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

vector<pint> vp[201];
int inf=1000100010;
int d[201][201],r[9];
bool used[9];
int n,m,R;
int warshall_floyd(){
    rep(k,n)rep(i,n)rep(j,n){
        if(d[i][k]==inf||d[k][j]==inf)continue;
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
}
int main(){
    cin>>n>>m>>R;
    int sr,ds,di,rr;
    rep(i,R){
        cin>>rr;
        r[i]=rr-1;
    }
    rep(i,n)rep(j,n) d[i][j]=inf;
    sort(r,r+R);
    rep(i,m){
        cin>>sr>>ds>>di;
        d[sr-1][ds-1]=di;
        d[ds-1][sr-1]=di;
    }
    warshall_floyd();
    int ans=inf;
    do{
        int sum=0;
        rep(i,R-1) sum+=d[r[i]][r[i+1]];
        ans=min(ans,sum);
    }while(next_permutation(r,r+R));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	ll h=n/3600;
	ll m=(n/60)%60;
	ll s=n%60;
	cout<<h<<":"<<m<<":"<<s<<endl;
}




Measured memory_bytes: 3216
#include <iostream>
#include <string>

using namespace std;

//#define int long long

int grid[1000][1000];

int W, H;

void DebugPrint()
{
    for (int i = 0; i < H; ++i)
    {
        for (int k = 0; k < W; ++k)
        {
            cout << grid[i][k];
        }
        cout << "\n";
    }
    cout << "\n";
}

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


    cin >> H >> W;

    for (int i = 0; i < H; ++i)
    {
        for (int k = 0; k < W; ++k)
        {
            char in;

            cin >> in;

            if (in == '.')
            {
                grid[i][k] = 0;
            }
            else
            {
                grid[i][k] = -1;
            }
        }
    }


    //for (int i = 0; i < H; ++i)
    //{
    //    for (int k = 0; k < W; ++k)
    //    {
    //        cout << grid[i][k];
    //    }
    //    cout << "\n";
    //}

    //スタートを0にする
    grid[0][0] = 1;

    for (int i = 0; i < H; ++i)
    {
        if (grid[i][0] == -1)
        {
            break;
        }

        grid[i][0] = 1;
    }

    for (int i = 0; i < W; ++i)
    {
        if (grid[0][i] == -1)
        {
            break;
        }

        grid[0][i] = 1;
    }


    //cout << "\n";
    //for (int i = 0; i < H; ++i)
    //{
    //    for (int k = 0; k < W; ++k)
    //    {
    //        cout << grid[i][k];
    //    }
    //    cout << "\n";
    //}

    for (int i = 1; i < H; ++i)
    {
        for (int k = 1; k < W; ++k)
        {
            //壁なら処理を飛ばす
            if (grid[i][k] == -1)
            {
                continue;
            }

            //上左が壁じゃなかったら加算する
            int sum = 0;

            sum += grid[i - 1][k] == -1 ? 0 : grid[i - 1][k];
            sum += grid[i][k - 1] == -1 ? 0 : grid[i][k - 1];

            grid[i][k] = sum % 1000000007;
        }

        //DebugPrint();
    }

    cout << grid[H - 1][W - 1] << endl;
}

Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[30],b[28];
	for(int i=1;i<=30;i++){
		a[i-1]=i;
	}
	for(int i=0;i<28;i++){
		cin>>b[i];
	}
	sort(b,b+28);
	int c[2]={0},j=-1,k=-1;
	for(int i=0;i<28;i++){
		j++;
		if(a[i]!=b[j]){
			k++;
			c[k]=a[i];
			j--;
		}
		if(j==27){
			break;
		}
	}
	if(c[0]==0){
		c[0]=29;
	}
	if(c[1]==0){
		c[1]=30;
	}
	cout<<c[0]<<endl<<c[1]<<endl;
	return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{  
    int n,k,sum=0;
    cin>>n>>k;
    int arr[n+1];
    memset(arr,0,sizeof(arr));
    while(k--){
        int d;
        cin>>d;
        while(d--){
            int a;
            cin>>a;
            arr[a]=1;
        }
    }
    for(int i=1;i<=n;i++) if(arr[i]==0) sum++;
    
    cout<<sum<<endl;
}

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

int main()
{
	int n;
	cin>>n;
	
	string s;
	
	long long arr[n];
	
	long double prod=1e10;

	map<pair<int,int>,long long> mp;
	
	for(int i=0;i<n;i++)
	{
		cin>>s;
		
		bool flag=0;
		arr[i]=0;	
		int cnt=0;
		
		for(int j=0;j<s.size();j++)
		{
			if(flag)
			{
				cnt++;
				arr[i]=arr[i]*10+s[j]-'0';		
			}
			else
			{
				if(s[j]=='.')
				{
					flag=1;
				}
				else
				{
					arr[i]=arr[i]*10+s[j]-'0';
				}
			}
		}
		
			while(cnt<9)
			{
				arr[i]*=10;
				cnt++;
			}
						
			int c1=0,c2=0;
			
			while(arr[i]%2==0)
			{
				c1++;
				arr[i]/=2;
			}
			
			while(arr[i]%5==0)
			{
				c2++;
				arr[i]/=5;	
			}
			
			//cout<<c1<<' '<<c2<<endl;
			
			mp[{c1,c2}]++;
	}
	
	vector<pair<pair<int,int>,long long> > v(mp.begin(),mp.end());
	
	long long ans=0;
	
	for(int i=0;i<v.size();i++)
	{
		int a=v[i].first.first;
		int b=v[i].first.second;
		
		long long cnt=v[i].second;
		
		if(2*a>=18 && 2*b>=18)
		{
			ans+=(cnt)*(cnt-1)/2;
		}
		
		//cout<<2*a<<' '<<2*b<<' '<<cnt<<endl;
		
		for(int j=i+1;j<v.size();j++)
		{
			int a1=v[j].first.first;
			int b1=v[j].first.second;
		
			long long cnt1=v[j].second;
			
			//cout<<a+a1<<' '<<b+b1<<' '<<cnt<<' '<<cnt1<<endl;
			
			if(a+a1>=18 && b+b1>=18)
			{
				ans+=cnt*cnt1;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5172
n, m, k = [int(i) for i in input().split()]

subsets = []
splits = [i for i in range(1, n)]
n -= 1
for i in range(2**n):
    x = []
    for j in range(n):
        if i&(1<<j):
            x.append(j)
    subsets.append(x)
n+=1
A = []
for i in range(n):
    A.append([int(j) for j in input()])
ans = n*m
for subset in subsets:
    cur_ans = len(subset)
    tmp = []
    col = 0
    subset.append(100000)
    running_sum = [0 for i in range(len(subset))]    
    while col<m:
        row_ptr = 0    
        for row in range(n):
            if row > subset[row_ptr]:
                row_ptr += 1
            running_sum[row_ptr] += A[row][col]
            if running_sum[row_ptr] > k:
                col -= 1
                running_sum = [0 for i in range(len(subset))]
                cur_ans += 1
                break
                
        col += 1                
        if cur_ans >= ans:
          break
    ans = min(ans, cur_ans)
print(ans)


Measured memory_bytes: 45660
N = int(input())
A = [int(x) for x in input().split()]
B = sorted([a-i-1 for i, a in enumerate(A)])
if (N%2): median = B[N//2]
else: median = (B[(N-1)//2] + B[N//2])//2
print(sum([abs(b-median) for b in B]))


Measured memory_bytes: 101364
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <vector<int> > Vec;
#define INF 20000000

void war(Vec& vec) {
	int v = vec.size();
		for (int k = 0; k < v; k++) {
			for (int i = 0; i < v; i++) {
				for (int j = 0; j < v; j++) {
					vec[i][j] = min(vec[i][j], vec[i][k] + vec[k][j]);
				}
			}
		}
}

int main() {
	while (1) {
		int n, m, s, g1, g2, a, b, c;
		cin >> n >> m >> s >> g1 >> g2;
		s--; g1--; g2--;
		if (!n)break;
		Vec G(n);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				G[i].push_back(i != j ? INF : 0);
			}
		}
			for (int i = 0; i < m; i++) {
				cin >> a >> b >> c;
				G[a - 1][b - 1] = c;
			}
			war(G);
			int res = INF;
			for (int i = 0; i < n; i++) {
				res = min(res, G[s][i] + G[i][g1] + G[i][g2]);
			}
			cout << res << endl;
	}
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int H, W, N; cin >> H >> W >> N;
	cout << (N + max(H, W)-1) / max(H, W) << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int k = Integer.parseInt(lines[1]);

      int[] arr = new int[n+1];
      Set<Integer> set = new HashSet<>();

      String line = in.readLine();
      char regex = ' ';
      boolean isContinue = true;
      for(int m=0,offset=0,next=0; isContinue; offset = ++next) {
        if((next = line.indexOf(regex,offset)) == -1) {
          next = line.length();
          isContinue = false;
        }
        m = Integer.parseInt(line.substring(offset,next));
        arr[m]++;
        set.add(m);
      }
      Arrays.sort(arr);
      // for (int i : arr) {
      //   System.out.print(i + " ");
      // }
      // System.out.println();
      int g = set.size();
      int ans = 0;
      for(int i=n-g+1; i<=n-k; i++) {
          ans += arr[i];
      }

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 53712
#include<stdio.h>
int main(){
  int n,m,i,a,b[20]={0};
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d",&a);
    b[a]=1;
  }
  while(1){
    for(i=n++;i&&b[i%10]==0;i/=10);
    if(i==0)break;
  }
  printf("%d\n",n-1);
  return 0;
}


Measured memory_bytes: 128
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        println((int)(Math.pow(sc.nextInt(), 2)));
    }

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

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

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 21716
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

int main() {
  using namespace std;
  int N, M;
  cin >> N >> M;

  vector<int> A(N);
  for (auto &e : A) cin >> e;

  auto all_votes = accumulate(A.begin(), A.end(), 0);
  
  auto popular_count = count_if(A.begin(), A.end(), [all_votes, M](auto e) {
    return all_votes * 1.0 / (4.0 * M) <= e;
  });
  
  if (M <= popular_count) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<long long> a(x), b(y), c(z);
  for (int i = 0; i < x; i++) cin >> a[i]; sort(a.begin(), a.end(), greater<long long>()); a.push_back(-1e17);
  for (int i = 0; i < y; i++) cin >> b[i]; sort(b.begin(), b.end(), greater<long long>()); b.push_back(-1e17);
  for (int i = 0; i < z; i++) cin >> c[i]; sort(c.begin(), c.end(), greater<long long>()); c.push_back(-1e17);
  priority_queue<tuple<long long, int, int, int>> que;
  set<tuple<int, int, int>> st;
  que.emplace(a[0] + b[0] + c[0], 0, 0, 0);
  vector<long long> ret;
  vector<int> di = {1, 0, 0};
  vector<int> dj = {0, 1, 0};
  vector<int> dk = {0, 0, 1};
  for (int cnt = 0; cnt < k; cnt++) {
    long long val;
    int i, j, k;
    tie(val, i, j, k) = que.top(); que.pop();
    cout << val << endl;
    for (int l = 0; l < 3; l++) {
      int nxi = i + di[l];
      int nxj = j + dj[l];
      int nxk = k + dk[l];
      if (st.emplace(nxi, nxj, nxk).second) {
        que.emplace(a[nxi] + b[nxj] + c[nxk], nxi, nxj, nxk);
      }
    }
  }
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}

const ll MX=600000;
ll fac[MX], ifac[MX];

void pre(){
 fac[0]=1;
 rep_a(i,1,MX) fac[i]= (i*fac[i-1])%mod;
 rep(i,MX) ifac[i]= po(fac[i], mod-2);
}

ll ncr(ll n, ll r){
 if(r>n || r<0 || n<0) return 0;
 return (fac[n]*((ifac[r]*ifac[n-r])%mod))%mod; 
}




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  
    int T=1;
    //cin >> T;
    while(T--){
        pre();
        ll n,m;
        cin>>n>>m;
        ll ans=0, tmp;
     
        rep(i,n+1){
            tmp = (ncr(n,i)*((ncr(m-i, n-i)*fac[n-i])%mod))%mod;

            if(i&1) ans-=tmp;
            else ans+=tmp;
            ans%=mod;
            ans+=mod;
            ans%=mod;
        }


        ans*=ncr(m,n);
        ans%=mod;
        ans*=fac[n];
        ans%=mod;

        cout<<ans<<el;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 13172
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a,b,m;
    cin >> a >> b >> m;
    int aa[a], bb[b], c[m], x[m], y[m], all[m+1];
    for(int i=0; i<a; i++) cin >> aa[i];
    for(int i=0; i<b; i++) cin >> bb[i];
    for(int i=0; i<m; i++){
        cin >> x[i] >> y[i] >> c[i];
        all[i] = aa[x[i]-1] + bb[y[i]-1] - c[i];
    }
    sort(aa, aa+a);
    sort(bb, bb+b);
    all[m] = aa[0] + bb[0];
    sort(all, all+m+1);
    cout << all[0];
}

Measured memory_bytes: 2560
a, b, c = map(int, input().split())
# import math
# left = a + b + 2 * math.sqrt(a * b)
left = 4 * a * b
right = (c - a - b) ** 2
if (c - a - b) >= 0 and left < right:
  print('Yes')
else:
  print('No')


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

using namespace std;
using ll = long long;

#define MOD 1000000007
template<int mod>
struct ModInt{
   int x;
   ModInt():x(0){}
   ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
   ModInt &operator+=(const ModInt &p){
       if((x+=p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator-=(const ModInt &p){
       if((x+=mod-p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator*=(const ModInt &p){
       x=(int)(1LL*x*p.x%mod);
       return *this;
   }
   ModInt &operator/=(const ModInt &p){
       *this*=p.inverse();
       return *this;
   }
   ModInt &operator^=(long long p){
       ModInt res = 1;
       for (; p; p >>= 1) {
           if (p & 1) res *= *this;
           *this *= *this;
       }
       return *this = res;
   }
   ModInt operator-()const{return ModInt(-x);}
   ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
   ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
   ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
   ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
   ModInt operator^(long long p)const{return ModInt(*this)^=p;}
   bool operator==(const ModInt &p)const{return x==p.x;}
   bool operator!=(const ModInt &p)const{return x!=p.x;}
   explicit operator int() const { return x; }
   ModInt operator=(const int p) {x = p; return ModInt(*this);}
   ModInt inverse()const{
       int a=x,b=mod,u=1,v=0,t;
       while(b>0){
           t=a/b;
           a-=t*b;
           std::swap(a,b);
           u-=t*v;
           std::swap(u,v);
       }
       return ModInt(u);
   }
   friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
       return os<<p.x;
   }
   friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
       long long x;
       is>>x;
       a=ModInt<mod>(x);
       return (is);
   }
};
typedef ModInt<MOD> mint;
 
struct MComb {
   std::vector<mint> fact;
   std::vector<mint> inversed;
   MComb(int n) { // O(n+log(mod))
       fact = std::vector<mint>(n+1,1);
       for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
       inversed = std::vector<mint>(n+1);
       inversed[n] = fact[n] ^ (MOD-2);
       for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
   }
   mint ncr(int n, int r) {
       return (fact[n] * inversed[r] * inversed[n-r]);
   }
   mint npr(int n, int r) {
       return (fact[n] * inversed[n-r]);
   }
   mint nhr(int n, int r) {
       assert(n+r-1 < (int)fact.size());
       return ncr(n+r-1, r);
   }
};
 
mint ncr(int n, int r) {
   mint res = 1;
   for (int i = n - r + 1; i <= n; i++) res *= i;
   for (int i = 1; i <= r; i++) res /= i;
   return res;
}

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    mint res = (mint(2)^n) - ncr(n, a) - ncr(n, b);
    cout << mint(res.x - 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
//long long dp[100000][100000]={0};

int main() {
    int a,b,k;
    int count =0;
    scanf("%d %d %d",&a,&b,&k);
    int an[101]={0},bn[101]={0};
    for(int i=1;i<=sqrt(a);i++) {
        if(i<=sqrt(a) && a%i==0) {
            an[i] = i;
          	if(i!=sqrt(a)) an[101-i] = a/i;
        }
    }
    for(int i=1;i<=sqrt(b);i++) {
        if(i<=sqrt(b) && b%i==0) {
            bn[i] = i;
            if(i!=sqrt(b)) bn[101-i] = b/i;
        }
    }
    sort(an,an+101);
    sort(bn,bn+101);
  	//REP(i,101) cout << an[i] << " ";
    for(int i=100;i>=0;i--) {
        for(int j=100;j>=0;j--) {
            if(an[i] == bn[j]) {
                count++;
                if(count == k) {
                    printf("%d\n",an[i]);
                    return 0;
                }
                break;
            }
        }
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    string x;
    cin >> x;

    if (x == "SUN")
    std::cout << '7' << std::endl;
    if (x == "SAT")
    std::cout << '1' << std::endl;
    if (x == "FRI")
    std::cout << '2' << std::endl;
    if (x == "THU")
    std::cout << '3' << std::endl;
    if (x == "WED")
    std::cout << '4' << std::endl;
    if (x == "TUE")
    std::cout << '5' << std::endl;
    if (x == "MON")
    std::cout << '6' << std::endl;

}

Measured memory_bytes: 256
N,X,Y=map(int,input().split(' '))
ans = [0]*N
for i in range(1,N+1):
    for j in range(i+1,N+1):
        ans[min(j-i,abs(X-i)+abs(Y-j)+1)]+=1
for i in ans[1:]:
    print(i)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << '\n'
#define FL freopen("in", "r", stdin),freopen("out", "w", stdout);
#define time cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e6 + 5;
const ll mod = 998244353;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)  
int main(){
    //FL;
    fin;
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b)) << '\n';
    time;
    return 0;
}   

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto n = readln.chomp.to!int;
  auto a = readln.chomp.split.to!(int[]);
  sort(a);
  int cnt;
  int res = a[0];
  int index;
  while (cnt != n - 1) {
    cnt = 0;
    foreach (i; 0..n) {
      if (i != index) {
        a[i] = a[i] % a[index];
        if (a[i] == 0) {
          cnt++;
        } else {
          if (a[i] < res) {
            res = a[i];
            index = i;
          }
        }
      }
    }
  }

  res.writeln;
}


Measured memory_bytes: 4472