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

int main() 
{
    int X, Y;
    cin >> X >> Y;
    
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            if (i + j == X) {
                int sum = i*2 + j*4;
                if (sum == Y) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)

#define PI M_PI
#define INF 1000000000
#define MOD 1000000007;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;



int main()
{
	int H, W, N;
	cin >> H >> W >> N;
	vi a(N);
	rep(i, N) cin >> a[i];

	vvi c(H, vi(W, 0));

	int n = 0, m = 0;
	rep(i, N)
	{
		rep(j, a[i])
		{
			c[n][m] = i + 1;
			m++;

			if (m >= W)
			{
				n++;
				m = 0;
			}
		}
	}

	for (int i = 1; i < H; i += 2)
	{
		reverse(c[i].begin(), c[i].end());
	}

	rep(i, H)
	{
		rep(j, W)
		{
			cout << c[i][j] << " ";
		}
		cout << endl;
	}


	return 0;
}


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

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

double dist(vector<int> x, vector<int> y, int i, int j)
{
	return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
}

int main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) cin >> p[i];

	vector<int> q(n);
	for (int i = 0; i < n; i++) cin >> q[i];

	vector<int> vec(n);
	for (int i = 0; i < n; i++) vec[i] = i + 1;

	map<vector<int>, int> mp;
	do
	{
		mp[vec] = mp.size();
	} while (next_permutation(vec.begin(), vec.end()));

	cout << abs(mp[p] - mp[q]) << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

void work() {
    ll n; cin>>n;
    ll ans = 0;
    ll i = 1;
    ll terms = 0;
    while (i <= n) {
        if (i%3 != 0 && i%5 != 0) {
            ans += i;
        }
        ++i;
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

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

int main(){
	int T;
	cin>>T;
	
	rep(t,T){
		int a,b,n;
		cin>>a>>b>>n;
		
		int maxi = 0;
		
		rep(i,n){
			int c;
			cin>>c;
			
			double d;
			int e;
			cin>>d>>e;
			
			int val = 0;
			if(c==1){
				val = a;
				rep(j,b){
					val = val+(int)(val*d)-e;
				}
			}else{
				val = a;
				int r = 0;
				rep(j,b){
					r += (int)(val*d);
					val -= e;
				}
				val += r;
			}
			maxi = max(maxi,val);
		}
		
		printf("%d\n",maxi);
	}
}

Measured memory_bytes: 1216
//12252024832524
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std; 

typedef long long LL;
const int MAXN = 10005;
int n,k;
bool vis[MAXN];

int Read()
{
	int x = 0,f = 1;char c = getchar();
	while(c > '9' || c < '0'){if(c == '-')f = -1;c = getchar();}
	while(c >= '0' && c <= '9'){x = (x*10) + (c^48);c = getchar();}
	return x * f;
}
void Put1(int x)
{
	if(x > 9) Put1(x/10);
	putchar(x%10^48);
}
void Put(int x,char c = -1)
{
	if(x < 0) putchar('-'),x = -x;
	Put1(x);
	if(c >= 0) putchar(c);
}
template <typename T>T Max(T x,T y){return x > y ? x : y;}
template <typename T>T Min(T x,T y){return x < y ? x : y;}
template <typename T>T Abs(T x){return x < 0 ? -x : x;}

int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n = Read();
	k = Read();
	for(int i = 1;i <= k;++ i)
	{
		int d = Read();
		for(int j = 1;j <= d;++ j)
		{
			int dz = Read();
			if(!vis[dz]) vis[dz] = 1,n--;
		}
	}
	Put(n);
	return 0;
}

Measured memory_bytes: 2968
#include<iostream>
#include<stdio.h>
#include<vector>
#include<math.h>

using namespace std;

int main()
{
	int n;
	int data[10000];
	cin >> n;
	int primenum = n;
	for (int i = 0; i < n; i++)
	{
		cin >> data[i];
	}

	int max = data[0];
	for (int i = 1; i < n; i++)
	{
		if (max < data[i])
		{
			max = data[i];
		}
	}

	for (int i = 0; i < n; i++)
	{
		int d = 2;

		if (d > sqrt(data[i]))
		{
			primenum = primenum;
		}
		else
		{
			while (d <= sqrt(data[i]))
			{
				if (data[i] % d == 0)
				{
					primenum--;
					break;
				}
				d++;
			}
		}
	}

	cout << primenum << endl;

	cin >> n;

	return 0;
}

Measured memory_bytes: 1196
import bisect

a, b, q =  [ int(v) for v in input().split() ]

temple_list = [ int(input()) for i in range(a) ]
shrine_list = [ int(input()) for i in range(b) ]


def excursion(x):
	global temple_list, shine_list
	temple_west = bisect.bisect_left(temple_list,x)
	shrine_west = bisect.bisect_left(shrine_list,x)

	tw, te, sw, se = temple_list[(temple_west-1)%a],temple_list[temple_west%a],shrine_list[(shrine_west-1)%b],shrine_list[(shrine_west)%b]
	print(min( abs(x-tw) + min(abs(sw-tw),abs(tw-se)) , abs(te-x) + min(abs(se-te),abs(te-sw)), abs(x-sw) + min(abs(tw-sw),abs(sw-te)) , abs(se-x) + min(abs(te-se),abs(se-tw))))
	return 


for i in range(q):
	excursion(int(input()))


Measured memory_bytes: 12188
#include <cstdio>
#include <vector>

typedef std::pair<int,int> P;

int N, M, H, K;
int ps[1001];
std::vector<P> bars;
bool hasBar[1000][1000];
int r1[1000][1001], r2[1001][1001], r3[1000][1001];

int main(){
    while(scanf("%d %d %d %d", &N, &M, &H, &K), N || M || H || K){
        bars.clear();
        for(int i=1;i<H;i++){
            for(int j=1;j<N;j++){
                hasBar[i][j] = false;
            }
        }
        
        for(int i=1;i<=N;i++){
            scanf("%d", ps+i);
        }

        for(int i=0;i<M;i++){
            int a, b;
            scanf("%d %d", &a, &b);

            bars.push_back(std::make_pair(a, b));
            hasBar[b][a] = true;
        }

        for(int i=1;i<=N;i++){
            r1[0][i] = i;
            r2[H][i] = i;
        }

        for(int i=1;i<H;i++){
            for(int j=1;j<=N;j++){
                r3[i][j] = j;
            }
        
            for(int j=1;j<N;j++){
                if(hasBar[i][j]){std::swap(r3[i][j], r3[i][j+1]);}
            }

            for(int j=1;j<=N;j++){
                r1[i][j] = r3[i][r1[i-1][j]];
            }
        }

        for(int i=H-1;i>=1;i--){
            for(int j=1;j<=N;j++){
                r2[i][j] = r2[i+1][r3[i][j]];
            }
        }

        int res = 0;
        for(int i=1;i<=K;i++){
            res += ps[r1[H-1][i]];
        }

        for(const P& p : bars){
            int sum = 0;
            std::swap(r3[p.second][p.first], r3[p.second][p.first+1]);
            for(int i=1;i<=K;i++){
                sum += ps[r2[p.second+1][r3[p.second][r1[p.second-1][i]]]];
            }
            res = std::min(res, sum);
            std::swap(r3[p.second][p.first], r3[p.second][p.first+1]);
        }

        printf("%d\n", res);
    }
}

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

int main(){
    int N;cin>>N;
    int info[N];
    rep(i,N)cin>>info[i];
    sort(info,info+N);
    int ans=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            ans+=max(lower_bound(info,info+N,info[i]+info[j])-info-j-1,(long)0);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

const unsigned long long int N = 1e+5;

int main() {
    using namespace std;
    unsigned long long int i, a[N] = {}, n;

    cin >> n;

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

    vector<unsigned long long int> vec(&a[0], &a[n]);

    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    unsigned long long int count, count2, old, x[2] = {};
    old = vec[0];
    count = 0;
    count2 = 0;
    for (vector<unsigned long long int>::iterator it=vec.begin(); it!=vec.end(); ++it) {
        if (count >= 2) {
            x[count2] = old;
            ++count2;
            if (count2 >= 2) {
                cout << x[0] * x[1] << endl;
                return 0;
            }
            count = 0;
        }
        if (*it != old) {
            count = 0;
        }
        ++count;
        old = *it;
    }

    if (count >= 2) {
        x[count2] = old;
        ++count2;
        if (count2 >= 2) {
            cout << x[0] * x[1] << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define pi pair<ll,ll>
#define __   ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define mod 1000000007



ll ar[]={0,0,1,-1};
ll br[]={1,-1,0,0};

string s,s1,s2;
ll n,m;
ll arr[500000];
ll brr[500000];
vector<ll>v,v1;

map<ll,ll>mp;
ll vis[500005];
int main()
{__
        ll a,b,c,d,e,f,g,x,y,z,t,k,l;
        int i,j,n;
        cin>>n>>k;

        for(i=1;i<=n;i++){
            cin>>arr[i];
        arr[i]+=arr[i-1];
        }
        double ans,shajib,mx=0,sum;
        for(i=k;i<=n;i++){
        sum=arr[i]-arr[i-k];
        ans=(sum*(sum+1))/2-(k*(k-1))/2;
        //cout<<ans<<" "<<sum<<endl;
        shajib=(sum-k+1)*1.0;
        ans=ans/shajib;
        mx=max(ans,mx);
        }
        printf("%.9f\n",mx);
}





Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    int n;
    cin >> n;
    if(n<1200){
        cout << "ABC" << endl;

    }else if(n<2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }

    return 0;
}

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

int main() {
  int N,cnt=0;
  string S;
  cin >> N >> S;
  for(int i=0;i<N-2;i++){
    if(S.at(i)=='A'&&S.at(i+1)=='B'&&S.at(i+2)=='C'){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)
a = Array.new( n, Array.new(m,0) )
n.times do |i|
  a[i] = gets.split.map(&:to_i)
end
b = Array.new(m,0)
m.times do |i|
  b[i] = gets.to_i
end
n.times do |i|
  sum = 0
  m.times do |j|
    sum += b[j]*a[i][j]
  end
  puts sum
end


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

int main() {
    int n,temp;
    cin>>n;
    set<int> st;
    rep(i,n) {
        cin>>temp;
        st.insert(temp);
    }
    cout<<st.size()<<endl;
} 


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

#define mp       make_pair
#define mt	 make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF=1<<29;
const double EPS=1e-9;
const int MOD = 100000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N,L;
vector<string> S;
int main(){
  cin >> N >> L;
  S.resize(N);
  for (int i = 0; i < N; i++){
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  string ans = "";
  for (int i = 0; i < N; i++){
    ans += S[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
x = int(input())
ans = 0
for f in range(x//500+1):
    if(x - 500 >= 0):
        x -= 500
        ans += 1000
for g in range(x//5+1):
    if(x - 5 >= 0):
        x -= 5
        ans += 5
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prl puts("\n------------------\n")
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prl 
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    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;
}
    const int maxn = 1e5 + 5;
    int a[maxn];

int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n = read();
    rep(i, 1, n) {
        a[i] = read();
    }
    int ans = 0;
    int cnt = 0;
    for (int i = 1; i <= n - 1; ++i) {
        if (a[i] >= a[i + 1]) {
            ++cnt;
        }else {
            cnt = 0;
        }
        ans = max(ans, cnt);
        prln(cnt);
    }
    cout << ans << endl;
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int main() {
	int n;	cin >> n;
	vint a(n);
	rep(i, n)	cin >> a[i];
	sort(all(a));
	vint list;
	for (int i = n - 2; i >= 0; i--) {
		if (a[i] == a[i + 1]) {
			list.push_back(a[i]);	i--;
		}
	}
	ll ret = 0;
	for (int i = list.size() - 2; i >= 0; i--){
		ret = max(ret, (ll)list[i] * list[i + 1]);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
t,a = map(int, input().split())
data = list(map(int, input().split())) 
degree = 1000000
for i,x in enumerate(data):
    temp = t - 0.006*x
    if degree > abs(temp-a):
        degree = abs(temp-a)
        num = i+1
print(num)        

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

struct Node { int p, l, r; };

int main() {
	int n;
	cin >> n;
	Node *u = new Node[n];
	for (int i = 0; i < n; i++)
		u[i].p = u[i].l = u[i].r = -1;
	for (int i = 0; i < n; i++) {
		int id, k;
		cin >> id >> k;
		if (k) {
			int *c = new int[k];
			for (int j = 0; j < k; j++)
				cin >> c[j];
			u[id].l = c[0];
			for (int j = 0; j < k; j++) {
				u[c[j]].p = id;
				if (j + 1 != k)
					u[c[j]].r = c[j+1];
			}
			delete[] c;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << "node " << i;
		cout << ": parent = " << u[i].p;
		int depth = 0;
		for (int id = i; u[id].p != -1; depth++)
			id = u[id].p;
		cout << ", depth = " << depth;
		if (u[i].p == -1)
			cout << ", root";
		else if (u[i].l == -1)
			cout << ", leaf";
		else
			cout << ", internal node";
		cout << ", [";
		int ifs = 1;
		for (int id = u[i].l; id != -1; id = u[id].r) {
			if (ifs == 0)
				cout << ", ";
			cout << id;
			ifs = 0;
		}

		cout << "]";
		cout << endl;
	}
	delete[] u;

	return 0;
}

Measured memory_bytes: 2588
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>

int main() {
	usize n, k;
	::std::cin >> n >> k;
	::std::cout << ((n+1) / 2 >= k ? "YES" : "NO") << ::std::endl;
	return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(20000)

def fill(m, h, w, x, y):
    m[y][x] = 0
    for i in range(-1, 2):
        for j in range(-1, 2):
            nx = x + i
            ny = y + j
            if nx < 0 or nx >= w or ny < 0 or ny >= h:
                continue
            if m[ny][nx] == 0:
                continue
            fill(m, h, w, nx, ny)

def solve(h, w):
    m = []
    for j in range(h):
        line = list(map(int, input().rstrip().split(' ')))
        m.append(line)
    

    count = 0
    for y in range(h):
        for x in range(w):
            if m[y][x] != 0:
                count += 1
                fill(m, h, w, x, y)

    print(count)

while True:
    w, h = map(int, input().rstrip().split(' '))
    if h == 0 or w == 0:
        break

    solve(h, w)




Measured memory_bytes: 8100
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

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

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

	int ans = 0;
	repk(i,1,N+1){
		int isum = 0;
		int now = i;
		while(now > 0){
			isum += now % 10;
			now /= 10;
		}
		// cout << i << ": " << isum << endl;
		if(isum >= A && isum <= B){
			ans += i;
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,n;
  cin>>k>>n;
  int a[n];
  cin>>a[0];
  int max = 0;
  for(int i = 1;i<n;i++)
  {
    cin>>a[i];
    if(max<(a[i]-a[i-1]))
    {
         max = (a[i]-a[i-1]);
    }
  }
  a[0]+=k;
  if(max<(a[0]-a[n-1]))
  {
  	max = a[0]-a[n-1];
  }
  cout<<(k-max);
  return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

void solv()
{
	int N; scanf("%d", &N);
	for (int X = N - N / 10; X <= N; X++){
		if (((X * 108) / 100) == N){
			printf("%d", X);
			return;
		}
	}
	printf(":(");

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
for _ in range(n):
    a = list(map(int, input().split()))
    if sum([x * y for x, y in zip(a[:], b[:])]) + c > 0:
        count += 1

print(count)

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

ll pot(ll base, ll potencia) {
    ll tot = 1;
    for (int i = 0; i <= potencia - 1; i++) {
        //cout << tot << '\n';
        tot *= base;
    }
    return tot;
}

int main() {
    ll h;
    cin >> h;
    int lastOne = (64 - __builtin_clzll(h));
    //cout << lastOne << '\n';
    ll ans = pot(2, lastOne) - 1;
    cout << ans << '\n';
    return 0;
}

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

ll func(vector<int> plus,string s){
    ll now_sum=0;
    ll num=(int)(s[0]-'0');
    //plus +を置く場所に1、置かない場所に0
    for(int i=0;i<s.size()-1;i++){
        if(plus[i]==1) {
            now_sum+=num;
            num = 0;
            num += s[i+1]-'0';
        }
        else{
            num=10*num;
            num+=(int)(s[i+1]-'0');
        }
    }
    now_sum+=num;
    return now_sum;
}

int main() {
    string s;
    cin >> s;
    // n +の配置位置の数
    int n = s.size()-1;
    ll sum = 0;

    // bit 全探索
    for (int bit = 0; bit < (1 << n); ++bit) {
        vector<int> plus(n);
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) {
            plus[n-i-1]=1;
            }

        }
        //sを分解して和を取る関数
        sum += func(plus,s);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
l = [list(map(int,input().split())) for i in range(m)]
a,b = [list(i) for i in zip(*l)]

for i in range(1,n+1):
    t = 0
    t += a.count(i)
    t += b.count(i)
    print(t)

Measured memory_bytes: 9032
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		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

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n

s = readChar()
t = readChar()
if t[0:-1]==s:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9644
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
string a, b, e;
int c, d;
void init(){
    cin >> a >> b >> c >> d >> e;
}
void solve(){
    if (a == e) --c;
    else --d;
    cout << c << " " << d << endl;
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[25],b[25],c[25],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=1;i<=n;i++)	cin>>b[i];
	for(int i=1;i<n;i++)	cin>>c[i];
	for(int i=1;i<=n;i++){
		ans+=b[a[i]];
		if(a[i]+1==a[i+1])	ans+=c[a[i]];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <string>
int main(){
  int H,W;
  std::cin >> H >> W;

  std::vector<std::string> s;
  std::string ss;
  for(int i = 0; i < H; i++) {
    std::cin >> ss;
    s.push_back(ss);
  }
for(int i= 0; i < H; i ++){
  for(int j = 0; j < W; j++){

      if(i == 0 && j == 0){ //左上角
        if(s[i][j] == '#'){
          if(s[i+1][j] != '#' &&s[i][j+1] != '#' ){
            std::cout << "No" << std::endl;
            return 0;
          }
        }
      }else if(i == 0 && j == W-1){//右上角
        if(s[i][j] == '#'){
          if(s[i+1][j] != '#' &&s[i][j-1] != '#' ){
            std::cout << "No" << std::endl;
            return 0;
          }
        }
      }else if(i == H-1 && j == 0){//左下角
        if(s[i][j] == '#'){

        if(s[i-1][j] != '#' &&s[i][j+1] != '#' ){
          std::cout << "No" << std::endl;
          return 0;
        }
      }
      }else if(i == H-1 && j == W-1) {//右下角
        if(s[i][j] == '#'){

        if(s[i-1][j] != '#' &&s[i][j-1] != '#' ){
          std::cout << "No" << std::endl;
          return 0;
        }
      }
      }else if(i == 0){ //上壁
        if(s[i][j] == '#'){

        if(s[i+1][j] != '#' &&s[i][j+1] != '#' && s[i][j-1] != '#' ){
          std::cout <<"No" << std::endl;
          return 0;
        }
      }
      }else if(i == H-1){//下壁
        if(s[i][j] == '#'){

        if(s[i-1][j] != '#' &&s[i][j-1] != '#' && s[i][j+1] != '#' ){
          std::cout << "No" << std::endl;
          return 0;
        }
      }
      }else if(j == 0){//左壁
        if(s[i][j] == '#'){

        if(s[i-1][j] != '#' &&s[i+1][j] != '#' && s[i][j+1] != '#' ){
          std::cout << "No" << std::endl;
          return 0;
        }
      }
      }else  if(j == W-1){//右壁
        if(s[i][j] == '#'){

        if(s[i-1][j] != '#' &&s[i+1][j] != '#' && s[i][j-1] != '#' ){
          std::cout << "No" << std::endl;
          return 0;
        }
      }
      }else{
        if(s[i][j] == '#'){

        if(s[i-1][j] != '#' &&s[i+1][j] != '#' && s[i][j-1] != '#' && s[i][j+1] != '#'){
          std::cout  <<"No" << std::endl;
          return 0;
        }
      }
      }
  }
}
  std::cout << "Yes" << std::endl;



  return 0;
}


Measured memory_bytes: 256
import scala.collection.mutable._

object Main {
  val sc = new java.util.Scanner(System.in)

  def main(args: Array[String]): Unit = {
    val n: Int = sc.nextLine.toInt
    val suits = List("S", "H", "C", "D")
    val mlist = scala.collection.mutable.MutableList.empty[(String, Int)]
    for (i <- 1 to n) {
      val Array(suit, rank) = sc.nextLine.split(' ')
      mlist += suit -> rank.toInt
    }

    val cards = suits.map(s => s -> Nil).toMap.map {
      case (s, r) =>
        s -> mlist.collect { case c if c._1 == s => c._2 }.toList
    }

    
    suits.foreach {
      case s if cards(s) != Nil =>
        Range(1, 13 + 1).filter(i => cards(s).indexOf(i) == (-1)).foreach(i => println(s"$s $i"))
      case s =>
        Range(1, 13 + 1).foreach(i => println(s"$s $i"))
    }

  }
}

Measured memory_bytes: 45220
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
const int INF = 1001001001;
int sum[11][1005];

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) {
        cin >> s[i];
    }
    rep(i, h) rep(j, w) {
        sum[i][j+1] = sum[i][j] + (s[i][j]-'0');
    }
    
    
    int ans = INF;
    rep(i, 1<<(h-1)) {
        int res = __builtin_popcount(i);
        int st = 0;
        int temp = 0;
        rep(j, w) rep(l, h) {
            temp += (sum[l][j+1] - sum[l][st]);
            if (i>>l&1 || l==h-1) {
                if (temp>k) {
                    if (st==j) {
                        res += 10000;
                        break;
                    }
                    st = j;
                    res++;
                    l = 0;
                }
                temp = 0;
               
            }
        }
        
        ans = min(ans, res);
    }
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// 6/2
// 2-6-4. 素数のこすう
// エラトステネスの篩
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

// const int MAX_N = 1000000;

vector<int> prime;  // i番目の素数
vector<bool> is_prime;  // iが素数かどうか

void sieve(int n) {
    // 一旦全ての数字を素数に。
    prime.resize(n, 0);
    is_prime.resize(n + 1, true);

    // 0, 1は素数では無い。
    is_prime[0] = is_prime[1] = false;

    int p = 0;

    for (int i = 2; i < n; i++) {
        if (is_prime[i]) {
            prime[p++] = i;
            for (int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }

    // return p;
}

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

    sieve(1e5 + 1);
    // cout << "here?" << endl;
    vector<int> numx(1e5 + 1, 0);  // numx[i] = 1までの2017に似た数の個数

    numx[0] = 0;
    numx[1] = 0;

    for (int i = 3; i <= 1e5; i += 2) {
        numx[i] = numx[i - 2];
        if (is_prime[i] && is_prime[(i + 1) / 2]) numx[i] += 1;
    }

    // cout << "here?2" << endl;

    vector<int> ans;

    rep(i, Q) {
        int l, r;
        cin >> l >> r;

        if (l == 1) {
            ans.push_back(numx[r]);
        } else {
            ans.push_back(numx[r] - numx[l - 2]);
        }
    }

    for (auto a : ans) cout << a << endl;
}


Measured memory_bytes: 1916
from collections import defaultdict

def lcm_dict(A):
    pf_d=defaultdict(int)
    for num in A:
        for k in range(2,int(num**0.5)+1):
            cnt=0
            while num%k==0:
                cnt+=1
                num//=k
            if cnt:
                pf_d[k]=max(pf_d[k],cnt)
        if num!=1:
            pf_d[num]=max(pf_d[num],1)
    return pf_d

def modinv(k,mod):
    return pow(k,mod-2,mod)

def main():
    mod=1000000007
    n=int(input())
    A=tuple(map(int,input().split()))
    lcm_d=lcm_dict(A)
    l=1
    for num in lcm_d:
        cnt=lcm_d[num]
        l*=pow(num,cnt,mod)
        l%=mod
    ans=0
    for a in A:
        ans+=l*modinv(a,mod)
        ans%=mod
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 44912
#include<bits/stdc++.h>
using namespace std;
int n;
string s[10000];

int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>s[i];
	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<s[i].size();j++)
		if(s[i][j]=='A'&&s[i][j+1]=='B')
		ans++;
	int a=0,b=0;
	int d=0;
	for(int i=0;i<n;i++)
	{
		if(s[i][0]=='B')
		b++;
		if(s[i][s[i].size()-1]=='A')
		a++;
		if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A')
		d++;
	}
	if(d==n||(d==a&&d==b&&d!=0))
	ans--;
	
	ans+=min(a,b);
	cout<<ans;
	return 0;
}

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int H, W, h, w;
   cin >> H >> W >> h >> w;
   if (H % h == 0 && W % w == 0) {
      cout << "No\n";
      return 0;
   }
   cout << "Yes\n";
   for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
         if (i % h == h - 1 && j % w == w - 1) {
            cout << -1007 * (h * w - 1) - 1 << " ";
         } else {
            cout << 1007 << " ";
         }
      }
      cout << "\n";
   }
}


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

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

  unordered_set<int> mods;
  int mod= 7 % K;
  while(!mods.count(mod)){
    mods.insert(mod);

    if(mod==0){ break; }
    else{
      mod= (10*mod+ 7) % K;
    }
  }
  int ans= mods.count(0) ? int(mods.size())
                         : -1;
  
  cout << ans << endl;
}

Measured memory_bytes: 42696
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  char a[4];
  int b[4], c=0;
  rep(i,0,4) cin >> a[i];
  rep(i,0,4){
    rep(j,0,4){
      if(a[i]==a[j]) c++;
    }
    b[i]=c;
    c=0;
  }
  sort(b, b+4);
  if(b[0]==2) co("Yes");
  else co("No");
  
  
  return 0;
}


Measured memory_bytes: 256
import sys

MOD = 10**9 + 7


def main():
    N = int(sys.stdin.readline().rstrip())

    all_ = pow(10, N, MOD)
    ote = pow(8, N, MOD)
    otn = pow(9, N, MOD)
    zte = pow(9, N, MOD)

    ans = all_ - otn - zte + ote

    print(ans % MOD)


main()


Measured memory_bytes: 9176
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int D;
int c[26];
vector<int> s;


void input()
{
    scanf("%d", &D);
    s.resize(D * 26);
    int i, j;
    for (i = 0; i < 26; i++) {
        scanf("%d", &c[i]);
    }
#define P(i,j) ((i)*26+(j))
    for (i = 0; i < D; i++) {
        for (j = 0; j < 26; j++) {
            scanf("%d", &s[P(i, j)]);
        }
    }
    return;
}

void calc(const vector<int>& t, vector<int>& ans)
{
    vector<int> last(26,-1);
    int sum = 0;
    int i,k;
    for (i = 0; i < D; i++) {
        sum += s[P(i, t[i])];
        last[t[i]] = i;
        for (k = 0; k < 26; k++) {
            sum -= c[k] * (i - last[k]);
        }
        ans[i] = sum;
    }
    return;
}

void sel(vector<int>& t)
{
    vector<int> last(26,-1);
    int i,j,k;
    for (i = 0; i < D; i++) {
        int max = -INF;
        int maxj = -1;
        for (j = 0; j < 26; j++) {
            int sum0 = s[P(i, j)];
            for (k = 0; k < 26; k++) {
                if(k!=j) sum0 -= c[k] * (i - last[k]);
            }
            if (max < sum0) {
                max = sum0;
                maxj = j;
            }
        }
        t[i] = maxj;
        last[maxj] = i;
    }
    return;
}

void solve()
{
    input();

    /*
    vector<int> t(D);
    int i;
    for (i = 0; i < D; i++) {
        scanf("%d", &t[i]); t[i]--;
    }
    vector<int> ans0(D);
    calc(t, ans0);
    */

    int i;
    vector<int> t(D);
    sel( t );

#if 0
    vector<int> ans0(D);
    calc(t, ans0);

    for (i = 0; i < D; i++) {
        printf("%d\n", ans0[i]);
    }
#endif
    for (i = 0; i < D; i++) {
        printf("%d\n", t[i]+1);
    }

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 3236
#------------------------------warmup----------------------------
import os
import sys
from io import BytesIO, IOBase
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
#-------------------game starts now-----------------------------------------------------
n,m,x=map(int,input().split())
e=[]
tot=999999999999999999999999999
def binary(n,ju):
    binaryNum = [0] * (ju) 
    i = 0
    while (n > 0):  
        binaryNum[i] = n % 2 
        n = int(n / 2) 
        i += 1 
    binaryNum.reverse()
    return binaryNum
for i in range(n):
    e.append(list(map(int,input().split())))
for i in range(0,2**(n)):
    ans=[0]*m
    s=binary(i,n)
    cost=0
    #print(s)
    for j in range(n):
        if s[j]==1:
            cost+=e[j][0]
            for k in range(m):
                ans[k]+=e[j][k+1]
    f=0
    for j in ans:
        if j<x:
            f=1
            break
    if f==0:
        tot=min(tot,cost)
if tot==999999999999999999999999999: 
    print(-1)
else:
    print(tot)

Measured memory_bytes: 68632
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

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

int main(){
    string s;
    cin >> s;
    int i;
    for(i=0;i<s.size()-1;i++){
        //cout << s[i] << " " << s[i+1] << endl;
        if(s[i] != s[i+1]){cout << "Yes" << endl;return 0;}
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String  str[] = new String[1];
		try{
		while(str !=null){

			str = br.readLine().split(" ");

			System.out.println(String.valueOf(Integer.parseInt(str[0])+Integer.parseInt(str[1])).length());

		}

	}catch(Exception e){
		System.exit(0);
	}


	}

}

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

using namespace std;

int main() {
  long long N;
  string ans = "";
  
  cin >> N;
  
  while (true) {
    N--;
    ans.insert(0, {N % 26 + 'a'});
    
    N /= 26;
    
    if (N == 0) {
      break;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;cin >> h >> w;
    int a[h][w],b[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> b[i][j];
        }
    }
    const int vmax=12800;
    bool c[h][w][2*vmax]={false};
    c[0][0][a[0][0]-b[0][0]+vmax]=true;
    c[0][0][b[0][0]-a[0][0]+vmax]=true;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=0;k<2*vmax;k++){
                if(!c[i][j][k]){
                    continue;
                }
                if(i<h-1){
                    c[i+1][j][k+a[i+1][j]-b[i+1][j]]=true;
                    c[i+1][j][k+b[i+1][j]-a[i+1][j]]=true;
                }
                if(j<w-1){
                    c[i][j+1][k+a[i][j+1]-b[i][j+1]]=true;
                    c[i][j+1][k+b[i][j+1]-a[i][j+1]]=true;
                }
            }
        }
    }
    int ans=inf;
    for(int i=0;i<2*vmax;i++){
        if(c[h-1][w-1][i]){
            chmin(ans,abs(i-vmax));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 160128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  vector<int> dp(N);
  dp.at(0) = 0;
  dp.at(1) = abs(vec.at(1) - vec.at(0));
  for(int i=2; i<N; i++){
    int x = dp.at(i-2) + abs(vec.at(i) - vec.at(i-2));
    int y = dp.at(i-1) + abs(vec.at(i) - vec.at(i-1));
    dp.at(i) = min(x,y);
  }
  cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        List<List<Integer>> graph = new ArrayList<>();
        int[] degree = new int[n+1];
        int[] dp = new int[n+1];
        for(int i = 0; i <= n; i++){
            graph.add(new ArrayList<>());
        }
        for(int i = 0; i < m; i++){
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            degree[y]++;
            graph.get(x).add(y);
        }
        Deque<Integer> stack = new LinkedList<>();
        for(int i = 1; i <= n; i++){
            if(degree[i] == 0){
                stack.push(i);
            }
        }
        List<Integer> list = new ArrayList<>();
        while(!stack.isEmpty()){
            int j = stack.pop();
            list.add(j);
            for(int k : graph.get(j)){
                degree[k]--;
                if(degree[k] == 0)
                    stack.push(k);
            }
        }
        for(int i : list){
            for(int j : graph.get(i)){
                dp[j] = Math.max(dp[j], dp[i] + 1);
            }
        }
        int ans = 0;
        for(int i = 1; i <= n; i++){
            ans = Math.max(ans, dp[i]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 102108
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

N, Y = map(int, input().split())
Y = int(Y/1000)
x = 0
x_right = -1
y = -1
z = -1

while 9 * x <= Y - N:
    if (Y - N - 9 * x) / 4 <= N and (Y - N - 9 * x) % 4 == 0:
        if N - (Y - N - 9 * x) / 4 - x >= 0 and N - (Y - N - 9 * x) / 4 - x <= N:
            y = (Y - N - 9 * x) / 4
            z = N - x - y
            x_right = x
    x += 1

print(int(x_right), int(y), int(z))




Measured memory_bytes: 14436
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int A = 0;
		int B = 0;
		int C = 0;
		Scanner sc = new Scanner(System.in);
		A = Integer.parseInt(sc.next());
		B = Integer.parseInt(sc.next());
		C = Integer.parseInt(sc.next());

		
		
		if (A==B&B==C) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 23252