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

#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = m; i >= l; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define Count_bit(x)    __builtin_pop(x)
#define u_map           unordered_map
#define fi              first
#define se              second
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             2000000000
#define ool             LLONG_MAX
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define vi              vector<int>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(int x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
const int base = 311;


const int N = 3e5;

int n, m, k, q, ans, a[N];
inline void Solve(){
    string t;
    cin >> t;
    bool ok = true;
    for(int i = 0; i <= Sz(t); i++){
        if(i&1){
            if(t[i] == 'R'){
                ok = false;
            }
        } else{
            if(t[i] == 'L'){
                ok = false;
            }
        }
    }
    if(ok) cout << "Yes"; else cout << "No";
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <string>
#pragma GCC optimize(2)
using namespace std;
typedef int LL;

LL n,ans = 0,cnt[555];
string s[200005],t,tt;
map <string,LL> mp[1000005]; LL vis[1000005];

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(LL ls,i = 1;i <= n;i ++){
		cin >> s[i]; ls = s[i].length();
		t = s[i]; reverse(t.begin(),t.end());
		mp[ls][t] ++; vis[ls] = 1;
	}
	for(LL len,ls,i = 1;i <= n;i ++){
		for(char j = 'a';j <= 'z';j ++) cnt[j] = 0;
		ls = s[i].length();
		for(LL j = 0;j < ls;j ++) cnt[s[i][j]] ++;
		t = ""; len = 0;
		for(LL j = ls - 1;j >= 0;j --){
			for(char k = 'a';k <= 'z';k ++){
				if(cnt[k]){
					t += k; len ++;
					if(vis[len])
						if(mp[len].find(t) != mp[len].end()) ans ++;
					t.pop_back(); len --;
				}
			}
			t += s[i][j]; cnt[s[i][j]] --; len ++;
		}
	}
	cout << ans - n << '\n';
	return 0;
}

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

int main() {
    ll n, ans = 0;
    cin >> n;
    int cnt = 0;
    while (n) {
        ans = ans + 1LL * pow(2, cnt);
        cnt++;
        n >>= 1;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3600
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
    long long int ans=1;
    int N;
    cin >> N;
    FOR(i,1,N+1){
        ans *= i;
        ans %= 1000000007;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

bool cmp(pair<int,int>a,pair<int,int>b) {
  return a.second < b.second;
}

int main(){
  ll n,m;
  cin >> n >> m;
  vector<pair<int,int>>A(m);
  for(int i=0;i<m;i++) cin >> A[i].first >> A[i].second;
  sort(All(A),cmp);
  int ans = 0;
  int end = 0;
  for(int i=0;i<m;i++){
    if(A[i].first >= end){
      end = A[i].second;
      ans++;
    }
  }
  cout<< ans <<endl;
}


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

int main() {
    string s; cin >> s;
    if (s == "SSS") {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    if (s[0] == 'R' && s[1] == 'R') ans++;
    if (s[1] == 'R' && s[2] == 'R') ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3576
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        Console.ReadLine();
        var d = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var ans = 0;
        for (int i = 0; i < d.Length; i++)
        {
            ans += d[i] - 1;
        }
        Console.WriteLine(ans);
    }
}


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

using namespace std;

int H,W;
const int MAXN = 1e3 + 5;
const int mod = 1e9 + 7;
vector <string> grid;
int dp[MAXN][MAXN]; //guarda quantos caminhos existem até (H-1,W-1) partindo de (i,j)

bool valid(int i,int j){
  return i >= 0 && i < H && j>=0 && j < W && grid[i][j] != '#';
}

bool destiny(int i,int j){
  return i == H-1 && j == W-1;
}

int solve(int i,int j){

  if(destiny(i,j)){
    return 1;
  }

  if(dp[i][j] != -1){
    return dp[i][j];
  }

  int r = 0;
  int d = 0;

  if(valid(i+1,j)){
    d = solve(i+1,j)%mod;
  }

  if(valid(i,j+1)){
    r = solve(i,j+1)%mod;
  }

  return dp[i][j] = (r + d)%mod;
}

int main(){
  cin >> H >> W;

  int h = H;

  while(h--){
    string line;
    cin >> line;
    grid.push_back(line);
  }

   memset(dp,-1,sizeof dp);

  cout << solve(0,0) << endl;
}

Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	cin>>n>>m;
	vi s;
	rep(i,n){
		int a;cin>>a;
		if(a)s.pb(i);
	}
	vi in(n);
	int t=0;
	rep(i,m){
		int a;cin>>a;
		if(i%2)rep(j,a)in[t+j]=1;
		t+=a;
	}
	int out=inf;
	rep(i,2){
		vi w;
		rep(j,n)if(in[j]==i)w.pb(j);
		if(w.size()!=s.size())continue;
		int sum=0;
		rep(j,w.size())sum+=abs(w[j]-s[j]);
		out=min(sum,out);
	}
	cout<<out<<endl;
}

Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int x, a;
  cin >> x >> a;
  if (x < a) {
    cout << 0 << endl;
  }
  else {
    cout << 10 << endl;
  }
  return 0;
}

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

char a[300000];
int main(){
    int n;
    char s;
    scanf("%d", &n);
    
    scanf("%c", &s);
    int rs = 0;
    for(int i=0; i<n; i++){
        scanf("%c", &a[i]);
        if(a[i] == 'R') rs++;
    }
    int ans = 0;
    for(int i=0; i<rs; i++){
        if(a[i] == 'W') ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3396
#pragma warning (disable :4996)
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-7
using namespace std;

const int mod = 1e9 + 7;
const int maxn = 1e5;
string s1, s2, s3;
bool ab[maxn], ac[maxn], bc[maxn];
bool match(char a, char b) {
	return a == b || a == '?' || b == '?';
}
int res = maxn;
int main(){
	cin >> s1 >> s2 >> s3;
	int a, b, c;
	a = s1.length(), b = s2.length(), c = s3.length();
	for (int i = 0; i < a; ++i) for (int j = 0; j < b; ++j) if (!match(s1[i], s2[j])) ab[i - j + 4000] = 1;
	for (int i = 0; i < a; ++i) for (int j = 0; j < c; ++j) if (!match(s1[i], s3[j])) ac[i - j + 4000] = 1;
	for (int i = 0; i < b; ++i) for (int j = 0; j < c; ++j) if (!match(s2[i], s3[j])) bc[i - j + 4000] = 1;
	for (int i = -4000; i <= 4000; ++i) {
		for (int j = -4000; j <= 4000; ++j) {
			if (!ab[i + 4000] && !ac[j + 4000] && !bc[j - i + 4000]) {
				int l, r;

				l = min(0, min(i, j)), r = max(a, max(b + i, c + j));
				res = min(res, r - l);
			}
		}
	}
	cout << res << endl;
}



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

 
int main(){
        int n,channel;
        cin >> n >> channel;
        vector<vector<int>> time(30,vector<int>(100005,0));
        rep(i,n){
                int s,t,c;
                cin >> s >> t >> c;
                --c;
                for(int i=s;i<=t;i++) time[c][i] = 1;
        }

        rep(j,100004){
                rep(i,channel-1) time[i+1][j] += time[i][j];
        }

        int ans = 0;
        rep(j,100005) ans = max(ans,time[channel-1][j]);
        cout << ans << endl;

        return 0;
}






Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
vector<int>primes;
#define MAX 35000
using ll=long long ;
ll flag=0;
ll ar[100];

int main()
{
    ll n,i,sum=0,l,t=1;
    string str,ptr;
    cin>>str>>ptr;
    if(str.length()>=ptr.length())
    {
        cout<<"No"<<endl;
        return 0;
    }
    else if((str.length()+1)<ptr.length())
    {
        cout<<"No"<<endl;
        return 0;
    }
    for(i=0;i<ptr.length()-1;i++)
    {
        if(str[i]!=ptr[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
  cout<<"Yes"<<endl;
}



Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <map>

using namespace std;
using lli = long long int;
using ll = long long;

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

    lli d = c - a - b;

    if (d > 0 && d * d > 4 * a * b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main()
{
  int64_t K;
  cin >> K;
  int64_t n = 7;
  for (int64_t i = 1; i <= 10000000; i++)
  {
    n %= K;
    if (n == 0)
    {
      cout << i << endl;
      return 0;
    }
    n *= 10;
    n += 7;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

template <class T>
map<T, T> prime_factorize(T n) {
    map<T, T> res;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1)
        res[n] = 1;
    return res;
}

int main() {
    ll n;
    cin >> n;
    auto m = prime_factorize(n);
    int sum = 0;
    for (auto it = m.begin(); it != m.end(); it++) {
        int i = 1;
        while (it->second >= i) {
            it->second -= i;
            //cout <<it->first<<' '<< it->second << endl;
            sum++;
            i++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
char hata[55][55],c;
int ans=10000000,lim,h,w,sum;

int main(){
    cin >> h >> w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> hata[j][i];
        }
    }

    for(int i=1;i<=h-2;i++){
       for(int j=i+1;j<=h-1;j++){

            //printf("i=%d j=%d\n",i,j);

        for(int k=1;k<=h;k++){
            for(int m=1;m<=w;m++){
                if(k<=i){
                    if(hata[m][k]!='W')sum++;
                }else if(k<=j){
                    if(hata[m][k]!='B')sum++;
                }else{
                    if(hata[m][k]!='R')sum++;
                }
            }
        }

    ans=min(ans,sum);
       //printf("sum=%d\n",sum);
       sum=0;
       }
    }

    cout << ans << endl;


return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
signed main() {
	int h, w;
	cin >> h >> w;
	int n; cin >> n;
	while(h!=0){
	vvel wr(h, vel(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> wr[i][j];
		}
	}
	vvel ka(h, vel(w));
	ka[0][0] = n;
	for (int in = 1; in <= h + w-2; in++) {
		if (in < w) {
			ka[0][in] = (ka[0][in-1] +wr[0][in-1]) / 2;
		}
		for (int i = 1; i < h; i++) {
			int j = in - i;
			if (j == 0) {
				ka[in][0] = (ka[in - 1][0] + 1-wr[in - 1][0]) / 2;
			}
			if (0 < j and j < w) {
				ka[i][j] = (ka[i - 1][j] + 1 - wr[i - 1][j]) / 2;
				ka[i][j] += (ka[i][j - 1] + wr[i][j - 1]) / 2;
			}
		}
	}
	int ni = 0;
	int nj = 0;
	while (ni < h and nj < w) {
		if ((ka[ni][nj] + wr[ni][nj])%2 == 0) {
			nj++;
		}
		else ni++;
	}
	cout << ni + 1 << " " << nj + 1 << endl;
	cin >> h >> w >> n;
	}
	return 0;
}



Measured memory_bytes: 18672
#include<bits/stdc++.h>
#define mod ((int)1e9+7)
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;

const int N = (int)2e5+5;

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

    int x;
    cin>>x;
    ll ans = (x/500)*1000;
    x %= 500;
    ans += (x/5)*5;
    cout<<ans;
}


Measured memory_bytes: 256
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define set0(x) memset(x,0,sizeof(x))
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();int f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int n,k,a[110],ok = 1,lsh = -1,sh = -1;
vector<int> ans;
void push(int x){
	//cout<<x<<endl;
	a[x]-=1;
	if(a[x]<0)ok = 0;
	ans.push_back(x);
}
int main() {
	read(n);read(k);
	for(int i=1;i<=n;i++)read(a[i]);
	for(int i=0;i<k;i++){
		int mi = 1000000;
		for(int i=1;i<=n;i++)if(a[i]<mi && i!=lsh)sh = i,mi = a[i];
		for(int i=1;i<=n;i++)if(i!=lsh && i!=sh)push(i);
		push(sh);
		lsh = sh;
	}
	for(int i=1;i<=n;i++)if(i!=sh)push(i);
	//cout<<ok<<endl;
	if(!ok){
		cout<<-1<<endl;
	}else{
		cout<<ans.size()<<endl;
		for(int i=0;i<ans.size();i++)cout<<ans[i]<<' ';
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

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

    std::cout << std::min(A, B) << " " << std::max(0, B - (N -A)) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n, m;
    cin >> n >> m;

    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    
    priority_queue<ll, vector<ll>, less<ll>> que;
    rep(i, n) que.push(a[i]);
    
    ll sum = 0;
    rep(i, n) sum += a[i];
    
    rep(i, m) {
        ll p = que.top();
        que.pop();
        ll d = p - p / 2;
        p /= 2;
        que.push(p);
        sum -= d;
    }

    put(sum);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 5072
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	auto ans = long.max;
	for( auto a = 1L; a ^^ 2 <= n; a++ )
	{
		if( n % a == 0 ) ans = min( ans, f( a, n / a ) );
	}
	
	return ans;
}

auto f( long a, long b )
{
	return max( a.to!( string ).length, b.to!( string ).length );
}


Measured memory_bytes: 256
M = 10**2 + 1
N = int(input())
L = [0 for _ in range(M**2+10)]
for i in range(1,M):
    for j in range(1,M):
        for k in range(1,M):
            n = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if n>N:
                break
            L[n] += 1
for i in range(1,N+1):
    print(L[i])


Measured memory_bytes: 9256
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define N 200005
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	int s,w;
	cin>>s>>w;
	if(s>w)
		cout<<"safe"<<endl;
	else
		cout<<"unsafe"<<endl;

	return 0;
}

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

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

    vector<int> count(n);
    for (auto i = 0; i < n; i++) {
        cin >> a;
        count[a - 1]++;
    }

    sort(count.begin(), count.end(), greater<>());
    int ans = 0;
    for (auto elm : count) {
        if(k <= 0) ans += elm;
        if(elm > 0) k--;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
def divisor(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


N = int(input())
ans = 0
for i in range(1, N + 1, 2):
    res = divisor(i)
    if len(res) == 8:
        ans += 1

print(ans)


Measured memory_bytes: 9108
#include <iostream>
#include <ostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    int n, size;
    cin >> n >> size;
    vector<string> before_line(n);
    vector<vector<int> > after_line(n+2, vector<int>(size+2));

    for (int i = 0; i < n; ++i) {
        cin >> before_line.at(i);
    }

    for (int i = 0; i < n; ++i) {
        string line = before_line.at(i);
        for (int j = 0; j < size; ++j) {
            if (line.at(j) == '#') {
                // up
                after_line.at(i).at(j+1) += 1;
                // up-right
                after_line.at(i).at(j+2) += 1;
                // right
                after_line.at(i+1).at(j+2) += 1;
                // down-right
                after_line.at(i+2).at(j+2) += 1;
                // down
                after_line.at(i+2).at(j+1) += 1;
                // down-left
                after_line.at(i+2).at(j) += 1;
                //left
                after_line.at(i+1).at(j) += 1;
                // up-left
                after_line.at(i).at(j) += 1;
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        string line = before_line.at(i);
        for (int j = 0; j < size; ++j) {
            if (line.at(j) == '#') {
                cout << '#';
            } else {
                cout << after_line.at(i+1).at(j+1);
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 20
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P; 
#define INF 100000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
   int n,m;
   cin>>n>>m;
   ll L=1;
   vector<int> cnt(n);
   REP(i,n){
       ll a;
       cin>>a;
       L=L/__gcd(L,a)*a;
       while(a%2==0){
           cnt[i]++;
           a/=2;
       }
   }
    L/=2;
    int ans=0;
        int tmp=m/L;
        ans=(tmp+1)/2;
    bool flag=true;
    REP(i,n){
        if(cnt[0]!=cnt[i]){
            flag=false;
            break;
        }
    }
    if(!flag) ans=0;
    OUT(ans);
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {

	public static List<String> z;
	
	public static int factorial(int n){
		  return n <= 0 ? 1 : n * factorial(n-1);
	}	
	
	public static void permutation(String q, String ans){
	        // Base Case
	        if(q.length() <= 1) {
	        	z.add(ans + q);
	        }
	        // General Case
	        else {
	            for (int i = 0; i < q.length(); i++) {
	                permutation(q.substring(0, i) + q.substring(i + 1),
	                        ans + q.charAt(i));
	            }
	        }
	    }
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		z = new ArrayList<>();
		double[] x = new double[N];
		double[] y = new double[N];
		double ans = 0;
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		String s = "";
		for(int i = 0; i < N; i++)
			s += i;
		permutation(s,"");
		for(int i = 0; i < z.size(); i++) {
			for(int j = 1; j < N; j++) {
				String q = z.get(i);
				int a = Character.getNumericValue(q.charAt(j));
				int b = Character.getNumericValue(q.charAt(j-1));
				ans += Math.pow(Math.pow(x[a]-x[b], 2) + Math.pow(y[a]-y[b], 2), 0.5);
			}
		}
		System.out.println(ans/factorial(N));
		
	}

}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct Latte{
    string s;
    vint acc;

    Latte(string str):s(str){
        acc.resize(s.size()+1);
        rep(i,s.size()){
            acc[i+1]=acc[i]+(s[i]=='A');
        }
    }

    int q(int l,int r){
        int a=acc[r]-acc[l];
        int b=r-l-a;
        return (b-a+3ll*1001001001)%3;
    }
};

int Q;

signed main(){
    string S,T;
    cin>>S>>T;

    scanf("%lld",&Q);

    Latte luz(S),izr(T);
    while(Q--){
        int l,r,ll,rr;
        scanf("%lld%lld%lld%lld",&l,&r,&ll,&rr);
        l--;ll--;
        if(luz.q(l,r)==izr.q(ll,rr))puts("YES");
        else puts("NO");
    }
    return 0;
}


Measured memory_bytes: 2560
use std::cmp;

fn main(){
  let nds: usize = read();
  
  for _ in 0 .. nds {
    let iof: usize = read();
    let oy: usize = read();
    let nom: usize = read();

    let mut mof: usize = 0;
    
    for _ in 0 .. nom {
      let tv: Vec<f64> = read_vec();
      let tf = tv[0] as usize;
      let air = tv[1];
      let fee = tv[2] as usize;

      let nair: usize = (air * 8192.0) as usize;
      
      let mut of: usize = iof;
      
      if tf == 0 {
        let mut ait: usize = 0;
        
        for _ in 0 .. oy {
          let it: usize = of * nair / 8192;
          ait += it;
          of = of - fee;
        }
        
        mof = cmp::max(mof, of + ait);
      } else {
        for _ in 0 .. oy {
          let it: usize = of * nair / 8192;
          of = of + it - fee;
        }
        
        mof = cmp::max(mof, of);
      }
    }
    println!("{}", mof);
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 5064
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; long long k; cin >> n >> k;
    int a[n], f[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> f[i];
    sort(a, a+n);
    sort(f, f+n);
    long long lb = -1, ub = 1LL<<60;
    while (ub - lb > 1) {
        long long cost = 0, m = (ub + lb) / 2;
        for (int i = 0; i < n; i++) {
            // (a-x) * f <= m
            cost += max(0LL, a[i] - m/f[n-i-1]);
        }
        if (cost > k) lb = m;
        else ub = m;
    }
    cout << ub << endl;
}


Measured memory_bytes: 1792
// abc150_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int k,x;
  cin>>k>>x;
  cout<<((500*k>=x)?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());
        
        int ans = 0;
        for(int i=0; i<=A; i++){
            for(int j=0; j<=B; j++){
                for(int z=0; z<=C; z++){
                    if((i*500) + (j*100) + (z*50) == X){
                        ans++;
                    }
                }
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21332
def readinput():
    d,t,s=map(int,input().split())
    return d,t,s

def main(d,t,s):
    if d<=t*s:
        return 'Yes'
    else:
        return 'No'

if __name__=='__main__':
    d,t,s=readinput()
    ans=main(d,t,s)
    print(ans)


Measured memory_bytes: 9160
#
# author Sidratul
#

from math import prod

if __name__ == '__main__':
    n = input()
    a = list(map(int, input().split(' ')))
    s = 1
    a.sort()
    x = True
    for i in range(len(a)):
        s = s * a[i]
        if s > 10**18:
            print(-1)
            x = False
            break
    if x:
        print(s)

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

#define mx 100005
using namespace std;

int n;
long long a[mx], b[mx], ans;
pair<long long, int> c[mx];

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d%d", &a[i], &b[i]);
		c[i] = make_pair(a[i] + b[i], i);
	}
	sort(c, c+n, greater<pair<long long, int> >());
	for(int i = 0; i < n; i++){
		if(i&1){
			ans -= b[c[i].second];
		}else ans += a[c[i].second];
	}
	printf("%lld\n", ans);

}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
#define foreach(ix,a) for(auto& (ix) : (a) 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,k;
  cin>>n>>k;
  vl x(n);
  rep(i,n){
    cin>>x[i];
  }
  sort(been(x));
  rep(i,k){
    x.pop_back();
  }
  ll ans =0;
  rep(i,n-k){
    ans+=x[i];
  }
  cout<<ans<<endl;


}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
 
class Main{
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String input_str;
            while((input_str = br.readLine()) != null){
                String[] input_strs = input_str.split(" ");
                Node node1 = new Node(input_strs[1]);
                Node node2 = new Node(input_strs[2]);
                Node result_node = new Node();
                if(input_strs[0].equals("i")){
                    result_node.intersection(node1, node2);
                }
                if(input_strs[0].equals("u")){
                    result_node.union(node1, node2);
                }
                System.out.println(result_node.toString());
            }
        }catch(Exception e){
        }
    }
}
 
class Node{
    Node left;
    Node right;
 
    Node(){
        left = null;
        right = null;
    }
 
    Node(String str){
        int lvl = 0;
        for(int i = 0; i < str.length(); i++){
            char ch = str.charAt(i);
            if(ch == '(') lvl++;
            if(ch == ')') lvl--;
            if(ch == ',' && lvl == 1){
                String left_str = str.substring(1, i);
                if(left_str.length() == 0){
                    left = null;
                }else{
                    left = new Node(left_str);
                }
                
                String right_str = str.substring(i+1, str.length()-1);
                if(right_str.length() == 0){
                    right = null;
                }else{
                    right = new Node(right_str);
                }
            }
        }
    }
 
    public String toString(){
        String result = "(";
        if(left != null) result += left.toString();
        result += ",";
        if(right != null) result += right.toString();
        result += ")";
        return result;
    }
 
    public Node intersection(Node node1, Node node2){
        if(node1.left != null && node2.left != null){
            left = new Node();
            left.intersection(node1.left, node2.left);
        }
        
        if(node1.right != null && node2.right != null){
            right = new Node();
            right.intersection(node1.right, node2.right);
        }
        return this;
    }
 
    public Node union(Node node1, Node node2){
        if(node1.left == null){
            left = node2.left;
        }else if(node2.left == null){
            left = node1.left;
        }else{
            left = new Node();
            left.union(node1.left, node2.left);
        }
        
        if(node1.right == null){
            right = node2.right;
        }else if(node2.right == null){
            right = node1.right;
        }else{
            right = new Node();
            right.union(node1.right, node2.right);
        }
        return this;
    }
}

Measured memory_bytes: 17884
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    string X;
    string Y;
    io.read(X, Y);
    int x = stoi(X, nullptr, 16);
    int y = stoi(Y, nullptr, 16);
    string ans = "<";
    if(x > y){
        ans = ">";
    }
    else if(x == y){
        ans = "=";
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    from itertools import accumulate

    N,Q= map(int, input().split())  # N=len(A)
    S=input()
    l=[list(map(int,input().split())) for i in range(Q)]
    A = []
    for i in range(N-1):
        if S[i:i+2]=='AC':
            A.append(1)
        else:
            A.append(0)

    B = [0] + A
    B = list(accumulate(B))  # 累積和を格納したリスト作成

 
    for a,b in l:
        ans = B[b-1]-B[a-1]
        print(ans)

resolve()

Measured memory_bytes: 33128
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

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

    vector <int> votes(N);

    int sum = 0;

    for (int i = 0; i < N; ++i) {
        cin >> votes[i];
        sum += votes[i];
    }

    int select = 0;

    for (int i = 0; i < N; ++i) {
        // votes[i] >= tot / 4M
        if (votes[i]*4*M >= sum) {
            ++select;
        }
    }

    cout << (select >= M ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<cmath>
#include<algorithm>
using namespace std;

int divisor(int N){
    set<int> divisors;
    for(size_t i = 1; i < sqrt(double(N)); i++)
    {
        if(N%i==0) {
            divisors.insert(i);
            divisors.insert(N/i);
        }
    }
    return divisors.size();
}

int main(){
    int N;
    cin >> N;
    int ret = 0;
    for(int i = 1; i <= N; i+=2)
    {
        if(divisor(i) == 8)
            ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int count =0;
  if(s[0] == 'o') ++count;
  if(s[1] == 'o') ++count;
  if(s[2] == 'o') ++count;
  cout << 700 + (100 * count) << endl;
}

Measured memory_bytes: 3620
W,H,x,y = map(int,input().split())

if x == 0 or x == W or y == 0 or y == H:
    menseki = W * H / 2
    print("{} 0".format(menseki))
elif x == W/2 and y == H/2:
    menseki = W * H / 2
    print("{} 1".format(menseki))
elif x == W/2 or y == H/2:
    menseki = W * H / 2
    print("{} 0".format(menseki))
else:
    menseki = W * H / 2
    print("{} 0".format(menseki))
    





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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n, s;
    cin>>n;
    int k=n;
    s = 0; 
    while(n!=0){
        s += n%10;
        n = n/10;
    }


    if(k%s==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
	int i,j,r,d,x;
	scanf("%d%d%d",&r,&d,&x);
	int v[100];
	v[0]=  r * x- d;
	for(i=1;i<10;i++)
	{
		v[i]= r * v[i-1] -d;
	 }
	 for(i=0;i<10;i++)
	 {
	 	printf("%d\n",v[i]);
	  } 
return 0;}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define nep next_permutation
#define MOD 1000000007ll
#define MIN (1e-10)
#define equal(a,b) (abs((a)-(b))<MIN)
#define v2 ten
#define chokusen senbun
#define tenten senbun
#define takaku vec<ten>
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
struct pea{
	ll f,s;
	bool operator<(const pea &p)const{
		return f!=p.f?f<p.f:s<p.s;
	};
};
struct tri{
	ll f,s,t;
	bool operator<(const tri &p)const{
		if(f!=p.f)return f<p.f;
		if(s!=p.s)return s<p.s;
		return t<p.t;
	};
};
class ten{
public:
	ld x,y;
	ten operator+(ten p){return{x+p.x,y+p.y};}
	ten operator-(ten p){return{x-p.x,y-p.y};}
	ten operator*(ld k){return{k*x,k*y};}
	ten operator/(ld k){return{x/k,y/k};}
	ld abs(){return sqrt(abs2());}
	ld abs2(){return x*x+y*y;};
	bool operator<(const ten &p)const{return x!=p.x?x<p.x:y<p.y;};
	bool operator==(const ten &p)const{return (-MIN<x-p.x)&&(x-p.x<MIN)&&(-MIN<y-p.y)&&(y-p.y<MIN);};
	ld naiseki(v2 b){return x*b.x+y*b.y;}
	ld gaiseki(v2 b){return x*b.y-y*b.x;}
};
struct senbun{ten p1,p2;};
struct en{ten o;ld r;};
bool sosu(ll n){
	if(n==2)return true;
	if(n<2||n%2==0)return false;
	for(ll i=3;i*i<=n;i+=2)if(n%i==0)return false;
	return true;
}
class eratos{
public:
	vec<bool> sosu;
	eratos(ll maxn){
		sosu.resize(maxn+1,true);
		sosu[0]=sosu[1]=false;
		for(ll i=2;i*i<=maxn;i++){
			if(sosu[i]){
				ll j=i+i;
				while(j<=maxn){
					sosu[j]=false;
					j+=i;
			  }
			}
		}
	}
};
void solve(){
	ll n;cin>>n;
	vll a(n);
	rep(i,0,n)cin>>a[i];
	ll k=*mae(ALL(a));
	ll ans=0;
	if(k<=100000){
		eratos b(k);
		rep(i,0,n)ans+=b.sosu[a[i]];
	}else{
		rep(i,0,n)ans+=sosu(a[i]);
	}
	cout<<ans<<kai;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int power[21];
	power[0] = 1;
	for (int i = 1; i <= 20; i++)
	{
		power[i] = 2 * power[i - 1];
	}
	int n;
	cin >> n;
	int x[n + 1];
	for (int i = 1; i <= n; i++)
	{
		cin >> x[i];
	}
	int l;
	cin >> l;
	int reach[n + 1][21];
	for (int j = 0; j <= 20; j++)
	{
		reach[n][j] = n;
	}
	for (int i = n - 1; i >= 1; i--)
	{
		int pos = lower_bound(x + 1, x + n + 1, x[i] + l + 1) - x;
		reach[i][0] = pos - 1;
		for (int j = 1; j <= 20; j++)
		{
			reach[i][j] = reach[reach[i][j - 1]][j - 1];
		}
	}
	int q;
	cin >> q;
	while (q--)
	{
		int a, b;
		cin >> a >> b;
		if (a > b)
		{
			int temp = a;
			a = b;
			b = temp;
		}
		int ans = 0, cur_pos = a;
		while (cur_pos != b)
		{
			int next_pos;
			for (int j = 20; j >= 0; j--)
			{
				if (j == 0 || reach[cur_pos][j] < b)
				{
					ans += power[j];
					next_pos = min(b, reach[cur_pos][j]);
					break;
				}
			}
			cur_pos = next_pos;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 200000
#define mod1 1000000007
#define mod2 1000000009
#define mod3 998244353
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
void Google(ll tt){
    cout<<"Case #"<<tt<<": ";
}

int main()
{
    IO
    clock_t begin = clock();
    ll n,p,ans=0;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        cin>>p;
        if(i%2==1 && p%2==1)
            ans++;
    }
    cout<<ans<<endl;
    // cout<<double(clock() - begin)/CLOCKS_PER_SEC<<endl;
    return 0;
}

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

int main() {
    ll n, m, x;
    cin >> n >> m >> x;

    vector<vector<ll>> a(n, vector<ll>(m));
    vector<ll> c(n);
    for (int i=0; i<n; i++) {
        cin >> c.at(i);
        for (int j=0; j<m; j++) {
            cin >> a.at(i).at(j);
        }
    } 

    ll iter=0, ans = 1000000000;

    while (iter < pow(2, n)) {
        iter++;
        bool failed = false;
        for (int i=0; i<m; i++) {
            ll itemind=0, skillpoint = 0;
            for (int j=1; j<pow(2, n); j = j*2) {
                if (j & iter) {
                    skillpoint += a.at(itemind).at(i);
                }
                itemind++;
            }
            if (skillpoint < x) {
                failed = true;
                break;
            }
        }
        if (!failed) {
            ll totc = 0, tmpiter = iter, itemind = 0;
            while (tmpiter > 0) {
                if (1 & tmpiter) totc += c.at(itemind);
                tmpiter /= 2;
                itemind++;
            } 
            if (ans > totc) ans = totc;
        }
    }

    if (ans != 1000000000) cout << ans << endl;
    else cout << -1 << endl;
}

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

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

    vector<int> vec(m * 2);
    for (int i = 0; i < m * 2; i++) cin >> vec.at(i);

    for (int i = 1; i <= n; i++) {
        int sum = 0;
        for (int j = 0; j < m * 2; j++) {
            if (vec.at(j) == i) sum++;
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

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

const double EPS = 1e-10;

double add(double a, double b){
    if(abs(a + b) < EPS * (abs(a) + abs(b)))return 0;
    return a + b;
}

struct Pt {
    double x, y;
    Pt(){}
    Pt(double x, double y):x(x), y(y){}
    Pt operator + (Pt p){return Pt(add(x, p.x), add(y, p.y));}
    Pt operator - (Pt p){return Pt(add(x, -p.x), add(y, -p.y));}
    Pt operator * (double d){return Pt(x * d, y * d);}
    double dot(Pt p){return add(x * p.x, y * p.y);}
    double det(Pt p){return add(x * p.y, -y * p.x);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
};
typedef Pt Vc;

struct Ln {
    Pt p1, p2;
    Ln(){}
    Ln(double x1, double y1, double x2, double y2):p1(Pt(x1, y1)), p2(Pt(x2, y2)){}
    Ln(Pt p1, Pt p2):p1(p1), p2(p2){}
    Pt project(Pt p){
        Pt base = p2 - p1;
        double r = base.dot(p - p1) / base.norm();
        return p1 + base * r;
    }
};

void CGL1A(){
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    Ln line(x1, y1, x2, y2);
    int n;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        double x, y;
        scanf("%lf %lf", &x, &y);
        Pt p = line.project(Pt(x, y));
        printf("%.10f %.10f\n", p.x, p.y);
    }
}

signed main(){
    
    CGL1A();
    
    return 0;
}


Measured memory_bytes: 3244
import math
import itertools

from functools import reduce

K = int(input())

def gcd(tempList):
    return reduce(math.gcd, tempList)

S = 0
tempDict = {}

for combination in itertools.combinations_with_replacement(range(1, K + 1), 3):
    if not combination[0] in tempDict:
        tempDict[combination[0]] = {}
    
    if not combination[1] in tempDict[combination[0]]:
        tempDict[combination[0]][combination[1]] = {}

    if not combination[2] in tempDict[combination[0]][combination[1]]:
        tempDict[combination[0]][combination[1]][combination[2]] = 0
        
    tempDict[combination[0]][combination[1]][combination[2]] = gcd(combination)


for n in itertools.product(range(1, K + 1), repeat=3):
    n = list(n)
    n.sort()
    
    S += tempDict[n[0]][n[1]][n[2]]

print(S)

Measured memory_bytes: 127808
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX (100005)
int N,A[MX];
bool ok(){
    sort(A,A+N);
    if(A[N-1]-*A>1)return 0;
    if(*A==A[N-1])return *A==N-1||2**A<=N;
    int U=0,V=0;
    F(N)U+=A[i]==*A;V=N-U;
    if(V==1)return 0;
    if(*A!=U){
        if(*A<U)return 0;
        return V/(*A-U+1)>1;
    }
    return 1;
}
int main(void){
    scanf("%d",&N),ga(N,A);
    puts(ok()?"Yes":"No");
    return 0;
}


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

void solve(){
	
}

int main(){
	fastio;
	int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int ans = a[0];
    for(int i=1;i<n;i++) ans ^= a[i];
    for(int i=0;i<n;i++){
        int b = ans^a[i];
        cout<<b<<" ";
    }
    cout<<endl;
	return 0;
}

Measured memory_bytes: 4328
N = int(input())
d = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, N+1):
    S = str(i)
    s = int(S[0])
    t = int(S[-1])
    d[s][t] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += d[i][j] * d[j][i]

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define MOD 998244353
using namespace std;
vector<int> v[100001];
bool vis[100001];
int dis[100001];
int n;
void dfs(int s)
{
    int curr=0;
    for(auto x:v[s])
    {
        if(dis[x]!=-1)
            curr=max(curr,1+dis[x]);
        else
        {
            dfs(x);
            curr=max(curr,1+dis[x]);
        }
    }
    dis[s]=curr;
}
int32_t main()
{
    int m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        --a,--b;
        v[a].pb(b);
    }
    for(int i=0;i<n;i++)
        dis[i]=-1;
    for(int i=0;i<n;i++)
    {
        if(dis[i]==-1)
            dfs(i);
    }
    int ans=0;
    for(int i=0;i<n;i++)
        ans=max(ans,dis[i]);
    cout<<ans;
}
    


Measured memory_bytes: 12568
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
 
int main() {
	int n, k, x;
	int i;
	int sum = 0;

	cin >> n >> k;

	for (i = 0; i < n; i++)
	{
		cin >> x;
		if (x < k - x)
		{
			sum += x * 2;
		}
		else
		{
			sum += (k - x) * 2;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 3632