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

int main() {
    int A1, A2, A3, minimum, maximum;
    cin >> A1 >> A2 >> A3;
    // 最小値を求める
    minimum = min(min(A1, A2), A3);
    maximum = max(max(A1, A2), A3);
    cout << maximum - minimum << endl;
    return 0;
}

Measured memory_bytes: 256
s=input().rstrip()
x=list(s)
G=0;
t=list(set(x))
for i in range(0,len(t)):
    if x.count(t[i])%2==0:
        continue;
    else:
        G=1;
        break;
if G==1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define bg begin()
#define en end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll gcd(ll a,ll b){
    if(a==0)
    return b;
    else
    return gcd(b%a,a);
}
ll sod(ll x){
    ll r,sum=0;
    while(x>0){
        r=x%10;
        x/=10;
        sum+=r;
    }
    return sum;
}
using namespace std;
int main()
{
    ll n,c=0,d=0;
    cin>>n;
    ll i;
    char a[n+1];
    scanf("%s",a);
    for(i=0;i<n;i++){
        if(a[i]=='R')
        c++;
    }
    for(i=0;i<c;i++){
        if(a[i]=='W')
        d++;
    }
    cout<<d;
}

Measured memory_bytes: 3880
#include<stdio.h>

int main(void){
	int ans[50],temp;
	int a,b,w,n;

	scanf("%d\n%d",&w,&n);
	
	for(int i=1;i<=w;i++){
		ans[i]=i;
	}
	for(int i=1;i<=n;i++){
		scanf("%d,%d",&a,&b);
		temp=ans[a];
		ans[a]=ans[b];
		ans[b]=temp;
	}
	for(int i=1;i<=w;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val h = (0 until n).map { sc.next().toInt() }
    println(edpcB(n, k, h))
}

fun edpcB(n: Int, k: Int, h: List<Int>): Int {
    val dp = (0 until n).map { Integer.MAX_VALUE }.toMutableList()
    dp[0] = 0
    for (i in 1 until n) {
        for (j in 1..k) {
            if (i - j >= 0) {
                dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i] - h[i - j]))
            }
        }
    }
    return dp[n - 1]
}

Measured memory_bytes: 87312
#include<iostream>
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
typedef long long int ll;


int main()
 {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
   fast;
  
     int n;cin>>n;
     int a=n%10;
     if(a==2||a==4||a==5||a==7||a==9)     cout<<"hon"<<endl;
     else if(a==0||a==1||a==6||a==8)      cout<<"pon"<<endl;
     else   cout<<"bon"<<endl;
  




	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 1001
#define MAX_H 10010
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll h, n, dp[MAX_H], a[MAX_N], b[MAX_N];

signed main(){
    cin >> h >> n;
    for(ll i=1; i<=n; i++) cin >> a[i] >> b[i];

    REP(j, MAX_H){
        if(j == 0) dp[j] = 0;
        else dp[j] = INF;
    }
    // REP(j, MAX_H) cout << dp[j] << " ";
    // cout << endl;
    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=MAX_H; j++){
            dp[j] = min(dp[j], dp[max(0LL, j-a[i])] + b[i]);
        }
    }
    // REP(j, h+1) cout << dp[j] << " ";
    // cout << endl;
    cout << dp[h] << endl;
    return 0;
}

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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    
    int ans=0;
    for(int i=1; i<N; i++){//左右の区切り位置
        int cnt=0;
        
        for(char c='a'; c<='z'; c++){
            bool right=false, left=false;
            
            for (int j=0; j<i; j++){
                if(S[j]==c) right=true;
            }
            
            for (int j=i; j<N; j++){
                if(S[j]==c) left=true;
            }
            if(right && left) cnt++;
        }
        ans=max(ans,cnt);
    }
    cout << ans << endl;
}

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

using namespace std;
long gcd(long a,long b){
  if(b==0)return a;
  else gcd(b,a%b);
}
long lcm(long a,long b){
  return a/gcd(a,b)*b;
}
int main(void){
  int N;
  cin>>N;
  vector<long>T(N);
  for(int i=0;i<N;i++)cin>>T[i];
  long ans=T[0];
  for(int i=1;i<N;i++)ans=lcm(ans,T[i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
mint dp[2001][2001];
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, k; cin >> n >> k;
   if (k==1){
      cout << 1 << endl;
      return 0;
   }
   combination C(n*k);
   dp[0][1] = 1;
   rep(j,n-1)dp[0][j+2] = dp[0][j+1] * C((j+2)*(k-1)-1, k-2);
   for (int i = 1; i <= n; i++)
      for (int j = i; j <= n; j++)
         dp[i][j] = dp[i-1][j] + dp[i][j-1]*C(i+j*(k-1)-1, k-2);
   cout << dp[n][n]*C.fact[n] << endl;
}

Measured memory_bytes: 96872
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cmath>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> p;
typedef vector<p> vp;
const int INF=1e9;
bool prime[1000005];
vi tmp;
ll n;

int main(int argc,char const* argv[])
{
  cin >> n;
  vi ans;
  if(n==0)
    {
      cout << 0 << endl;
      return 0;
    }
  if(n==1)
    {
      cout << 1 << endl;
      return 0;
    }
  while(n!=0)
    {
      if(n%2!=0)
	{
	  ans.push_back(1);
	  n--;
	}
      else
	{
	  ans.push_back(0);
	}
      n/=-2;
    }
  reverse(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++)
    {
      cout << ans[i];
    }
  cout << endl;
  return 0;
}


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

using namespace std;
int main(){
int A,B;
cin>>A>>B;
  if(A==B){
    cout<<A+B;
  }
else if(A>B){
    cout<<2*A-1;
}
else{
    cout<<2*B-1;
}
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;


int main()
{
    ll x,y;
    scanf("%lld %lld",&x,&y);

    for(int i=1;x<=y;i++)
    {
        x *= 2;
        if(x>y)
        {
            printf("%d\n",i);
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    string str;
    cin >> str;
    if (str == "AAA" | str == "BBB")
    {
        printf("No");
    }
    else
    {
        printf("Yes");
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


int main()
{
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0) {
			return 0;
		} else {
			ll ans = n*n + m*m;
			ll ansa = 1000, ansb = 1000, ansans = 10000000;
			FOR(i, 1, 150)
			{
				FOR(j, i + 1, 150)
				{
					ll temp = i*i + j*j;
					if (ans > temp || (ans == temp && i <= n)) continue;
					if (temp < ansans || (temp == ansans && i < ansa)) {
						ansa = i;
						ansb = j;
						ansans = temp;
					}
				}
			}
			cout << ansa << " " << ansb << endl;
		}
	}
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;

ll C[55][55];


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	for(int n = 0 ; n <= 54 ; ++n){
		C[n][0] = C[n][n] = 1;
		for(int k = 1 ; k < n ; ++k)
			C[n][k] = C[n-1][k-1] + C[n-1][k];
	}
	int n , p;
	cin >> n >> p;
	
	vi v(n);
	int e = 0 , o = 0;
	rep(i , n){
		cin >> v[i];
		if(v[i] & 1){
			++o;
		}else{
			++e;
		}
	}
	
	ll dp[n + 1][2];
//	dp[0][0] = 1;
//	dp[0][1] = 0;
	
	dp[1][0] = v[0] % 2 == 0;
	dp[1][1] = v[0] % 2 == 1;
	
	repi(i , n){
		if(i == n)break;
		
		dp[i + 1][0] = v[i] % 2 == 0;
		dp[i + 1][1] = v[i] % 2 == 1;
		
		dp[i + 1][0] += dp[i][0];
		dp[i + 1][1] += dp[i][1];
		
		if(v[i] & 1){
			dp[i + 1][0] += dp[i][1];
			dp[i + 1][1] += dp[i][0];
		}else{
			dp[i + 1][0] += dp[i][0];
			dp[i + 1][1] += dp[i][1];
		}
	}


	cout << dp[n][p] + (p == 0);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
#define MOD 1000000007
using namespace std;

typedef long long ll;

bool hurui[1001];
ll prime_count[1001];

int main() {
    ll N, count = 1LL;
    vector<ll> prime_num;
    cin >> N;
    for (int i = 2; i < 1001; i++) hurui[i] = true;
    hurui[0] = hurui[1] = false;
    int i, j;
    for (i = 2; i < 1001; i++) {
        if (hurui[i]) {
            prime_num.push_back(i);
            j = i;
            while (j < 1001) {
                j += i;
                hurui[j] = false;
            }
        }
    }
    for (i = 1; i <= N; i++) prime_count[i] = 1LL;
    for (i = 1; i <= N; i++) {
        ll sub_num = i;
        for (j = 0; j < prime_num.size(); j++) {
            ll div_num = prime_num[j];
            while (sub_num % div_num == 0) {
                prime_count[prime_num[j]]++;
                div_num *= prime_num[j];
            }
        }
    }
    for (i = 1; i <= N; i++) {
        count = ((count % MOD) * (prime_count[i] % MOD)) % MOD;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define INF (ll)1e18+9
#define N 2000006

using namespace std;

string s;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    if (s.length() < 4) cout << "No" << endl;
    else if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') cout << "Yes" << endl;
    else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    int n;
    cin >> n;
    vector<int> l(n);

    rep(i,n)cin >> l[i];
    ssort(l);
    int count=0;
    rep(i,n-2){
        FOR(j,n-1,i+1){
            FOR(k,n,j+1){
                if(l[i]<l[j]+l[k]&&l[j]<l[i]+l[k]&&l[k]<l[i]+l[j]){
                    count++;
                }else{
                    break;
                }
            }
        }
    }
    cout << count << endl;
}

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

class Program
{
    static void Main()
    {
        var num = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToArray();
        if (num[0] == 1)
        {
            Console.WriteLine("0");
        }
        else
            Console.WriteLine("1");

    }
}

Measured memory_bytes: 19044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  vector<int> dp(N + 1, N);
  dp[0] = 0;
  for (int i = 0; i <= N; i++) {
    dp[i] = min(dp[i], dp[i - 1] + 1);
    for (int pow6 = 6; pow6 <= min(N, i); pow6 *= 6)
      dp[i] = min(dp[i], dp[i - pow6] + 1);
    for (int pow9 = 9; pow9 <= min(N, i); pow9 *= 9)
      dp[i] = min(dp[i], dp[i - pow9] + 1);
  }

  cout << dp[N] << endl;
}


Measured memory_bytes: 3572
// E - Bomber
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int h, w, m;
	cin >> h >> w >> m;
	set<pair<int, int>> s;
	vector<pair<int, int>> r(h), c(w);
	for (int i = 0; i < h; i++) r[i].second = i;
	for (int i = 0; i < w; i++) c[i].second = i;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		s.insert({x, y});
		r[x].first++; c[y].first++;
	}

	sort(r.begin(), r.end(), greater<pair<int, int>>());
	sort(c.begin(), c.end(), greater<pair<int, int>>());

	int ans = 0;
	bool found = true;
	for (int i = 0; i < r.size(); i++) {
		if (i > 0 && r[0].first - r[i].first > 0) break;
		for (int j = 0; j < c.size(); j++) {
			if (j > 0 && c[0].first - c[j].first > 0) break;
			int n = r[i].first + c[j].first;
			if (s.count({r[i].second, c[j].second}))
				n--;
			else
				found = false;
			ans = max(ans, n);
			if (!found) break;
		}
		if (!found) break;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 21912
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

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

    vector <int> a(26), b(26);

    for(int i = 0; i < S.length(); i++){
        a[S[i] - 'a'] += 1;
        b[T[i] - 'a'] += 1;
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    
    bool flag = true;
    for(int i = 0; i < 26; i++){
        if(a[i] != b[i]){
            flag = false;
        }
    }
    
    if (flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 776
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

int main() {
   int a;
   cin>>a;
   vector<int> vec(a);
   rep(i,a){
      cin>>vec.at(i);
   }
   int sum=0;
   rep(i,a-1){
      for(int j=i+1;j<a;j++){
         sum+=vec.at(i)*vec.at(j);
      }
   }
   cout<<sum<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;
int a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    ll x , k , d; cin >> x >> k >> d;
    x = abs(x);
    ll step = x / d;
    if (step >= k){
        cout << x - k * d << endl;
    }
    else {
        if (step % 2 == 0){
            if (k % 2 == 0){
                cout << x % d << endl;
            }
            else {
                cout << d - x % d << endl;
            }
        }
        else {
            if (k % 2 != 0){
                cout << x % d << endl;
            }
            else {
                cout << d - x % d << endl;
            }
        }
    }
    return 0;
}

/*
1000000000000000 1000000000000001 1000000000000000
*/


Measured memory_bytes: 3656
#include <bits/stdc++.h>
// O - Matching

#define MOD 1000000007

using namespace std;

bool a[22][22];
int dp[22][2097155];

int main() {
    int N,i,j,k;

    scanf("%d",&N);

    for (i = 1;i <= N;i++)
        for (j = 0;j < N;j++)
            scanf("%d",&a[i][j]);

    dp[0][0] = 1;
    for (i = 1;i <= N;i++) {
        for (k = 0;k < N;k++) {
            if (a[i][k]) {
                for (j = 0;j < (1 << N);j++) {
                    if (j & (1 << k)) {
                        dp[i][j] += dp[i - 1][j ^ (1 << k)];
                        dp[i][j] %= MOD;
                    }
                }
            }
        }
    }

    printf("%d\n",dp[N][(1 << N) - 1]);

    return 0;
}


Measured memory_bytes: 172288
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeSet;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		TreeSet<Integer> map = new TreeSet<Integer>(Collections.reverseOrder());
		int[] dp = new int[100001];
		Arrays.fill(dp, Integer.MAX_VALUE/2);
		dp[0] = 0;
		/* 1円について */ map.add(1);
		for(int i = 1; i < dp.length; i++) dp[i] = i;
		/* 6円について */ for(int i = 6; i < dp.length; i *= 6) map.add(i);
		/* 9円について */ for(int i = 9; i < dp.length; i *= 9) map.add(i);
		for(int d : map) {
			dp[d] = 1;
			for(int i = 0; i + d < dp.length; i++) dp[i + d] = Math.min(dp[i] + 1, dp[i + d]);
		}
		System.out.println(dp[N]);
	}
}

Measured memory_bytes: 22356
using System.Linq;
using System.Collections.Generic;
using System;

public class Recipe
{
    public string product { get; set; }
    public List<string> material { get; set; }
}
public class hello
{
    public static void Main()
    {
        while (true)
        {
            var dict = new Dictionary<string, int>();
            var recipes = new List<Recipe>();
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                dict[line[0]] = int.Parse(line[1]);
            }
            var m = int.Parse(Console.ReadLine().Trim());
            for (int i = 0; i < m; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                var k = int.Parse(line2[1]);
                var a = new Recipe();
                a.product = line2[0];
                a.material = new List<string>();
                for (int j = 0; j < k; j++)
                    a.material.Add(line2[j + 2]);
                recipes.Add(a);
            }
            var target = Console.ReadLine().Trim();
            var ans = Getprice(dict,recipes, target);
            Console.WriteLine(ans);
        }
    }
    public static int Getprice (Dictionary<string,int> d,List<Recipe> r,string t)
    {
        var a = r.Where(x => x.product == t).Count();
        if (a ==1)
        {
            var aa = r.Where(x => x.product == t).First();
            var ptotal = 0;
            foreach (var x in aa.material)
                ptotal += Getprice(d, r, x);
            return Math.Min(ptotal, d[t]);
        }
        return d[t];
    }
}

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

int main() {
  int n;
  string s;
  cin>>n>>s;
  bool ans=true;
  if(n%2==0){
    for(int i=0;i<n/2;i++){
      if(s[i]!=s[(s.size())/2+i])ans=false;
    }
  }
    else ans=false;
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }

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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int a; cin >> a;
	cout << a + (a * a) + (a * a * a) << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  string X;
  cin >> X;
  ll length = X.size();
  ll p_s = 0,p_t = 0;
  ll minus = 0;
  while (p_s < length && p_t < length) 
    {
      if (X[p_s] == 'S') 
	{
	  if (p_s > p_t)
	    p_t = p_s + 1;
	  while (p_t < length)
	    {
	      if (X[p_t] == 'T') 
		{
		  minus += 2;
		  X[p_t] = 'o';
		  break;
		}
	      p_t++;
	    }
	}
      p_s++;
    }
  cout << length - minus << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int a;
  int b;
  int c;
  int count;
  cin >> n;


  for (int i = 1; i <= n;i++){
    count = 0;

    if(i > 3){
      a = 1;
      b = 1;
      c = 1;
      int p = 0;
      for (int n = 1; n < 100; n++)
      {
        p = 0;
        for (int l = 1; l < 100; l++)
        {
          p = 0;
          for (int m = 1; m < 100; m++)
          {

            p = (n * n) + (l * l) + (m * m) + (n * l) + (l * m) + (m * n);
            if (p == i)
            {
              count++;
            }
            else if (p > i)
            {
              if(m == 1){
                p = -1;
              }
              break;
            }
          }
          if(p == -1){
              if(l == 1){
                p = -2;
              }
              break;
          }
        }
        if(p == -2){
          break;
        }
      }
    }

    cout << count << std::endl;
  }

  
  return 0;

}

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

using namespace std;

using ll = long long;

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define INF 100000000000ULL

void solve() {
    size_t n, k;
    cin >> n >> k;
    vector<vector<size_t>> a(64);
    REP(i, 64) {
        a.at(i).resize(n);
    }
    REP(i, n) {
        a.at(0).at(i) = i;
        cin >> a.at(1).at(i);
        a.at(1).at(i)--;
    }
    REP1(i, 62) {
        REP(j, n) {
            auto idx = a.at(i).at(j);
            a.at(i + 1).at(j) = a.at(i).at(idx);
        }
    }
    //REP(i, 5) {
    //    REP(j, n) {
    //        cout << a.at(i).at(j) << " ";
    //    }
    //    cout << endl;
    //}
    //cout << endl;
    bitset<64> bit(k);
    size_t dst = 0;
    REP(i, 63) {
        if (bit[i])
            dst = a.at(i + 1).at(dst);
    }
    cout << dst + 1 << endl;
}

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

    solve();

    return 0;
}

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

int main(int argc, char const *argv[])
{
//    freopen("in.txt", "r", stdin);
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    c -= (a - b);
    cout << max(0, c) <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

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

    vector<long long> dp(n, 0);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for (int i = 2; i < n; i++) {
        int d1 = abs(h[i] - h[i - 1]);
        int d2 = abs(h[i] - h[i - 2]);
        dp[i] = min(dp[i - 2] + d2, dp[i - 1] + d1);
    }

    cout << dp[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  int A[N];
  REP(i,N)cin>>A[i];
  cout<<1+(N-2)/(K-1)<<endl;
  return 0;
}


Measured memory_bytes: 640
N = int(input())
d = list(map(int, input().split()))

d = sorted(d)

former = d[:eval(str(int(len(d) / 2)))]
latter = d[eval(str(int(len(d) / 2))):]

if former[-1] == latter[0]:
  print(0)
else:
  print(latter[0] - former[-1])


Measured memory_bytes: 14428
#include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;

int main()
{
	int H,W;
	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		
		for(int i = 0;i < H;i++){
			for(int j = 0;j < W;j++){
				if(i % 2 == 0 && j % 2 == 0) cout << "#";
				if(i % 2 == 0 && j % 2 == 1) cout << ".";
				if(i % 2 == 1 && j % 2 == 0) cout << ".";
				if(i % 2 == 1 && j % 2 == 1) cout << "#";
			}
			cout << endl;
		}
		cout << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  ll ans = 0;
  if(n > k) {
    rep(i, n-k) ans+= h[i];
  }
  cout << ans << endl;
  return 0;
}

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

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

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

Measured memory_bytes: 256
import numpy as np

N, M = map(int, input().split())

ks_list = []
for i in range(M):
    ks = list(map(int, input().split()))
    ks_list.append(ks)
    
p = list(map(int, input().split()))
ans = 0

for x in range(2 ** N):
#     print("===========", x, ans)
    for m in range(M):
        c = 0
        for k in range(1, ks_list[m][0]+1):
            ks_mk = -ks_list[m][k]
            if int(format(x,'b').zfill(10)[ks_mk]) == 1:
                c += 1
#             print(ks_list, ks_list[m][k], ks_mk, format(x,'b').zfill(10), format(x,'b').zfill(10)[ks_mk])
#         print(c, p[m])
        if c % 2 != p[m]:
#             print("break")
            break
        if m == M-1:
            ans += 1
#     print(ans, ks_list, c, p)

print(ans)

Measured memory_bytes: 20744
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    set<string> s;
    while(n--){
        string x;
        cin >> x;
        s.insert(x);
    }
    cout << SZ(s);
    return 0;
}


Measured memory_bytes: 19284
n = int(input())
ls = list(map(str,input()))
r = len(ls)
for i in range(r):
    if ord(ls[i]) + n <= 90:
        ls[i] = chr(ord(ls[i]) + n)
    else:
        ls[i] = chr((ord(ls[i]) + n)%90+64)
a = "".join(ls)
print(a)



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

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

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/* func */

/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

//#define int ll
//#define int long long

int kai(int i){ 
  int cnt = 0;
  
  int one = i % 10;
  int ten = (i / 10)%10;
  int tho = (i / 1000)%10;
  int man = (i / 10000);
  
  if(one == man && ten == tho)
   ++cnt;

  return cnt; 
}

signed main()
{
  int a,b; cin >> a >> b;
  int ans = 0;
  
  FOR(i, a, b+1)
   ans += kai(i);
  
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 2e5+10;
const int M = 1e6+10;
/*=================================================================================*/

int n, m;
ll sum[N<<2], tag[N<<2];
struct node {
   int l, r, a;
}b[N];

vector<pii> a[N];

bool cmp(node x, node y) {
   return x.r < y.r;
}

void add(int rt, int L, int R, int x, int y, ll val) {
   if(x <= L && y >= R) {
      sum[rt] += val, tag[rt] += val;
      return;
   }
   int mid = (L + R) >> 1;
   if(x <= mid) add(rt<<1, L, mid, x, y, val);
   if(y > mid) add(rt << 1 | 1, mid+1, R, x, y, val);
   sum[rt] = max(sum[rt<<1], sum[rt<<1|1]) + tag[rt];
}

int main() {
   scanf("%d %d", &n, &m);
   for1(i, m) {
      scanf("%d %d %d", &b[i].l, &b[i].r, &b[i].a);   
      a[b[i].r].pb(pii(b[i].l, b[i].a));
   }
   sort(b+1, b+1+m, cmp);
   int idx = 1;
   for1(i, n) {
      add(1, 1, n, i, i, sum[1]);
      // while(b[idx].r == i) {
      //    // debug1 printf("%d %d %d\n", b[idx].l, b[idx].r, b[i].a);
      //    add(1, 1, n, b[idx].l, i, b[idx].a);
      //    idx++;
      // }
      for(auto it : a[i]) {
         add(1, 1, n, it.first, i, it.second);
      }
       
   }
   cout << max(sum[1], (ll)0) << endl;
   return 0;
}

Measured memory_bytes: 24076
#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 ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 998244353;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
int n, k;
int dp[N]; // dp[i] = 1 if(first )
void solve(){
    cin >> n >> k;
    vector<int> a(n);
    for(int &x : a)
        cin >> x;
    
    for(int i = 0; i <= k; ++i)
        for(int x : a)
            if(x + i <= k && !dp[i])
                dp[i + x] = 1;
    

    cout << (dp[k] ? "First" : "Second");
}
 
int main(){
    speed();
    int t = 1;

    // cin >> t;
    while(t--)solve();
} 

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int a,b,d,r;
  double f; 
  scanf("%d %d",&a,&b);
  d=a / b;
  r=a % b;
  f=(double) a / b;
 
  printf("%d %d %.5lf\n",d,r,f);

  return 0;
}

Measured memory_bytes: 640
#define DEBUG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
#define F first
#define S second 
#define pb push_back
#define endl "\n"

#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }

#ifdef DEBUG
    #define dbg(s) {s;}
#endif

#ifndef DEBUG
    #define dbg(s)
#endif

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) { // from [0, x-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

#define int ll
#define i32 int32_t

#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 

#define all(v) (v).begin(),(v).end()

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

int getInt () {
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}


ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 

const ll mod = 1e9 + 7;

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 1e6 + 7;

const ll inf = 1e9 + 7;


i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);

    IOS;
    int n;
    cin>>n;

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

    int ans  = 0;
    
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            ans+=arr[i]*arr[j];
        }
    }

    cout<<ans<<endl;
    
}





Measured memory_bytes: 256
// AtCoder ABC123: A - Five Antennas
// 2019.9.9 bal4u

#include <stdio.h>

#define ABS(x)  ((x)>=0?(x):-(x))

int main()
{
	int i, j, k, d, a[5], ans;
	
	for (i = 0; i < 5; i++) scanf("%d", a+i);
	scanf("%d", &k);
	ans = 0; for (i = 0; i < 5; i++) for (j = i+1; j < 5; j++) {
		d = ABS(a[i]-a[j]);
		if (d > k) ans++;
	}
	puts(ans > 0? ":(": "Yay!");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 5003, M = 1000000007;

int n;
int p[N];
int qmm;
vector<int> g[N];

int ast[N], f[N];

bool c[N];
int q;
void dfs(int x)
{
    c[x] = true;
    ++q;
    for (int i = 0; i < g[x].size(); ++i)
    {
        int h = g[x][i];
        if (!c[h])
            dfs(h);
    }
    if (p[x] != -1 && !c[p[x]])
        dfs(p[x]);
}

int ans;

int dp[N][N];

void solv()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &p[i]);
        if (p[i] != -1)
            g[p[i]].push_back(i);
        else
            ++qmm;
    }
    ast[0] = 1;
    for (int i = 1; i <= n; ++i)
        ast[i] = (ast[i - 1] * 1LL * (n - 1)) % M;
    f[0] = 1;
    for (int i = 1; i <= n; ++i)
        f[i] = (f[i - 1] * 1LL * i) % M;
    int ans = 0;
    vector<int> v;
    for (int i = 1; i <= n; ++i)
    {
        if (p[i] == -1)
        {
            q = 0;
            dfs(i);
            v.push_back(q);
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        if (!c[i])
        {
            dfs(i);
            ans = (ans + ast[qmm]) % M;
        }
    }
    dp[0][0] = 1;
    for (int i = 0; i < v.size(); ++i)
    {
        for (int j = 0; j < v.size(); ++j)
        {
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % M;
            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j] * 1LL * v[i]) % M;
        }
    }
    for (int j = 2; j <= v.size(); ++j)
    {
        ans = (ans + (dp[v.size()][j] * 1LL * f[j - 1]) % M * 1LL * ast[qmm - j]) % M;
    }
    for (int i = 0; i < v.size(); ++i)
    {
        ans = (ans + (v[i] - 1) * 1LL * ast[qmm - 1]) % M;
    }
    ans = ((n * 1LL * ast[qmm]) % M - ans + M) % M;
    printf("%d\n", ans);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 101536
#include <iostream>
using namespace std;
//C - Sugar Water
int main(void){
    int a,b,c,d,e,f;
    int ans1=0,ans2=0;
    std::cin >> a >> b >> c >> d >> e >>f;
    a*=100;
    b*=100;
    int g,h,t;
    for (int i = 0; i<=30 && i*a<=f; i++) {
        for(int j=0; j<=30 && i*a+j*b<=f;j++){
            if(i+j){
                g=i*a+j*b;//水の量
                h=min(g*e/100,f-g);//溶けることのできる砂糖の量
                t=0;//溶けている砂糖の量
                for(int k=0;k<=3000 && c*k<=h;k++){
                    for(int l=0;l<=3000 && c*k+d*l<=h;l++){
                        t=max(t,c*k+d*l);
                    }
                }
                if(ans1==0 || t*(ans1+ans2)>ans2*(g+t)){
                    ans1=g;
                    ans2=t;
                }
            }
        }
    }
    
    std::cout << ans1+ans2 << " " << ans2 << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n,m;
    cin >> n >> m;
    int numa[n][m];
    int numb[m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> numa[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin >> numb[i];
    }
    int ans[n]={};
    for(int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            ans[i]+=numa[i][j]*numb[j];
        }
    }
    
    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3104
def resolve():
  N, K = map(int, input().split(" "))
  A = [int(x) for x in input().split(" ")]
  maxA = max(A)
  base = 10**9+7
  # counter_of_A = [0]*(maxA+1)
  integra_of_counter = [0]*(maxA+1)

  # A の転倒数を数える。
  inversion_num_of_first_A = 0
  for a in reversed(A):
    if a > 1:
      inversion_num_of_first_A += integra_of_counter[a-1]
    
    for x in range(a, maxA+1):
      integra_of_counter[x] += 1


  # B の 2 番目の転倒数を数える
  inversion_num_of_second_A = 0
  for a in reversed(A):
    if a > 1:
      inversion_num_of_second_A += integra_of_counter[a-1]
    
    for x in range(a, maxA+1):
      integra_of_counter[x] += 1
  # print(integra_of_counter)
  # print(inversion_num_of_second_A)

  # print("K =", K, "a =", inversion_num_of_first_A, "d =", inversion_num_of_second_A - inversion_num_of_first_A)
  if K%2 == 0:
    result = K//2 * (2*inversion_num_of_first_A%base + (K-1)*(inversion_num_of_second_A - inversion_num_of_first_A)%base)
  else:
    result = (inversion_num_of_first_A%base + ((K-1)*(inversion_num_of_second_A - inversion_num_of_first_A)//2)%base)*K
  result %= base

  print(result)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 9260
#include<iostream>
#include<stack>
#include<stdlib.h>
 
 
using namespace std;
 
int main(void) {
  stack<int> S;
 
  int q;
  int next;
  string s;
  while(cin >> s) {
    if(s[0]=='+') {
        q=S.top();
        S.pop();
        next=S.top();
        S.pop();
        S.push(next+q);
    }
    else if(s[0]=='-') {
        q=S.top();
        S.pop();
        next=S.top();
        S.pop();
        S.push(next-q);
    }
    else if(s[0]=='*') {
        q = S.top();
        S.pop();
        next = S.top();
        S.pop();
        S.push(next*q);
    }
    else if(s[0]=='/') {
        q= S.top();
        S.pop();
        next=S.top();
        S.pop();
        S.push(next/q);
    }
    else {
        S.push(atoi(s.c_str()));
    }
  }
  cout << S.top() << endl;
  S.pop();
  return 0;
}


Measured memory_bytes: 3128
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <string>
#include <deque>
#include <stack>
#include <cmath>

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (LL i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<LL> VI;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 400007;
const long double PI = acos(-1.);
const double EPS = 1e-6;
LL mod = 1000LL * 1000 * 1000 + 7;

int n,k;
int arr[3][MAX/4];
int dpT[MAX/4][4];
int dp(int pos,int type)
{
	if(pos>n-1)
		return 0;
	if(dpT[pos][type]!=-1)
		return dpT[pos][type];
	return dpT[pos][type] = max(dp(pos+1,(type+1)%3)+arr[(type+1)%3][pos],dp(pos+1,(type+2)%3)+arr[(type+2)%3][pos]);
}



int main()
{
	//freopen("input.tXXt", "r", stdin);
	ios_base::sync_with_stdio(0);
	FILL(dpT,-1);
	cin >> n;
	FOR(i,0,n)
		FOR(j,0,3)
			cin >> arr[j][i];
	cout<<max(dp(0,0),dp(0,1));




	return 0;
}


Measured memory_bytes: 7680
import bisect
n, d, a = map(int, input().split())
XH = sorted([list(map(int, input().split())) for _ in range(n)])
X, H = zip(*XH)
K = [-(-i//a) for i in H]
L = [0]*(n+2)
ans = 0
for i in range(n):
  L[i+1] += L[i]
  s = max(K[i]-L[i+1], 0)
  ans += s
  L[i+1] += s
  L[bisect.bisect_right(X, X[i]+2*d)+1] -= s
print(ans)

Measured memory_bytes: 115132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,s,ans=0;cin>>n;
  lvector v(n,0);rep(i,n) {cin>>v[i];s+=v[i];}
  rep(i,n-1) {
    s-=v[i];
    ans+=v[i]*s;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

const Int INF = 1e18;

int main(){ 
    Int N;
    cin >> N;
    vector<Int> A(N);
    rep(i,N) {
        cin >> A[i];
        if (A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    Int ans = 1;
    rep(i,N) {
        if (INF / A[i] >= ans) {
            ans *= A[i];
            if (ans > INF) {
                cout << -1 << endl;
                return 0;
            }
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 3976
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),

signed main(){
    FASTER;
    int n,k;cin>>n>>k;
    double ans=0;
    for(int sc=1;sc<=n;sc++){
        if(sc>n)break;
        double lo=1.0/n;
        int s=sc;
        while(s<k){
            s*=2;
            lo*=(0.5);
        }
        
        ans+=lo;
    }
    cout<<fixed<<setprecision(9)<<ans;
}

Measured memory_bytes: 3704