akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <string>

#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	int N;
	cin >> N;

	int l[101] = {};

	for(int i = 1; i <= 100; ++i){
		int count = 0;
		for(int j = i; j % 2 == 0; j /= 2){
			count++;
		}
		l[i] = count;
	}
	int max = 0, id = 0;
	for(int i = 0; i <= N; ++i){
		if(max <= l[i]){
			id = i;
		}
		max = MAX(max, l[i]);
	}
	cout << id << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++){
    if(n % i == 0 && i < 10 && n/i <10){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int N, K, a[111], memo[111111][2];


int dfs(int K, int i)
{
  if (memo[K][i] >= 0)
    return memo[K][i];
  
  for (int k = 0; k < N; k ++)
    if (a[k] <= K)
      if (dfs(K - a[k], 1 - i) == i)
        return memo[K][i] = i;

  return memo[K][i] = 1 - i;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> N >> K;

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

  memset(memo, -1, sizeof(memo));

  std::cout << (dfs(K, 0) == 0 ? "First" : "Second") << std::endl;

  return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=200000+10;
int n,h[N],a[N];
LL bit[N],dp[N];
void add(int pos,LL x){
	while(pos<N){
		bit[pos]=max(bit[pos],x);
		pos+=pos&-pos;
	}
}
LL query(int pos){
	LL ans=0;
	while(pos>0){
		ans=max(ans,bit[pos]);
		pos-=pos&-pos;
	}
	return ans;
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&h[i]);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	LL ans=0;
	for(int i=1;i<=n;i++){
		dp[i]=query(h[i])+a[i];
		add(h[i],dp[i]);
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>

int main( int argc, char **argv ) {

  int i;
  int j;

  for (i = 1; i <= 9; i++) {
    for (j = 1; j <= 9; j++) {
      printf("%dx%d=%d\n", i, j, i * j);
    }
  }
  
  return EXIT_SUCCESS;
}

Measured memory_bytes: 0
import sys


class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


N, M = map(int, input().split())
bridge = [list(map(lambda n: int(n) - 1, x.split())) for x in sys.stdin.readlines()]

ans = [0] * (M + 1)
ans[M] = (N * (N - 1)) // 2
uf = UnionFind(N)

for i in range(M - 1, 0, -1):
    a, b = bridge[i]
    pre = uf.parents[uf.find(b)]
    uf.union(a, b)
    post = uf.parents[uf.find(b)]

    ans[i] = ans[i + 1] - pre * (post - pre)

for i in range(M):
    print(ans[i + 1])


Measured memory_bytes: 34480
#include<stdio.h>
#define min(a,b) ((a) < (b) ? a : b)
#define max(a,b) ((a) > (b) ? a : b)
main()
{

    int a,b,c,a1,b1,c1;

    while(scanf("%d %d %d",&a,&b,&c)!=EOF){

    a1=min(min(a,b),c);
    c1=max(max(a,b),c);
    if(a1!=a && c1!=a ) b1=a;
    else if (a1!=b && c1!=b) b1=b;
    else b1=c;
        printf("%d %d %d\n",a1,b1,c1);
    }

    return 0;




}



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

int main(void) {
    long long X;
    cin >> X;
    int year = 0;
    long long n = 100;
    while (n < X) {
        n *= 1.01;
        ++year;
    }
    printf("%d\n", year);
    return 0;
}


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

int main(int, char**) {
  int64_t X;
  std::cin >> X;
  const int64_t ureshisa_big = 1000 * (X / 500);
  const int64_t ureshisa_small = 5 * ((X % 500) / 5);
  std::cout << ureshisa_big + ureshisa_small << std::endl;
}


Measured memory_bytes: 256
while True:
    n=input()
    if n=='0':
        break
    a=list(n)
    A=0
    B=0
    for i in range(1,len(a)):
        if a[i]=='A':
            A+=1
        else:
            B+=1
    if A<=10 and B<=10:
        if A==10:
            A+=1
        if B==10:
            B+=1
    else:
        if A<B:
            B+=1
        else:
            A+=1
    print(A,B)
        


Measured memory_bytes: 5552
#include<iostream>
#include<vector>
#include<climits>
#include<math.h>
#include<float.h>
#include<algorithm>
#include<time.h>
using namespace std;

#define ll long long int
#define ld long double
#define sll(x) scanf("%lli", &x)
#define sll2(x,y) scanf("%lli %lli", &x,&y)
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define eloop(i,a,b) for(ll i=a; i<=b; i++)
#define svll(v,a,b) eloop(i,a,b){ll t; sll(t); v[i]=t;}
#define all(x) x.begin(), x.end()
#define nan LLONG_MAX
#define nin LLONG_MIN
#define dan DBL_MAX
#define din DBL_MIN
#define nl printf("\n");
#define vll vector<ll> 
#define pii pair<int, int> 
#define vpii vector<pii >
#define ff first
#define ss second
#define prvp(v,a,b) eloop(i,a,b) cout << "(" << v[i].ff << ", " << v[i].ss << ")" ;
#define prvi(v,a,b) eloop(i,a,b) cout << v[i] << " ";
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

int main(){
	//freopen("1.txt", "r", stdin);
	ll T=1;// sll(T);
	//cout << "outside while loop" << endl;
	while(T--){
		ll a,b; sll2(a,b);
		
		cout << a*b << endl;
	}
	

	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll cnt4 = 0, cnt2 = 0, cnt1 = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        if(a%4 == 0) {
            cnt4++;
        }
        else if(a%2 == 0) {
            cnt2++;
        }
        else {
            cnt1++;
        }
    }

    if(cnt2 == 0) {
        if(cnt4 + 1 >= cnt1) {
            out("Yes");
        }
        else {
            out("No");
        }
    }
    else {
        if(cnt4 >= cnt1) {
            out("Yes");
        }
        else {
            out("No");
        }
    }

    re0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<cmath>
#include<algorithm>
#define LONG long long int
using namespace std;


int main() {
	char color = '0';
	string input;
	int sum = 0;
	int n = 0;
	cin >> input;
	for (int i = 0; i < input.size(); i++)
	{
		if (input[i] == color)
		{
			sum++;
		}
		if (color == '0')color = '1';
		else color = '0';
		n++;
	}

	cout << min(sum, n - sum) << endl;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
	#define int long long
	#define rep(i,m,n) for(int i=m;i<n;i++)
	#define repr(i,n,m) for(int i=n;i>=m ;i--)
	#define mod 1000000007
	#define float long double
	#define pb push_back
	#define mp make_pair
	#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
	using namespace std;
	 
	bool sortbysec(const pair<int,int> &a, 
	              const pair<int,int> &b) 
	{ 
	    return (a.second < b.second); 
	}
	bool sortinrev(const pair<int,int> &a,  
	               const pair<int,int> &b) 
	{ 
	       return (a.first > b.first); 
	}
	void swap(int *a,int *b)
	{
		int t=*a;
		*a=*b;
		*b=t;
	}
	void solve()
	{
		int x,y,a,b,c;
		cin>>x>>y>>a>>b>>c;
		int arr1[a],arr2[b],arr3[c];
		rep(i,0,a)
		cin>>arr1[i];
		rep(i,0,b)
		cin>>arr2[i];
		rep(i,0,c)
		cin>>arr3[i];
		sort(arr1,arr1+a);
		sort(arr2,arr2+b);
		sort(arr3,arr3+c);
		vector<int>v1;
		for(int i=a-1;i>=a-x;i--)
			v1.pb(arr1[i]);
		for(int i=b-1;i>=b-y;i--)
			v1.pb(arr2[i]);
		for(int i=c-1;i>=0;i--)
			v1.pb(arr3[i]);
		sort(v1.begin(),v1.end(),greater<int>());
		int total=0;
		rep(i,0,x+y)
		total+=v1[i];
		cout<<total;

	}
	signed main()
	{ 
		// #ifndef ONLINE_JUDGE
	 //   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	 //   #endif  
	   int t=1; 	
	   //cin>>t;
	   while(t--)
	   {
	      solve();
	      cout<<"\n";
	   }
	   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	  return 0;
	 }		

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

int main() {
  int N;
  cin >> N;

  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];

  map<int, int> a_map;
  for (int i = 0; i < N; i++) {
    a_map[a[i] - 1]++;
    a_map[a[i]]++;
    a_map[a[i] + 1]++;
  }

  int max_count = 0;
  for (auto itr = a_map.begin(); itr != a_map.end(); itr++) {
    max_count = max(max_count, itr->second);
  }
  cout << max_count << endl;
}


Measured memory_bytes: 8012
a = gets.chomp.to_i
b = gets.chomp.split(" ").map(&:to_i)

cnt = a/2
upsor = b.sort
dwsor = b.sort {|a, b| b <=> a }

max = upsor.slice(cnt-1)
min = dwsor.slice(cnt-1)

upc = min
dwc = max

if (upc-dwc) == 0
  puts "0"
else
  puts (upc-dwc)
end

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

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin (),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)

const double pi = 2*acos(0.0);
//__gcd(n1, n2);
//cout << fixed;
//cout << setprecision(6); //fixes # of dp



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int a, b;
    int ans = -1;
    cin >> a >> b;
    f(i, 1, 10000){
        int c = i * 0.08;
        int d = i * 0.1;
        if(c == a&& d == b){
            ans = i;
            break;
        }
    }
    cout << ans;
}








Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int n;
int d[101],a[101],pos[101];
int dp[101][6000];
int data[6000][10];
vector<int> num;
vector<int> order[6000];
int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&d[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<7;i++)num.push_back(i);
	int all=0;
	do{
		order[all++]=num;
	}while(next_permutation(num.begin(),num.end()));
	for(int i=0;i<all;i++){
		vector<int> tmp1,tmp2;
		for(int j=0;j<8;j++){
			tmp1=order[i];
			for(int k=0;k<7;k++){
				if(tmp1[k]>=j)tmp1[k]++;
			}
			tmp2.clear();
			for(int k=1;k<=7;k++){
				tmp2.push_back(tmp1[k]);
				if(tmp2[k-1]>tmp1[0])tmp2[k-1]--;
			}
			data[i][j]=lower_bound(order,order+all,tmp2)-order;
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<all;j++){
			for(int k=0;k<7;k++){
				pos[order[j][k]]=k;
			}
			int res=dp[i][j];
			for(int k=0;k<7;k++){
				if(i-7+k>=0 && 7-k<=d[i])res+=a[i];
			}
			for(int k=0;k<8;k++){
				dp[i+1][data[j][k]]=max(dp[i+1][data[j][k]],res);
				ans=max(ans,dp[i+1][data[j][k]]);
				if(i-7+pos[k]>=0 && 7-pos[k]<=d[i])res-=a[i];
				if(i-7+pos[k]>=0 && 7-pos[k]<=d[i-7+pos[k]])res+=a[i-7+pos[k]];
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

const int INF = 1000000009;

vector<int> a, ans;
vector<vector<int>> tree;
vector<int> dp;

void dfs(int v, int p = -1) {
  int idx = lower_bound(dp.begin(), dp.end(), a[v]) - dp.begin();
  int old_value = dp[idx];
  dp[idx] = a[v];
  ans[v] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
  for (int u : tree[v]) {
    if (u == p) {
      continue;
    }
    dfs(u, v);
  }
  dp[idx] = old_value;
}

int main() {
  int n;
  cin >> n;

  a = ans = vector<int>(n);
  tree = vector<vector<int>>(n);
  dp.assign(n, INF);

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

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    tree[u - 1].push_back(v - 1);
    tree[v - 1].push_back(u - 1);
  }

  dfs(0);

  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 27960
#include <bits/stdc++.h>
using namespace std;
string back(string s,int t){
    string ss="";
    for (int i = 0; i < t; i++) {
        ss+=s.at(s.size()-t+i);
    }
    return ss;
}
void pop(string &s,int t){
    for (int i = 0; i < t; i++) {
        s.pop_back();
    }
    return;
}
int main() {
    string s;cin>>s;
    string ans="NO";
    while(s.size()>4){
        if(back(s,5)=="erase"||back(s,5)=="dream") {
            pop(s,5);
        }else if(back(s,6)=="eraser") {
            pop(s,6);
        }else if(back(s,7)=="dreamer") {
            pop(s,7);
        }else{break;}
    }
    
    if(s.size()==0) ans="YES";
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define uLL unsigned long long
using namespace std;
#define LL long long
int mark[2333];
int main() {
	int L,R;
	cin >> L >> R;
	for(int i=L,s=1; i<=R && s <= 2019*3; i++,s++) mark[i%2019] ++;
	int ans = 2019;
	for(int i=0; i<=2019; i++) {
		if(!mark[i]) continue;
		mark[i] --;
		for(int j=0; j<=2019; j++) if(mark[j]) ans = min(ans,i*j%2019);
		mark[i] ++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

int N, K;
vector<int> A;
vector<int> G;

int main() {
	cin >> N >> K;
	A.resize(N);
	in(A);
	G.resize(K + 1,0);
	for (int k = 0; k <= K; k++) {
		set<int> s;
		for (int n = 0; n < N; n++) {
			if (k < A[n])continue;
			s.insert(G[k - A[n]]);
		}
		int g = 0;
		while (s.count(g) != 0)g++;
		G[k] = g;
	}
	if (G[K] == 0)cout << "Second" << endl;
	else cout << "First" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
#include <cstring>


int main() {
    int n; std::cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        int a; std::cin >> a;
        cnt += (i & 1) && (a & 1);
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 3592
#line 1 "d.cpp"
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 3 "../../library/prime_factorization.hpp"

map<ll, ll> prime_factorization(ll n) {
  map<ll, ll> m;
  for (ll i = 2; i*i <= n; i++) {
    while (n%i == 0) {
      m[i]++;
      n /= i;
    }
  }
  if (n != 1) m[n]++;
  return m;
}
#line 3 "d.cpp"

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

  ll ans = 0;

  auto m = prime_factorization(n);
  for (auto&& i : m) {
    ll t = i.second;
    ll cnt = 1;
    while ((cnt+1)*(cnt+2)/2 <= t) {
      cnt++;
    }
    ans += cnt;
  }

  cout << ans << el;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

#define DEBUG(fmt, ...)
//#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

// (x^n)%m
ll modpow(ll x, ll n, ll m){
    ll ret = 1;
    while( n != 0 ){
        if( n&1 ){ ret = (ret*x)%m; }
        x = (x*x)%m;
        n >>= 1;
    }
    return ret;
}

// (x^(m-2))%m
ll modinv(ll x, ll m){
    return modpow(x, m-2 , m);
}



vector<ll> modfact;
vector<ll> modfactinv;


ll modcomb(ll n, ll r){
    // n! / (r! * (n-r)!)
    ll denom = 1;
    ll numer = 1;
    numer = modfact[n];
    denom = (modfactinv[r] * modfactinv[n-r])%MOD;
    DEBUG("modfactinv[%lld]=%lld modfactinv[n-r(%lld)]=%lld", r, modfactinv[r], n-r, modfactinv[n-r]);
    DEBUG("numer = %lld , denom=%lld", numer, denom);
    return (numer * denom)%MOD;
}

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll n, k;

    cin >> n >> k;

    modfact.resize(2*100000+1);
    modfactinv.resize(2*100000+1);
    modfact[0] = 1;
    modfactinv[0] = modinv(1, MOD);
    ll fact = 1;
    for( int i = 1; i <= 2*100000; i++){
        fact = (fact*i)%MOD;
        modfact[i] = fact;
        modfactinv[i] = modinv(fact, MOD);
    }

    ll ans = 0;
    for(int i = 0; i < n && i <= k; i++ ){
        // nCi * (n-i)Hi -> nCi * (n-1)Ci
        ll tmp = (modcomb(n,i) * modcomb(n-1,i))%MOD;
        DEBUG("i=%d  tmp=%lld", i, tmp);
        ans += tmp;
    }

    cout << (ans+MOD)%MOD << endl;
}


Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main(){
  int n, t;
  int mincost = 1001;
  cin >> n >> t;
  
  for(int i = 0; i < n; i++){
    int costi, timei;
    cin >> costi >> timei;
    if(timei <= t && costi < mincost){
      mincost = costi;
    }
  }
  
  if(mincost == 1001) cout << "TLE" << endl;
  else cout << mincost << endl;
  
  return 0;
}

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

using namespace std;

#define int long long

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

    int n, m;
    cin >> n >> m;

    int d = 1;
    vector <int> v;
    while (d * d <= m) {
        if (m % d == 0) {
            v.push_back(d);
            v.push_back(m / d);
        }
        ++d;
    }

    int ans = -1;
    for (int e : v) {
        if (e * n <= m) ans = max(ans, e);
    }

    cout << ans << '\n';
    return 0;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define unmap  	unordered_map<int,int>
#define	unset	unordered_set<int>
#define maxpq  	priority_queue<int>
#define minpq  	priority_queue<int, vector<int>, greater<int>>
#define pb 		push_back		
#define ll 		long long
#define ull     unsigned ll
#define ff 		first
#define ss 		second//typedef second ss;
#define foton(i,n) for(int i=0;i<n;i++)
#define	faton(i,a,n)	for(int i=a;i<=n;i++)
#define mod 	1000000007
#define endl "\n"
using namespace std;

int n,m;
char a[1001][1001];
int t[1001][1001];
int add(int a, int b){
    return ((a%mod)+(b%mod))%mod;
}
int fun(int i,int j){
    if(a[i][j] == '#') return 0;
    if(i>=n || j>=m) return 0;
    if(i==n-1 && j==m-1) return 1;
    if(t[i][j] != -1) return t[i][j];
    return t[i][j] = add(fun(i+1,j),fun(i,j+1));
}
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    memset(t,-1,sizeof(t));
    cout<<fun(0,0)%mod<<endl;
}


Measured memory_bytes: 8632
//LIS
#include<iostream>
using namespace std;
int main(){
  int n,h1[101],r1[101],m,h2[101],r2[101],k;
  int data[201],data2[201],dp[201];

  data[0]=data2[0]=0;

  
  while(cin >>n && n!=0){
    dp[0]=0;

    k=0;
    for(int i=1;i<=n;i++){
      cin >>h1[i]>>r1[i];
      data[i]=h1[i];data2[i]=r1[i];}
    cin >>m;
    for(int i=1;i<=m;i++){
      cin >>h2[i]>>r2[i];
      data[i+n]=h2[i];data2[i+n]=r2[i];}
    int key;
    for(int i=1;i<n+m+1;i++){
      key=i;
      for(int j=i;j<n+m+1;j++){
	if(data[key]>data[j])key=j;}
      swap(data[i],data[key]);
      swap(data2[i],data2[key]);}

    for(int i=1;i<n+m+1;i++){
      key=0;
      for(int j=0;j<i;j++){
	
	if( (  data[j]<data[i] && data2[j]<data2[i] )  && dp[j]>dp[key]) {
	  key=j;
	}
      }
      dp[i] = dp[key]+1;
    }
   
    for(int i=1;i<n+m+1;i++){
      if(dp[i]>k)k=dp[i];

    }
    cout<<k<<endl;
    /*
	for(int i=0;i<n+m+1;i++){
      cout<<dp[i]<<endl;
      cout<<data[i]<<" "<<data2[i]<<endl;}
    */
  }
}
    
    
  
  

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long N, x;
vector<long long> a1, a2;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long ans0 = 0;
	cin >> N >> x;
	for(int i=0; i<N; i++){
		long long v;
		cin >> v;
		if(v > x){
			ans0 += (v - x);
			v = x;
		}
		a1.push_back(v);
		a2.push_back(v);
	}
	a1.push_back(0);
	a2.push_back(0);

	long long ans1 = ans0;
	for(int i=1; i<N; i+=2){
		long long v = min(x - a1[i - 1], x - a1[i + 1]);
		if(a1[i] > v){
			ans1 += (a1[i] - v);
			a1[i] = v;
		}
	}
	//printf("ans1=%lld\n", ans1);

	long long ans2 = ans0;
	for(int i=1; i<N; i++){
		long long d = x - a2[i - 1];
		if(a2[i] > d){
			ans2 += (a2[i] - d);
			a2[i] = d;
		}
	}
	//printf("ans2=%lld\n", ans2);
	//printf("%lld\n", min(ans1, ans2));
	printf("%lld\n", ans2);

	return 0;
}

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

const int N_MAX = 100, A_MAX = 100, INF = 2e9;

int n;
int a[N_MAX + 2];

int costMin;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];

    costMin = INF;
    for(int i = -A_MAX; i <= A_MAX; i++)
    {
        int costCur = 0;
        for(int j = 1; j <= n; j++)
            costCur += (i - a[j]) * (i - a[j]);

        costMin = min(costMin, costCur);
    }

    cout << costMin << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int H, W, i, j;

  while(1){
    scanf("%d %d", &H, &W);

    if(H == 0 && W == 0){
      break;
    }

    for(i=1 ; i <= H ; i++){
      for(j=1 ; j <= W ; j++){

	if(i % 2 == 0){
	  if(j % 2 == 0){
	    printf("#");
	  }
	  else{
	    printf(".");
	  }
	}

	else{
	  if(j % 2 == 0){
	    printf(".");
	  }
	  else{
	    printf("#");
	  }
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}
   

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    a[i]--;
    sum=sum+a[i];
  }
  cout<<sum<<endl;
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    map<char, int> mp;

    for (int i=0; i<4; i++) {
        mp[s[i]]++;
    }

    if (mp.size() == 2) {
        for (auto it: mp) {
            if (it.second != 2) {
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
	return 0;
    }

    cout << "No";

    return 0;
}



Measured memory_bytes: 256
//2018.09.14 6min
//TLE

#include <iostream>
using namespace std;

int main() {
    long N, K;
    cin >> N >> K;

    long ans = 0;
    long num,num2=0;

    num = N/K;
    ans = num*num*num;

    long i;
    if(K%2==0){
        for(i=1;i<N+1;i++){
            if(i%K == K/2)num2++;
        }
        ans += num2*num2*num2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort compare a;
    let sum = Array.fold_left (+) 0 a in
    let sum = sum - a.(n - 1) / 2 in
    Printf.printf "%d\n" sum
)

Measured memory_bytes: 3828
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define full  -1
#define empty -1
#define N 200

void popnum();
void push();
int pop();
int isempty();
int isfull();

int c[N];
int top=0,a,b;

int main(){
  int x,i;
  char s[100];
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      popnum();
      push(a+b);
    } else if ( s[0] == '-' ){
      popnum();
      push(a-b);
    } else if ( s[0] == '*' ){
      popnum();
      push(a*b);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());

  return 0;
}

void push(int x){
  if(isfull()!=full)
    c[top++]=x; 
}
int pop(){

  if(isempty()!=empty){
    return c[--top]; 
  }
  else return empty;

}
int isempty(){
  if(top==0)return empty;
  return 0;
}
int isfull(){
  if(top==N)
    return full;
  return 0;
}

void popnum(){
  b=pop();
  a=pop();
}



Measured memory_bytes: 2104
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <memory.h>
#include <cmath>
#include <array>

void re(int& x);

void re(char* c);
template<class T, class... Ts> void re(T& t, Ts&... ts);

void pr(const char *x);

void ps();
template<class T, class... Ts> void ps(const T& t, const Ts&... ts);

#ifdef FFDBG

#else
#define dbg(x...) dsfdsfsdfasd
#endif

#define rep(i, a, b) for(int i = a; i < (b); ++i)

int n, a, b, c, d;
char s[210000];
int r[210000];

void solve()
{
    re(n,a,b,c,d,s); a--;b--;c--;d--;

    r[a] = 1;
    rep(i,a+1,n) if (s[i] == '.') {
        r[i] = r[i-1];
        if (i-2 >= 0) r[i] = (r[i] || r[i-2]);
    }   

    if (!r[c] || !r[d]) {
        ps("No");
        return;
    }

    if (c < d) {
        ps("Yes");
        return;
    }

    rep(i,b,d+1) {
        if (i-1 >= 0 && i+1 < n && r[i-1] && r[i] && r[i+1]) {
            ps("Yes");
            return;
        }
    }

    ps("No");
}

int main() {

    solve();
}

void re(int& x) { scanf("%d", &x); }

void re(char* c) { scanf("%s", c); }
template<class T, class... Ts> void re(T& t, Ts&... ts) { 
    re(t); re(ts...); 
}

void pr(const char *x) { printf("%s", x); }

void ps() { pr("\n"); }
template<class T, class... Ts> void ps(const T& t, const Ts&... ts) { 
    pr(t); if (sizeof...(ts)) pr(" "); ps(ts...); 
}



Measured memory_bytes: 1152
#include <stdio.h>

int main(){
    int n, min = 1000000, max = -1000000; 
    long int sum = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        int a;
        scanf("%d", &a);
        if(min > a){
            min = a;
        }
        if(max < a){
            max = a;
        }
        sum += a;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
int main(){


vector<int> v={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int n; cin>>n;
cout<<v[n];

return 0;
}

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

public class Main
{
	public static void main(String[] args)
	{
		int[] h = new int[300];
		int[] w = new int[300];
		Scanner sc = new Scanner(System.in);
		int count=0,i=0,j=0,k=0;
		while(true)
		{
			h[count] = sc.nextInt();
			w[count] = sc.nextInt();
			if((h[count]==0)&&(w[count]==0))break;
			count++;
		}
		for(i=0;i<count;i++)
		{
			for(j=0;j<h[i];j++)
			{
				for(k=0;k<w[i];k++)
				{
					if(j%2==0)
					{
						if(k%2==0)System.out.printf("#");
						else System.out.printf(".");
					}
					else
					{
						if(k%2==0)System.out.printf(".");
						else System.out.printf("#");			
					}
					
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
	}
}

Measured memory_bytes: 59968
#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    bool yes = false;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        if (a == b) {
            cnt++;
        }
        else {
            cnt = 0;
        }
        if (cnt == 3) {
            yes = true;
        }
    }
    if (yes) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <utility>
#include <queue>
#include <string>
#include <vector>
#define llint long long
#define lim 1000000000LL

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

struct node{
	llint val;
	string s;
	llint num;
	vector<llint> vec;
	node(){}
	node(llint a){
		val = a;
	}
	node(string t){
		s = t;
		val = -1;
	}
};

string s;
int k;
vector<node> tree;

llint parseNum(int &p)
{
	llint ret = 0;
	while(s[p] >= '0' && s[p] <= '9'){
		ret *= 10;
		ret += s[p] - '0';
		p++;
	}
	return ret;
}

string parseString(int &p)
{
	string ret;
	while(s[p] >= 'A' && s[p] <= 'Z'){
		ret += s[p];
		p++;
	}
	return ret;
}

void parseSeq(int &p, int root)
{
	while(1){
		if(s[p] >= '0' && s[p] <= '9'){
			llint mul = parseNum(p);
			tree.push_back(node(mul));
			tree[root].vec.push_back(tree.size()-1);
			if(s[p] == '('){
				p++;
				parseSeq(p, tree.size()-1);
				p++;
			}else{
				int r = tree.size()-1;
				string t;
				t += s[p];
				tree.push_back(node(t));
				tree[r].vec.push_back(tree.size()-1);
				p++;
			}
		}
		else if(s[p] >= 'A' && s[p] <= 'Z'){
			string t = parseString(p);
			tree.push_back(node(t));
			tree[root].vec.push_back(tree.size()-1);
		}else break;
	}
}

llint dfs(llint v)
{
	if(tree[v].val == -1){
		tree[v].num = tree[v].s.size();
		return tree[v].s.size();
	}
	llint cnt = 0;
	for(int i = 0; i < tree[v].vec.size(); i++){
		int u = tree[v].vec[i];
		cnt += dfs(u);
		cnt = min(cnt, lim);
	}
	tree[v].num = cnt * tree[v].val;
	tree[v].num = min(tree[v].num, lim);
	return tree[v].num;
}
char dfs2(llint v, llint k)
{
	if(tree[v].val == -1) return tree[v].s[k];
	
	llint pos;
	if(tree[v].num >= lim) pos = k;
	else pos = k % (tree[v].num/tree[v].val);
	
	llint cnt = 0;
	for(int i = 0; i < tree[v].vec.size(); i++){
		int u = tree[v].vec[i];
		if(cnt + tree[u].num > pos) return dfs2(u, pos - cnt);
		cnt += tree[u].num;
	}
}

int main(void)
{
	while(1){
		cin >> s >> k;
		if(s == "0" && k == 0) break;
		s += "#";
		
		tree.clear();
		tree.push_back(node(1));
		
		int p = 0;
		parseSeq(p, 0);
		
		llint res = dfs(0);
		if(res <= k){
			cout << 0 << endl;
			continue;
		}
		cout << dfs2(0, k) << endl;
	}
	
	return 0;
}


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

using ll= long long;
#define double long double
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _set(x) __builtin_popcount(x)
#define _setl(x) __builtin_popcountll(x)
#define PI  3.14159265358979323846264338327950L
#define mod 1000000007LL

void debug(){
	cerr<<"]\n";
}
template<class H,class ... T> void debug(H h,T... t){
	cerr<<h;
	if(sizeof... (t)){
		cerr<<", ";
	}
	debug(t...);
}
#ifdef DEBUG
	#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", debug(__VA_ARGS__)
	#define dpv(...) cerr<< "["#__VA_ARGS__ " : ";for(int i: (__VA_ARGS__)){cerr<<i<<" ";}cerr<<"]\n"
#else
	#define dbg(...) 0
	#define dpv(...) 0
#endif

void solve(){
	ll a[4];
	for(int i=0;i<4;i++){
		cin>>a[i];
	}
	ll mx= -1e18;
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			mx = max(mx, a[i]*a[2+j]);
		}
	}
	cout<<mx<<"\n";
}


int32_t main(){
	IOS
	// freopen("input.txt","r",stdin);
	int _;
	// cin>>_;
	_=1;
	for(int i=1;i<=_;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

/*
   check for overflows int long long
   correct mize of array
*/


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

int main() {
	vector<char> S(3);
	vector<char> T(3);
	int cnt = 0;
	for (int i = 0; i < 3; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < 3; i++) {
		cin >> T[i];
	}
	for (int i = 0; i < 3; i++) {
		if (S[i] == T[i]) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
	 	Scanner sc = new Scanner(System.in);
	 	int N = sc.nextInt();
	 	int[] L = new int[N];
	 	int sum = 0;
	 	for(int i = 0; i < N; i++) {
	 		L[i] = sc.nextInt();
	 	}
	 	Arrays.sort(L);
	 	
	 	for(int i = 0; i < N-1; i++) {
	 		sum += L[i];
	 	}
	 	
	 	if(L[N-1] < sum) {
	 		System.out.println("Yes");
	 	}else {
	 		System.out.println("No");
	 	}
	 }
}


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

int main() {
  int N, M, a[50], b[50];
  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> a[i] >> b[i];
  int c[51] = {};
  for (int i = 0; i < M; i++) {
    c[a[i]]++;
    c[b[i]]++;
  }
  for (int i = 1; i <= N; i++) cout << c[i] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int Q = stdIn.nextInt();
		int[] c = new int[Q];
		int[] a = new int[Q];
		int[] n = new int[Q];
		for(int i = 0; i < Q; i++) {
			c[i] = stdIn.nextInt();
			a[i] = stdIn.nextInt();
			n[i] = stdIn.nextInt();
		}
		for(int i = 0; i < Q; i++) {
			int count = 0;
			while(true) {
				if(c[i] >= 1 && a[i] >= 1 && n[i] >= 1) {
					count++;
					c[i]--;
					a[i]--;
					n[i]--;
					continue;
				}
				else if(c[i] >= 2 && a[i] >= 1) {
					count++;
					c[i]-= 2;
					a[i]--;
					continue;
				}
				else if(c[i] >= 3) {
					count++;
					c[i] -= 3;
					continue;
				}
				break;
			}
			System.out.println(count);
		}
	}
		
}

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

int main(){
	long long A,B,C,ans=0;
	cin >> A >> B >> C;
	
	ans+=B;
	ans+=min(C,B);
	C-=B;
	if(C>0)ans+=min(C,A);
	C-=A;
	if(C>0)ans++;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,0,n)

typedef vector<vvi> vvvi;
struct node{
    int t,y,x,cost;
    node(int t,int y,int x,int cost):t(t),y(y),x(x),cost(cost){
	}
    bool operator<(const node& other)const{
        return cost>other.cost;
	}
};
const int MAX=INT_MAX/10;
const int NONE=-1;
int dy[]={1,0,-1,-1,-1,0,0},dx[]={0,1,1,0,-1,-1,0};
int dy2[]={1,1,0,-1,0,1,0};
int dx2[]={0,1,1,0,-1,-1,0};
int getYX(int yx,int lyx){
    return yx+lyx;
}
int main() {
	int sy,sx,gy,gx;
    cin>>sx>>sy>>gx>>gy;
    int n;
    cin>>n;
    vi y(n),x(n);
    REP(i,n){
        cin>>x[i]>>y[i];
	}
    int ly,lx;
    cin>>lx>>ly;
    vvi field(ly*2+1,vi(lx*2+1));
    REP(i,n){
        field[getYX(y[i],ly)][getYX(x[i],lx)]=1;
	}
    sy=getYX(sy,ly);
    sx=getYX(sx,lx);
    gy=getYX(gy,ly);
    gx=getYX(gx,lx);
    priority_queue<node> q;
    q.push(node(0,sy,sx,0));
    vvvi cost(6,vvi(ly*2+1,vi(lx*2+1,MAX)));
    cost[0][sy][sx]=0;
    while(!q.empty()){
        node cnode=q.top();q.pop();
        if(cost[cnode.t][cnode.y][cnode.x]<cnode.cost){
            continue;
		}
        REP(d,7){
            int yy=cnode.y+(abs(cnode.x-lx)%2?dy2[d]:dy[d]);
            int xx=cnode.x+(abs(cnode.x-lx)%2?dx2[d]:dx[d]);
            bool cantmove=false;
            if(yy<0||yy>getYX(ly,ly)||xx<0||xx>getYX(lx,lx)||field[yy][xx]){
                yy=cnode.y;
                xx=cnode.x;
                cantmove=true;
			}
            int newcost=cnode.cost+(abs((cnode.y-ly)*(cnode.x-lx)*cnode.t)%6!=d||cantmove);
            int newt=(cnode.t+1)%6;
            if(cost[newt][yy][xx]>newcost){
                cost[newt][yy][xx]= newcost;
                q.push(node(newt,yy,xx,newcost));
			}
		}
	}
    int ans=MAX;
    REP(t,6){
        ans=min(ans,cost[t][gy][gx]);
	}
    cout<<(ans==MAX?-1:ans)<<endl;
}

Measured memory_bytes: 2588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int A,B,C,D;cin >> A >> B >> C >> D;
    if(B + 1 != D){
        cout << 1 << endl;
    }
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  int vmax = -1;
  while (n--) {
    int h;
    cin >> h;
    if (vmax <= h) {
      ++ans;
      vmax = h;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
n = int(input())

A = []

for _ in range(n):
    t = int(input())
    A.append([list(map(int, input().split())) for _ in range(t)])

ans = 0
max = 0
flag = 0

for i in range(2**n):
    ans = 0
    flag = 0
    for j in range(n):
        if ((i>>j) & 1) == 1 and flag ==  0:
            for k,l in A[j]:
                if ((i>>(k-1)) & 1) != l:
                    flag = 1
                    break
    if flag == 0:
        ans = bin(i).count('1')
        if ans > max:
            max = ans
print(max)

Measured memory_bytes: 3064
object Main extends App {
  import scala.io.StdIn._


  val l = readLine.trim.toInt
  val a = readLine.trim.toInt
  val b = readLine.trim.toInt
  val c = readLine.trim.toInt
  val d = readLine.trim.toInt
  println(
    l - List((a + c - 1) / c, (b + d - 1) / d).max
  )
  implicit class ScopeFunc[T](val value: T){
    def let[A](func: T ⇒ A): A = func(value)
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}


Measured memory_bytes: 43996
def main():
    n = int(input())
    s = []
    for _ in range(n):
        ss = int(input())
        s.append(ss)

    sm = sum(s)
    if sm % 10 != 0:
        print(sm)
        return

    s.sort()
    for i, ss in enumerate(s):
        if ss % 10 != 0:
            print(sm - ss)
            return
    print(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

class UnionFind{
private:
	vector<int> parent;
	vector<int> mem;
	int compo;
	int N;
public:
	UnionFind(int n_){
		Initialize(n_);
	}
	
	void Initialize(int n_){
		N=n_;
		parent.resize(N);
		mem.resize(N);
		for(int i=0;i<N;i++){
			parent[i]=i;
			mem[i]=1;
		}
		compo = N;
	}
	
	int Parent(int a){
		if(parent[a] == a)return a;
		return parent[a] = Parent(parent[a]);
	}
	
	bool IsUnited(int a, int b){
		return Parent(a) == Parent(b);
	}
	
	void Unite(int a, int b){
		a = Parent(a); b = Parent(b);
		if(a == b) return;
		parent[a] = b;
		mem[b] += mem[a];
		compo -= 1;
	}
	
	bool IsRoot(int x){
		return x == parent[x];
	}
	int MemCnt(int x){
		return mem[Parent(x)];
	}
	
	int Compo(){
		return compo;
	}
	
};

int main(){
	
	int N, K, L;
	cin >> N >> K >> L;
	vector<int> P(K), Q(K);
	for(int i=0;i<K;i++) cin >> P[i] >> Q[i];
	for(int i=0;i<K;i++) P[i]--, Q[i]--;
	vector<int> R(L), S(L);
	for(int i=0;i<L;i++) cin >> R[i] >> S[i];
	for(int i=0;i<L;i++) R[i]--, S[i]--;
	
	
	UnionFind UF1(N);
	for(int i=0;i<K;i++) UF1.Unite(P[i], Q[i]);
	
	UnionFind UF2(N);
	for(int i=0;i<L;i++) UF2.Unite(R[i], S[i]);
	
	vector<ll> compoHash(N);
	ll mod = N;
	for(int i=0;i<N;i++){
		compoHash[i] = UF1.Parent(i) * mod + UF2.Parent(i);
	}
	
	map<ll,ll> mp;
	for(int i=0;i<N;i++) mp[compoHash[i]]++;
	
	for(int i=0;i<N;i++){
		printf((i == 0 ? "%d" : " %d"), mp[compoHash[i]]);
	}
	printf("\n");
	
    return 0;
}

Measured memory_bytes: 18048
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n;
        ll sum = 0;
        ll ans = 0;
        cin >> n;
        for(i = 0; i < n; i++){
            ll x;
            cin >> x;
            ans += sum * x;
            ans %= MOD;
            sum += x;
            sum %= MOD;
        }
        cout << ans;
    }
    return 0;
}

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

using namespace std;

int res;

int main()
{
    string s;
    cin >> s;
    
    for (int i = 0; i < s.size(); ++i)
    {
        for (int j = 2; i + j < s.size(); j += 2)
        {
            bool pass = true;

            for (int k = 0; k < j / 2; ++k)
            {
                if (s[i + k] != s[i + j / 2 + k])
                {
                    pass = false;
                    break;
                }
            }
            
            if (pass)
                res = max(res, j);
        }
    }
    
    cout << res;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
	IOS;
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int max=a[0],ans=0;
	for(int i=0;i<n;i++)
	{
		int c=0;
	    for(int j=i-1;j>=0;j--)
	    {
	    	if(a[i]<a[j])
	    	c=1;
		}
		if(!c)
		ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int a[3];

    cin >> a[0];
    cin >> a[1];
    cin >> a[2];

    int min = 1000000;

    for(int i = 0; i < 2; i++)
    {
        for(int j = i + 1; j < 3; j++)
        {
            if(min > a[i] + a[j]) min = a[i] + a[j];
        }
    }

    cout << min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n;
    cin>>n;
    pll p[n];
    multiset<pll> m;
    for(ll i=0;i<n;i++)
    {
        cin>>p[i].ff>>p[i].ss;
        m.insert(mp(p[i].ff,p[i].ss));
    }
    sort(p,p+n);
    ll r,q;
    ll ans=0,ma;
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            r=p[j].ff-p[i].ff;
            q=p[j].ss-p[i].ss;
            ma=0;
            if(r!=0||q!=0){
            for(ll k=0;k<n;k++)
            {
                ll x=p[k].ff-r;
                ll y=p[k].ss-q;
                if(m.find(mp(x,y))!=m.end())
                    ma++;
            }}
            if(ma>ans)
                ans=ma;
        }
    }
    cout<<(n-ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <functional>
#include <algorithm>
#define Fi first
#define Se second
using namespace std; //575;
using ll = long long;

ll n;
pair<ll, ll> p[200005];

int main()
{
    scanf("%lld", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld %lld", &p[i].Se, &p[i].Fi);

        p[i].Se *= -1;
    }

    sort(p, p + n, greater<>());

    int time = p[0].Fi;
    for (int i = 0; i < n; i++) {
        if (time >= p[i].Fi) {
            time = p[i].Fi + p[i].Se;
        }
        else {
            time += p[i].Se;
        }
    }

    if (time < 0) {
        puts("No");
    }
    else {
        puts("Yes");
    }
}


Measured memory_bytes: 3328
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	double r,a,b;
	cin>>r;
	a=2*3.141592653589*r;
	b=3.141592653589*r*r;
	printf("%6lf %6lf\n",b,a);
	return 0;
}


Measured memory_bytes: 3188