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

using ll=long long;

const int MAX = 2200000;
const long long MOD = 1000000007;
long long INF = 90000000001000;


int main() {

    int n,m;cin >> n >> m;
    int e[10][10];
    for (int i = 0; i < 10; ++i)
    {
       for (int j = 0; j < 10; ++j)
       {
           e[i][j] = 0;
       }
    }
    for (int i = 0; i < m; ++i)
    {
        int a,b;cin >> a >> b;a--;b--;
        e[a][b] = e[b][a] = 1;
    }

    vector<int> p(n-1);
    for (int i = 0; i < n-1; ++i)
    {
       p[i] = i+1;
    }
    int cnt=0;
    do{
        
        int flag = 1;
        for (int i = 0; i < n-2; ++i)
        {
            if(i==0&&e[p[0]][0]!=1){flag = 0; break;}
            if(e[p[i+1]][p[i]]!=1){flag = 0; break;}
        }
        if(flag) cnt++;
    }while(next_permutation(p.begin(),p.end()));

    cout << cnt;

return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
typedef pair<int,int> P;
P score[100001],par[100001];
int main() {
	int n,m,h,k;
	while(scanf("%d %d %d %d",&n,&m,&h,&k),n) {
		vector<P> v;
		int p[1001],s[1001];
		for(int i=0;i<n;i++) {
			s[i]=i;
			scanf("%d",&p[i]);
		}
		for(int i=0;i<m;i++) {
			int a,b;scanf("%d %d",&a,&b);
			v.push_back(P(b,a-1));
		}
		sort(v.begin(),v.end());
		for(int i=0;i<m;i++) {
			int a,b,j=m-i-1;
			par[i].first=s[v[i].second];
			par[i].second=s[v[i].second+1];
			swap(s[v[i].second],s[v[i].second+1]);
			score[j].first=p[v[j].second];
			score[j].second=p[v[j].second+1];
			swap(p[v[j].second],p[v[j].second+1]);
		}
		int sum=accumulate(p,p+k,0);
		int ans=sum;
		for(int i=0;i<m;i++) {
			if(par[i].first<k&&par[i].second>=k) {
				ans=min(ans,sum-(score[i].second-score[i].first));
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 3504
K, N = [int(s) for s in input().split()]
A_list = [int(s) for s in input().split()]

d_list = []
for i, A in enumerate(A_list):
    if i == N - 1:
        d = K - A_list[i] + A_list[0]
    else:
        d = A_list[i + 1] - A_list[i]
    d_list.append(d)

d_sum_min = K - max(d_list)
print(d_sum_min)


Measured memory_bytes: 26444
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 998244353;
const int N = 1e6 + 5;

int i,n,power[15],mx;
string ans;

void solve()
{
    cin>>n;
    power[0]=1;
    for(i=1;i<=12;++i)
    {
        power[i]=power[i-1]*26;
    }
    int len=1;
    while(n>power[len])
    {
        n-=power[len];
        len++;
    }
    n--;
    vector<char> ans;
    for(i=0;i<len;++i)
    {
        ans.pb('a'+n%26);
        n/=26;
    }
    reverse(all(ans));
    for(auto i:ans)
        cout<<i;
}

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

Measured memory_bytes: 3652
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, K;
  std::cin >> N >> K;
  std::vector<i64> H;
  tools::read(H, N);

  if (K < N) {
    std::nth_element(H.begin(), H.begin() + (N - K - 1), H.end());
  }
  std::cout << std::accumulate(H.begin(), H.begin() + std::max<i64>(0, N - K), static_cast<i64>(0)) << std::endl;
  return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;


const int nmx = 110;
const int vmx = 1010;

int dp[3030][3030];
int path[3030][3030];

int main() {
    string s, t;
    cin >> s >> t;

    rep(i,s.size()) {
        rep(j,t.size()) {
            // 左上 1
            // 上 2
            // 左 3
            if (s[i]==t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
                path[i+1][j+1] = 1;
            }
            else {
                if (dp[i+1][j]>dp[i][j+1]) {
                    dp[i+1][j+1] = dp[i+1][j];
                    path[i+1][j+1] = 3;
                } 
                else {
                    dp[i+1][j+1] = dp[i][j+1];
                    path[i+1][j+1] = 2;
                }
            }
        }
    }
    string ans = "";
    
    //rep(i,s.size()+1) {
    //    rep(j,t.size()+1) {
    //        cout << path[i][j] << " ";
    //    }
    //    cout << endl;
    //}
    int i = s.size();
    int j = t.size();
    while (i > 0 && j > 0) {
        if (path[i][j]==1) {
            --i; --j;
            ans += s[i];
        } 
        else if (path[i][j]==2) --i;
        else if (path[i][j]==3) --j;
    }
    reverse(all(ans));
    cout << ans << endl;
    return 0;
}




















Measured memory_bytes: 71936
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] b = new int[n-1];
        for (int i = 0; i< n - 1; i++) {
            b[i] = scan.nextInt();
        }

        int ans = b[0];
        for (int i = 0; i < n-2; i++) {
            ans += Math.min(b[i], b[i+1]);
        }
        ans += b[n-2];
        System.out.println(ans);
    }

}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>

using namespace std;

vector<long> s,t;

long INF = 1e16+7;

int A,B,Q;
int main () {
    cin >> A >> B >> Q;
    for(int i=0;i<A;i++) {
        long x;
        cin>>x;
        s.push_back(x);
    }
    for(int i=0;i<B;i++) {
        long x;
        cin>>x;
        t.push_back(x);
    }
    s.push_back(-INF);s.push_back(INF);
    t.push_back(-INF);t.push_back(INF);
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    while(Q--) {
        long x;
        cin >> x;
        auto itr = lower_bound(s.begin(),s.end(),x);
        long rs = (*itr),ls = *prev(itr);
        itr = lower_bound(t.begin(),t.end(),x); // itr
        long rt = (*itr),lt = *prev(itr);
        long ans = min(max(rt,rs)-x,x-min(lt,ls));
        ans = min(ans,rt-ls+min(abs(rt-x),abs(ls-x)));
        ans = min(ans,rs-lt+min(abs(rs-x),abs(lt-x)));
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var a = Sarray().Sum();
            WriteLine(a < 22 ? "win" : "bust");
        }
    }
}


Measured memory_bytes: 18792
require 'prime'
M = 100000
ps = Hash[Prime.each(M).map{ |p| [p,1] }]
t = 0
ss = [0] + (1..M).map{ |i| t += i&1 > 0 && ps[i] && ps[(i+1)/2] ? 1 : 0 }
Q = gets.to_i
Q.times {
  l,r = gets.split.map(&:to_i)  
  p ss[r] - ss[l-1]
}

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

int A,B,C,X,Y;
int main(){
	cin >> A >> B >> C >> X >> Y;
	int m = 0;
	int ans = 1e9;
	while(m<=max(X,Y)){
		ans = min(ans,2*m*C+A*max((X-m),0)+B*max((Y-m),0));
		m++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
//const ll mod = 998244353;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
//ll a[MAX],b[MAX];
ld dp[305][305][305];

ld solve(ll a, ll b, ll c)
{
	if(a + b + c == 0)
		return 0;
	ld &ans = dp[a][b][c];
	if(ans >= 0)
		return ans;
	ans = 0;
	//bug(ans)
	ld tot = (ld)(a+b+c);
	ans = n/tot;
	if(a)
		ans += solve(a-1,b,c)*((ld)a/tot);
	if(b)
		ans += solve(a+1,b-1,c)*((ld)b/tot);
	if(c)
		ans += solve(a,b+1,c-1)*((ld)c/tot);
	return ans;
}

int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

cin >> n;
vll cnt(4,0);
mem(dp,-1);
fr(i,0,n)
{
	cin >> k;
	cnt[k]++;
}
//bug(cnt[3])
cout << setprecision(10) << fixed;
cout << solve(cnt[1],cnt[2],cnt[3]);

  
eNd();
	return 0;
 
}

Measured memory_bytes: 447208
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
 
using namespace std;
typedef long long ll;
 
int main(){
	string s;
	cin >> s;
for(ll i = 0; i<1e8; i++)
if(i == -1)
cout << "piyo" << endl;
	if(s.size()>=4 && s.substr(0,4) == "YAKI")
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,m,n) for(ll i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back





int main(){

    int x;
    cin>>x;

    cout<<abs(1-x)<<endl;








}

Measured memory_bytes: 3596
#include <cmath>
#include <iostream>
#include <string>

using namespace std;

int main(){
    int N, D, i, j, k, M=0;
    int x[20][10];
    double l;

    cin >> N >> D;

    for (i = 1; i <= N; i++) {
      for (j = 1; j <= D; j++) {
        cin >> x[i][j];
      }
    }

    for (i = 1; i <= N-1; i++) {
      for (j = i+1; j <= N; j++) {
        l = 0;
        for (k = 1; k <= D; k++) {
          l += pow(((x[i][k])-(x[j][k])), 2.0);
        }
        for (k = 1; k <= l; k++) {
          if(k*k == l){
            M++;
          }
        }
      }
    }

    cout << M;


    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    ll n;cin>>n;
    if(n==1){cout<<0<<endl;return 0;}
    ll l=1,m=1,k=1;
    rep(i,n){
        l*=8;
        l%=MOD;
        m*=9;
        m%=MOD;
        k*=10;
        k%=MOD;
    }
    k-=2*m;
    while(k<0)k+=MOD;
    k+=l;
    k%=MOD;
    cout<<k<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =1e18+7;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld i,j,ans,k,n,x,y,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
set <pair<lld,pll> > mark;
int main()
{
  lld a,b,c,ta,tb,tc;
        ts(a,b,c);
        mark.insert({a,{b,c}});
        lld cnt=0;
  while((a%2==0&&b%2==0&&c%2==0))
  {
    ta=(b+c)/2;tb=(a+c)/2;tc=(a+b)/2;
    if(mark.find({ta,{tb,tc}})!=mark.end())
    {
      cout<<-1<<endl;
      return 0;
    }
    cnt++;
    
    a=ta,b=tb,c=tc;
     mark.insert({a,{b,c}});
  }      
  cout<<cnt<<endl;
        return 0;
}

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 ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  int cnt = 0;
  rep(i,n-2){
    for(int j =i+1;j<n-1;++j){
      for(int k = j+1;k<n;++k){
          if(l[i]==l[j]) continue;
          if(l[j]==l[k]) continue;
          if(l[k]==l[i]) continue;
          if(l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[k]+l[i]>l[j]) cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3604
import sys

input = sys.stdin.readline
S = input().strip()
T = input().strip()

ans = float("inf")
ls = len(S)
lt = len(T)
for i in range(ls - lt + 1):
    tmp = 0
    for j in range(lt):
        if S[i+j] != T[j]:
            tmp += 1
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 9076
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();

    if (n % 2 == 0 && n > 1) {
      int nn = n / 2;
      if (s.substring(0, nn).equals(s.substring(nn, n))) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[5],k;
  for(int i=0;i<5;++i)cin>>a[i];
  cin>>k;
  for(int i=0;i<4;++i)for(int j=i+1;j<5;++j)if(abs(a[i]-a[j])>k){
    cout<<":(";
    return 0;
  }
  cout<<"Yay!";
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

const int mod = 1e9 + 7;

int main(){
  int N;
  scanf("%d", &N);
  
  int a[N][N];
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      scanf("%d", &a[i][j]);
    }
  }
  
  long long dp[1 << N];
  dp[0] = 1;
  for(int s = 1; s < (1 << N); s++){
    int i = __builtin_popcount(s);
    dp[s] = 0;
    for(int j = 0; j < N; j++){
      if((s & (1 << j)) && a[i - 1][j]){
        dp[s] += dp[s ^ (1 << j)];
        dp[s] %= mod;
      }
    }
  }
  
  printf("%lld\n", dp[(1 << N) - 1]);
  
  return 0;
}

Measured memory_bytes: 16512
#include <cmath>
#include <limits>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define MAXSIZE 1000000
#define MAXL 300
typedef long long int lli;

lli pow_lli(lli a, lli x){
    lli value = 1;
    for(lli i = 0; i < x; i++){
        value *= a;
    }
    return value;
}

int main(){
    lli n, p;
    cin >> n >> p;

    if(n == 1){
        cout << p << endl;
    }else{
        lli p_copy = p, ans = 1;
        lli nums[MAXSIZE] = {};
        
        lli sisu;
        for(lli i = 2; i < sqrt(p); i++){
            if(nums[i] == 0){
                sisu = 0;
                while(p_copy % i == 0){
                    p_copy /= i;
                    sisu++;
                }

                if(sisu > 0){
                    //cout << i << "^" << sisu << endl;
                    ans *= pow_lli(i, (sisu / n));
                    //cout << "ans = " << ans << endl;
                }

                for(lli j = i * i; j < sqrt(p); j += i){
                    if(nums[j] == 0){
                        nums[j] = -1;
                    }
                }
            }
        }

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

Measured memory_bytes: 8064
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h,ans;
    ll Q,K,P,C,N,X,A,B;
    ll pi = M_PI;
    long double H,M, kh,km;

    string S;
    map<long double, ll> m;
    vector<ll>  aa;
    
    cin>>N;
    bool zeroflag=false;
    bool bigflag=false;
    Q=-1;
    
    rep(i,N){
        cin >> h;
        aa.push_back(h);
        if(h==0) zeroflag=true;
        else if(h>1000000000000000000)bigflag=true;
        
    }
    if(zeroflag==true){
        cout <<0<<endl;
        return 0;
    }else if(bigflag==true){
        cout <<-1<<endl;
        return 0;
    }

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

    ans=1;
    rep(i,N){
        ans=ans*aa[i];
        if(aa[i]==0){
            cout<< 0<<endl;
            return 0;
        }
    if(ans>1000000000000000000){
            cout<< -1<<endl;
            return 0;
        
    }else if(log10(ans)+log10(aa[i+1]) >18 && i!=N-1){

        cout<< -1<<endl;
            return 0;
    }
    }
    cout <<setprecision(20)<<ans<<endl;
    
    return 0;
}

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

using namespace std;

int main(){

  //int i,m,M;
  //string S,T,U;
  double N;
  const double PI=3.14159265358979323846;
  //cin>>S>>T;
  
  cin>>N;
  //cin>>U;

  
  //  cout<<S<<endl;
  cout<<N*PI*2.0<<endl;
    return 0;
}


Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

int main() {
    vector<vector<int>> paper(10, vector<int>(10));
    while (true) {
        string str;
        getline(cin, str);
        if (str.empty())break;

        char c[10];
        for (int i = 0; i < str.size(); i++)c[i] = str[i];
        int x = stoi(strtok(c, ","));
        int y = stoi(strtok(NULL, ","));
        int s = stoi(strtok(NULL, ","));

        switch (s) {
            case 1: {
                for (int i = 0; i < 10; i++) {
                    for (int j = 0; j < 10; j++) {
                        if (abs(x - i) + abs(y - j) <= 1)paper[i][j]++;
                    }
                }
                break;
            }
            case 2: {
                for (int i = -1; i <= 1; i++) {
                    for (int j = -1; j <= 1; j++) {
                        int nx = x + i, ny = y + j;
                        if (0 <= nx && nx < 10 && 0 <= ny && ny < 10)paper[nx][ny]++;
                    }
                }
                break;
            }
            case 3: {
                for (int i = 0; i < 10; i++) {
                    for (int j = 0; j < 10; j++) {
                        if (abs(x - i) + abs(y - j) <= 2)paper[i][j]++;
                    }
                }
                break;
            }
        }
    }

    int zero = 0, strong = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            if (paper[i][j] == 0)zero++;
            strong = max(strong, paper[i][j]);
        }
    }
    cout << zero << endl << strong << endl;
    return 0;
}


Measured memory_bytes: 3028
x,y = map(int,input().split())
mod = 10**9 + 7

def getComb(a,b,mod):
  if b > a:
    return 0
  if a - b > b :
    b = a - b
  comb = 1
  for i in range(b+1,a+1):
    comb = (comb * i) % mod
  d = 1
  for i in range(1,a-b+1):
    d = (d * i) % mod
  comb *= pow(d,mod-2,mod)
  return comb % mod

if x > 2*y or y > 2*x:
  print(0)
  exit()
if (x+y)%3 != 0:
  print(0)
  exit()
times = (x+y)//3
tmp = abs(x-y)
xtimes = (times - tmp) //2
ans = getComb(times,xtimes,mod)
print(ans)

Measured memory_bytes: 3064
import math

if __name__ == '__main__':
    A, B, H, M = map(int, input().split())
    
    minute_passed = float(H) * 60.0 + float(M)
    l = (0.5 * (math.pi / 180.0) * minute_passed) % (2.0 * math.pi)
    s = (6.0 * (math.pi / 180.0) * minute_passed) % (2.0 * math.pi)
    deg = abs(s - l)
    print(format(math.sqrt(B ** 2.0 + A ** 2.0 - 2.0 * A * B * math.cos(deg)), '.20f'))

Measured memory_bytes: 9524
// AOJ 2263: The First Acceptance
// 2017.11.11 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#define TM 0
#if TM
#include <time.h>
#endif

#define QSIZE 1002

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

typedef struct { int key; } QUE;
QUE que[QSIZE+5];
int qsize;

void max_heapify(int i)
{
	int l, r, max;
	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].key > que[i].key) max = l;
	else max = i;
	if (r < qsize && que[r].key > que[max].key)	max = r;
	if (max != i) {
		QUE t = que[i]; que[i] = que[max], que[max] = t;
		max_heapify(max);
	}
}

int deq()
{
	if (qsize == 0) return 0;
//	*a = que[0].key;
	que[0] = que[--qsize];
	max_heapify(0);
	return 1;
}

void enq(int t)
{
	int i, max;
	i = qsize++;
	que[i].key = t;
	while (i > 0 && que[max = PARENT(i)].key < que[i].key) {
		QUE t = que[i]; que[i] = que[max], que[max] = t;
		i = max;
	}
}

typedef struct { int a, b; } T;
T tbl[1002];

int cmp(T *a, T *b) { return a->b - b->b; }

int main()
{
	int n, i, t, a, b, f, ans, sum;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d%d", &tbl[i].a, &tbl[i].b);
	qsort(tbl, n, sizeof(T), cmp);

	qsize = 0;
	for (ans = sum = 0, i = 0; i < n; i++) {
		a = tbl[i].a, b = tbl[i].b, f = 0;
		if (sum + a <= b) ans++, f = 1;
		else if (qsize > 0 && (t = que[0].key) > a) deq(), sum -= t, f = 1;
		if (f) sum += a, enq(a);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    int N;
    cin >> N;//入力値は100万までなのでintでおｋ
    long long total = 0;//10兆越え
    for(int i = 1; i <= N; i++){
        if(i % 3 == 0){
            continue;
        }else if(i % 5 == 0){
            continue;
        }else{
            total += i;
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 3640
const main = args => {
  const [n, y] = args.split(' ').map(arg => +arg);
  let ans = [-1, -1, -1];

  [...Array(n + 1)].forEach((_, i) => {
    let flg = false;
    [...Array(n + 1)].forEach((_, j) => {
      if (i + j > n) return;
      if (10000 * i + 5000 * j + 1000 * (n - (i + j)) === y) {
        ans = [i, j, n - (i + j)];
        return flg = true;
      }
    });
    if (flg) return;
  });

  console.log(ans.join(' '));
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 35288
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    int G; cin >> G; G /= 100;
    vi p(n); vi c(n);
    rep(i, n) cin >> p[i] >> c[i], c[i] /= 100;

    int res = inf;
    rep(k, bit(n)){
        int score = 0;
        int cnt = 0;

        rep(i, n){
            if((k >> i) & 1){
                score += p[i] * (i + 1) + c[i];
                cnt += p[i];
            }
        }
        rrep(i, n){
            if((k >> i) & 1) continue;
            rep(_, p[i]){
                if(score < G){
                    score += (i + 1);
                    cnt++;
                }
            }
        }

        chmin(res, cnt);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define fr first
#define sc second
using namespace std;
const int inf = 2e18 + 7;
const int mod = 1e9 + 7;
const int maxn = 3007;
signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  int ans = 0;
  if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') ans = 1;
  if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) ans = 2;
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') ans = 3;
  cout << ans;
}

Measured memory_bytes: 3604
x1, y1, x2, y2 = list(map(int, input().split()))
vector = (x2-x1, y2-y1)
x3, y3 = x2-vector[1], y2+vector[0]
x4, y4 = x1-vector[1], y1+vector[0]
print(x3, y3, x4, y4)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 100000000000000LL;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

struct point {
    ll next;
    ll cost;
};

int main() {
    ll N, K;

    cin >> N >> K;
    vector<point> points(N + 1);

    for (ll i = 1; i <= N; i++) {
        cin >> points[i].next;
    }

    for (ll i = 1; i <= N; i++) {
        cin >> points[i].cost;
    }

    map<ll, vector<ll>> unions;
    vector<pair<ll, ll>> isshu_costs;
    set<ll> done;

    for (ll i = 1; i <= N; i++) {
        if (done.count(i)) {
            continue;
        }

        ll cst = 0;
        point p = points[i];
        done.insert(i);
        while (true) {
            cst += points[p.next].cost;
            done.insert(p.next);
            unions[i].push_back(p.next);
            if (p.next == i) {
                break;
            }
            p = points[p.next];
        }
        isshu_costs.push_back(make_pair(i, cst));
    }

    ll max_result = -INF;
    for (auto ic : isshu_costs) {
        ll cost = ic.second;
        ll i = ic.first;
        ll size = unions[i].size();
        ll ic_result = 0;
        ll RK = -1;
        if (cost > 0) {
            if (K >= 2 * size) {
                ll shu = K / size - 1;
                ic_result += shu * cost;
                RK = K - shu * size;
            } else {
                RK = K;
            }
        } else {
            RK = size;
        }
        ll max_move = -INF;
        for (ll s : unions[i]) {
            ll total = 0;
            point pp = points[s];
            for (ll j = 0; j < RK; j++) {
                total += points[pp.next].cost;
                pp = points[pp.next];
                max_move = max(total, max_move);
            }
        }
        ic_result += max_move;
        max_result = max(max_result, ic_result);
    }
    print(max_result);
}


Measured memory_bytes: 4092
#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, q;
  string s;
  cin >> n >> s >> q;
  vector<set<int>> is(26);
  rep(i,n) is[s[i]-'a'].insert(i);
  rep(qi,q) {
    int ty;
    cin >> ty;
    if (ty == 1) {
      int i; char c;
      cin >> i >> c;
      --i;
      is[s[i]-'a'].erase(i);
      s[i] = c;
      is[s[i]-'a'].insert(i);
    } else {
      int l, r;
      cin >> l >> r;
      --l;
      int ans = 0;
      rep(i,26) {
        auto it = is[i].lower_bound(l);
        if (it != is[i].end() && *it < r) ++ans;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}

Measured memory_bytes: 26244
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		try (Scanner s = new Scanner(System.in)) {
			int n = 3;
			int[] array = new int[n];
			for (int i = 0; i < n; i++) {
				array[i] = s.nextInt();
			}
			Arrays.sort(array);
			System.out.println((array[0] == 5 && array[1] == 5 && array[2] == 7) ? "YES" : "NO");
		}
	}
}


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

#define ll long long

using namespace std;

int pmod(int x, int y, int p){ int res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1)  res = (res*x) % p;  y = y>>1; x = (x*x) % p; } return res; }  
ll pmod(ll x, ll y, ll p){ ll res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1)  res = (res*x) % p;  y = y>>1; x = (x*x) % p; } return res; } 


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

	int n;
	cin >> n;
	vector <int> a(n),b(n);
	for(auto &i : a)
		cin >> i;
	for(int i = 0; i < n; ++i){
		b[i] = a[i] + i;
		a[i] = a[i] - i;
	}

	unordered_map <int,int> seena, seenb;
	ll res = 0;
	for(int i = 0; i < n; ++i){
		res += seena[-b[i]];
		res += seenb[-a[i]];
		seena[a[i]]++;
		seenb[b[i]]++;
		cerr << res << " " << a[i] << " " << b[i] << endl;
	}
	cout << res;
	return 0;
}

// x2 + x1 = abs(i2 - i1)
// x2 + x1 = i2 - i1 -> x2 - i2 = -(x1 - i1)
// x1 + x2 = - i2 + i1 -> x2 + i2 = -(x1 + i1)
//

Measured memory_bytes: 36944
x, y, tx, ty = map(int, input().split())

# xy軸方向それぞれの距離
dx = abs(tx - x)
dy = abs(ty - y)

s = ''

# 1回目の往復は(x, y)から右にdx, 上にdy、(tx, ty)から左にdx, 下にdy移動する
s += 'R'*dx + 'U'*dy + 'L'*dx + 'D'*dy

# ２回目の往復は1回目とは別の座標を通るので最短で4座標遠回りする
# 行きは、１座標下に、(dx+1)右に、(dy+1)上に、1座標左に、
# 帰りは、1座標上に、(dx+1)左に、(dy+1)下に、1座標右に移動する
s += 'D' + 'R'*(dx+1) + 'U'*(dy+1) + 'L' + 'U' + 'L'*(dx+1) + 'D'*(dy+1) + 'R'

print(s)

Measured memory_bytes: 3060
let () = Scanf.scanf "%d\n" @@ fun n ->
  let ds = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  Printf.printf "%d\n" @@
  Array.fold_left (Array.fold_left ( + )) 0 @@
  Array.init n @@ fun i ->
    Array.init n @@ fun j ->
      if i <= j
      then 0
      else ds.(i) * ds.(j)



Measured memory_bytes: 2432
#include "bits/stdc++.h"
using namespace std;

////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define len(x) ((int)(x).size())
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1e9+7;
inline int mod (ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

////////////////////////// Solution starts below. //////////////////////////////

const int N = 2e5+20;

int h, w;
int n;
vector<pii> vec;
int fact[N], invFact[N];
pii qntWays[3010];

int powMod (int b, int p) {
	int ret = 1;
	while (p) {
		if (p&1) ret = mod (ret * 1LL * b);
		b = mod (b * 1LL * b);
		p >>= 1;
	}
	
	return ret;
}

int invMod (int b) {
	return powMod (b, MOD-2);
}

int binomial (int a, int b) {
	return mod (fact[a] * 1LL * mod (invFact[a - b] * 1LL * invFact[b]));
}

int ways (int a, int b) {
	return binomial (a+b-2, a-1);
}

int main () {
	scanf ("%d %d", &h, &w);
	
	fact[0] = 1;
	invFact[0] = 1;
	int mx = max (h, w);
	for (int i = 1; i <= 2*mx; i++) {
		fact[i] = mod (fact[i-1] * 1LL * i);
		invFact[i] = invMod (fact[i]);
	}
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		int r, c;
		scanf ("%d %d", &r, &c);
		vec.push_back ({r, c});
	}
	
	sort (vec.begin(), vec.end());
	for (int i = 0; i < n; i++) {
		pii p = vec[i];
		qntWays[i] = {ways (p.x, p.y), ways (h-p.x+1, w-p.y+1)};
	}
	
	
	int ans = ways (h, w);
	for (int i = 0; i < n; i++) {
// 		printf ("%d %d\n", p.x, p.y);
		for (int j = 0; j < i; j++)
			if (vec[j].y <= vec[i].y)
				qntWays[i].x = mod (qntWays[i].x - mod (ways (vec[i].x-vec[j].x+1, vec[i].y-vec[j].y+1) * 1LL * qntWays[j].x));
// 		printf ("%d: %d\n", i, qntWays[i].x);
		ans = mod (ans - mod (qntWays[i].x * 1LL * qntWays[i].y));
	}
	
	printf ("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1920
import math

h, w = map(int, input().split())
diff_2 = min(h, w)

if h % 3 == 0 or w % 3 == 0:
    print(0)
    exit()

elif h % 2 == 0 and w %2 == 0:
    if h >= w:
        side1 = int(w/2)
        diff = 1000000000000000
        for i in range(1, h):
            rect1 = side1 * i
            rect2 = w * (h - i)
            if diff > abs(rect1 - rect2):
                diff = abs(rect1 - rect2)
    else:
        side1 = int(h / 2)
        diff = 1000000000000000
        for i in range(1, w):
            rect1 = side1 * i
            rect2 = h * (w - i)
            if diff > abs(rect1 - rect2):
                diff = abs(rect1 - rect2)
    print(min(diff, diff_2))


elif h % 2 == 0 or w % 2 == 0:
    if h % 2 == 0:
        side1 = int(h/2)
        diff = 1000000000000000
        for i in range(1, w):
            rect1 = side1 * i
            rect2 = h * (w-i)
            if diff > abs(rect1 - rect2):
                diff = abs(rect1 - rect2)
                # print(i, diff)
        print(min(diff, diff_2))
    else:
        side1 = int(w / 2)
        diff = 1000000000000000
        for i in range(1, h):
            rect1 = side1 * i
            rect2 = w * (h-i)
            if diff > abs(rect1 - rect2):
                diff = abs(rect1 - rect2)
        print(min(diff, diff_2))
else:
    if h >= w:
        side1 = math.ceil(h/2)
        side2 = math.floor(h/2)
        diff = 1000000000000000
        for i in range(1, w):
            rect1 = side1 * i
            rect2 = side2 * i
            rect3 = (w-i) * h
            t = (max(rect1, rect2, rect3) - min(rect1, rect2, rect3))
            if diff > t:
                diff = t
        print(min(diff, diff_2))
    else:
        side1 = math.ceil(w/2)
        side2 = math.floor(w/2)
        diff = 1000000000000000
        for i in range(1, h):
            rect1 = side1 * i
            rect2 = side2 * i
            rect3 = (h-i) * w
            t = (max(rect1, rect2, rect3) - min(rect1, rect2, rect3))
            if diff > t:
                diff = t
        print(min(diff, diff_2))






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

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

int main(void) {
    int n, k, ans = 1;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> k;
    REP(i, n) {
        ans = min(ans * 2, ans + k);
    }

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

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

int main() {
	int a, b, k; cin >> a >> b >> k;
	int cnt = 1;
	vector<int> v;

	while (min(a, b) >= cnt) {
		if (a%cnt == 0 && b%cnt == 0) {
			v.push_back(cnt);
		}
		cnt++;
	}
	
	sort(v.begin(), v.end(), greater<int>());
	cout << v[k-1] << endl;

	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  auto f = [W] {
      for (int i = 0; i < W + 2; ++i) cout << '#';
      cout << endl;
    };
  f();
  for (int i = 0; i < H; ++i) {
    string s;
    cin >> s;
    cout << ("#" + s + "#") << endl;
  }
  f();
}


Measured memory_bytes: 256
from collections import deque


def inpl():
    return list(map(int, input().split()))


N, K = inpl()
AB = [inpl() for i in range(N - 1)]
path1 = [[] for i in range(N)]
for a, b in AB:
    a -= 1
    b -= 1
    path1[a].append(b)
    path1[b].append(a)

flag = [False for i in range(N)]
MOD = 10**9 + 7

ans = 1
que = deque()
que.append(0)
while que:
    i = que.popleft()
    if flag[i] is True:
        sumi = 1
    else:
        sumi = 0
        flag[i] = True

    for j in path1[i]:
        if flag[j] is True:
            sumi += 1
        else:
            que.append(j)
            flag[j] = True

    # print(sumi, i)
    for i in range(sumi, len(path1[i]) + 1):
        ans *= K - i
        ans %= MOD
    # print(ans)

print(ans % MOD)


Measured memory_bytes: 43620
#include <iostream>
using namespace std;
int n,a[51];
long long d=0;
int main(){
    cin >> n;
    for (int i=1;i<=n;i++)
    cin>>a[i];
    for (int i=1;i<=n;i++)
    for (int j=i+1;j<=n;j++) d+=a[i]*a[j];
    cout <<d;
    return 0;
}

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

void solve () {
    int a, b, c;
    int k;
    cin >> a >> b >> c;
    cin >> k;
    while (b <= a && k > 0) {
        b *= 2;
        k--;
    }
    while (c <= b && k > 0) {
        c *= 2;
        k--;
    }
    if (b > a && c > b) {
        cout << "Yes";
    } else {
        cout << "No";
    }

}

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


Measured memory_bytes: 3644
#include <stdio.h>
int main(){
    int a[3][3],i,j,b,n,c,d;
    for(i=0;i<3;i++){
        scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
    }
    scanf("%d",&n);
    for(b=0;b<n;b++){
        scanf("%d",&c);
        for(i=0;i<3;i++){
            for(j=0;j<3;j++){
                if(c==a[i][j]){
                    a[i][j]=0;
                }
            }
        }
    }
    d=0;
    for(i=0;i<3;i++){
        if(a[i][0]+a[i][1]+a[i][2] == 0){
            d=1;
        }else if(a[0][i]+a[1][i]+a[2][i] == 0){
            d=1;
        }
     }
    if(a[1][1]+a[2][2]+a[0][0] == 0){
        d=1;
    }else if(a[2][0]+a[1][1]+a[0][2] == 0){
        d=1;
    }
    
    if(d==1){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
struct dice{
  int up,s,e,w,n,dn;
  void to(char dir){
    if(dir=='N'){
      int tmp = n;
      n = up;
      up = s;
      s = dn;
      dn = tmp;
    }else if(dir=='S'){
      int tmp = s;
      s = up;
      up = n;
      n = dn;
      dn = tmp;
    }else if(dir=='E'){
      int tmp = e;
      e = up;
      up = w;
      w = dn;
      dn = tmp;
    }else if(dir=='W'){
      int tmp = w;
      w = up;
      up = e;
      e = dn;
      dn = tmp;
    }else if(dir=='R'){
      int tmp = e;
      e = n;
      n = w;
      w = s;
      s = tmp;
    }else if(dir=='L'){
      int tmp = e;
      e = s;
      s = w;
      w = n;
      n = tmp;
    }
  }
  void to(string dirs){
    REP(i,dirs.size()) to(dirs[i]);
  }
};
signed main(){
  int a[6];
  REP(i,6) cin >> a[i];
  dice di = {a[0],a[1],a[2],a[3],a[4],a[5]};
  int n;
  string s = "RRRRNRRRRSERRRRWSRRRRNWRRRRWRRRR";
  cin >> n;
  REP(i,n){
    int a,b;
    cin >> a >> b;
    REP(i,s.size()){
      di.to(s[i]);
      if(di.up==a&&di.s==b) {
        cout << di.e << endl;
        break;
      }
    }
  }
}



Measured memory_bytes: 3184
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define INF 1000000

int dp[41][401][401];
int main()
{
	int N, Ma, Mb;
	int min_v = INF;
	vector<int> a, b, c;

	cin >> N >> Ma >> Mb;
	REP(i, 0, N) {
		int aa, bb, cc;
		cin >> aa >> bb >> cc;
		a.push_back(aa);
		b.push_back(bb);
		c.push_back(cc);
	}
	REP(i, 0, 41) REP(j, 0, 401) REP(k, 0, 401) dp[i][j][k] = INF;
	
	dp[0][0][0] = 0;
	REP(i, 0, N) {
		REP(j, 0, 401) {
			REP(k, 0, 401) {
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
				if (j + a[i] < 401 && k + b[i] < 401) {
					dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
				}
			}
		}
	}

	REP(j, 1, 401) {
		REP(k, 1, 401) {
			if (dp[N][j][k] != INF && j*Mb == k*Ma) min_v = min(min_v, dp[N][j][k]);
		}
	}
	if (min_v == INF) cout << -1 << endl;
	else cout << min_v << endl;

    return 0;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main(){
    int A, B;
    cin >> A >> B;
 
    int p = 10 * B;
    while(p <= 10 * B + 9){
        int price = 0.08 * p;
        if (price == A){
            cout << p << endl;
            return 0;
        }else
        {
            p++;
        }
    }
 
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

vector<int> adj[100005];

int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> h(n);
    for(int i=0;i<n;i++)
        cin>>h[i];
    for(int i=0;i<m;i++)
    {
        int p,q;
        cin>>p>>q;
        if(find(adj[p].begin(),adj[p].end(),q)==adj[p].end())
            adj[p].push_back(q);
        if(find(adj[q].begin(),adj[q].end(),p)==adj[q].end())
            adj[q].push_back(p);
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(adj[i+1].size()==0)
            ans++;
        else
        {
            int r=h[i],z=0;
            for(int j=0;j<adj[i+1].size();j++)
            {
                if(h[adj[i+1][j]-1] >= r)
                {
                    z++;
                    break;
                }
            }
            if(z==0)
                ans++;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8808
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <fstream>
#include <cmath>

using namespace std;

int main(void){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int sum=0;
    for(int i=0;i<n;i++){
        if(i >= k){
            sum += y;
        }else{
            sum += x;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256