akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main() {
    int N;
    cin >> N;
    double b;
    vector<ll> A(N);
    vector<vector<ll>> d(19, vector<ll>(19, 0)), s(20, vector<ll>(20, 0));
    rep(i, N) {
        cin >> b;
        //b = 999;
        A[i] = 1000000000 * b + 0.5;
        //cout << A[i] << "\n";
        ll x = A[i], y = 0, z = 0;
        while (x % 2 == 0 && y < 18) {
            x /= 2;
            y++;
        }
        x = A[i];
        //cout << x << "\n";
        while (x % 5 == 0 && z < 18) {
            x /= 5;
            z++;
        }
        d[y][z]++;
        //cout << A[i] << " " << y << " " << z << "\n";
    }
    /*
    rep(i, 19) {
        rep(j, 19) {
            cout << d[i][j] << " ";
        }
        cout << "\n";
    }
    cout << "\n";
    */
    for (int i = 18; i >= 0; i--) {
        for (int j = 18; j >= 0; j--) {
            s[i][j] = d[i][j] + s[i + 1][j] + s[i][j + 1] - s[i + 1][j + 1];
        }
    }
    /*
    rep(i, 19) {
        rep(j, 19) {
            cout << s[i][j] << " ";
        }
        cout << "\n";
    }
    */
    ll ans1 = 0, ans2 = 0;
    rep(i, 19) {
        rep(j, 19) {
            rep(k, 19) {
                rep(l, 19) {
                    if (i + k < 18 || j + l < 18) continue;
                    if (i == k && j == l) {
                        ans1 += 1LL * d[i][j] * (d[i][j] - 1) / 2;
                    } else {
                        ans2 += 1LL * d[i][j] * d[k][l];
                    }
                }
            }
        }
    }
    cout << ans1 + ans2 / 2 << "\n";
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    vector<int> c(n-1), s(n-1), f(n-1);
    for(int i = 0; i < n-1; i++) cin >> c[i] >> s[i] >> f[i];
    for(int i = 0; i < n; i++) {
        int t = 0;
        for(int j = i; j < n-1; j++) {
            if(t <= s[j]) {
                t = s[j];
                t += c[j];
            } else {
                int st = ((t+f[j]-1)/f[j])*f[j];
                t = st;
                t += c[j];
            }

        }
        cout << t << endl;
    }
}

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

int main() {
    int N, S;
    std::cin >> N >> S;

    int A[N];
    for (int i = 0; i < N; ++i) {
        std::cin >> A[i];
    }

    const int64_t MOD = 998244353;
  
    // dp[i][j]: 最初の i 個について考えたとき、総和が j になる部分集合を含む集合の個数
    // 1. A[i] を選ばない場合、部分集合自体は変化しないが、それを含む集合の個数は 2 倍になるので、dp[i+1][j] += dp[i][j] * 2
    // 2. A[i] が選べるなら、dp[i+1][j] += dp[i][j-A[i]]
    std::vector<std::vector<int64_t>> dp(N + 1, std::vector<int64_t>(S + 1, 0));
    dp[0][0] = 1;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= S; ++j) {
            dp[i+1][j] += dp[i][j] * 2 % MOD;
            if (j - A[i] >= 0) {
                dp[i+1][j] += dp[i][j-A[i]];
                dp[i+1][j] %= MOD;
            }
        }
    }

    std::cout << dp[N][S] << std::endl;

    return 0;
}


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

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

const int inf = 1 << 25;
const ll INF = 1LL << 55;

int main()
{
  string s; cin >> s;
  reverse(s.begin(), s.end());
  if(s.find("C") != string::npos && s.find("F") != string::npos && s.find("C") > s.find("F")) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
def resolve():
    X,K,D = map(int,input().split())
    X = abs(X)
    if K * D <= X:
        print(X-K*D)
        return
    K -= X//D
    X %= D
    if K %2 ==0:
        print(X)
    else:
        print(abs(X-D))

resolve()

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

#define rep(i,x) for(int i=0;i<(int)(x);++i)

using Int = long long;
int mo = 1e9+7;
int inf = 1e9;

string S, T;
int q;

int A[2][100010];
int B[2][100010];

signed main()
{
    cin >> S >> T >> q;

    for (int i = 1; i <= (int)S.size(); ++i) {
        A[0][i] = A[0][i-1];
        B[0][i] = B[0][i-1];
        if (S[i-1] == 'A') A[0][i]++;
        else B[0][i]++;
    }

    for (int i = 1; i <= (int)T.size(); ++i) {
        A[1][i] = A[1][i-1];
        B[1][i] = B[1][i-1];
        if (T[i-1] == 'A') A[1][i]++;
        else B[1][i]++;
    }
    
    bool debug = false;

    rep(_, q) {
        int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d);
        int sA = A[0][b] - A[0][a-1];
        int sB = B[0][b] - B[0][a-1];
        int tA = A[1][d] - A[1][c-1];
        int tB = B[1][d] - B[1][c-1];

        if (debug) {
            printf("query %d:\n", _);
            for (int i = a-1; i <= b-1; ++i) {
                printf("%c", S[i]);
            } printf("\n");

            for (int i = c-1; i <= d-1; ++i) {
                printf("%c", T[i]);
            } printf("\n");

            printf("sA = %d, sB = %d\n", sA, sB);
            printf("tA = %d, tB = %d\n", tA, tB);
        } 

        if ((sA + sB * 2) % 3 == (tA + tB * 2) % 3 or (sB + sA * 2) % 3 == (tB + tA * 2) % 3) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2432
#include<stdio.h>
int main(){
  int i;
  double a=0,count=0;

  while(scanf("%lf",&a)!=EOF){
    count=a;
    for(i=0; i<9; i++){
      if(i%2==0) a*=2.0;
      else a/=3.0;
      count+=a;
    }
    printf("%.8lf\n",count);
  }

  return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> score(N);
    for(int i=0; i<N; i++) cin >> score[i];

    int start = 0;
    int last = K;


    for(int i=K; i<N; i++) {
        if(score[start] >= score[last]) {
            cout << "No" << endl;
        }
        if(score[start] < score[last]) {
            cout << "Yes" << endl;
        }
        start++;
        last++;
    }
}

Measured memory_bytes: 4044
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int a[128],s[128],pre[128],sum[128];
int main()
{
	int n;
	read(n);
	for (int i=1;i<=n;i++) read(a[i]),sum[i]+=sum[i-1]+a[i];
	for (int i=1;i<=n;i++) read(s[i]);
	for (int i=n;i>=1;i--) pre[i]=pre[i+1]+s[i];
	for (int i=1;i<=n;i++) ans=max(ans,sum[i]+pre[i]);
	cout<<ans;
	return 0;
}









Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;

    return 0;
}

Measured memory_bytes: 3544
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var a []int
var dp []int
var (
	n int
	m int
)

func main() {
	sc.Split(bufio.ScanWords)
	// n, m := nextInt(), nextInt()
	fmt.Scan(&n, &m)

	a = make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&a[i])
	}

	dp = make([]int, n+10)
	for i := 0; i < m; i++ {
		dp[a[i]] = -1
	}
	dp[0] = 1
	mod := 1000000007
	for i := 0; i < n; i++ {
		if dp[i] == -1 {
			continue
		}
		if dp[i+1] != -1 {
			dp[i+1] += dp[i]
			dp[i+1] %= mod
		}

		if dp[i+2] != -1 {
			dp[i+2] += dp[i]
			dp[i+2] %= mod
		}

	}

	fmt.Println(dp[n])

}

// var reached = [100010]bool{}

// func dfs(i int) int {

// 	if i == n {
// 		fmt.Printf("i=%d\n", i)
// 		return 1
// 	}
// 	var res int
// 	if i+1 < n+1 && s[i+1] != -1 {
// 		// reached[i+1] = true
// 		res += dfs(i + 1)
// 	}

// 	if i+2 < n+1 && s[i+2] != -1 {
// 		res += dfs(i + 2)
// 	}

// 	return res
// }


Measured memory_bytes: 5504
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
  string s;

  cin >> s;

  if (s.length() % 2 != 0) {
    cout << "No" << endl;
    return 0;
  } else {
    sort(begin(s), end(s));
    char c = s[0];
    int count = 1;
    for (int i = 1; i < s.length(); ++i) {
      if (c != s[i]) {
        if (count % 2 != 0) {
          cout << "No" << endl;
          return 0;
        } else {
          c = s[i];
          count = 1;
        }
      } else {
        count++;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define MAX 100000
using namespace std;
int Partition(int A[],int p,int r);

int main()
{
	int n,i,j,q;
	int A[MAX];

	cin >> n;
	for(i=0;i<n;i++){
		cin >> A[i];
	}

	//q = Partition(A,A[0],A[n-1]);
	q = Partition(A,0,n-1);

	for(i=0;i<q;i++){
		cout << A[i] << ' ' ;
	}

	cout << '[' << A[i] << "] " ;
	i++;

	for(;i<n-1;i++){
		cout << A[i] << ' ';
	}

	cout << A[i] << endl ;

	return 0;
}

int Partition(int A[],int p,int r){
	int x,i,j,tmp;
	
	x = A[r];
	i = p-1;

	for(j=p;j<r;j++){
		if(A[j]<=x){
			i = i+1;
            tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	
	tmp = A[i+1];
	A[i+1] = A[r];
	A[r] = tmp;
	
	return i+1;
}

Measured memory_bytes: 1552
/*input
1 2 22
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
typedef vector<int> vii;
typedef pair<int,int> pii;
#define F first
#define S second
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,a[5*100000];

void solve(){
	int a,b,c;cin>>a>>b>>c;
	if(a+b+c>=22){
		cout<<"bust";
	}	
	else{
		cout<<"win";
	}
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int32_t main(){
    fast_io;
    int n;
    cin>>n;
    int a[n];
    int tot=0;
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    	tot ^= a[i];
    }
    for (int i = 0; i < n; ++i)
    {
    	disp((tot^a[i]));
    }

    return 0;
}

Measured memory_bytes: 5180
/*input
1
99999
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n,freq[100005];

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a[i];
		++freq[a[i]];
	}
	ans=freq[0]+freq[1];
	for(int i=1;i<100004;++i){
		ans=max(ans,freq[i]+freq[i-1]+freq[i+1]);
	}
	cout<<ans;
}

Measured memory_bytes: 1792
N,M=map(int,input().split())
acs=[0 for i in range(N)]
wa=[0 for i in range(N)]

for  i in range(M):
    p,S=map(str,input().split())
    p=int(p)
    if S=='AC':
        acs[p-1]=1
    elif S=='WA' and acs[p-1]==0: 
        wa[p-1]+=1
for i in range(N):
    if acs[i]==0:
        wa[i]=0
ans=[sum(acs),sum(wa)]
print(*ans)

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

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

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	int A, B; cin >> A >> B;

	cout << A * (N / (A + B)) + min(N % (A + B),A) << endl;


	return 0;
}



Measured memory_bytes: 256
(N, K) = map(int, input().split())
A = list(map(int, input().split()))

k = K
d = 0
while k > 0:
    d += 1
    k = k >> 1

bset = 0x0
for i in range(d-1, -1, -1):
    b = 0x1 << i
    bcnt0 = 0
    for j in range(len(A)):
        if A[j] & b == 0:
            bcnt0 += 1
    # 1
    if bcnt0 > len(A)//2 and bset | b <= K:
        bset |= b

    #print('b: ' + str(b))
    #print('bcnt0: ' + str(bcnt0))

X = bset
ans = 0
for i in range(len(A)):
    ans += A[i] ^ X

print(ans)



Measured memory_bytes: 14620
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>
#include <iomanip>

using namespace std;

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, m;
  cin >> n >> m;
  map<int, bool> mp;

  rep(i, 0, m) {
    int a;
    cin >> a;
    mp[a] = true;
  }

  int dp[100001] = {};
  dp[0] = 1;

  rep(i, 0, n + 1) {
    if(!mp[i + 1]) dp[i + 1] += dp[i];
    if(!mp[i + 2]) dp[i + 2] += dp[i];
    dp[i + 1] %= mod;
    dp[i + 2] %= mod;
  }

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


Measured memory_bytes: 7296
from collections import deque
import sys

N,K=map(int,input().split())
A=list(map(int,input().split()))
M=10**9+7

if N==K:
    T=1
    for a in A:
        T=(T*a)%M
    print(T)
    sys.exit()
elif max(A)<0 and K%2==1:
    A.sort(reverse=True)
    T=1
    for i in range(K):
         T=(T*A[i])%M
    print(T)
    sys.exit()
    
U=list(map(lambda x:max(x,0),A))
U.sort(reverse=True)
U=deque(U)

V=list(map(lambda x:min(x,0),A))
V.sort()
V=deque(V)

T=1
Y=0
while Y<K:
    x1,x2=U[0],U[1]
    y1,y2=V[0],V[1]

    if Y==K-1 or x1*x2>=y1*y2:
        Y+=1
        T=(T*x1)%M
        _=U.popleft()
        U.append(0)
    else:
        Y+=2
        T=(T*y1*y2)%M
        _=V.popleft()
        _=V.popleft()
        V.append(0)
        V.append(0)
print(T)


Measured memory_bytes: 121816
#include <stdio.h>

int main(void){
	int i, j;
	int H, W;
	while(1){
		scanf("%d %d", &H, &W);
		if(H==0 && W==0) break;
		for(i=1;i<=H;i++){
			if(i%2==1){
				for(j=1;j<=W;j++){
					if(j%2==1) printf("#");
					else printf(".");
				}
			}else{
				for(j=1;j<=W;j++){
					if(j%2==1) printf(".");
					else printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2608
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main() {
    int x, n;
    cin >> x >> n;
    int in;
    map <int, int> m;
    if (n == 0)  {
        cout << x;
    }
    else {
    while (n--) {
        cin >> in;
        m[in] = in;
    }
    // m[x] = x;
    int minDiff(200);
    int save(200);
    for (int i = -100; i <= 110; i++) {
        if (m.find(i) == m.end()) {
            if (abs(i - x) < minDiff){ minDiff = abs(i - x); save = i; }
        }
    }
    cout << save;
    }
    return 0;
}

Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), sum = 0;
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			sum += a[i] = sc.nextInt();
		Arrays.sort(a);
		if (sum % 10 == 0)
			for (int i = 0; i < n; i++)
				if ((sum - a[i]) % 10 != 0) {
					sum -= a[i];
					break;
				}
		out.println(sum % 10 == 0 ? 0 : sum);
		out.flush();
		out.close();
	}

	static class MyScanner {
		StringTokenizer st;
		BufferedReader br;

		public MyScanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public MyScanner(String file) throws IOException {
			br = new BufferedReader(new FileReader(new File(file)));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}


Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<cstring>
using namespace std;

#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
///////////////////////////



int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	int n, y;
	cin >> n >> y;
	y /= 1000;
	int q0 = 0, q1 = 0, q2 = 0;
	q0 = y / 10;
	y -= q0 * 10;
	q1 = y / 5;
	y -= q1 * 5;
	q2 = y;
	if(q0 + q1 + q2 > n){
		printf("-1 -1 -1\n");
		return 0;
	}

	while(q0 + q1 + q2 < n && q0){
		q0 -= 1;
		q1 += 2;
	}
	while(q0 + q1 + q2 < n && q1){
		q2 += 5;
		q1 -= 1;
	}
	while(q0 + q1 + q2 > n && q1 > 1){
		q0 += 1;
		q1 -= 2;
	}
	if(q0 + q1 + q2 == n){
		printf("%d %d %d\n",q0,q1,q2);
		return 0;
	}
	printf("-1 -1 -1\n");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    
    int ans = 0;
    for ( int i = 0; i < a+1; i++ )
    {
        for ( int j = 0; j < b+1; j++ )
        {
            for ( int k = 0; k < c+1; k++ )
            {
                if ( i*500 + j*100 + k*50 == x)
                    ans++;
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"

using namespace std;
int main()
{
	vector<int> a(5);
	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
	}
	int k;
	cin >> k;
	sort(a.begin(), a.end());
	if (a[4] - a[0] <= k)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** アンテナーの数 */
	private static final int N = 5;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int[] n = IntStream.range(0, 5).map(i -> scanner.nextInt()).sorted().toArray();
			int k = scanner.nextInt();
			System.out.println((n[N - 1] - n[0] > k) ? ":(" : "Yay!");
		}
	}
}


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

int main() {
	int x,y;
	cin>>x>>y;
	int sum = 0;
	map<int, int> mp;
	mp[1] = 300000;
	mp[2] = 200000;
	mp[3] = 100000;
	mp[555] = mp[1]*2 + 400000;
	if(x==y && x==1) {
		sum+=mp[555];
	} else {
		sum+=mp[x];
		sum+=mp[y];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math,std.random;
const dx = [1,0,-1,0], dy = [0,1,0,-1];
const readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};
void read(T...)  (auto ref T args){ mixin(readMixin);}
void readArray(T)(auto ref T args){ mixin(readMixin);}
int read(){int n;read(n);return n;}
void times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}
auto dot(R1,R2)(R1 a,R2 b){ElementType!(R1) res=0;for(;!a.empty&&!b.empty;a.popFront(),b.popFront())res+=a.front*b.front;return res;}
struct infIota{int i=0;enum empty=false;int front(){return i;}void popFront(){i++;}}

int calc(int n){
	if (n < 10) return 0;
	int [] ns;
	while(n){ns ~= n % 10;n /= 10;}
	int [] res;
	auto tens = ()=> infIota().map!"10^^a";
	foreach(i;1 .. ns.length){
		res ~= ns[0..i].dot(tens()) * ns[i..$].dot(tens());
	}
	return 1 + calc(res.reduce!(max));
}
void main(){ 
	read().times({ read().calc.writeln; });
}

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

int main() {
	string s, ans; cin >> s;
	int N = s.size();
	for( int i = 0 ; i < N ; i++ ){
		if(s[i] == '0')ans.push_back('0');
		if(s[i] == '1')ans.push_back('1');
		if(s[i] == 'B' && !(ans.empty()))ans.pop_back();
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2010;
int n,m,ans,a[N][N],up[N],L[N],R[N];
char s[N];
int main(){
    scanf("%d%d",&n,&m);ans=max(n,m);
    for(int i=1;i<=n;i++){
        scanf("%s",s+1);
        for(int j=1;j<=m;j++)
            a[i][j]=s[j]=='.'?0:1;
    }
    --n;--m;
    for(int i=1;i<=m;i++)L[i]=1,R[i]=m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            a[i][j]^=a[i+1][j]^a[i][j+1]^a[i+1][j+1];
    for(int i=1;i<=n;i++){
        int l=0,r=m+1;
        for(int j=1;j<=m;j++)
            if(a[i][j])up[j]=0,l=j,L[j]=1;
            else ++up[j],L[j]=max(L[j],l+1);
        for(int j=m;j;j--)
            if(a[i][j])r=j,R[j]=m;
            else {
                R[j]=min(R[j],r-1);
                ans=max((R[j]-L[j]+2)*(up[j]+1),ans);
            }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 15872
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int x, y, z, c = 0, w = 0;

  cin >> x >> y >> z;

  while (w + y + 2 * z <= x)
  {
    c++;
    w += y + z;
  }
  w += z;

  cout << c << '\n';

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(v) for v in input().split()]
P = sorted([(v, i) for i, v in enumerate(A)], key=lambda x: x[0], reverse=True)
dp = [[0 for j in range(2005)] for i in range(2005)]

for i in range(N):
    pi = P[i][1]
    for l in range(i+1):
        r = i - l
        dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + (pi - l) * A[pi])
        dp[i+1][l] = max(dp[i+1][l], dp[i][l] + ((N-r-1) - pi) * A[pi])

ans = 0
for i in range(N+1):
    ans = max(ans, dp[N][i])

print(ans)


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

const int MAXH = 55;
const int MAXW = 55;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
const int INF = 1<<28;

int W, H, N;
int G[MAXH][MAXW];

int bfs(int sx, int sy, int tx, int ty) {
  if(sx == tx && sy == ty) return 0;
  int cost[MAXH][MAXW];
  queue<pair<int,int> > que;
  fill(cost[0], cost[MAXH], INF);
  cost[sy][sx] = 0;
  que.push(make_pair(sx, sy));
  while(que.size()) {
    pair<int,int> p = que.front();
    que.pop();
    int px = p.first;
    int py = p.second;
    for(int k = 0; k < 4; ++k) {
      if(G[py][px]&(1<<k)) continue;
      int nx = px + dx[k];
      int ny = py + dy[k];
      if(nx < 0 || nx >= W) continue;
      if(ny < 0 || ny >= H) continue;
      if(cost[ny][nx] != INF) continue;
      cost[ny][nx] = cost[py][px] + 1;
      que.push(make_pair(nx, ny));
      if(nx == tx && ny == ty) return cost[ny][nx];
    }
  }
  return INF;
}

int main() {
  fill(G[0], G[MAXH], 0);
  cin >> W >> H >> N;
  for(int k = 0; k < N; ++k) {
    int sx, sy, dx, dy;
    cin >> sx >> sy >> dx >> dy;
    if(sx == dx) {
      for(int i = min(sy,dy); i < max(sy,dy); ++i) {
	if(sx) G[i][sx-1] |= 1<<0;
	G[i][sx] |= 1<<2;
      }
    } else {
      for(int i = min(sx,dx); i < max(sx,dx); ++i) {
	if(sy) G[sy-1][i] |= 1<<1;
	G[sy][i] |= 1<<3;
      }
    }
  }
  int ix, iy, ox, oy;
  cin >> ix >> iy >> ox >> oy;
  int base = bfs(ix,iy,ox,oy);
  int res = base;
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      for(int k = 0; k < 4; ++k) {
	int ni = i + dy[k];
	int nj = j + dx[k];
	if(ni < 0 || ni >= H) continue;
	if(nj < 0 || nj >= W) continue;
	if(!(G[i][j]&(1<<k))) {
	  G[i][j] |= 1<<k;
	  G[ni][nj] |= 1<<((k+2)%4);
	  int cost = bfs(ix,iy,ox,oy);
	  if(cost != INF) {
	    res = max(res, cost);
	  }
	  G[i][j] &= ~(1<<k);
	  G[ni][nj] &= ~(1<<((k+2)%4));
	}
      }
    }
  }
  cout << res-base << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define endl '\n'
#define int ll

const double PI = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = (int) (1e9) + 7;
const int MX = 777777 + 5;
const int mod = 1777777777;
const double EPS = 1e-10;
const ll MXP = 8999251775770639633;

inline int len(string s){return s.size();}
inline int len(int* A){return (sizeof(A))/sizeof(A[0]);}
template <typename T>inline int len(vector<T> v){return v.size();}
template <typename T>inline int len(set<T> v){return v.size();}
template <typename T,typename S>inline int len(map<T,S> v){return v.size();}

int fac[MX+5];
int power(int x, int y, int p)
{
    int res = 1;

    x = x % p;

    while (y)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}

int C(int n, int r, int p)
{
    if (r==0)
        return 1;

    return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
}

void init(int mod){
    fac[0] = 1;
    for (int i=1 ; i<=MX; i++)
        fac[i] = fac[i-1]*i%mod;
}

int CC(int a, int b){
    int res = 1;
    rep(i,a+1,a-b+1)res *= i,res/=a-i+1;
//    rep(i,1,b+1)res /= i;
    return res;
}

bool equal(double a, double b) {
    return std::fabs(a - b) < std::numeric_limits<double>::epsilon();
}

map<string, int> m;
string trim(string s){
    string res;
    for (int i = 0; i < s.size() && isalpha(s[i]); ++i) {
        res += tolower(s[i]);
    }
    return res;
}

vector<int > vi;
void _() {
    int a,b,c;
    cin >> a >> b >> c;
    for (int i = 1; i <= __gcd(a,b); ++i) {
        if(!(__gcd(a,b)%i))vi.emplace_back(i);
    }
    cout << vi[vi.size()-c];




};

#undef int
int main() {
#if __MINGW32__
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Input.txt", "r", stdin);
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Output.txt", "w", stdout);

#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector <int > v;
int main()
{
    int m, n, k, t, s;
    n=-2;
    while(cin >>m)
    {
        if(m==0) cout<<0;
        else
        {
            s = m;
        while(m != 0)
        {
            k = m % n;
            t = m / n;
            if(k < 0)
            {
                k -= n;
                t++;
            }
            m = t;
            v.push_back(k);
        }

        for(int i=v.size()-1;i>=0 ;i--)
            cout<<v[i];
        }

        cout<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <cmath>
#include <cstdio>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

const double PI=4*atan(1.0);
typedef complex<double> P;

// àÏ
double dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
// OÏ
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
// a©çbÖ¶üèÅ½x©
double diffAngle(P a,P b){
  // cos>0&&sin>0 -> 0 -> 90
  // cos<0&&sin>0 -> 90->180
  // cos<0&&sin<0 -> 180->270
  // cos>0&&sin<0 -> 270 -> 359
    //double cosn=dot(a,b)/(abs(a)*abs(b));
    //double sinn=cross(a,b)/(abs(a)*abs(b));
    //double angle=acos(cosn);
    //if(sinn>0||EQ(sinn,0))
    //    return angle;
    //return 2*PI-angle;
    double angle=atan2(cross(a,b),dot(a,b));
    if(angle<0)
        return 2*PI+angle;
    return angle;
}

int main(){
    int n;
    while(cin>>n&&n!=0){
        vector<P> points;
        for(int i = 0; i < n; i++){
            int x,y;
            cin>>x>>y;
            points.push_back(P(x,y));
        }
        vector<bool> isUsed(points.size(),false);
        double sum=0;
        P cp=P(0,1);
        P pp=P(0,0);
        int cnt=n;
        while(cnt--){
            int idx=-1;
            double minAngle=100000000;
            for(int i = 0; i < points.size(); i++){
                if(isUsed[i]) continue;
                double ca=diffAngle(points[i]-pp,cp);
                //cout<<ca<<endl;
                if(EQ(minAngle,ca)){
                    if(abs(points[idx]-pp)>abs(points[i]-pp))
                        idx=i;
                }
                else if(minAngle>ca){
                    idx=i;
                    minAngle=ca;
                }
            }
            isUsed[idx]=true;
            double inc=abs(points[idx]-pp);
            sum+=inc;
            P p=(points[idx]-pp);
            cp=p/abs(p);
            pp=points[idx];
        }
        printf("%.1f\n",sum);
    }
    return 0;
}

Measured memory_bytes: 0
from collections import deque

line = input()

s1 = deque()
s2 = deque()

n = len(line)
total_area = 0

for i in range(n):
    if line[i] == "\\":
        s1.append(i)
    elif line[i] == "/":
        if s1: # if s1 is not empty
            j = s1.pop()
            area = i - j
            total_area += area
            if s2 and j < s2[-1][0]: # integrate the area of ponds
                while s2 and j < s2[-1][0]:
                    pre_pond = s2.pop()[1]
                    area += pre_pond
            s2.append([j,area])

print(total_area) 
if total_area!=0:
    print("{} ".format(len(s2)) + " ".join([str(x[1]) for x in s2]))
else:
    print(0)


Measured memory_bytes: 6564
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12

llong ketamax[80];
llong sanjo[80];
llong nijo[80];
int roop=0;
int dp[100][5];

int init(int x, int y) {
	int i, j;
	for (i = 1;i <= x;i++) {
		for (j = 0;j < y;j++) {
			dp[i][j] = 0;
		}
	}
	return 0;
}

llong rec(llong keta, llong sum) {

	int r;
	int i;
	llong ret = 0;

	roop++;
	//printf("keta=%lld,sum=%lld,roop=%d\n",keta,sum,roop);

		//再帰の終了条件と返り値を書く

	if (sum >= ketamax[keta]) {
		return sanjo[keta];
	}else if(sum==0){
		return 1;
	}else if (keta == 1) {
		return sum+1;
	}

	//今の桁の数字を数値に直すのとroop回数を決める

	//x=(int)n[keta]-'0';

	r = min(2,sum/nijo[keta]);

	if (dp[keta][r] > 0) {
		return dp[keta][r];
	}


	//再帰先(rec())を書く
	for (i = 0;i <= r;i++) {
		ret = ret + rec(keta - 1, sum - i*nijo[keta]);
		ret = ret % 1000000007;
	}

	dp[keta][r] = ret;
	return ret;
}

int main(void)
{
	//変数の宣言
	llong n;

	//よく使う変数
	int i, j, k, l;
	int flag = 0;
	llong int ans = 0;
	int count = 0;
	llong int temp, temp1, temp2;
	int max, min;
	int len;
	int sum = 0;
	int under, upper, middle;
	int dummy;

	//データの読み込み
	scanf("%lld", &n);
	//scanf_s("%lld", &n);

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	temp = 1;
	count = 1;
	ketamax[1] = 2;
	nijo[1] = 1;
	sanjo[1] = 3;
	
	while (temp < n) {
		temp = temp * 2;
		count++;
		ketamax[count] = temp*4-2;
		nijo[count] = nijo[count - 1] * 2;
	}

	for (i = 1;i <= count;i++) {
		if (i == 1) {
			sanjo[i] = 3;
		}
		else {
			sanjo[i] = (sanjo[i - 1] * 3) % 1000000007;
		}
	}

	init(80, 4);
	ans = rec(count, n);

	//	printf("計算部分終了\n");
	//出力

	printf("%lld", ans);


	//	printf("結果の出力終了\n");

	return 0;

}



Measured memory_bytes: 128
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;
constexpr ll MOD = 1000000007;

const int MAX = 510000;

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


#define rep(i, N) for(ll i=0; i<(N); ++i)

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


ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

template<typename T> inline string toString(const T &a) {
  ostringstream oss; oss << a; return oss.str();
}

ll gcd(ll x, ll y) { return x % y ? gcd(y, x % y) : y; }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

/*
* 積が負になる数: 負数 * 正数
* 積が正になる数: 正数 * 正数 or 負数 * 負数
* 答えが0になる数: 0 * 何でも
*/

ll repeatSquaring(ll n, ll p, ll mod) {
  if(p == 0) return 1;
  if(p % 2 == 0) {
    ll t = repeatSquaring(n, p / 2, mod);
    return t * t % mod;
  } else {
    return (n * repeatSquaring(n, p - 1, mod)) % mod;
  }
}

ll comb(ll n, ll k, ll mod) {
  //分子
  ll res = 1;
  rep(i, k) res = res * (n - i) % mod;
  
  //分母（逆数にする前）
  ll bunbo = 1;
  rep(i, k) bunbo = bunbo * (k - i) % mod;
  
  res = (res * repeatSquaring(bunbo, mod - 2, mod)) % mod;
  return res;
}

int main() {
  COMinit();
  ll n, k;
  cin >> n >> k;
  
  ll sum = 0;
  rep(i, min(k+1, n)) {
    sum = (sum + COM(n, i) * COM(n - 1, i) % MOD) % MOD;
  }
  
  cout << sum << endl;
}

/*
int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  
  //まず，正，0，負になるペアの個数を数える
  int posct = 0;
  int zeroct = 0;
  int negct = 0;
  rep(i, N) {
    if(A[i] < 0)  ++negct;
    if(A[i] == 0) ++zeroct;
    if(A[i] > 0)  ++posct;
  }
  
  //各符号の組
  int pos_pairct = (posct * posct - posct) / 2 + (negct * negct - negct) / 2;
  int neg_pairct = negct * posct;
  int zero_pairct = (zeroct * zeroct - zeroct) / 2 + (posct * zeroct + negct * zeroct);
  
  sort(A.begin(), A.end());
  
  //順番を区別していったん数えることにする
  //同じインデックス同士は掛けないが，別のインデックスで同じ数なら掛ける
  if(K <= neg_pairct) {
    //負の領域
    //負 * 正 で二分探索
    //負を全部正にして，全部ソートすれば良いのか．筆はなくて生徒みなせばよい．順番が逆になるくらいか
    // int mid = neg_pairct / 2;
    // while(true) {
    //   if(A) 
    // }
  } else if(K <= neg_pairct + zero_pairct) {
    //ゼロの領域
    cout << 0 << endl;
    return 0;
  } else {
    //正の領域
    //昇順
    
    //二分探索で解いてみる    
    int beginIndex = -1;
    rep(i, N) {
      if(A[i] > 0) beginIndex = i;
    }
    int endIndex = N - 1;
    
    int mid = (endIndex - beginIndex) / 2 + beginIndex;
    while(true) {
       
    }
    
  }
}
*/

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

const int N = 1e6 + 10;
int cnt[N], n, v, u;
bool white[N], allchild[N], ans = false;
vector<int> g[N];

void dfs(int v, int p){
	for (int u : g[v])
		if(u != p)
			dfs(u, v);
	cnt[v] = 1;
	for (int u : g[v])
		if(u != p)
			cnt[v] += cnt[u];
	if(cnt[v] % 2 == 0)
		white[v] = true;
	bool f = true;
	for (int u : g[v])
		if(u != p)
			if(!white[u])
				f = false;
	allchild[v] = f;
	
	int c = 0;
	for (int u : g[v])
		if(u != p)
			c += allchild[u];
	if(c >= 2)
		ans = true;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n;
	for (int i = 0; i + 1 < n; i++){
		cin >> v >> u;
		v--;u--;
		
		g[v].push_back(u);
		g[u].push_back(v);
	}
	
	dfs(0, 0);
	
	if(allchild[0])
		return cout << "First", 0;
	int c = 0;
	for (int u : g[0])
		c += allchild[u];
	if(ans)
		return cout << "First", 0;
		
	cout << "Second";
	return 0;
}

Measured memory_bytes: 30080
import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map{it.toInt()}

    val A = Array(N) { readLine()!!.split(" ").map{it.toInt()}}

    val st = TreeSet<Int>((1..M).toList())

    fun rec(): Int {
        val mp = TreeMap<Int, Int>()

        for (r in A) {
            val p = r.first { st.contains(it) }!!

            mp[p] = (mp[p] ?: 0) + 1
        }

        val e = mp.maxWith(Comparator<Map.Entry<Int, Int>> { a, b -> a.value - b.value })!!

        st.remove(e.key)

        if (st.isEmpty()) {
            return e.value
        } else {
            return Math.min(e.value, rec())
        }
    }

    println(rec())
}


Measured memory_bytes: 76228
#include<stdio.h>
#define max 26
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
}node;

node Y[max];

int Max(int , int);
int depth(int);
int height(int);

int main(){
  int i,n;
  int id,l,r;
  
  scanf("%d",&n);
  
  for(i=0;i<=n-1;i++){
    Y[i].parent=NIL;
  }
  
  for(i=0;i<=n-1;i++){
    scanf("%d %d %d",&id,&l,&r);
    Y[id].left=l,Y[id].right=r;
    if(l!=NIL)Y[l].parent=id;
    if(r!=NIL)Y[r].parent=id;
  }
    
  for(i=0;i<=n-1;i++){
    printf("node %d: parent = %d, sibling = ",i,Y[i].parent);
    
    if(Y[i].parent==NIL){
      printf("-1");
    }
    else if(Y[Y[i].parent].left==i){
      printf("%d",Y[Y[i].parent].right);
    }
    else{
      printf("%d",Y[Y[i].parent].left);
    }
    printf(", degree = ");
    if(Y[i].left==NIL && Y[i].right==NIL){
      printf("0");
    }
    else if (Y[i].left!=NIL && Y[i].right!=NIL){
      printf("2");
    }
    else{
      printf("1");
    }
    printf(", depth = %d, height = %d, ",depth(i),height(i));
    if(Y[i].parent==NIL){
      printf("root\n");
    }
    else if(Y[i].left==NIL && Y[i].right==NIL){
      printf("leaf\n");
    }
    else{
      printf("internal node\n");
    }
  }
  return 0;
}

int Max(int c,int d){
  if(c>d)return c;
  else return d;
}

int depth(int j){
  int k=0;
  while(Y[j].parent!=NIL){
    j=Y[j].parent;
    k++;
  }
  return k;
}

int height(int k){
  int H1=0,H2=0;
  if(Y[k].left!=NIL){
    H1=height(Y[k].left)+1;
  }
  if(Y[k].right!=NIL){
    H2=height(Y[k].right)+1;
  }
  return Max(H1,H2);
}



Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n;cin >> n;
  int a[n];rep(i,n){
    cin >> a[i];
  }
  int ans = MOD;
  rep(i,n){
    int sum = 0;
    while(a[i]%2 == 0){
      a[i]/= 2; sum++;
    }
    ans = min(ans,sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue<long long int> 
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
 
int solve(int a[],int n,int k,int i,int dp[])
{

    if(i==n)
        return 0;
    if(i==(n-1))
        return abs(a[n-1]-a[n]);
    else
    {
        ll x,j;
        ll y=INT_MAX;
        FOR(j,1,k+1)
        {   
            if((i+j)>n)
                break;
            if(dp[i+j]==-1)
                dp[i+j] = solve(a,n,k,i+j,dp);
            x = abs(a[i]-a[i+j]) + dp[i+j];
            y = min(x,y);
        }
        dp[i] = y;
        return dp[i];
    }
}
int main()
{
    flash;
    int t,n,k,i;
    t=1;
    int dp[100001];
    while(t--)
    {
        cin>>n>>k;
        int a[n];
        memset(dp,-1,sizeof(dp));
        FOR(i,0,n)  cin>>a[i];
        cout<<solve(a,n-1,k,0,dp)<<endl;
        
    }
}

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

int main(){
  int n;
  cin>> n;
  vector<int> l(n);
  for (int i=0; i<n; i++) cin>> l[i];
  sort(l.begin(),l.end());
  int ans=0;
  for (int i=0; i<n-2; i++){
    int k=i+2;
    for (int j=i+1; j<n-1; j++){
      if (j>=k) k=j+1;
      while (k<n && l[k]<l[i]+l[j]) k++;
      ans+=k-j-1;
    }
  }
  cout<< ans <<endl;
}

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

using namespace std;

typedef long long ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int K, N;
    cin >> K >> N;
    vector<int> h(N);
    int ret = 0;
    for(int i = 0; i < N ; ++i){
        cin >> h[i];
        if(i > 0){
            ret = max(ret, h[i] - h[i-1]);
        }
    }
    ret = max(ret, K + h[0] - h[N-1]);
    cout << K - ret << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;
  if (N/1000 == N/100%10 && N/100%10 == N/10%10) {
    cout << "Yes" << endl;
  }
  
  else if (N%10 == N/100%10 && N/100%10== N/10%10) { 
    cout << "Yes" << endl;
  }
  else  { 
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a = [int(num) for num in input().split()]
count = 0
for i in range(1, n-1):
    if a[i-1] < a[i] and a[i] < a[i+1]:
        count += 1
    elif a[i-1] > a[i] and a[i] > a[i+1]:
        count += 1
print(count)


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

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

use std::cmp::{max, min};

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    println!("{}", a + b + c - max(a, max(b, c)));
}


Measured memory_bytes: 2104
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    n = int(input())
    l = sorted(Input())
    x, y = sum(l[:-1]), l[-1]
    print("Yes" if y < x else "No")


main()

Measured memory_bytes: 9172