akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MAX_V 10001
#define f first
#define s second
#define mp make_pair
#define mod 1000000007
#define inf 1e8
using namespace std;

typedef long long ll;

int V,m;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
vector<pair<int,int> > vpp;
bool used[MAX_V]={};
int cmp[MAX_V];
ll dp[MAX_V];
vector<int> e[MAX_V];
 
void add_edge(int from, int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}
 
void dfs(int v){
  used[v] = true;
  for(int i = 0;i < G[v].size();i++){
    if(!used[G[v][i]])dfs(G[v][i]);
  }
  vs.push_back(v);
}
 
void rdfs(int v,int k){
  used[v] = true;
  cmp[v] = k;
  for(int i = 0;i < rG[v].size();i++){
    if(!used[rG[v][i]]) rdfs(rG[v][i],k);
  }
}
 
void scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v = 0;v < V;v++){
    if(!used[v]) dfs(v);
  }
  memset(used,0,sizeof(used));
  int k = 0;
  for(int i = vs.size() - 1;i >= 0;i--){
    if(!used[vs[i]])rdfs(vs[i],k++);
  }
  return;
}

ll rec(int v,int cm){
  ll res=1;
  int tmp=cmp[v];
  if(tmp==cm)return 1;
  if(dp[tmp]!=inf)return dp[tmp];
  //  if(rG[v].size()==0)return dp[tmp]=2;

  for(int i=0;i<e[tmp].size();i++){
    int now=e[tmp][i];
    for(int j=0;j<rG[now].size();j++){
      int next=rG[now][j];
      res*=rec(next,tmp);
      res%=mod;
    }
  }
  return dp[tmp]=res+1;
}

int main()
{
  int a,b,q;

  cin>>V>>m;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    a--;b--;
    add_edge(a,b);
  }
 
  scc();

  for(int i=0;i<V;i++){
    vpp.push_back(mp((-1)*cmp[i],i));
  }
  sort(vpp.begin(),vpp.end());

  for(int i=0;i<V;i++)vpp[i].f=(-1)*vpp[i].f;

  for(int i=0;i<vpp.size();i++)e[vpp[i].f].push_back(vpp[i].s);

  for(int i=0;i<V;i++)dp[i]=inf;
  ll ans=1;
  for(int i=0;i<vpp.size();i++){
    if(dp[vpp[i].f]==inf){
      ans*=rec(vpp[i].s,inf);
      ans%=mod;
    }
  }

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

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, M;
  cin >> N >> M;
  int ans = 1;
  REP(i, M) ans *= 2;
  ans *= 1900 * M + 100 * (N - M);
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main()
{
	int N,M;
	while(cin>>N>>M, N|M)
	{
		int t;
		set<int> s;
		for (int i = 0; i < N + M; i++)
		{
			cin>>t;
			s.insert(t);
		}

		int past = 0, m = 0;
		for (set<int>::iterator it = s.begin(); it != s.end(); ++it)
		{
			m = max(m, *it - past);
			past = *it;
		}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 1336
import sys
input = sys.stdin.readline


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    L = max(K, max(A), 1).bit_length()
    k = [0 for i in range(L)]
    i = 0
    while K:
        k[i] += K & 1
        i += 1
        K >>= 1
    b = [0 for i in range(L)]
    for a in A:
        i = 0
        x = a
        while x:
            b[i] += x & 1
            i += 1
            x >>= 1
    k = k[::-1]
    b = b[::-1]
    # dp[i][1]: 上位iビットがKと等しいときの最大値
    # dp[i][0]: 上位iビットがKより小さいときの最大値
    dp = [[-1, -1] for i in range(L+1)]
    dp[0][1] = 0
    for i in range(L):
        if dp[i][0] >= 0:
            dp[i+1][0] = (dp[i][0] << 1) + max(b[i], N-b[i])
        if dp[i][1] >= 0:
            if k[i] == 1:
                dp[i+1][0] = max(dp[i+1][0], (dp[i][1] << 1) + b[i])
                dp[i+1][1] = (dp[i][1] << 1) + (N-b[i])
            else:
                dp[i+1][1] = (dp[i][1] << 1) + (b[i])
    return max(dp[L][1], dp[L][0])


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 14620
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (auto& a : A) {
        cin >> a;
    }
    for (auto& b : B) {
        cin >> b;
    }
    vector<int> cnt(N + 1, 0);
    for (auto& a : A) {
        ++cnt[a];
    }
    for (auto& b : B) {
        ++cnt[b];
    }
    rep(i, 0, N) {
        if (cnt[i + 1] > N) {
            cout << "No" << endl;
            return 0;
        }
    }
    reverse(all(B));
    int same_val = 0;
    rep(i, 0, N) {
        if (A[i] == B[i]) {
            same_val = A[i];
            break;
        }
    }
    if (same_val) {
        vector<int> idx_buf;
        rep(i, 0, N) {
            if (B[i] != same_val && A[i] != same_val) {
                idx_buf.push_back(i);
            }
        }
        rep(i, 0, N) {
            if (A[i] == B[i]) {
                int target = idx_buf.back();
                idx_buf.pop_back();
                swap(B[i], B[target]);
            }
        }
    }
    cout << "Yes" << endl;
    rep(i, 0, N) {
        cout << B[i] << " \n"[i + 1 == N];
    }
    return 0;
}

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

using namespace std;

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

const int MOD = 1000000007;

vector<ll> fact;
vector<ll> rfact;

ll mm(ll a, ll b) {
    return (a * b) % MOD;
}

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

ll deg(ll a, ll d) {
    if (d < 0) {
        d += MOD - 1;
    }
    if (d == 0) {
        return 1;
    }
    ll ans = deg(a, d / 2);
    ans = mm(ans, ans);
    if (d % 2 == 1) {
        ans = mm(ans, a);
    }
    return ans;
}

ll C(int a, int b) {
    return mm(fact[a], mm(rfact[a - b], rfact[b]));
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

void prep() {
    int maxint = 2000000;
    fact.assign(maxint + 1, 1);
    rfact.assign(maxint + 1, 1);
    for (ll i = 1; i <= maxint; ++i) {
        fact[i] = mm(fact[i - 1], i);
    }
    rfact[maxint] = deg(fact[maxint], -1);
    for (ll i = maxint - 1; i >= 0; --i) {
        rfact[i] = mm(rfact[i + 1], i + 1);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    prep();
    
    int n;
    string s;
    cin >> n >> s;
    int m = s.size();
    
    ll ans = 0;
    ll deg25 = 1;
    ll r26 = deg(26, -1);
    ll deg26 = deg(26LL, n);
    for (ll i = m - 1; i < n + m; ++i) {
        ans = am(ans, mm(C(i, m - 1), mm(deg25, deg26)));
        //cout << C(i, m - 1) << " " << deg25 << " " << deg26 << "\n";
        deg25 = mm(deg25, 25LL);
        deg26 = mm(deg26, r26);
    }
    cout << ans << "\n";
    
    return 0;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}

#define INF (int)(1e9)

int f, c;
char grid[32][32];

int dx[] = {-1, 0, 1, 0}; // 4
int dy[] = {0, 1, 0, -1}; // 4

inline bool valid(int x, int y) {
    return x >= 0 && y >= 0 && x < f && y < c;
}

inline int bfs(int x, int y) {
    int ret = 0;
    vvi dist(f, vi(c, INF));
    dist[x][y] = 0;
    queue<ii> q;
    q.push({x, y});
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
        rep(k, 0, 4) {
            int tx = p.fi + dx[k];
            int ty = p.se + dy[k];
            if (valid(tx, ty) && grid[tx][ty] != '#' && dist[tx][ty] == INF) {
                dist[tx][ty] = 1 + dist[p.fi][p.se];
                q.push({tx, ty});
                ret = max(ret, dist[tx][ty]);
                //cerr << "tx -> " << tx << " ty -> " << ty << " ret -> " << ret << endl;
            }
        }
    }
    return ret;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    cin >> f >> c;

    rep(i, 0, f)
        cin >> grid[i];

    int ans = -1;
    rep(i, 0, f) {
        rep(j, 0, c) {
            if (grid[i][j] != '#') {
                int bf = bfs(i, j);
                //cerr << "bf(" << i << "," << j << ") -> " << bf << endl;
                ans = max(ans, bf);
            }
        }
    }
    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 256
n=input()
if n[-1]==str(3):
    print("bon")
elif n[-1]== str(0):
    print("pon")
elif n[-1]== str(1):
    print("pon")
elif n[-1]== str(6):
    print("pon")
elif n[-1]== str(8):
    print("pon")
else:
    print("hon")


Measured memory_bytes: 9108
#include <stdio.h>
int main()
{
    long long int n, k, i, count = 0, min, sumn, max;
    scanf("%lld %lld", &n, &k);
    sumn = n * (n + 1) / 2;
    for(i = k; i <= n + 1; i++)
    {
        min = i * (i - 1) / 2;
        max = sumn - (n - i) * (n - i + 1) / 2;
        count += (max - min + 1) % 1000000007;
        count = count % 1000000007;
    }
    printf("%lld", count);
    return 0;
}


Measured memory_bytes: 1676
# ALDS_1_4_A

n = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]

count = 0

for i in T:
    for j in S:
        if i == j:
            count += 1
            break

print(count)


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

int main()
{
    std::string s,t,u;
    int a,b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    
    if(s == u) a--;
    if(t == u) b--;
    cout << a << " " << b;
    /*
    int a[n];
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a[i] = tmp;
    }
    
    int ans = 0;
    cout << ans << endl; 
    */
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
using ll = long long;
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;
}
int main() {
    ll n;
    cin >> n;
    ll a[n], b[n];
    for (ll i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    ll ans = 0;
    if (n % 2 == 1) {
        ans = b[n / 2] - a[n / 2] + 1;
    }
    else{
        ll x = b[n / 2 - 1] + b[n / 2];
        ll y = a[n / 2 - 1] + a[n / 2];
        ans = x - y + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6760
#include <stdio.h>
#include <math.h>

int main(void) {
  int a, b;
  while(scanf("%d%d", &a, &b) != EOF) {
    int c = a + b;
    int d = (int)log10(c) + 1;
    printf("%d\n", d);
  }
  return 0;
}


Measured memory_bytes: 2820
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x); x=((x)*(x));n=n/2;}return result;}



int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ld a[n];
	rep(i,0,n) cin >> a[i];
	ld ans=0;
	rep(i,0,n){
		ans+=(ld)(1.0*(1/a[i]));
	}
	//trace1(ans);
	cout << fixed << setprecision(20) << 1.0*(1/ans);
	return 0;
}


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

int main(){
  vector<char> s(19);
  for(int i=0;i<19;i++){
    cin >> s.at(i);
  }
  
  s.at(5)=' ';
  s.at(13)=' ';
  for(int i=0;i<19;i++){
    cout << s.at(i) ;
  }
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k,c;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n;

	flag=true;

	f(i,0,n-1) {
        cin>>ara[i];
        if(ara[i] & 1) count++;

	}

	if(count){
        cout<<0<<endl;
	}
	else{
        c=0;
        while(flag==true)
        {
            f(i,0,n-1) {
               if(ara[i]%2==0) ara[i]>>=1;
               else{
                    flag=false;
                    break;
               }
            }
            c++;
        }
        cout<<c-1<<endl;
	}

}


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

int main (){
    int N , K, tmp, total=0;

    cin >> N;
    cin >> K;

    int x[N];

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

        if(abs(K - x[i]) < x[i]){
            tmp = abs(K - x[i]);
            tmp *= 2;

            total += tmp;
            tmp = 0;
        }
        else{
            tmp = x[i];
            tmp *= 2;

            total += tmp;
            tmp = 0;
        }
    }

    cout << total << endl;
}

Measured memory_bytes: 256
import math
import fractions
A,B,C,D = map(int,input().split())
def lcm(a,b):
    return (a*b)//fractions.gcd(a,b)
def solve(n,a,b):
    return n - (n//a + n//b - n//lcm(a,b))
print(solve(B,C,D)-solve(A-1,C,D))

Measured memory_bytes: 5340
#include <cstdio>

int A[100009];

int main(){
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    bool first = false;
    for (int i = 0; i < N; i++){
        if (A[i]%2==1) first = true;
    }
    if (first) printf("first");
    else printf("second");
}


Measured memory_bytes: 512
N, X = map(int, input().split())
A = list(map(int, input().split()))
B = A[:]

ans = sum(A)
for x in range(1, N + 1):
    for i in range(N)[::-1]:
        if B[i] > A[i - x]:
            B[i] = A[i - x]
    ans = min(ans, sum(B) + x * X)
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int ten(int tmp){
	if(tmp == 0) return 1;
	return 10*ten(tmp-1);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N,K;
	cin >> N >> K;
	int D[10];
	for(int i=0; i<K; i++) cin >> D[i];
	for(int i=N; i<100000; i++){
		string S = to_string(i);
		bool flg = true;
		for(int j=0; j<S.size(); j++){
			for(int k=0; k<K; k++){
				if(S[j] == D[k]+'0') flg = false;
			}
		}
		if(flg){
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
/*
    _____
  .'|||||'.
 /  >   <  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
    |||||
*/

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
#define CL(x,v); memset(x,v,sizeof(x));
#define INF 0x3f3f3f3f
#define LL long long
#define REP(i,r,n) for(int i=r;i<=n;i++)
#define RREP(i,n,r) for(int i=n;i>=r;i--)

int main()
{
    int r;
    scanf("%d",&r);
    printf("%d\n",3*r*r);
    return(0);
}


Measured memory_bytes: 256
from itertools import accumulate

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

if N == 2:
    if S == '#.':
        print(1)
    else:
        print(0)
    exit()

s = [1 if i == '#' else 0 for i in S]
a = list(accumulate(s))
b = list(reversed(list(accumulate(reversed(s)))))
answer = N
for i in range(1, N - 1):
    tmp = a[i] + N - i - 1 - b[i]
    if tmp < answer:
        answer = tmp

answer = min(answer, a[-1], N - a[-1])
print(answer)

Measured memory_bytes: 22504
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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


void oneCase () {
    vector<int> a(3);
    for (auto& el : a) {
        cin >> el;
    }
    sort(a.begin(), a.end());
    if (a[0] == a[2]) {
        cout << "No" << "\n";
        return;
    }
    if (a[0] == a[1] || a[1] == a[2]) {
        cout << "Yes" << "\n";
        return;
    }
    cout << "No" << "\n";


}




int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    char c;
    cin>>c;
    cout<<char(c+1)<<endl;
}

Measured memory_bytes: 256
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

int main (){
    ll int n; cin >> n;
    ll int ans=0;

    for(int i=1; i<=n; i++){
        if(n % i){
            ans += n / i;
        } else {
            ans += (n / i) -1;
        }
    }
    cout << ans;
}

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

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

    vector<ll> N(87);

    N[0] = 2LL;
    N[1] = 1LL;

    for(int i = 2; i < 87; i++) {
        N[i] = N[i - 1] + N[i - 2];
    }

    int n;
    cin >> n;
    cout << N[n] << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    while (n != 0) {
        n = (n - n%k) / k;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

long long L[90];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  L[0] = 2; L[1] = 1;
  for(int i=2; i<90; i++) L[i] = L[i-1] + L[i-2];
  int n;
  cin >> n;
  cout << L[n] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int K, N, m; cin >> K >> N;
  vector<int> A(N); for (auto &a : A) cin >> a;
  m = K - (A.back() - A[0]); for (int i{1}; i < N; ++i) m = max(m, A[i] - A[i - 1]);
  cout << K - m << endl;}

Measured memory_bytes: 4044
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,i,l,r;
	ll m,a[1234],ans;
	bool flag;
	while(true){
		cin >> n >> m;
		if(!(n&&m)){
			break;
		}
		flag = false;
		r = (n-1);
		ans = 0ll;
		for(i=0; i<n; ++i){
			cin >> a[i];
		}
		sort(a,a+n);
		for(l=0; l<n; ++l){
			while(r && a[l]+a[r]>m){
				--r;
			}
			if(a[l]+a[r]<=m && l!=r){
				flag = true;
				ans = max(ans,a[l]+a[r]);
			}
		}
		if(flag){
			cout << ans << endl;
		}else{
			cout << "NONE" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3004
# #バブルソート
# def BubbleSort(C,N):
#     for i in range (0,N,1):
#         for j in range(N-1,i-1,-1):
#             if int(C[j][1:2]) < int(C[j-1][1:2]):
#                 tmp = C[j]
#                 C[j] = C[j-1]
#                 C[j-1] = tmp
#     print(' '.join(C))

#バブルソート
def BubbleSort(C,N):
    flag = 1
    while flag:
        flag = 0
        for j in range(N-1,0,-1):
            if int(C[j][1:2]) < int(C[j-1][1:2]):
                tmp = C[j]
                C[j] = C[j-1]
                C[j-1] = tmp
                flag = 1
    print(' '.join(C))
    
    
                
                
#選択ソート
def SelectionSort(C,N):
    for i in range(0,N,1):
        minj = i
        for j in range(i,N,1):
            if int(C[j][1:2]) < int(C[minj][1:2]):
                minj = j
        tmp = C[i]
        C[i] = C[minj]
        C[minj] = tmp
    print(' '.join(C))
        
#安定かどうかの判定
def isStable(inp, out,N):
    for i in range(0,N):
        for j in range(i+1,N):
            for a in range(0,N):
                for b in range(a+1,N):
#                     print("inp(i,j):",inp[i],inp[j],"out(b,a):",out[b],out[a]+"\n")
                    if int(inp[i][1]) == int(inp[j][1]) and inp[i] == out[b] and inp[j] == out[a]:
                        print('Not stable')
                        return
    print('Stable')


#愚直に調べるパターン
N = int(input())
A = list(input().split())
Bubble_A = A.copy()
Selection_A = A.copy()

BubbleSort(Bubble_A,N)
isStable(A,Bubble_A,N)
SelectionSort(Selection_A,N)
isStable(A,Selection_A,N)


Measured memory_bytes: 5608
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=0x3f3f3f3f;
static const ll INFL=0x3f3f3f3f3f3f3f3f;




void mainmain(){

    int L;
    cin >> L;

    vll A(L);
    rep(i, L) cin >> A[i];

    vvll dp;
    initvv(dp, L+1, 5, INFL);
    dp[0][0] = A[0];
    dp[0][1] = (A[0] == 0 ? 2 : A[0] % 2);
    dp[0][2] = 1 - A[0] % 2;
    dp[0][3] = (A[0] == 0 ? 2 : A[0] % 2);
    dp[0][4] = A[0];

    reep(i, 1, L) {
        vll tmp(5);
        tmp[0] = A[i];
        tmp[1] = (A[i] == 0 ? 2 : A[i] % 2);
        tmp[2] = 1 - A[i] % 2;
        tmp[3] = (A[i] == 0 ? 2 : A[i] % 2);
        tmp[4] = A[i];
        dp[i][0] = dp[i-1][0] + tmp[0];
        dp[i][1] = min({dp[i-1][0], dp[i-1][1]}) + tmp[1];
        dp[i][2] = min({dp[i-1][0], dp[i-1][1], dp[i-1][2]}) + tmp[2];
        dp[i][3] = min({dp[i-1][0], dp[i-1][1], dp[i-1][2], dp[i-1][3]}) + tmp[3];
        dp[i][4] = min({dp[i-1][0], dp[i-1][1], dp[i-1][2], dp[i-1][3], dp[i-1][4]}) + tmp[4];
    }

    cout << min({dp[L-1][0], dp[L-1][1], dp[L-1][2], dp[L-1][3], dp[L-1][4]}) << endl;
}



}

int main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 16504
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,n) for(int (i)=a;(i)<(int)(n);(i)++)
#define rrep(i,a,n) for(int (i)=(n)-1;(i)>=a;(i)--)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

int main() {
	while (true) {
		int a,b;
		char c;

		cin >> a >> c >> b;

		if (c == '?') {
				return 0;
		}

		if (c == '+') {
				cout << a + b << endl;
		} else if (c == '-') {
				cout << a - b << endl;
		} else if (c == '*') {
				cout << a * b << endl;
		} else {
				cout << a / b << endl;
		}	
	}
}

Measured memory_bytes: 3096
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
double EPS = 1e-11;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

ll N, M;
ll S[2010], T[2010];
ll dp[2010][2010];
ll sum[2010][2010];
void solve(){
  cin >> N >> M;
  rep(i, N) cin >> S[i];
  rep(i, M) cin >> T[i];
  rep(i, N)rep(j, M){
    if(S[i] == T[j]){
      dp[i+1][j+1] = sum[i][j] + 1;
      dp[i+1][j+1] %= MOD;
    }
    sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] + MOD - sum[i][j] + dp[i+1][j+1];
    sum[i+1][j+1] %= MOD;
  }
  cout << (sum[N][M] + 1) % MOD << endl;
}

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


Measured memory_bytes: 63744
#include<iostream>
using namespace std;
int main()
{
    int sequence[100010];
    for(int i = 0; i <= 100005; i++){
        sequence[i] = 0;
    }
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int in;
        cin >> in;
        if(in <= 100000){
            sequence[in]++;
        }
    }
    int rest = 0;
    for(int i = 1; i <= 100000; i++){
        if(sequence[i] >= i){
            rest += i;
        }
    }
    int answer = n - rest;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve(){
    int n;
    cin>>n;
    int arr[n];int val[100001]={0};
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
        val[arr[i]]++;
    }
    int q;
    cin>>q;
    while(q--){
        int b,c;
        cin>>b>>c;
        int count=val[b];
        val[b]=0;
        val[c]+=count;
        sum+=(c-b)*count;
        cout<<sum<<"\n";
    }
}

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

Measured memory_bytes: 5212
#pragma region includes
#include <bits/stdc++.h>
#pragma endregion
#pragma region defines
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), V.end()
template <class T>
void CO(T value) {
  cout << value << endl;
}
#pragma endregion

int main() {
  int N, K, d, cnt = 0;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N) A[i] = 0;

  REP(i, K) {
    cin >> d;
    REP(j, d) {
      int B;
      cin >> B;
      A[B-1]++;
    }
  }
  REP(i, N) if(A[i] == 0) cnt++;

  CO(cnt);
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
	int N,i,T;
	char S[51];
 
      	scanf("%d%s",&N,S);

	T = 0;
	for(i=0;i<N;i++)
           if((S[i]=='A')&&(S[i+1]=='B')&&(S[i+2]=='C'))
               T++;

	printf("%d",T);

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

//#include<boost/circular_buffer.hpp>
using namespace std;

//cout << fixed << setprecision(10);
typedef long long ll;
#define PI 3.141592653589793
#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}
	long long int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

long long int lcm(long long int a, long long int b) {
	long long int L;
	L = a / gcd(a, b);
	L *= b;
	return L;
}

vector<long long  int> Prime;
void Eratosthenes(long long int n) {
	vector<bool> is_prime(n, true);
	is_prime.at(0) = false;
	is_prime.at(1) = false;
	for (long long int i = 2; i * i <= n; i++) {
		if (is_prime.at(i)) {
			for (int j = i * i; j < n; j += i) {
				is_prime.at(j) = false;
			}
		}
	}
	for (int i = 2; i < n; i++) {
		if (is_prime.at(i))
			Prime.emplace_back(i);
	}
}

/*
map<int, int> prime;
void Prime_number(long long int n) {
	for (int i = 2; i <= n; i++) {
		int count = 0;
		while (n % i == 0) {
			count++;
			n /= i;
		}
		if (count != 0) {
			prime.insert(make_pair(i, count));
		}
	}
}
*/
//std::cout.fill('0');

int keta(long long int N) {
	int k = 0;
	while (N > 0) {
		N /= 10;
		k++;
	}
	return k;
}

int Combination(int n, int m) {
	long long int s = 1, t = 1;
	int tmp = n;
	while (n - m != tmp) {
		s *= tmp;
		tmp--;
	}
	tmp = m;
	while (tmp != 1) {
		t *= tmp;
		tmp--;
	}
	return s / t;
}


int main() {
	long long int n;
	cin >> n;
	Eratosthenes(100005);
	for (int i = 0; i < Prime.size(); i++) {
		if (n <= Prime.at(i)) {
			cout << Prime.at(i) << endl;
			return 0;
		}
	}
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int N;
vector<int> G[100010];
int memo[2][100010];

int DP(int idx,int par,int col)
{
	if(memo[col][idx]!=-1)return memo[col][idx];
	int res=1;
	for(auto e:G[idx])
	{
		if(e==par)continue;
		if(col==0)
		{
			res*=DP(e,idx,1LL);
			res%=MOD;
		}
		else
		{
			res*=(DP(e,idx,0LL)+DP(e,idx,1LL));
			res%=MOD;
		}
	}

	memo[col][idx]=res;
	return memo[col][idx];
}

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

	cin>>N;
	int x,y;
	rep(i,0,2)rep(j,0,100010)memo[i][j]=-1;
	rep(i,0,N-1)
	{
		cin>>x>>y;
		x--,y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}

	cout<<(DP(0,-1,0)+DP(0,-1,1))%MOD<<endl;
	
	return 0;
}

Measured memory_bytes: 14208
import copy
n=int(input())
a=[int(input()) for i in range(n)]
a_copy=copy.deepcopy(a)
a_copy=sorted(a_copy)
max_num=a_copy[-1]
sec_num=a_copy[-2]
answer=[]
for j in range(len(a)):
  if a[j]==max_num:
    answer.append(sec_num)
  else:
    answer.append(max_num)
for k in range(len(answer)):
  print(answer[k])

Measured memory_bytes: 16156
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <vector>
using namespace std;
const int maxn = 1e5+5;
typedef long long ll;
int a[20][20], c[20], vis[20];
int n, m, x;
int d[20];

void dfs(int u, int &ans) {
    if (u==n+1) {
        memset(d, 0, sizeof(d));
        int sum = 0;
        for (int i=1; i<=n; i++) {
            if (vis[i]==1) {
                sum+=c[i];
                for (int j=1; j<=m; j++) {
                    d[j]+=a[i][j];
                }
            }
        }

        for (int j=1; j<=m; j++) {
            if (d[j] < x) {
                return;
            }
        }
        if (ans == -1) {
            ans = sum;
        } else {
            ans = min(ans, sum);
        }
        return;
    }

    vis[u]=0;
    dfs(u+1, ans);
    vis[u]=1;
    dfs(u+1, ans);
}

int main() {
    cin >> n >> m >> x;
    for (int i=1; i<=n; i++) {
        cin >> c[i];
        for (int j=1; j<=m; j++) {
            cin >> a[i][j];
        }
    }   

    int ans = -1;
    dfs(1, ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int num[100000];
int add[100000]={0};
int main(){
	int str;
	while(cin>>str){
		int ans=0x3f3f3f;
		
		for(int i=0;i<str;i++){
			cin>>num[i];
		}
		sort(num,num+str);
		for(int i=num[0];i<=num[str-1];i++){
			for(int j=0;j<str;j++){
				add[i]+=(num[j]-i)*(num[j]-i);
			}
			ans=min(add[i],ans);
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int N, M; cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  rep(i, M) cin >> s.at(i) >> c.at(i);
  vector<int> num(N,-1);
  bool ok = true;
  rep(i, M){
    if(num.at(s.at(i)-1)==-1) {
      num.at(s.at(i)-1) = c.at(i);
    } else if (num.at(s.at(i)-1) == c.at(i)){
      num.at(s.at(i)-1) = c.at(i);
    } else {
      ok = false;
      break;
    }
  }
  int ans = 0;
  if(N != 1 && num.at(0) == 0) ok = false;
  if(N != 1 && num.at(0) == -1) num.at(0) = 1;
  rep(i, N) if(num.at(i) == -1) num.at(i) = 0;
  if(ok){
    rep(i, N) ans += num.at(i) * pow(10, N-1-i);
  } else {
    ans = -1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3816
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to,cap,rev; 
	edge (int from, int to, int cap, int rev){
		this->from=from; this->to=to; this->cap=cap; this->rev=rev;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;


int w, h, n;
int x[110], y[110], a[110];

int main(){
	cin >> w >> h >> n;
	FORI(0, n) {
		cin >> x[i] >> y[i] >> a[i];
	}
	int lx = 0, rx = w;
	int ly = 0, ry = h;
	FORI(0, n) {
		if (a[i] == 1)
			lx = max(lx, x[i]);
		if (a[i] == 2)
			rx = min(rx, x[i]);
		if (a[i] == 3)
			ly = max(ly, y[i]);
		if (a[i] == 4)
			ry = min(ry, y[i]);
	}
	int X = max(rx - lx, 0);
	int Y = max(ry - ly, 0);
	cout << X*Y << endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int x,len,n,m;
char a[11];
char r[21];
int main()
{
	scanf("%s",a);
	len=strlen(a);
	scanf("%d",&x);
	for(int i=0;i<x;i++){
		scanf("%s",r);
		for(int j=0;j<10;j++){
			r[j+10]=r[j];
		}
		r[20]='\0';
		int k=0;
		for(int i=0;i<10;i++){
			for(k=0;k<len;k++){
				if(a[k]!=r[i+k]) break;
				if(k==len-1) {
					m++;
					goto e;
				}
			}
		}
		e: ;
	}
	printf("%d\n",m);
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
using namespace std;

int main(void){
    int X, Y, A, B, C, pbuf, qbuf, rbuf;
    vector<int> p, q, r;

    cin >> X >> Y >> A >> B >> C;
    for(int i=0; i<A; i++){
        cin >> pbuf;
        p.push_back(pbuf);
    }
    for(int i=0; i<B; i++){
        cin >> qbuf;
        q.push_back(qbuf);
    }
    for(int i=0; i<C; i++){
        cin >> rbuf;
        r.push_back(rbuf);
    }
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end());

    vector<int> pq;
    long long res = 0;
    copy(p.begin(), p.begin()+X, back_inserter(pq));
    copy(q.begin(), q.begin()+Y, back_inserter(pq));
    sort(pq.begin(), pq.end(), greater<int>());

    for(int i=0; i<X+Y; i++){
        if(i < X+Y-C-1){
            res += pq[i];
        }else{
            res += max(pq[i], r[i-X-Y+C]);
        }
    }
    
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2552
iN,iM = [int(_) for _ in input().split()]

if iM % iN == 0:
    print(iM // iN)
else:
    aRet = []
    for i in range(1,iM//iN + 1):
        if iM % i == 0:
            aRet.append(i)
    print(aRet[-1])


Measured memory_bytes: 41788
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

A,B=get_i
ans=0
A.upto(B) do|n|
    x=n.to_s.split("")
    xn=x.size
    flag=true
    (xn/2).times do|i|
      if x[i]!=x[xn-1-i]
          flag=false
          break
      end 
    end
    ans+=1 if flag
end
puts ans

Measured memory_bytes: 2044
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
#include<queue>
using namespace std;
int leng[200001],par[200001],cnt[200001];
int main(void)
{
	int n,m,a,b,x,y,mx,i;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)	{
		leng[i]=1;	par[i]=i;	cnt[i]=1;
	}
	for(i=0;i<m;i++)	{
		scanf("%d %d",&a,&b);
		while(a!=par[a]) a=par[a];
		while(b!=par[b]) b=par[b];
		if(a!=b)	{
			if(leng[a]>leng[b])	{
				par[b]=a;
				cnt[a]=cnt[a]+cnt[b];
			}
			else if(leng[b]>leng[a])	{
				par[a]=b;
				cnt[b]=cnt[a]+cnt[b];
			}
			else {
				par[a]=b;
				cnt[b]=cnt[b]+cnt[a];
				leng[b]++;
			}
		}
	}
	mx=-1;
	for(i=1;i<=n;i++)	mx=max(mx,cnt[i]);
	printf("%d\n",mx);	
	return 0;
}

Measured memory_bytes: 4072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long M = GetLong();
		long V = GetLong();
		long P = GetLong();
		long[] A = GetLongs((int)N);
		Array.Sort(A);
		Array.Reverse(A);

		long ng = N;
		long ok = P - 1;
		while(Abs(ok - ng) > 1)
		{
			long mid = (ng + ok) / 2;
			if(A[mid] + M < A[P - 1])
			{
				ng = mid;
				continue;
			}
			
			long sum = (P - 1 + N - mid) * M;
			for(long i = P - 1; i < mid; i++)
				sum += Max(0, A[mid] + M - A[i]);

			if(sum >= M * V)
				ok = mid;
			else
				ng = mid;
		}
		WriteLine(ok + 1);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

int main()
{
    const int MAGIC = 20;
    int n, m, c;
    int a[MAGIC][MAGIC];
    int b[MAGIC];
    int i, j;
    int count = 0;
    int eq;
    cin >> n >> m >> c;
    for (i = 0; i < m; i++)
    {
        cin >> b[i];
    }
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    count = 0;
    for (i = 0; i < n; i++)
    {
        eq = c;
        for (j = 0; j < m; j++)
        {
            eq += a[i][j] * b[j];
        }
        if (eq > 0)
        {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256