akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	vector< vector< int > > G(N);
	rep(i, N - 1) {
		int u, v;
		cin >> u >> v;
		--u;
		--v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	vector< vector< int > > dp(N);
	vector< int > ans(N);
	auto f = [&](auto &&f, int x, int p) -> void {
		int l = -1, r = N - 1;
		while (r - l > 1) {
			int m = (l + r) / 2;
			if (dp[m].size() == 0) {
				r = m;
				continue;
			}
			if (A[x] <= dp[m].back()) {
				r = m;
			} else {
				l = m;
			}
		}
		dp[r].push_back(A[x]);
		int l2 = -1, r2 = N;
		while (r2 - l2 > 1) {
			int m2 = (l2 + r2) / 2;
			if (dp[m2].size() == 0) {
				r2 = m2;
			} else {
				l2 = m2;
			}
		}
		ans[x] = r2;
		for (auto j : G[x])
			if (j != p) {
				f(f, j, x);
			}
		dp[r].pop_back();
	};
	f(f, 0, -1);
	for (int i = 0; i < N; i++)
		cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 38452
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
bool b,c,d,e;
int main(){
int a;
for(int i=0;i<4;i++){
cin>>a;
if(a==1) b=true;
if(a==4) c=true;
if(a==7) d=true;
if(a==9) e=true;
}
cout<<(b&&c&&d&&e?"YES":"NO");
}

Measured memory_bytes: 256
n, k = map(int, input().split())
d = list(input().split())
#n = 1000
flag = True
while flag:
    flag2 = True
    for si in str(n):
        if si in d:
            n += 1
            flag2 = False
            break
    if flag2:
        break
    else:
        flag = True
            
print(n)


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

using namespace std;

int main()
{
    string a, b, c;
    cin >> a >> b >> c;

    cout << (char)(a[0] - 0x20);
    cout << (char)(b[0] - 0x20);
    cout << (char)(c[0] - 0x20) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
   long long int w;
   cin>>w;
   long long int wt[n],v[n];
   for(int i=0;i<n;i++)
   cin>>wt[i]>>v[i];
   long long int dp[n+1][w+1];
   for(int i=0;i<=n;i++)
   {
       for(int j=0;j<=w;j++)
       {
           if(i==0||j==0)
           {
               dp[i][j]=0;
           }
           else{
               if(wt[i-1]>j)
               {
                   dp[i][j]=dp[i-1][j];
               }
               else{
                   dp[i][j]=max(v[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
               }
           }
       }
   }
   cout<<dp[n][w]<<endl;

    return 0;
}

Measured memory_bytes: 79104
# C
n = int(input())
a = list(map(int, input().split()))

l = [0]*(10**5+10)
for i in range(n):
    l[a[i]] += 1
    
s = 0
for j in range(1, len(l)-1):
    if  s < l[j-1] + l[j] + l[j+1]:
        s = l[j-1] + l[j] + l[j+1]
        
print(s)

Measured memory_bytes: 13964
from collections import defaultdict

N = int(input())
S = str(input())

dic = defaultdict(int)

for i in range(2 ** N):
    a = str()
    b = str()
    for j in range(N):
        if (i >> j) & 1:
            a += S[j + N]
        else:
            b += S[j + N]
    
    dic[(a, b)] += 1

count = 0
for i in range(2 ** N):
    a = str()
    b = str()
    for j in range(N):
        if (i >> j) & 1:
            a += S[j]
        else:
            b += S[j]
    count += dic[b[::-1], a[::-1]]

print (count)

Measured memory_bytes: 166008
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int>>rows,cols;
void Try(int n, vector<int>cur, int lim, bool r){
	if(n == lim){
		//for(int i:cur)cout << i << " "; cout << endl;
		if(r)rows.push_back(cur);
		else cols.push_back(cur);
	}
	else {
		auto copy = cur;
		copy.push_back(n);
		Try(n+1,cur,lim,r);
		Try(n+1,copy,lim,r);
	}
}
int32_t main(){
	int h,w,k;
	cin >> h >> w >> k;
	Try(0,vector<int>(),h,1);
	Try(0,vector<int>(),w,0);
	vector<string>grid(h);
	for(int i = 0 ; i < h ; i++){
		cin >> grid[i];
	}
	int res = 0;
	for(auto tr : rows){
		for(auto tc : cols){
			auto copy = grid;
			for(int i : tr){
				for(int r = 0 ; r < w ; r++)copy[i][r] = 'r';
			}
			for(int j : tc){
				for(int c = 0 ; c < h ; c++)copy[c][j] = 'r';
			}
			int tot = 0;
			for(string i : copy){
				tot+=count(i.begin(),i.end(),'#');
			}
			if(tot == k){res++;
				//for(auto i : copy){for(auto j:i)cout << j; cout << endl;}
			}
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 3632
N = int(input())

def divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors

counter = 0
for n in range(1, N+1):
    if len(divisors(n)) == 8 and n % 2 == 1:
        counter += 1
print(counter)

Measured memory_bytes: 3188
#include<iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;
int dp[201][201];
int main(){
    int d,n,ans=0;
    cin>>d>>n;
    int a[201],b[201],c[201],tem[201];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<d;i++)
        cin>>tem[i];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    for(int m=1;m<d;m++)
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                if(a[i]<=tem[m]&&tem[m]<=b[i]  &&  a[j]<=tem[m-1]&&tem[m-1]<=b[j])
                    dp[m][i]=max(dp[m][i],abs(c[i]-c[j])+dp[m-1][j]);
    for(int i=0;i<n;i++)
        ans=max(ans,dp[d-1][i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
    ll x, y, z;
    cin >> x >> y >> z;
    if(x == y && x == z || y == x && y == z || z == x && z == y || x != y && x != z && y != z)
        cout << "No";
    else
        cout << "Yes";
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int N;
long long M;

vector<pair<long long, long long>>prime_factrization(long long M) {
	vector<pair<long long, long long>>res;
	for (int i = 2; i * i <= M; i++) {
		if(M % i != 0) continue;
		int count = 0;
		while (M % i == 0) { count++; M /= i; }		
		res.push_back(make_pair(i, count));
	}
	if (M != 1) res.push_back(make_pair(M, 1));
	return res;
}
//逆元を求める関数
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;
}
void solve() {
	cin >> N >> M;
	COMinit();
	vector<pair<long long, long long>> ret = prime_factrization(M);
	long long ans = 1;
	for(auto pa : ret) {
		int num = pa.second;
		long long tmp = COM(num + N - 1, N - 1);
		ans = (ans * tmp) % MOD;
	}
	cout << ans << endl;
	return;
}

int main(int args, char* argv[]) {
	solve();
}

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

void C (string x, string y){
    int p = x.size() ;
    int q = y.size() ;
    vector<vector<int>> dp (p + 1 , vector<int> (q + 1)) ;
    rep(i, p){
        rep(j, q){
            if(x.at(i) == y.at(j)){
                dp[i+1][j+1] = dp[i][j] + 1 ;
            }
            else {
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]) ;
            }
        }
    }
    cout << dp[p][q] << endl;
}

int main() {
    int n ; 
    cin >> n ;
    vector<string> s (n) ;
    vector<string> t (n);
    rep(i, n){
        cin >> s[i] ;
        cin >> t[i] ;
    }
    rep(k, n){
        C(s[k], t[k])  ;
    }
}


Measured memory_bytes: 6852
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int k;
  string s;
  cin >> k >> s;

  if(k >= s.size()) cout << s << endl;
  else cout << s.substr(0,k) << "..." << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i,a,b) for (int i = a; i <= (int)(b); i++)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

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

int main() {
  LL a[2],k;
  cin >> a[0] >> a[1] >> k;
  int now=0,nxt=1;
  REP(i,k) {
    if ( a[now]&1 ) a[now]--;
    a[now]/=2;
    a[nxt]+=a[now];
    swap(now,nxt);
  }
  cout << a[0] << ' ' << a[1] << '\n';
  return 0;
}


Measured memory_bytes: 3604
"""
author : halo2halo
date : 8, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A = int(readline())
S, T = readline().decode('utf-8').split()

C = [None] * (A * 2)
C[::2] = S
C[1::2] = T

ans = ''.join(C)

print(ans)


Measured memory_bytes: 3060
n,m = map(int,input().split())
l = []
wa = 0
for i in range(m):
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    wa += a
    l.append([a,b,c])
dp = [[wa + 1 for i in range(2**n)] for i in range(m+1)]
bit = 2**n
#print(l)
for i in range(1,m+1):
    a,b,c = l[i-1]
    bitc = 0
    for x in c:
        bitc += 2**(x-1)
    for j in range(bit):
        j2 = j
        mod = 1
        for k in range(n):
            if (j >> k) & 1:
                continue
            else:
                if (bitc >> k) & 1:
                    j2 += 2**k
        #print(i,j,j2)
        if j == 0:
            dp[i][j2] = min([dp[i-1][j2],a,dp[i][j2]])
        else:
            dp[i][j2] = min([dp[i-1][j]+a,dp[i-1][j2],dp[i][j2]])
        if j2 != j:
            dp[i][j] = dp[i-1][j]
ans = dp[m][bit-1]
#print(dp)
if ans <= wa:
    print(dp[m][bit-1])
else:
    print(-1)

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

const int Maxn = 200005;

int n, a, b, c, d;
char str[Maxn];

int main()
{
    scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
    scanf("%s", str + 1);
    if (c > d) { swap(a, b); swap(c, d); }
    while (a < c || b < d)
        if (b + 1 <= d && b + 1 != a && str[b + 1] != '#') b++;
        else if (b + 2 <= d && b + 2 != a && str[b + 2] != '#') b += 2;
        else if (a + 1 <= c && a + 1 != b && str[a + 1] != '#') a++;
        else if (a + 2 <= c && a + 2 != b && str[a + 2] != '#') a += 2;
        else { printf("No\n"); return 0; }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <ctime>
#include <climits>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <cstdlib>

using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
int ilimit = INT_MAX;
long int llimit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

int Func2(int n,int m){
    long int s2 = 1,
        r = 1;


    for(int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % pow107;
    }

    return s2;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2

int main(){
    long int n,t = 0;
    cin >> n;
    vector<long int> v;
    for(int i = 0; i < n; ++i){
        long int a;
        cin >> a;
        v.push_back(a);
        t += a;
    }
    long int min = ilimit,a = 0;
    for(int i = 0; i < n - 1; ++i){
        a += v[i];
        t -= v[i];
        //cout << a << " " << t << endl;
        if(min > abs(a-t)){
            min = abs(a-t);
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 2420
#include<iostream>
#pragma warning(disable:4996)
using namespace std;

struct Card{char suit, value;};

void bubble(struct Card A[], int N){
	for(int i=0; i<N; i++){
		for(int j=N-1; j>=i+1; j--){
			if( A[j].value < A[j-1].value ){
				Card t = A[j];
				A[j] = A[j-1];
				A[j-1] = t;
			}
		}
	}
}

void selection(struct Card A[], int N){
	for(int i=0; i<N; i++){
		int minj = i;
		for(int j=i; j<N; j++){
			if( A[j].value < A[minj].value ) minj =j;
		}
		Card t = A[i];
		A[i] = A[minj];
		A[minj] = t;
	}
}

void print(struct Card A[], int N){
	for(int i=0; i<N; i++){
		if( i>0 ) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << "\n";

}

// ????????????????????¨?????????????????????????????????
bool isStable(struct Card C1[], struct Card C2[], int N){
	for(int i=0; i<N; i++){
		if( C1[i].suit != C2[i].suit ) return false;
	}
	return true;
}

int main(){
	Card C1[100], C2[100];
	int N;
	char ch;
	cin >> N;

	for(int i=0; i<N; i++){
		cin >> C1[i].suit >> C1[i].value;
	}
	for(int i=0; i<N; i++) C2[i] = C1[i];
	bubble(C1,N);
	selection(C2,N);
	print(C1,N);
	cout << "Stable" << "\n";
	print(C2,N);

	if( isStable(C1, C2, N) ){
		cout << "Stable" << "\n";
	}else{
		cout << "Not stable" << "\n";
	}
	return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  string s;
  string t;
  cin>>s;
  cin>>t;
  bool c = 1;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      c = 0;
  	}
  }
  if(c){
    cout<< "Yes" <<endl;
  }
  else{
    cout<< "No" <<endl;
  }
  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
double dis(int x, int y) {
	return (double)sqrt(double(pow(x, 2)) + double(pow(y, 2)));
}
int main(){
	int d; double e;
	while (cin >> d >> e) {
		if (d == 0)break;
		double mi = (double)1000;
		for (int i = 0; i <= d; i++) {
			mi = min(mi, (double)abs(e - dis(i, d - i)));
		}
		cout << fixed << setprecision(4) << mi<<endl;
	}
	return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

ll m(string &s, ll bits, vector<ll> &t){
    if(bits<=0) return 0;
    ll ret = 0;
    ll base = 1;
    PER(i,s.length()-1,0){
       if(s[i]=='1'){
           ret += base;
           ret %= bits;
       }
       t.push_back(base);
       base *= 2;
       base %= bits;
    }
    reverse(t.begin(), t.end());
    return ret;
}

ll b(ll n){
    ll ret=0;
    while(n > 0){
        ret += (n & 1);
        n >>= 1;
    }
    return ret;
}

int main(){
    ll N=ii();
    string S=is();
    ll bits=0;
    for(char c : S){
        if(c=='1') bits++;
    }
    ll pg, ng;
    vector<ll> pg2, ng2;
    pg = m(S, bits+1, pg2);
    ng = m(S, bits-1, ng2);
    REP(i,0,N){
        ll n;
        ll ret=1;
        if(S[i]=='1'){
            if(bits-1<=0){
                oie(0);
                continue;
            }
            n=ng;
            n-=ng2[i];
            n+=(bits-1);
            n%=(bits-1);
        }else{
            n=pg;
            n+=pg2[i];
            n%=(bits+1);
        }
        while(n>0){
            n%=b(n);
            ret++;
        }
        oie(ret);
    }

    return 0;
}


Measured memory_bytes: 8120
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 998244353
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi>b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    ll a,v,b,t,w;cin>>a>>v>>b>>w>>t;
    ll c=abs(b-a);
    ll s=(v-w);
    if(a==b){
        cout<<"YES"<<endl;
        return 0;
    }
    if(s<0){
        cout<<"NO"<<endl;
        return 0;
    }
    if(s*t>=c){
        cout<<"YES"<<Endl;
    }
    else cout<<"NO"<<endl;
    //-------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------








































Measured memory_bytes: 3652
import numpy as np
import collections
import copy
H,W,K = map(int, input().split())
data_list = [list(input()) for i in range(H)]
data_np = np.array(data_list)
count = 0
for i in range(2 ** H):
  for k in range(2 ** W):
    data_tmp = copy.deepcopy(data_np)
    for j in range(0,H):
      if i >> j & 1:
        data_tmp[j,:] = '.'
    for l in range(0,W):
      if k >> l & 1:
        data_tmp[:,l] = '.'
    if (np.count_nonzero(data_tmp == '#') == K):
      count = count+ 1
print(count)


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{
		int X =nextInt();
		int Y =nextInt();
		int n = (2*Y-X)/3;
		int m = Y-2*n;

		if((X+Y)%3!=0||0>n||0>m){
			System.out.println(0);
			return;
		}
		Com com = new Com();
		com.COMinit();

		long ans = com.COM(n+m, n);

		System.out.println(ans);

	}





	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

	static class Com{
		int MAX = 1000010;
		int MOD = 1000000007;
		long[] fac=new long[MAX];
		long[] finv =new long[MAX];
		long[] inv = new long[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 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;
		}
	}
}



Measured memory_bytes: 47956
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//a???????????????
		int a = sc.nextInt();
		//b???????????????
		int b = sc.nextInt();
		//c???????????????
		int c = sc.nextInt();

		//
		if(a < b && b < c){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26280
#include<iostream>
#include<cstdio>
#define n 100

using namespace std;

void insert(int A[], int N) {
	for (int i = 1; i < N; i++) {
		int t = A[i];
		int j = i - 1;
		while (j >= 0 && t < A[j]) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = t;

		for (int i = 0; i < N; i++) {
			cout << A[i];
			if(i != N -1) cout << " ";
		}
		cout << endl;
	}
}

int main() {
	int N, A[n];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	for(int i = 0; i < N; i++){
	    cout << A[i];
	    if(i != N-1) cout << " ";
	}
	cout << endl;

	insert(A, N);

	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if((a+b)%2==0){
        cout<<(a+b)/2<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mst(a,b) memset(a,b,sizeof(a))
#define lowbit(x) ((x)&(-x))
#define X first
#define Y second
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 300000+10;
const int maxm = 200000+10;
const int mod = 1e9+7;
const double eps = 1e-9;
int a[maxn];
ll pre[maxn],suf[maxn];
multiset<int> s;
int main() {
#ifdef local
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n; cin>>n;
    ll sum=0;
    for (int i=1;i<=n*3;i++){
        cin>>a[i];
        if (i<=n) {
            sum+=a[i];
            s.insert(a[i]);
        } else {
            if (*s.begin()<a[i]){
                sum-=*s.begin();
                s.erase(s.begin());
                s.insert(a[i]);
                sum+=a[i];
            }
        }
        pre[i]=sum;
    }
    s.clear();
    sum=0;
    for (int i=3*n;i>=1;i--){
        if (i>2*n){
            sum+=a[i];
            s.insert(a[i]);
        } else {
            if (*s.rbegin()>a[i]){
                sum-=*s.rbegin();
                s.erase(--s.end());
                s.insert(a[i]);
                sum+=a[i];
            }
        }
        suf[i]=sum;
    }
    ll ans=-INF;
    for (int i=n;i<=2*n;i++){
        ans=max(ans,pre[i]-suf[i+1]);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 10752
N = int(input())

dp = [float('inf') for _ in range(N + 1)]
dp[0] = 0

for i in range(1, N + 1):
	power = 1
	while(power <= i):
		dp[i] = min(dp[i], dp[i - power] + 1)
		power *= 6
	
	power = 1
	while(power <= i):
		dp[i] = min(dp[i], dp[i - power] + 1)
		power *= 9
	
print(dp[N])

Measured memory_bytes: 6296
use std::io;

fn main() {
    let a = parse_line::<usize>();
    let b = parse_line::<usize>();
    let mut answers = vec![1, 2, 3];
    answers[a - 1] = 0;
    answers[b - 1] = 0;
    let result = answers.iter().filter(|&i| i > &0).next().unwrap();
    println!("{:?}", result);
}

fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
from collections import Counter

N=int(input()) 
S = []
for i in range(N):
    S.append(list(input()))

    # Counterは要素を数え上げる
cnt = Counter()
ans = 0
for s in S:
    # 単語をアナグラムの判別がしやすように並び替え
    a = ''.join(sorted(list(s)))
    # cntの中に同じものがあればカウント 
    if a in cnt:
        # ans += 1 じゃダメ ここがcollection.Counterを使うキモな気がする　 
        ans += cnt[a]
    # アナグラム判定後にcntに要素を加える
    cnt[a] += 1
print(ans)

Measured memory_bytes: 39428
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
#define pie 3.141592653589793238
const int inf=0x3f3f3f3f3f3f3f3f;

void zz(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

int32_t main(){
zz();
int n;cin>>n;
int m;cin>>m;
int s=0;
vi v(m);for(int i=0;i<m;i++){cin>>v[i];s+=v[i];}
if(s>n)cout<<-1<<endl;
else cout<<n-s<<endl;

}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10;
int a[M];
pair<int,pii>cur[M];
main()
{
	int n;
	cin>>n;
	int nowx=0,nowy=0;
	int last=0;
	for(int i=1;i<=n;i++)
	{
		cin>>cur[i].F>>cur[i].S.F>>cur[i].S.S;
	}
	sort(cur+1,cur+n+1);
	for(int i=1;i<=n;i++)
	{
		int ti,x,y;
		ti=cur[i].F,x=cur[i].S.F,y=cur[i].S.S;
		int len=abs(nowx-x)+abs(nowy-y);
		if(len>(ti-last))return cout<<"No",0;
		if(len%2!=(ti-last)%2)return cout<<"No",0;
		last=ti;
		nowx=x;
		nowy=y;
	}
	cout<<"Yes";
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define MAXN 1000005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,a[MAXN],b[MAXN];
string str;
int main()
{
    scanf("%d",&n);
    cin>>str;
    for(int i=1;i<=n;i++) a[i]=(str[i-1]-'0');
    for(int i=1;i<=n-1;i++) b[i]=max(a[i+1]-a[i],a[i]-a[i+1]);
    n--;
    int res=0;
    for(int i=0;i<=n-1;i++)
    {
        if(b[i+1]&1)
        {
            int x=1;
            for(int k=0;k<20;k++) if((!((n-1)&(1<<k)))&&(i&(1<<k))) x=0;
            res^=x;
        }
    }
    bool f=false;
    for(int i=1;i<=n;i++) if(b[i]==1) f=true;
    if(f)
    {
        printf("%d\n",res);
    }
    else 
    {
        for(int i=1;i<=n;i++) b[i]/=2;
        int res=0;
        for(int i=0;i<=n-1;i++)
        {
            if(b[i+1]&1)
            {
                int x=1;
                for(int k=0;k<20;k++) if((!((n-1)&(1<<k)))&&(i&(1<<k))) x=0;
                res^=x;
            }
        }
        printf("%d\n",res*2);
    }
    return 0;
}

Measured memory_bytes: 9220
S = input()
N = len(S)
mod = 2019
X = [0 for _ in range(N)]
base = 1
for i in range(N, 0, -1):
    X[i-1] = ((int(S[i-1]) * base) % mod)
    base *= 10
    base %= mod
for i in range(1, N):
    X[i] += X[i-1]
    X[i] %= mod
D = {i: 0 for i in range(mod)}
for i in range(N):
    D[X[i]] += 1
XX = 0
for i in D:
    if i != 0:
        XX += (D[i] * (D[i] - 1)) // 2
    else:
        XX += (D[0] * (D[0] + 1)) // 2
print(XX)

Measured memory_bytes: 16592
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib> 
using namespace std;
char a[10];
int main()
{
  scanf("%s",a+1); 
  int kill=0;
  for(int i=1;i<=3;i++)
    if(a[i]==a[i+1]) kill=1;
  if(kill==0) cout<<"Good";
  else cout<<"Bad";
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> p;


int main()
{
  int n,k,x,y,res;
  cin >> n >> k >> x >> y;
  if (n <= k) {
    res = n * x;
  }else{
    res = k * x + (n-k) * y;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=1e5+1;
int arr[200000]; map<int,int>mp; vector<int>vc;
int main() {
    quick
int n,mx=0; scanf("%d",&n);
for(int i=0;i<n;i++){scanf("%d",&arr[i]);
mx=max(arr[i],mx);
if(!mp[arr[i]]){vc.push_back(arr[i]);}
mp[arr[i]]++;
}
sort(vc.begin(),vc.end());
for(int i=0;i<n;i++){
    if(arr[i]!=mx){printf("%d\n",mx);}
    else {
      if(mp[mx]>1){printf("%d\n",mx);}
      else{
       printf("%d\n",vc[vc.size()-2]);
      }
    }
}
}

Measured memory_bytes: 8440
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int beki[6] = {1,2,4,8,16,32};
  int N,M;
  cin >> N >> M;

  int t = M*1900 + (N-M)*100;
  cout << t*beki[M] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin>>n;
	
	int dept=100000;
	
	for(int i=0;i<n;i++){
		dept+=dept/20;
		if(dept%1000)
			dept+=1000-dept%1000;
	}
	cout<<dept<<endl;
	
	return 0;
}

Measured memory_bytes: 0
n = int(input())
a = 1
b = 1
c = 1
for _ in range(n):
    a *= 10
    a %= 1000000007
    b *= 9
    b %= 1000000007
    c *= 8
    c %= 1000000007
print((a - 2*b + c)%1000000007)

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

void rec(int d, long long val, vector<long long> &all) {
  all.push_back(val);
  if (d == 10) return;

  for (int j = -1; j <= 1; j++) {
    int add = (val % 10) + j;
    if (add >= 0 && add <= 9) rec(d + 1, val * 10 + add, all);
  }
}

int main() {
  int K;
  cin >> K;
  vector<long long> all;
  for (int i = 1; i < 10; i++) rec(1, i, all);

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

  cout << all.at(K - 1) << endl;
}

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

int main(void){
  bool flag = false;
  while(true){
    int price;
    cin >> price;
    if(price == 0){ break; }
    if(flag){ cout << endl; } 

    int s_coin[4], t_coin[4], radix[4] = {10, 50, 100, 500};
    cin >> s_coin[0] >> s_coin[1] >> s_coin[2] >> s_coin[3];

    
    int BillsAll = 0;
    for(int i = 0; i < 4; i++){ BillsAll += s_coin[i] * radix[i]; }
    int balance = BillsAll - price;
    for(int i = 3; i >= 0; i--){
      t_coin[i] = balance / radix[i];
      balance -= (balance / radix[i]) * radix[i];
    }
    for(int i = 0; i < 4; i++)
      if(s_coin[i] > t_coin[i])
        cout << radix[i] << " " << s_coin[i] - t_coin[i] << endl;
    flag = true;
  }
  
  return 0;
}

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

int main(){
  int s,ans=0;
  char op;

  cin >> ans;
  while(cin >> op){
    if(op=='='){
      cout << ans << endl;
      return 0;
    }

    cin >> s;
    if(op=='+')ans += s;
    if(op=='-')ans -= s;
    if(op=='*')ans *= s;
    if(op=='/')ans /= s;
  }
}

Measured memory_bytes: 1160
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
using namespace std;

typedef long long ll;

const int INF = 1<<30;
#define rep(i, n) for(ll i = 0; i < (n); i++)

int m, n;
bool exist[7400000];
void solve(){
  while(true) {
    cin >> m >> n;
    if (m == 0 && n == 0) break;
    rep(i, 7400000) exist[i] = 0;
    int now = m;
    rep(_, n){
      while(exist[now]) now++;
      for(int i = now; i < 7400000; i += now) exist[i] = 1;
    }
    int ans = 0;
    for(int i = m + 1; i < 7400000; i++){
      if(!exist[i]){
        ans = i;
        break;
      }
    }
    cout << ans << endl;
  }
}


int main(){
  solve();
}



Measured memory_bytes: 10300
#include<stdio.h>
int main(void){

int W, H, x, y, r;

scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
printf("Yes\n");
}

else{
printf("No\n");
}

return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;	
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

const ll INF = 1e15;

int main() {
	ll n;
	cin >> n;
	vector<ll> as(n);
	rep(i, n)cin >> as[i];
	vector<ll> low(n), high(n);
	rep(i, n) {
		low[i] = as[i] - i;
		high[i] = as[i] + i;
	}
	unordered_map<ll, ll> lows, highs;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		ll lkey = -as[i]-i;
		sum += (lows[lkey]);
		ll hkey = i-as[i];
		sum += (highs[hkey]);
		//cout << i << " " << sum << endl;
		lows[low[i]]++;
		highs[high[i]]++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 38856
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	char a[10]; 
	int x,i,min,y;
	while(scanf("%s",&a)!=EOF)
	{
		min=753;
		x=strlen(a);
		for(i=0;i<=x-3;i++)
		{
			y=(a[i]-'0')*100+(a[i+1]-'0')*10+(a[i+2]-'0');
			if(abs(y-753)<=min)
			min=abs(y-753);
		}
		printf("%d",min);
	}
}

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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

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

const int MAXN = 105;
const int MAXK = 1e5 + 500;
const int INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;
const int LOG = 18;
const double EPS = 1e-9;
const double PI = 3.1415926535;

ll candies[MAXN];
ll prefix[MAXK];
ll dp[MAXN][MAXK];

ll add(ll a, ll b) {
    return (a + b) % MOD;
}

ll subt(ll a, ll b) {
    return (a - b + MOD) % MOD;
}

void preprocess(int N) {
    prefix[0] = 1;
    for(int i = 0; i <= candies[0]; i++)
        dp[0][i] = 1;
    for(int i = 0; i < N; i++)
        dp[i][0] = 1;
}

int main() {
    int N, K;

    cin >> N >> K;
    for(int i = 0; i < N; i++)
        cin >> candies[i];

    preprocess(N);
    for(int i = 1; i < N; i++) {
        for(int j = 1; j <= K; j++)
            prefix[j] = add(prefix[j - 1], dp[i - 1][j]);

        for(int j = 1; j <= K; j++)
            if(candies[i] + 1 > j)
                dp[i][j] = prefix[j];
            else
                dp[i][j] = subt(prefix[j], prefix[j - candies[i] - 1]);
    }

    cout << dp[N - 1][K] << endl;

    return 0;
}


Measured memory_bytes: 80896
#include <stdio.h>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>

int main() {
  int n, m, x; scanf("%d%d%d", &n, &m, &x);
  std::vector<int> c(n);
  std::vector<std::vector<int>> a(n, std::vector<int>(m));
  for(int i = 0; i < n; i++) {
    scanf("%d", &c[i]);

    for(auto& v: a[i]) scanf("%d", &v);
  }

  int ans = 1 << 30;
  for(int i = 0; i < (1 << n); i++) {
    int cost = 0;
    std::vector<int> tmp(m);
    for(int j = 0; j < n; j++) {
      if(i >> j & 1) continue;
      cost += c[j];
      for(int k = 0; k < m; k++) tmp[k] += a[j][k];
    }

    if(*min_element(begin(tmp), end(tmp)) >= x) ans = std::min(ans, cost);
  }
  if(ans == 1 << 30) ans = -1;

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3780
a, b, c = map(int, raw_input().split())
max_value = max([a,b,c])

target_value = max_value
while True:
    if (target_value*3 - (a+b+c)) % 2 == 0:
        break
    target_value += 1

diff_a = (target_value - a)
diff_b = (target_value - b)
diff_c = (target_value - c)

if diff_a % 2 == 0 and diff_b % 2 == 0 and diff_c % 2 == 0:
    count = diff_a / 2 + diff_b / 2 + diff_c / 2
    print(count)
else:
    count = diff_a / 2 + diff_b / 2 + diff_c / 2 + 1
    print(count)


Measured memory_bytes: 2568
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2010;
int sum_v[N][N],sum_l[N][N],sum_r[N][N];
int n,m,q;
char s[N][N];
int read(){
    char ch=getchar();int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++){
        scanf("%s",s[i]+1);
        for(int j=1;j<=m;j++)
            if(s[i][j]=='1'){
                sum_v[i][j]=1;
                if(s[i][j-1]=='1')sum_l[i][j]=1;
                if(s[i-1][j]=='1')sum_r[i][j]=1;
            }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            sum_v[i][j]+=sum_v[i-1][j]+sum_v[i][j-1]-sum_v[i-1][j-1];
            sum_l[i][j]+=sum_l[i-1][j]+sum_l[i][j-1]-sum_l[i-1][j-1];
            sum_r[i][j]+=sum_r[i-1][j]+sum_r[i][j-1]-sum_r[i-1][j-1];
        }
    while(q--){
        int x=read(),y=read(),xx=read(),yy=read();
        int ans=sum_v[xx][yy]-sum_v[x-1][yy]-sum_v[xx][y-1]+sum_v[x-1][y-1];
        ans-=sum_l[xx][yy]-sum_l[x-1][yy]-sum_l[xx][y]+sum_l[x-1][y];
        ans-=sum_r[xx][yy]-sum_r[x][yy]-sum_r[xx][y-1]+sum_r[x][y-1];
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 52992
#include<iostream>
using namespace std;
const int maxn=1e5+10;
int main()
{
	int n;
	cin>>n;
	int arr[maxn];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int sum=0;
	int cur=0;
	for(int i=0;i<n-1;i++)
	{
		if(arr[i]>=arr[i+1])
			sum++;
		if(sum>cur)
			cur=sum;
		if(arr[i]<arr[i+1])
			sum=0;
	}
	cout<<cur;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll H, W, N, ans[11];
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main()
{
    cin >> H >> W >> N;
    set<pair<int, int>> st, br;
    ans[0] = (H - 2) * (W - 2);
    for (int i = 0; i < N; i++)
    {
        int y, x;
        cin >> y >> x;
        y--, x--;
        br.insert({y, x});
        st.insert({y, x});
        for (int i = 0; i < 8; i++)
        {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 1 || ny > H || nx < 1 || nx > W)
                continue;
            st.insert({ny, nx});
        }
    }
    for (auto &p : st)
    {
        ll y = p.first, x = p.second, cnt = 0;
        cnt += (br.find(p) != br.end());
        for (int i = 0; i < 8; i++)
        {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 0 || ny >= H || nx < 0 || nx >= W)
            {
                cnt = -1;
                break;
            }
            cnt += (br.find({ny, nx}) != br.end());
        }
        if (cnt != -1)
            ans[cnt]++, ans[0]--;
    }
    for (int i = 0; i < 10; i++)
        cout << ans[i] << endl;
}

Measured memory_bytes: 47104
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include <math.h>
int main(void){
	double x1,x2,y1,y2,z,i,j,k,m;
	scanf("%lf %lf %lf %lf",&x1,&x2,&y1,&y2 );
	printf("%f\n",sqrt(pow(y1-x1,2)+pow(y2-x2,2)) );

	return 0;
}

Measured memory_bytes: 652
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NQ = Sarray();
            var N = NQ[0];
            var Q = NQ[1];
            var S = ReadLine();
            var rui = new long[N + 1];
            for (var i = 2; i < N + 1; ++i)
                rui[i] = rui[i - 1] + (S.Substring(i - 2, 2) == "AC" ? 1 : 0);
            for (var i = 0; i < Q; ++i)
            {
                var lr = Sarray();
                var l = lr[0] - 1;
                var r = lr[1] - 1;
                var ans = rui[r + 1] - rui[l];
                if (0 < l)
                {
                    if (S.Substring((int)l - 1, 2) == "AC")
                        --ans;
                }
                WriteLine(ans);
            }

            Out.Flush();
        }
    }
}

Measured memory_bytes: 18996
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int arr[MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;
    cin>>n>>k;

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

    ll low = 1, high = 1e16, mid, ans;

    while(low <= high) {
        mid = (low + high + 1) >> 1;
        ll cnt = 0;
        for(int i = 0; i < n; i++) {
            cnt += (ll) (arr[i] / mid) - 1;
            if(arr[i] % mid != 0)
                cnt++;
        }
        if(cnt <= k) {
            ans = mid;
            high = mid - 1;
        }
        else {
            low = mid + 1;
        }
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 4420
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#define int long long
using namespace std;
int n,ans=2000000000;
signed main(){
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ans = min(ans, a + b);
	}
	cout << ans << endl;
	system("PAUSE");
	return 0;
}


Measured memory_bytes: 504