akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(100000)

def dfs(v, tm):
    dts[v] = est[v] = tm + 1
    child = 0

    for i in adj[v]:
        if est[i] == float('inf'):
            child += 1
            parents[i] = v
            dfs(i, tm + 1)
            est[v] = min(est[v], est[i])

            if parents[v] is None and child > 1: aps[v] = True
            if parents[v] is not None and est[i] >= dts[v]: aps[v] = True

        elif parents[v] != i:
            est[v] = min(est[v], dts[i])


nv, ne = map(int, input().split(' '))
adj = [[] for _ in range(nv)]
est = [float('inf')] * nv
parents = [None] * nv
aps = [False] * nv
dts = [0] * nv

for _ in range(ne):
    s, t = map(int, input().split(' '))
    adj[s].append(t)
    adj[t].append(s)

dfs(0, 0)

for i in range(nv):
    if aps[i]:
        print(i)

Measured memory_bytes: 20304
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class T> inline std::istream& operator >> (std::istream& is, std::vector<T>& v) { for (T& x : v) { is >> x; }return is; }
	template<class T> inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) {
		for (auto itr = v.begin(); itr != v.end();) { os << (*itr) << ((++itr != v.end()) ? " " : ""); }
		return os;
	}
	template<class V, typename T>inline void fill(V& v, const T& val) { v = val; }
	template<class V, typename T>inline void fill(std::vector<V>& v, const T& val) { for (V& x : v) { fill(x, val); } }
	template<class V, typename H>inline void resize(std::vector<V>& v, const H h) { v.resize(h); }
	template<class V, typename H, typename... T>inline void resize(std::vector<V>& v, const H& h, const T& ... t) { v.resize(h); for (auto& x : v) { resize(x, t...); } }
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }

	void solve() {
		IOS;
		double a, b, h, m;
		cin >> a >> b >> h >> m;
		double theta = 0;
		double pi = 3.14159265358979;
		int time = 60 * h + m;
		double ta = (double)time / 720;
		ta *= 2 * pi;
		double tb = (double)m / 60;
		tb *= 2 * pi;
		double tc = abs(ta - tb);
		tc = min(2 * pi - tc, tc);
		double res = a * a + b * b - 2 * a * b * cos(tc);
		res = sqrt(res);
		cout << setprecision(20) << res << endl;
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}


Measured memory_bytes: 4244
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var A1 = cin.ReadInt;
            var A2 = cin.ReadInt;
            var A3 = cin.ReadInt;
            WriteLine(A1+A2+A3>=22 ? "bust" : "win");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 13268
/**
 *    author:  gzhffIThh
 *    created: 19.08.2020
**/
#include <bits/stdc++.h>

using namespace std;

const int N=300010;

int n,m,k,ll[N],hh[N];
int xx[N],yy[N];
bool vish[N],visl[N];

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  scanf("%d%d%d",&n,&m,&k);
  int mxh=0,mxl=0;
 	for(int i=1;i<=k;i++){
 		int x,y;scanf("%d%d",&x,&y);
 		xx[i]=x;yy[i]=y;
 		hh[x]++;mxh=max(mxh,hh[x]);
 		ll[y]++;mxl=max(mxl,ll[y]);
 	}
 	long long tmp=0,hx=0,lx=0;
 	for(int i=1;i<=n;i++){
 		if(hh[i]==mxh)vish[i]=1,hx++;
 	}
 	for(int i=1;i<=m;i++){
 		if(ll[i]==mxl)visl[i]=1,lx++;
 	}
 	for(int i=1;i<=k;i++){
 		if(vish[xx[i]]&&visl[yy[i]])tmp++;
 	}
 	printf("%d\n",mxh+mxl-(tmp==(lx*hx)));

  return 0;
}


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

int main() { 
    int n, f, ans = 0;
    string s;
    cin >> n >> s;
    for(int l = 0; l < 10; ++l) {
        for(int m = 0; m < 10; ++m) {
            for(int r = 0; r < 10; ++r) {
                f = 0;
                for(int i = 0; i < n; ++i) {
                    if(f == 0 && s[i] - '0' == l) {
                        f = 1;
                    } else if(f == 1 && s[i] - '0' == m){
                        f = 2;
                    } else if(f == 2 && s[i] - '0' == r){
                        ans++;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

X = [int(i) for i in input().split()]

tmp = 0
res = 0
res = 15 - sum(X)

print(res)


Measured memory_bytes: 30892
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

const int MAX_R = 16005;
const int MAX_C = 8005;
bool dp_x[MAX_R][MAX_C], dp_y[MAX_R][MAX_C];

int main(){
    string s; cin >> s; int n = (int)s.size();
    int x, y; cin >> x >> y; x += 8000; y += 8000;

    dp_x[8000][0] = true; dp_y[8000][0] = true;
    vector<int> xdir, ydir;
    bool next_x = true; int count = 0;
    rep(i, n){
        if(s[i] == 'F'){
            count++;
        }
        else{
            if(count > 0){
                if(next_x) xdir.push_back(count);
                else ydir.push_back(count);
            }
            count = 0;
            next_x = !next_x;
        }
    }
    if(count > 0){
        if(next_x) xdir.push_back(count);
        else ydir.push_back(count);
    }

    int cx = 0;
    for(int& d : xdir){
        cx++;
        if(cx == 1 && s[0] == 'F'){
            dp_x[8000 + d][1] = true;
            continue;
        }
        rep(i, MAX_R){
            if(dp_x[i][cx-1]) { dp_x[i + d][cx] = true; dp_x[i - d][cx] = true; }
        }
    }

    int cy = 0;
    for(int& d : ydir){
        cy++;
        rep(i, MAX_R){
            if(dp_y[i][cy-1]) { dp_y[i + d][cy] = true; dp_y[i - d][cy] = true; }
        }
    }

    string ans = "No";
    if(dp_x[x][cx] && dp_y[y][cy]) ans = "Yes";
    cout << ans << endl;
}

Measured memory_bytes: 129280
import sys
import os
import itertools
import numpy as np
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

    N=int(input())

    name=[]

    while N > 0:
        N-=1
        name.append(N%26)
        N//=26

    # print(len(alphabet))
    # print(name)
    ans=""
    for n in name:
        ans+=chr(ord('a')+n)


    print(ans[::-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 27184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const double pi = 3.141592653589793;



int main(){
    ll A;
    cin>>A;
    long double B;
  	cin>>B;
    B=B*100+0.001;
  	ll BB=B;
  	long long C=A*BB;
    C/=100;
  	cout<<C<<endl;
}



Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,S=0;cin>>N;int L[N];
  for(int i=0;i<N;i++)cin>>L[i];
  sort(L,L+N);
  for(int i=0;i<N;i++){
    for(int j=0;j<i;j++){
      for(int k=0;k<j;k++){
        if(L[i]<L[j]+L[k])S++;
      }
    }
  }
  cout<<S<<endl;
}

Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v: Vec<usize> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();
    let mut a: Vec<isize> = vec![0; v[0]];
    let mut b: Vec<isize> = vec![0; v[0]];
    for i in 0..v[0] {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let u: Vec<isize> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();
        a[i] = u[0];
        b[i] = u[1];
    }
    let mut p: Vec<isize> = vec![std::isize::MAX; v[0]];
    let mut q: Vec<usize> = vec![0; v[0]];

    for i in 0..v[1] {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let u: Vec<isize> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();
        for j in 0..v[0] {
            let z = (a[j]-u[0]).abs() + (b[j]-u[1]).abs();
            if z < p[j] {p[j] = z; q[j] = i+1;}
        }
    }
    for i in 0..v[0] {
        println!("{}", q[i]);
    }
}



Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>


using namespace std;


#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


const int N = 111111;
bool ans[N];

int main()
{
	int n,a,b;
	string s;
	
	cin>>n>>a>>b>>s;
	
	int cnt = 0;
	int kgcnt = 0;
	rep(i,s.size())
	{
		bool h = false;
		if(s[i] == 'a')
		{
			h = cnt<a+b;
		}
		if(s[i] == 'b')
		{
			h = kgcnt<b && cnt<a+b;
			if(h) kgcnt++;
		}
		if(s[i] == 'c')
		{
			
		}
		
		if(h)puts("Yes");
		else puts("No");
		
		if(h)cnt++;
	}
}




Measured memory_bytes: 896
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val AB = Array(N) { Pair(sc.next().toLong(), sc.next().toLong()) }
        val Xs = AB.sortedBy { it.first }
        val Xe = AB.sortedBy { -it.second }
        val ans = if (N % 2 == 1) {
            val mi = (N + 1) / 2 - 1
            Xe[mi].second - Xs[mi].first + 1
        } else {
            val mi1 = N / 2 - 1
            val mi2 = N / 2
            (Xe[mi1].second + Xe[mi2].second) - (Xs[mi1].first + Xs[mi2].first) + 1
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 81104
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;

//桁数を取得する
unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
int main() {

    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<n+1;i++) {
        if(GetDigit(i)%2==1)  ans++;
    }
    
    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;i++)
#define repa(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18+1);
const long long int MIN = (ll)(-1e18-1);
const long long int mod = (ll)(1e9+7);
using namespace std;

ll max(ll a,ll b,ll c) {return max(max(a, b), c);}
ll min(ll a,ll b,ll c) { return min(min(a, b), c);}
ll max(ll a,ll b) {return (a>b) ? a : b;}
ll min(ll a,ll b) {return (a<b) ? a : b;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power_mod(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=(p*a)%mod_;} n/=2; a=(a*a)%mod_;} return p%mod_;}
                                                 /*Code Begins*/

vll a, pr, su;
ll dp[500][500];

ll count(ll x, ll y){
    if(x>=y){
        dp[x][y]=0;
        return 0;
    }
    if(dp[x][y]>=0) return dp[x][y];
    dp[x][y]=MAX;
    for(int i=x;i<=y;i++){
        dp[x][y] = min(count(x,i) + count(i+1,y) + pr[y+1] - pr[x], dp[x][y]);
    }
    return dp[x][y];
}




int main(){
    _cin;
    // cout << setprecision(22);
    ll mn = MAX, mx = MIN;
    ll n, t, m, k, i, j,  sum=0,  prev, flag=0, cnt=0;
    ll x=0, y=0, fx, diff, tot=0, l , r;
    int TC=1;
    // cin >> TC;
while(TC--){
    cin >> n;
    a.assign(n,0);
    pr.assign(n+1,0);
    su.assign(n,0);
    fo(i,n) cin >> a[i];
    fo(i,n+1) fo(j,n+1) dp[i][j]=-1;
    pr[0]=0;
    repa(i,1,n+1) pr[i]=a[i-1]+pr[i-1];
    cout  << count(0,n-1);
}
 return 0;      
}

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

int main()
{
	int h, w;
	int cnt = 0;
	char c;
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>c;
			if(c == '#') ++cnt;
		}
	}
	if(cnt == h + w - 1) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	//getchar();getchar();
	return 0;
}

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 102;
char s[N];

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    scanf("%s", s);
    int n = strlen(s), res = 0;
    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[n-i-1]) res++;
    }
    printf("%d", res);
    return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define Mod 1000000007

using namespace std;
char a[1100][1100];
int h,w,dp[1100][1100];

int Rec(int i,int j)
{
    if(i >= h || j>= w || a[i][j]=='#')
        return 0;
    if(i==h-1 && j==w-1)
        return 1;
    if(dp[i][j]+1)
        return dp[i][j];
    int ans=0;

    ans=(ans%Mod + Rec(i+1,j)%Mod)%Mod;
    ans=(ans%Mod + Rec(i,j+1)%Mod)%Mod;


    return dp[i][j]=ans;
}

int main()
{
    cin>>h>>w;
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
            cin>>a[i][j];
    memset(dp,-1,sizeof(dp));

    cout<<Rec(0,0);





    return 0;
}


Measured memory_bytes: 6144
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		char[]c=s.next().toCharArray();
		int r=0,n=c.length;
		for(int i=0;i<n/2;++i)
			if(c[i]!=c[n-i-1])
				++r;
		System.out.println(r);
	}
}


Measured memory_bytes: 21844
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	
	int n, a, b;
	int x = 0, y = 0, z = 0;
	

	cin >> n >> a >> b;
	vector<int> p(n);
	FOR(i, 0, n-1) {
		cin >> p[i];
		if (p[i] <= a) {
			x++;
		}
		else if (p[i] <= b) {
			y++;
		}
		else {
			z++;
		}
	}

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

	cout << min(x, min(y, z)) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vpll flag, D; vll path;
//***********//
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int main() {
	cin >> N >> M;
	ans = 1;
	ll pre = 1;
	vl dp(N + 1);
	ll L = M - N;
	dp[0] = 1;
	dp[1] = L;
	for (i = 2; i <= N; i++) {
		(dp[i] = (dp[i - 2] * (i - 1)) % MOD + (dp[i - 1] * (i - 1)) % MOD+ (dp[i - 1] * L) % MOD) %= MOD;
	}
	ll base = 1;
	for (k = M; k >= M - N + 1;k--) {
		(base *= k) %= MOD;
	}
	(ans = dp[N] * base) %= MOD;
	//debug(dp[N],ans);
	cout << ans;
}

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

int main(void){
  char S[4];
  bool ans = true;
  cin >> S;
  for(int i = 0; i < 3; i++){
    if(S[i] == S[i + 1])
      ans = false;
  }
  if(ans) cout << "Good" << "\n";
  else cout << "Bad" << "\n";
  return 0;
}   


Measured memory_bytes: 3640
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n"
#define int ll 
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
long const M=1e9+7;
const long mxN =2e5+2 ;
ll a[mxN] ;
void solve(){
  ll n,k ; cin >> n >> k ;
  Rep(i,n)
    cin >> a[i] ;
  int x =1 ;
  int cnt =0 ,steps=1;
  map<int,int> check;
  check[x]=steps ;
  int cyc =0 ;
  vector<int>pos={x} ;
  while(1){
    if(check[a[x]]!=0){
      ++steps ;cyc = steps-check[a[x]] ;
      break ;
    }
    ++steps ;
    x=a[x] ;
    check[x]=steps ;
    pos.pb(x) ;
  }
  vi cycle ;
  while(sz(cycle)!=cyc){
    cycle.pb(pos.back()) ;
    pos.pop_back() ;
  }
  reverse(all(cycle)) ;
  if(k<sz(pos)){
    cout << pos[k] << endl ;
    return ;
  }
  k-=sz(pos) ;
  ll rem= k%cyc ;
  cout << cycle[rem] << endl ;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}

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


void solve(long long A, long long B, long long C){
    if (C <= B / A) {
        cout << C <<endl;
    }
    else {
        cout << B / A << endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;
    
    if (N%2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    
    ll Tmp = 10;
    ll Res = 0;
    while (Tmp <= N) {
        Res += N / Tmp;
        Tmp *= 5;
    }
    cout << Res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) { if (a < b) { return b; } return a; }

template<class T>
bool chmin(T &a, const T &b) { if (a > b) { a = b; return a; } return a; }

int main() {
    ll n, k; 
    cin >> n >> k;

    vector<ll> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    // rep(i, n) cout << p[i];

    ll sum = 0;
    rep(i, k) sum += p[i];

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

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

int main(){
  std::vector<int> a={1,3,5,7,8,10,12};
  std::vector<int> b={4,6,9,11};
  std::vector<int> c={2};

  int x, y;
  cin >> x >> y;

  bool xx=false;
  bool yy=false;
  for(int A:a) {
    if(A==x) xx=true;
    if(A==y) yy=true;
  }
  if(xx && yy){
    cout << "Yes" << endl;
    return 0;
  }
  bool xxx=false;
  bool yyy=false;
  for (int B:b) {
    if(B==x) xxx=true;
    if(B==y) yyy=true;
  }
  if(xxx && yyy){
    cout << "Yes" << endl;
    return 0;
  }

  bool xxxx=false;
  bool yyyy=false;
  for (int C:c) {
    if(C==x) xxxx=true;
    if(C==y) yyyy=true;
  }
  if(xxxx && yyyy){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;
int main() {
 int N;
 cin>>N;
 vector<string>W(N);
 set<string>a;
 for(int i=0;i<N;i++){
     cin>>W[i];
 }
  a.insert(W[0]);
 for(int i=1;i<N;i++){
     if(W[i-1].at(W[i-1].size()-1)!=W[i].at(0)||a.count(W[i])){
      cout<<"No"<<endl;return 0;
     }
     a.insert(W[i]);
 }
 cout<<"Yes"<<endl;   
 return 0;}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	public static void main(String[] args) {
		FasterScanner sc = new FasterScanner();

		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[n + 1];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		a[n] = x;
		Arrays.sort(a);
		int ans = a[1] - a[0];
		for (int i = 2; i < a.length; i++)
			ans = gcd(ans, a[i] - a[i - 1]);
		System.out.println(ans);

	}

	static int gcd(int a, int b) {
		int temp;
		while (b != 0) {
			temp = a % b;

			a = b;
			b = temp;
		}
		return a;
	}

	public static class FasterScanner {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = System.in.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public int[] nextIntArray(int n, int offset) {
			int[] arr = new int[n + offset];
			for (int i = 0; i < n; i++) {
				arr[i + offset] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}
			return arr;
		}

		public long[] nextLongArray(int n, int offset) {
			long[] arr = new long[n + offset];
			for (int i = 0; i < n; i++) {
				arr[i + offset] = nextLong();
			}
			return arr;
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
	}
}

Measured memory_bytes: 24568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, A, B, C;
vector<int> l;
int solve(int i, int a, int b, int c){
  if(i == N){
    if(a == 0 || b == 0 || c == 0) return 1e9;
    else return abs(A-a) + abs(B-b) + abs(C-c) - 30;
  }
  int ret;
  ret = solve(i+1, a, b, c);
  ret = min(ret, solve(i+1, a+l[i], b, c) + 10);
  ret = min(ret, solve(i+1, a, b+l[i], c) + 10);
  ret = min(ret, solve(i+1, a, b, c+l[i]) + 10);
  return ret;
}
int main(void){
  cin >> N >> A >> B >> C;
  l.resize(N);
  for(int i=0; i<N; i++) cin >> l[i];
  int ans = solve(0, 0, 0, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import Data.Int
import Data.Ratio

main = do
  n <- readLn
  as <- map read.words <$> getLine
  print $ solve (Mod n) (map Mod as)

solve :: ModInt -> [ModInt] -> ModInt
solve n as = sum $ zipWith (*) as $ map (*product[1..n]) ps where
  ps = map (subtract 1) $ zipWith (+) csr (reverse csr)
  csr = scanl1 (+) $ map recip [1..n]

modulo = 10^9+7

newtype ModInt = Mod Int deriving (Eq,Read)

instance Show ModInt where
  show (Mod a) = show a
instance Bounded ModInt where
  maxBound = Mod $ modulo - 1
  minBound = Mod 0
-- Caution! For (>=modulo), this doesn't work.
instance Enum ModInt where
  toEnum a = Mod $ mod a modulo
  fromEnum (Mod a) = a
instance Num ModInt where
  (Mod a) + (Mod b) = Mod $ mod (a+b) modulo
  (Mod a) * (Mod b) = Mod $ mod (a*b) modulo
  abs = id
  signum = const (Mod 1)
  fromInteger a = Mod $ fromIntegral $ mod a $ fromIntegral modulo
  negate (Mod 0) = Mod 0
  negate (Mod a) = Mod $ modulo - a
instance Fractional ModInt where
  recip a = a ^ (modulo-2)
  fromRational r = Mod (n * signum d) / Mod (abs d) where
    [n,d] = [fromIntegral] <*> ( [numerator,denominator] <*> [r] )


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

int main() {
	int n;
	cin >> n;
	int n432 = n / 10;
	int n4 = (n / 1000) * 1000;
	int n321 = n - n4; 
	if (n % 1111 == 0 || n432 % 111 == 0 || n321 % 111 == 0 || n % 1000 == 0) {
		cout << "Yes" << endl;
	} else { 
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	ArrayList<Integer> t = new ArrayList<Integer>();
	int count;
	String num = "1";
	int sum;
	int max =1;

	Main(int n,int k,String[] S){
		for(int p=0;p<n;p++){
			if(!(S[p].equals(num))){
				if(num.equals("0")){
					num="1";
				}else{
					num="0";
				}
				t.add(count);
				count=0;
			}
			count++;
		}

		t.add(count);			//ラス1回追加
		if(num.equals("0"))t.add(0);	//10並びにしたいので、終端数が1の場合は末尾0が0個扱い
      
		Iterator it = t.iterator();
		count=0;
		while(it.hasNext()&&count<k*2+1){
			sum += (int)(it.next());
			count++;
		}

		max=sum;

		while(count<t.size()){
			sum += t.get(count);
			sum += t.get(count+1);
			sum -= t.get(count-k*2-1);
			sum -= t.get(count-k*2);
			if(sum>max)max=sum;
			count+=2;
		}

		// 出力
		System.out.println(max);
	}

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

		String s = sc.next();
		String[] S = s.split("");

		new Main(n,k,S);
	}
}

Measured memory_bytes: 32440
#include <bits/stdc++.h>
#pragma GCC target ("arch=sandybridge")
using namespace::std;
#define int long long

#define all(x) (x).begin(), (x).end()
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}
template <class T> ostream& operator<<(ostream &O, const deque<T>& v) {for (const T &e: v) O << e; return O;}






void _main() {
        int n; cin >> n;
        int m; cin >> m;
        int k; cin >> k;
        vector<string> g(n);
        int ans = 0;
        for (int i = 0; i < n; i++) cin >> g[i];
        for (int mask1 = 0; mask1 < (1 << n); mask1++) {
                for (int mask2 = 0; mask2 < (1 << m); mask2++) {
                        auto grid = g;
                        for (int bit = 0; bit < n; bit++) {
                                if (1 << bit & mask1) {
                                        for (int col = 0; col < m; col++) grid[bit][col] = 'R';
                                }
                        }

                        for (int bit = 0; bit < m; bit++) {
                                if (1 << bit & mask2) {
                                        for (int row = 0; row < n; row++) grid[row][bit] = 'R';
                                }
                        }

                        int freq = 0;
                        for (int i = 0; i < n; i++) {
                                freq += count(all(grid[i]), '#');
                        }

                         ans += freq == k;
                }
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3572
while True:
    H, W = (int(x) for x in input().split())
    if H == W == 0:
        break
    s = 0
    for row in range(H):
        if row % 2 == 0:
            print("#." * (W//2) + "#"*(W%2))
        else:
            print(".#" * (W//2) + "."*(W%2))                
    print()


Measured memory_bytes: 5620
#include <iostream>
#include <queue>

using namespace std;

struct test {
    int p1;
    int p2;
    int p3;
    int r;
};

int main()
{
    int a,b,c;
    int N;
    vector<int> parts;

    int t1,t2,t3,res;

    queue<test> td;

    cin >> a >> b >> c;
    while(a!=0 && b!=0 && c!=0) {
        cin >> N;
        for(int i=0; i<a+b+c; i++) {
            parts.push_back(2);
        }

        for(int i=0; i<N; ++i) {
            cin >> t1 >> t2 >> t3 >> res;
            if(res==1) {
                parts[t1-1]=parts[t2-1]=parts[t3-1]=1;
                continue;
            }
            if(parts[t1-1]==1 && parts[t2-1]==1) {
                parts[t3-1]=0;
                continue;
            } else if(parts[t1-1]==1 && parts[t3-1]==1) {
                parts[t2-1]=0;
                continue;
            } else if(parts[t2-1]==1 && parts[t3-1]==1) {
                parts[t1-1]=0;
                continue;
            } else {
                td.push({t1,t2,t3,res});
            }
        }
        int cd=0;
        while(!td.empty()) {
            test temp;
            temp = td.front();
            td.pop();
            t1=temp.p1;
            t2=temp.p2;
            t3=temp.p3;
            res=temp.r;
            if(res==1) {
                parts[t1-1]=parts[t2-1]=parts[t3-1]=1;
                cd=0;
                continue;
            }
            if(parts[t1-1]==1 && parts[t2-1]==1) {
                parts[t3-1]=0;
                cd=0;
                continue;
            } else if(parts[t1-1]==1 && parts[t3-1]==1) {
                parts[t2-1]=0;
                cd=0;
                continue;
            } else if(parts[t2-1]==1 && parts[t3-1]==1) {
                parts[t1-1]=0;
                cd=0;
                continue;
            } else {
                td.push({t1,t2,t3,res});
                ++cd;
            }
            if(cd==(int)td.size()+1) break;
        }

        for(int i=0; i<a+b+c; ++i) {
            cout << parts[i] << endl;
        }

        cin >> a >> b >> c;

        while(!td.empty()) {
            td.pop();
        }
        parts.clear();
    }

    return 0;
}

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

int main(){
	int n;
	cin>>n;
	vector<pair<int,int> > a(n);
	vector<pair<int,int> > b(n);
	
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		a[i]=make_pair(x,y);
	}
	
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		b[i]=make_pair(x,y);
	}
	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	
	int ans=0;
	
	int l=0;
	int r=0;
	
	for(r=0;r<n;r++){
		int ty=-1;
		int x=-1;
		for(l=0;l<n;l++){
			if(a[l].first<b[r].first&&a[l].second<b[r].second){
				//b[r].first=-1;
				//b[r].second=-1;
				if(ty<a[l].second){
					ty=a[l].second;
					x=l;
				}
			}
		}
		if(x!=-1){
			ans++;
			a[x].first=1e9;
			a[x].second=1e9;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
// 枝定義
struct Edge
{
	int	to;
	ll	dist;
	Edge(){}
	Edge(int to, ll dist) : to(to), dist(dist){}
};

// グラフ定義(二次元配列)
template <class E>
using Graph = vector<vector<E>>;

// ダイクストラ
template<class D, D infVal>
class Dijkstra
{
public:
	// res[i] = sからiまでの最短距離
	vector<D> res;

	// 復元パス
	//	vector<int> pathList;

private:
	vector<int> pathRev;

public:
	template<class E>
	Dijkstra(const Graph<E> &G, int startFrom)
	{
		int V = (int)G.size();
		res = vector<D>(V, infVal);
		pathRev.resize(V, -1);

		using P = pair<D, int>;
		priority_queue<P, vector<P>, greater<P>> que;
		que.push(P(0, startFrom));
		res[startFrom] = 0;

		while (!que.empty()) {
			P p = que.top(); que.pop();
			int egdeFrom = p.second;

			// 違う最短距離がキューにあるのでスキップ
			if (res[egdeFrom] < p.first) {
				continue;
			}

			// 最短距離を更新
			for (E edge : G[egdeFrom]) {
				D nextDist = p.first + edge.dist;
				if (nextDist < res[edge.to]) {
					res[edge.to] = nextDist;
					pathRev[edge.to] = egdeFrom;
					que.push(P(nextDist, edge.to));
				}
			}
		}
	}

	// 経路を取得する
	vector<int> getPath(int dstPos)
	{
		vector<int> pathList;

		while (dstPos != -1) {
			pathList.push_back(dstPos);
			dstPos = pathRev[dstPos];
		}
		reverse(pathList.begin(), pathList.end());
		return pathList;
	}
};

int main()
{
	int N, X, Y;
	cin >> N >> X >> Y;
	Graph<Edge>	G(N);
	REP(i, N - 1) {
		int a = i;
		int b = i + 1;
		G[a].emplace_back(Edge(b, 1));
		G[b].emplace_back(Edge(a, 1));
	}
	X--;
	Y--;
	G[X].emplace_back(Edge(Y, 1));
	G[Y].emplace_back(Edge(X, 1));


	vector<int> ans(N - 1, 0);
	REP(i, N - 1) {
		Dijkstra<ll, (ll)2e18> dijk(G, i);
		REPN(j, i + 1, N) {
			ll dist = dijk.res[j];
			ans[dist - 1]++;
		}
	}

	for (auto one : ans) {
		cout << one << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
    COMinit();
    int h, w, a, b;
    long long int sum = 0;
    cin >> h >> w >> a >> b;
    long long max = COM(h+w-2, w-1);
    long long int pre1 = 0;
    for(int i=a-1;i>=0;--i){
        long long int pre2 = COM(h-i+b-2, b-1);
        sum += (pre2-pre1)*COM(w+i-b, w-b);
        sum %= MOD;
        pre1 = pre2;
    }
    if(max-sum >= 0) cout << (max-sum)%MOD << endl;
    else cout << (max-sum+MOD)%MOD << endl;
}

Measured memory_bytes: 12160
S = sorted(list(map(str, input())))
T = sorted(list(map(str, input())), reverse = True)
length = min(len(S), len(T))

flg = 2

for i in range(length):
	if S[i] < T[i]:
		flg = 1
		break
	elif S[i] > T[i]:
		flg = 0
		break

if flg == 1:		
	print("Yes")
elif flg == 0:
	print("No")
else:
	if len(S) < len(T):
		print("Yes")
	else:
		print("No")

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

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

    int n;
    cin >> n;

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (i & 1) cnt++;
    }

    printf("%.10f\n", (double) cnt / n);
}


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

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

int main(){
    int a, b; cin >> a >> b;
    --a; --b;
    vector<vector<char>> field(100, vector<char>(100));
    for(int i=0; i<50; ++i) for(int j=0; j<100; ++j) field[i][j] = '#';
    for(int i=50; i<100; ++i) for(int j=0; j<100; ++j) field[i][j] = '.';

    for(int i=0; i<50; i+=2){
        if(a == 0) break;
        for(int j=0; j<100; j+=2){
            if(a == 0) break;
            field[i][j] = '.';
            --a;
        }
    }

    for(int i=51; i<100; i+=2){
        if(b == 0) break;
        for(int j=0; j<100; j+=2){
            if(b == 0) break;
            field[i][j] = '#';
            --b;
        }
    }


    printf("100 100\n");
    for(int i=0; i<100; ++i){
        for(int j=0; j<100; ++j){
            cout << field[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
input()
a = [0] + list(map(int, input().split())) + [0]
a = [j - i for i, j in zip(a, a[1:])]
x = sum(abs(i) for i in a)
for i, j in zip(a, a[1:]):
    if i * j >= 0:
        print(x)
    else:
        print(x - 2 * (min(abs(i), abs(j))))

Measured memory_bytes: 20428
def array_integer(a)
	0.upto(a.count) {|x|
		a[x] = a[x].to_i
	}
	return a
end

r,c = array_integer(STDIN.gets.split(" "))

matrix = Array.new(r+1).map{Array.new(c+1, 0)}
vertical_sum = Array.new(c, 0)

0.upto(r-1) {|i|
	matrix[i] = array_integer(STDIN.gets.split(" "))
	matrix[i][c] = matrix[i].sum
	0.upto(c-1) {|j|
		vertical_sum[j] += matrix[i][j]
	}
}
matrix[r] = vertical_sum
matrix[r][c] = vertical_sum.sum

0.upto(r) {|i|
	0.upto(c) {|j|
		print matrix[i][j]
		print " " if j != c
	}
	print "\n"
}



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

int main() {
    int n;
    cin >> n;
    int a[n], c[n] = {0};
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        if(a[i]%2 == 1) {
            c[i] = 1;
        } else {
            c[i] = 2;
        }
    }
    int ans = pow(3, n), m_ans = 1;
    for(int i = 0; i < n; ++i) m_ans *= c[i];
    cout << ans - m_ans << '\n';

    return 0;
}


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

int main() {
    size_t n, k;
    cin >> n >> k;
    vector<int> ps(n);
    for (size_t i = 0; i < n; i++) {
        cin >> ps[i];
    }
    vector<double> es(n);
    for (size_t i = 0; i < n; i++) {
        es[i] = (ps[i] + 1) / 2.0;
    }
    vector<double> ss(n + 1);
    partial_sum(es.begin(), es.end(), ss.begin() + 1);
    double maxE = 0;
    for (size_t i = 0; i < n - k + 1; i++) {
        maxE = max(maxE, ss[i + k] - ss[i]);
    }
    cout << fixed << setprecision(12) << maxE << endl;

    return 0;
}


Measured memory_bytes: 4096
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

move = 0

if n >= m:
  print(move)
elif n==1:
  move = max(x) - min(x)
  print(move)
else:
  x_diff = [None]*(m-1)
  for i in range(m-1):
    x_diff[i] = [i+1, x[i+1] - x[i]]
  x_diff = sorted(x_diff, key=lambda x:-x[1])
  sep = sorted(x_diff[:n-1])
  for j in range(n):
    if j==0:
      move += max(x[0:sep[j][0]])-min(x[0:sep[j][0]])
    elif j==n-1:
      move += max(x[sep[j-1][0]:])-min(x[sep[j-1][0]:])
    else:
      move += max(x[sep[j-1][0]:sep[j][0]])-min(x[sep[j-1][0]:sep[j][0]])
  print(move)

Measured memory_bytes: 22368
#include <math.h>

#include <iostream>
#include <vector>
using namespace std;

bool JudgePrime(int num) {
    if (num > 2) {
        if (num % 2 == 0)
            return false;
        else {
            bool is_prime = true;
            for (int i = 3; i < num; i++) {
                if (num % i == 0) is_prime = false;
            }
            if (!is_prime) return false;
            if (is_prime) return true;
        }
    } else
        return true;
}

void PrimeFact(vector<int>& prime, int num) {
    for (int i = 2; i <= num; i++) {
        if (JudgePrime(i)) {
            int num_c = num;
            int count = 0;
            bool div_fin = false;
            while (!div_fin) {
                if (num_c % i == 0) {
                    num_c /= i;
                    count++;
                } else
                    div_fin = true;
            }
            prime[i - 1] += count;
        }
    }
}

int main() {
    int n;
    int mod = pow(10, 9) + 7;
    cin >> n;
    vector<int> prime(n);
    long int total = 1;
    for (int i = 1; i <= n; i++) {
        PrimeFact(prime, i);
    }
    for (int i = 0; i < n; i++) {
        total = (total * (prime[i] + 1) % mod) % mod;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 #define MAX 1000000000005
 #define ll long long int
 int main()
 {    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        long long int m,sum=0,k=0,c,i,d=0,j,sum1=0,x,sum2=0,sum3=0,l,kk,sum4=0,sum5=0,y,z,sum6=0,e;
                 string a,b;
            cin>>a>>b;
             for(i=0;i<a.size();i++)
             { if(a[i]!=b[i])
                  k++;
             }
             cout<<k<<endl;
 }

Measured memory_bytes: 3788
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<set>
using namespace std;
int n;
pair <int,int> a[200005];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	    scanf("%d",&a[i].first);
	sort(a,a+n);
	int ans=0;
	for(int i=n;i--;)
	{
		if(a[i].second)
		    continue;
		int j;
		for(j=1;j<=a[i].first;j*=2)
		    ;
		int k=upper_bound(a,a+i,make_pair(j-a[i].first,0))-a;
		if(0<k&&k<=i&&a[i].first+a[k-1].first==j)
		{
			ans++;
			a[i].second=a[k-1].second=1;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792