akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	String a = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
        String ans[] = a.split(", ");
      	int b = sc.nextInt();
        
        System.out.println(ans[b - 1]);
      
    }
}

Measured memory_bytes: 35692
#include <bits/stdc++.h>
#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define inf 1000000000000000000
#define mod 1000000007
using namespace std;
int main () {
	ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s;
	scanf("%lld %lld %lld %lld %lld %lld", &a, &b, &c, &d, &e, &f);
	g = 0; h = 10000;
	for (i = 0; i * 100 <= f; i += a) {
		for (j = 0; (i + j) * 100 <= f; j += b) {
			n = (i + j) * 100; r = (i + j) * e;
			for (k = 0; k <= r && n + k <= f; k += c) {
				for (l = 0; k + l <= r && n + k + l <= f; l += d) {
					o = k + l; p = k + l + n;
					if (o * h > g * p) g = o, h = p;
				}
			}
		}
	} 
	if (g == 0) h = a * 100;
	printf("%lld %lld\n", h, g);
	return 0;
}

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

using namespace std;

void solve()
{
	string str;
	cin >> str;
	for(int i = str.size() - 1; i >= 0; --i)
	{
		cout << str[i];
	}
	cout << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

int main() {
  ll D;
  ll G;

  cin >> D >> G;

  vector<P> lst;
  for (int i = 0; i < D; i++) {
    P tmp;
    cin >> tmp.first >> tmp.second;
    lst.emplace_back(tmp);
  }

  ll ans = 2000;
  for (ll i = 0; i < (1LL << D); i++) {
    ll tmpScore = 0;
    ll tmpPNum = 0;
    for (ll j = 0; j < D; j++) {
      if (((i >> j) & 1LL) == 1) {
        tmpScore += 100 * (j+1) * lst[j].first + lst[j].second;
        tmpPNum += lst[j].first;
      }
    }  // j
    bool fin = false;
    for (ll j = D - 1; j >= 0; j--) {
      if (((i >> j) & 1LL) == 1) continue;
      for (ll k = 0; k < lst[j].first; k++) {
        if(tmpScore >= G){
          fin = true;
          break;
        }
        tmpScore += 100 * (j+1);
        tmpPNum++;
      }
      if (fin) break;
    }  // j
    if (tmpPNum < ans) ans = tmpPNum;
  }  // i

  cout << ans << endl;

  return 0;
}


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

int main(void){
    int N,T,P;
    cin>>N>>T;
    P=1001;


    for(int i=1;i<=N;i++){
        int c,t;
        cin>>c>>t;
        if(t<=T && c<P){
            P=c;
        }
        
    }
    if(P>1000){
        cout<<"TLE"<<endl;
    }else{
        cout<<P<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b, c, d;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b >> c >> d;
	cout << (((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d) ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println(Math.pow(sc.nextDouble()/3,3));
    }
    static long factorial(long num){
        if (num<2)return 1;
        else return num*factorial(num-1);
    }
    static int arraySum(int[] array){
        int ans = 0;
        for (int value : array) ans += value;
        return ans;
    }
    static long combination(long a, long b){
        long data = 1;
        for (int i=0;i<b;i++){
            data*=a-i;
        }
        return data/factorial(b);
    }
    static double log(double base,double antilogarithm){
        return Math.log(antilogarithm)/Math.log(base);
    }

    static long gcd(long x,long y){
        if (y==0)return x;
        else return gcd(y,x%y);
    }
    static long lcm(long x,long y){
        return x/gcd(x,y)*y;
    }
    static HashMap<Long,Long> factorization(long num){
        HashMap<Long,Long> hash = new HashMap<>();
        long n = num;
        long count = 2;
        while (n>1){
            while (n%count==0){
                n/=count;
                if (hash.containsKey(count))hash.put(count,hash.get(count)+1);
                else hash.put(count,1L);
            }
            count++;
        }
        return hash;
    }

}


Measured memory_bytes: 37464
import math
from collections import defaultdict,deque
#from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

n=ii()
a=ll()
lol=[]
for i in range(n):
    lol.append([a[i],i+1])
lol.sort()
for i in lol:
    print(i[1],end=" ")

Measured memory_bytes: 97812
n,k = gets.split(" ").map(&:to_i)

if k%2 == 1
    puts (n/k) ** 3
end
if k%2 == 0
    a = k / 2
    count = 0
    while a <= n do
        count += 1
        a += k
    end
    puts count ** 3 + (n/k) ** 3
end



Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double d = sc.nextInt();
        double t = sc.nextInt();
        double s = sc.nextInt();
      
      //f/s <= t 
      if(d/s <= t){
                System.out.println("Yes");
      }else{
                System.out.println("No");
      }


        sc.close();
    }
}

Measured memory_bytes: 35672
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 1; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    rep(i,10) {
        rep(j, 10) {
            if(i * j == n) ++cnt;
        }
    }
    if (cnt > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

typedef long long ll;

void solve() {
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int pass = 0, rank = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'c') {
			cout << "No\n";
		} else if (s[i] == 'a') {
			if (pass < a + b) {
				pass++;
				cout << "Yes\n";
			} else {
				cout << "No\n";
			}
		} else {
			if (pass < a + b && rank < b) {
				pass++;
				rank++;
				cout << "Yes\n";
			} else {
				cout << "No\n";
			}
		}
	}
}


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

	int tt = 1;
	// cin >> tt;
	for (int i = 1; i <= tt; ++i) {
		// cout << "Case #" << i << ": ";
		solve();
	}

	return 0;
}


Measured memory_bytes: 3740
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX = 2100000;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

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

  for(int i = 1; i <= k; i++){
    ll res = COM(n-k+1, i) * COM(k-i + i-1,k-i) % MOD;
    cout << res << ln;
  }
}
  


Measured memory_bytes: 49408
def solve(n, t, ab_list):
    ab_list_s = sorted(ab_list, key=lambda x: x[0])
    res = 0
    dp = [0] * t
    for i in range(n):
        for s in range(t - 1, -1, -1):
            if dp[s] > 0 or s == 0:
                u = s + ab_list_s[i][0]
                r = dp[s] + ab_list_s[i][1]
                if u >= t:
                    res = max(res, r)
                else:
                    dp[u] = max(dp[u], r)
    return max(res, max(dp))


def main():
    n, t = map(int, input().split())
    ab_list = []
    for _ in range(n):
        a, b = map(int, input().split())
        ab_list.append([a, b])
    res = solve(n, t, ab_list)
    print(res)


def test():
    assert solve(2, 60, [[10, 10], [100, 100]]) == 110
    assert solve(3, 60, [[10, 10], [10, 20], [10, 30]]) == 60
    assert solve(3, 60, [[30, 10], [30, 20], [30, 30]]) == 50


if __name__ == "__main__":
    # test()
    main()


Measured memory_bytes: 47080
class Combinator
  MAX = 2000000 # nCkの最大のnより大きいこと。MODより小さいこと。
  MOD = 1000000007

  def initialize
    @fac = Array.new(MAX)
    @fac[0] = 1
    @fac[1] = 1
    @finv = Array.new(MAX)
    @finv[0] = 1
    @finv[1] = 1
    @inv = Array.new(MAX)
    @inv[1] = 1
    (2..(MAX-1)).each do |i|
      @fac[i] = @fac[i-1]*i%MOD
      @inv[i] = MOD-@inv[MOD%i]*(MOD/i)%MOD
      @finv[i] = @finv[i-1]*@inv[i]%MOD
    end
  end

  def call(all, select)
    return 0 if all < select
    return 0 if all < 0||select < 0
    @fac[all]*(@finv[select]*@finv[all-select]%MOD)%MOD
  end
end
@combinator = Combinator.new

x, y = gets.split.map(&:to_i)
m = (2 * y - x) / 3
n = (2 * x - y) / 3
if m < 0 || n < 0 || x != m + 2 * n || y != n + 2 * m
  puts 0
  exit 0
end
puts @combinator.call(n+m, [n, m].min)



Measured memory_bytes: 48636
#include<iostream>
using namespace std;
int main()
{
  string S;
  long long K,change=0,renzoku=0,R=0,R2=0;
  char now='1';
  cin >> S >> K ;
  
  if(S[0]==S[S.length()-1] && S.length()!=2){
      R=1;R2=1;
      for(int i=S.length()-2;i>1;i--){
        if(S[S.length()-1]==S[i])R++;
        else break;
      }
      for(int i=1;i<S.length()-2;i++){
        if(S[0]==S[i])R2++;
        else break;
    }
  }
    for(int j=0;j<S.length();j++){
      if(S[j]==now){
         renzoku++;
      }
      else{
         now=S[j];
         change+=renzoku/2;
         renzoku=1;
      }
      //cout<<renzoku;
    }
  change+=renzoku/2;
  change*=K;
  if(R%2==1&&R2%2==1)change+=K-1;
  if(S.length()==1)change=K/2;
  int g=0;
  for(int i=1;i<S.length();i++){
     if(S[0]==S[i])g++;
     else break;
     if(g==S.length()-1){
       change=S.length()*K/2;
     }
  }
  cout << change;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a;
	cin >> a;
	int answer = 0;
	for (int C = 1; C <= a; C += 2) {
		int divisors = 0;
		for (int X = 1; X <= C; ++X) {
			if (C % X == 0) {
				++divisors;
			}
		}
		if (divisors == 8) {
			++answer;
		}
	}
	cout << answer << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>

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

using namespace std;

int main(){
	long long int g=0,p=0,ans; 
	string str;
	cin>>str;
	FOR(i,str.size()){
		if(str[i]=='g')
			g++;
		else
			p++;
	}
	if((g+p)%2==0)
		ans=g-(g+p)/2;
	else
		ans=g-(g+p+1)/2;

	cout<<ans;
return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
const int MAXN=110;
const int MAXK=100010;

int n,k;
int a[MAXN],f[MAXK];

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	memset(f,-1,sizeof(f));
	for(int i=1;i<=k;i++)
		for(int j=1;j<=n;j++){
			if(i-a[j]>=0){
				// printf("%d:%d %d %d ",i,f[i],f[i-a[j]],i-a[j]);
				f[i]=std::max(f[i],-f[i-a[j]]);
				// printf("%d\n",f[i]);
			}
			else
				f[i]=std::max(f[i],-1);
		}
	puts(f[k]>0?"First":"Second");
	return 0;
}

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

int main(void)
{
    int N, D, i, c=0;
    long double t;

    scanf("%d %d", &N, &D);
    long long X[N], Y[N];
    for(i=0; i<N; i++) {
        scanf("%lld %lld", &X[i], &Y[i]);
    }

    for(i=0; i<N; i++) {
        t = sqrt(X[i]*X[i] + Y[i]*Y[i]);
        if(t <= D) {
            c++;
        }
    }

    printf("%d\n", c);

    return 0;
}

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

using namespace std;

int main() 
{
    int a, b, c, d, conta = 0, contb = 0;
    cin >> a >> b >> c >> d;
    while (a > 0)
    {
        conta += 1;
        a -= d;
    }
    while (c > 0)
    {
        contb += 1;
        c -= b;
    }
    if (conta >= contb)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		String[] tokens = in.nextLine().split(" ");
		int a[] = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = Integer.parseInt(tokens[i]);
		}
		in.close();
		int result = 0;
		for (int i = 0; i < n; ++i) {
			result += a[i] - 1;
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 22740
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AApplePie solver = new AApplePie();
        solver.solve(1, in, out);
        out.close();
    }

    static class AApplePie {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt(), p = in.nextInt();

            p += a * 3;

            out.println(p / 2);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22868
N = int(input())
S = [input() for _ in range(N)]

cnt = 0
cntA = 0
cntB = 0
cntAB = 0

for s in S :
    for i in range(1, len(s)) :
        if s[i - 1] =='A' and s[i] == 'B':
            cnt += 1
    if s[0] == 'B' and s[len(s) - 1] == 'A':
        cntAB += 1
    elif s[0] == 'B' :
        cntB += 1
    elif s[len(s) - 1] == 'A' :
        cntA += 1

ans = min(cntA, cntB)
if cntAB >= 2 :
    ans += (cntAB - 1)
if cntAB >= 1 and max(cntA, cntB) != 0:
    ans += 1

'''
if max(cntA, cntB) == 0:
    ans = cntAB - 1
else :
    ans += cntAB
'''
if ans == len(S) :
    ans -= 1

print(cnt + ans)


Measured memory_bytes: 3700
// Marcin Knapik
#include<bits/stdc++.h>
#include<unistd.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
 
typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;
 
#define boost                   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define REP(i, a, b)            for (int i = (a); i <= (b); i++)
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define TRAV(i, n)              for(auto&i:n)
#define beg(x)                  (*(x.begin()))
#define re(x)                   int x; cin >>x;   
#define f                       first
#define s                       second
 
template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}
 
template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }
 
const ll T = 1 << 20;
const ll INF = 1e9 + 7;
// const ll mod = 998244353;
const ll BIG_INF = 1e18 + 7;
const ll  N = 1e6+7;
const int LOG = 17;
 
ll n, m, q;
bool prime(ll x){
	for(ll i = 2; i <= sqrt(x); i++){
		if(x%i == 0)
			return 0;
	}
	return 1;
}

vll dzileniki(ll x){
	vll male;
	vll duze;
	for(ll i = 1; i<= sqrt(x); i++){
		if(x%i == 0){
			male.pb(i);
			if(i*i != x){
				duze.pb(x/i);
			}
		}
	}
	reverse(all(duze));
	vll ret(sz(male)+sz(duze));
	// merge(all(male), all(duze), ret);
	for(auto&u:duze)
		male.pb(u);
	return male;
}

signed main(){
	boost;
	cin >> n >> m;
	//cout << dzi
	vll A = dzileniki(n);
	vll B = dzileniki(m);
	vll C(sz(A), sz(B));
	auto it = set_intersection(all(A), all(B), C.begin());
	C.resize(it-C.begin());
	int ans = 0;
	TRAV(u, C)
		ans+= prime(u);
	cout << ans << '\n';
}

Measured memory_bytes: 512
#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 10000007
#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*b/gcd(a,b);}

int main(){
    int n,k;
    cin>>n>>k;
    int ans=k;
    rep(i,n){
        if(i!=0)ans*=k-1;
    }
  cout<<ans;
}

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

int n,m,sum;
int a[101];

int main()
{
	std:ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i],sum+=a[i];
    cin>>m;
    for(int i=1,p,x;i<=m;++i)
	{
    	cin>>p>>x;
        cout<<sum-a[p]+x<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("-O3","unroll-loops")
#include<bits/stdc++.h>
 
using namespace std;
 
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
#define move(x) ans.push_back(x),c[x]--,now=x;
 
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 998244353; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}

int dp[2020][2020];
int cumR[2020];
int A[2020],B[2020];
int sumR,sumB;
void solve() {
	string S;cin>>S;
	int N=S.size();
	COMinit();
	REP(i,N){
		int num=S[i]-'0';
		A[i]+=num;
		B[i]+=2-num;
		cumR[i+1]+=cumR[i]+A[i];
		sumR+=A[i];
		sumB+=B[i];
	}
	dp[0][0]=1;
	REP(i,N){
		REP(r,N+1){
			if(r>0&&cumR[i+1]>=r)dp[i+1][r]+=dp[i][r-1];
			int cumB=(i+1)*2-cumR[i+1];
			if(cumB>=i+1-r)dp[i+1][r]+=dp[i][r];
			dp[i+1][r]%=MOD;
			//pe(i+1);pe(r);print(dp[i+1][r]);
		}
	}
	ll ans=0;

	REP(r,N+1){
		ll res=mult(dp[N][r],fac[N]);
		res=mult(res,mult(finv[sumR-r],finv[sumB-(N-r)]));
		ans=add(ans,res);
	}
	print(ans);
}

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

	solve();
}

Measured memory_bytes: 36864
#include <bits/stdc++.h>
#define  ref(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
typedef long long ll;
 
using namespace std;
ll a,b;
double x;
 
int main()
{
    cin>>a>>x;
    b=x*100+1e-9;
    a*=b;
    a/=100;
    cout<<a<<endl;
    return 0;
    }

Measured memory_bytes: 3708
a, b = map(str, input().lower().split())
str1 = ""
str2 = ""
for i in range(int(b)):
    str1 = str1 + a

for i in range(int(a)):
    str2 = str2 + b

if str1 < str2:
    print(str1)
elif str1 > str2:
    print(str2)
elif str1 == str2:
    print(str1)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
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){
                    if(j%2==0)cout << "#";
                    else cout << ".";
                }else{
                    if(j%2==0)cout << ".";
                    else cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define M 100005
using namespace std;
int n,x[M],y[M],a[M],b[M],f[M],sz[M];
int markx[M],marky[M],marka[M],markb[M];
vector<int>v[M];
long long ans;
int Find(int x) {
	return x==f[x]?x:(f[x]=Find(f[x]));
}
void Union(int a,int b) {
	a=Find(a),b=Find(b);
	f[b]=a;
}
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++)scanf("%d%d",&x[i],&y[i]),a[i]=x[i],b[i]=y[i];
	int q1,q2;
	sort(a+1,a+n+1);
	q1=unique(a+1,a+n+1)-a-1;
	sort(b+1,b+n+1);
	q2=unique(b+1,b+n+1)-b-1;
	for(int i=1; i<=n; i++)x[i]=lower_bound(a+1,a+q1+1,x[i])-a;
	for(int i=1; i<=n; i++)y[i]=lower_bound(b+1,b+q2+1,y[i])-b;
	for(int i=1; i<=n; i++)f[i]=i,sz[i]=1;
	for(int i=1; i<=n; i++) {
		if(markx[x[i]])Union(markx[x[i]],i);
		if(marky[y[i]])Union(marky[y[i]],i);
		markx[x[i]]=Find(i);
		marky[y[i]]=Find(i);
	}
	for(int i=1; i<=n; i++)v[Find(i)].push_back(i);
	for(int i=1; i<=n; i++) {
		int xx=0,yy=0;
		for(int j=0; j<v[i].size(); j++) {
			if(!marka[x[v[i][j]]])xx++;
			if(!markb[y[v[i][j]]])yy++;
			marka[x[v[i][j]]]=markb[y[v[i][j]]]=1;
		}
		for(int j=0; j<v[i].size(); j++) marka[x[v[i][j]]]=markb[y[v[i][j]]]=0;
		if(xx>1&&yy>1)ans+=1ll*xx*yy-v[i].size();
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 7168
N, K = gets.split.map(&:to_i)
if K > (N - 1) * (N - 2) / 2
  p -1
  exit
end
ans = []
2.upto(N) do |i|
  ans << "1 #{i}"
end
cnt = 0
from = 2
to = 3
while cnt < (N - 1) * (N - 2) / 2 - K
  ans << "#{from} #{to}"
  cnt += 1
  if to >= N
    from += 1
    to = from + 1
  else
    to += 1
  end
end
puts ans.size
puts ans


Measured memory_bytes: 2172
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9


int main() {
	int N; cin >> N;
	int a[N+2];
	a[0] = 0;
	for (int i = 1; i <= N; i++) cin >> a[i];
	a[N + 1] = 0;

	int tot = 0;
	for (int i = 0; i <= N; i++) tot += abs(a[i + 1] - a[i]);

	for (int i = 1; i <= N; i++) {
		int ans = tot;
		ans -= abs(a[i] - a[i - 1]);
		ans -= abs(a[i + 1] - a[i]);
		ans += abs(a[i + 1] - a[i - 1]);
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 1664
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var s string
	con.Scan(&s)
	h := make([]bool, 26)
	for _, c := range s {
		if h[c-'a'] {
			con.Println("no")
			return nil
		}
		h[c-'a'] = true
	}
	con.Println("yes")
	return nil
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair

/*int P[10010];
void init(int n){//Union-find
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/


/*
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
*/

//cerrはコメントアウトしなくても通る

int main(){
    int a,b,ab,x,y;
    cin >> a>>b>>ab>>x>>y;
    int sum;
    sum=a*x+b*y;
    int temp=INF;
    if(a>ab*2||b>ab*2){
        int z=max(x,y);
        temp=z*ab*2;
    }
    while(x>0&&y>0&&a+b>ab*2){
        x--;y--;
        sum=sum-a-b+ab*2;
    }
    cerr<<x<<" "<<y<<endl;
    cout<<min(sum,temp)<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  int n;
  cin >> n;
  vi a(n + 2);
  int sum = 0;
  a.at(0) = 0;
  a.at(n + 1) = 0;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i + 1);
    sum += max(a.at(i + 1) - a.at(i), a.at(i) - a.at(i + 1));
  }
  sum += max(a.at(n), -a.at(n));
  for (int i = 1; i <= n; i++) {
    int ans = sum;
    ans -= max(a.at(i) - a.at(i - 1), a.at(i - 1) - a.at(i));
    ans -= max(a.at(i) - a.at(i + 1), a.at(i + 1) - a.at(i));
    ans += max(a.at(i + 1) - a.at(i - 1), a.at(i - 1) - a.at(i + 1));
    cout << ans << endl;
  }
}

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

Measured memory_bytes: 256
N,M=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
A.reverse()
K=sum(A)
answer=0
breakflag=0
for i in range(0,N):
  if  A[i]*M*4>=K:
    if i==N-1:
      breakflag=1
    continue
  else:
    answer=i
    break
if breakflag==1:
  answer=N
if answer>=M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
H, W = gets.split.map(&:to_i).sort # 常に W >= H であるものとする
answer = nil

if H % 3 == 0 || W % 3 == 0
  # 縦横どちらかが3で割れるならば3等分が可能ということなので答えは0になる
  answer = 0
else
  # 縦横どちらも3では割り切れない場合

  # まず長辺で分割してから短辺で分割するパターン
  w_cdds = []
  (-1..1).each do |num|
    temp = num + W/3
    w_cdds << temp if temp.between?(1, W-1)
  end
  w_cdds.each do |x|
  # 1.step(W-1) do |x|
    pieces = [x*H, (W-x)*(H/2), (W-x)*(H-(H/2))]
    answer = [answer, pieces.max - pieces.min].compact.min
  end

  # 次に短辺で分割してから長辺で分割するパターンパターン
  h_cdds = []
  (-1..1).each do |num|
    temp = num + H/3
    h_cdds << temp if temp.between?(1, H-1)
  end
  h_cdds.each do |y|
  # 1.step(H-1) do |y|
    pieces = [y*W, (H-y)*(W/2), (H-y)*(W-(W/2))]
    answer = [answer, pieces.max - pieces.min].compact.min
  end

  # 長辺で3分割するパターン
  answer = [answer, H].compact.min
end

puts answer


Measured memory_bytes: 1788
#include <bits/stdc++.h>
const int maxn=1e5+10,mod=998244353;
typedef long long ll;
using namespace std;
int n,m,k,t;
int a[maxn];
int b[maxn];
int p,v;
bool ok(int x)
{
    ll left = (ll)(v - min(p,v))*m;
    ll lim = m+a[x];
    for(int i=1;i<=n;i++)b[i]=a[i];
    b[x]=lim;
    for(int i=1;i<=n-p+1;i++)
    {
        if(i==x)continue;
        b[i]+=min(left,min((ll)m,max(0LL,lim-a[i])));
        left-=min(left,min((ll)m,max(0LL,lim-a[i])));
    }
    if(left)return false;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(i==x)continue;
        if(b[i]>lim)cnt++;
    }
    return cnt<p;
}
int main()
{
    int i,j;
    //freopen("in.txt","r",stdin);
    scanf("%d%d%d%d",&n,&m,&v,&p);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    int l=1,r=n-p+1,ret=n-p+1;
    while(l<=r)
    {
        int mid=l+r>>1;
        if(ok(mid))ret=mid,r=mid-1;
        else l=mid+1;
    }
    printf("%d\n",n-ret+1);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc,char *args[]){
    int i,a,b,c,ans;
    ans = 0;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a;i<b+1;i++){
        if(c%i == 0) ans += 1;
    }
    printf("%d\n",ans);
    return 0;
}



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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    bool ok = true;
    REP(i, n){
        int a;
        cin >> a;
        ok &= (a%2 || !(a%3) || !(a%5));
    }
    cout << (ok ? "APPROVED" : "DENIED") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define ZERO(a) memset(a,0,sizeof(a))
using namespace std;
typedef signed long long ll;

void solve(){
 string s,t;
 int n,a=0,b=0;
 cin>>n;
 while(n--){
  cin>>s>>t;
  if(s<t) b+=3;
  else if(s>t) a+=3;
  else{
   a++;
   b++;
  }
 }
 cout<<a<<" "<<b<<endl;
}

int main(){
 solve();
 return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    double ans;
    ll a,b,x;cin>>a>>b>>x;

    if(x<=a*b*a/2.0){
        ans=atan((2*x+.0)/(a*b*b));
    }else{
        ans=atan((a*a*a+.0)/(2*b*a*a-2*x));
    }

    cout<<fixed;

    cout<<setprecision(10)<<90-ans*180/pi<<endl;
    return 0;
}

Measured memory_bytes: 4024
// atcoder/abc128/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    vector<int> v(m, 0);
    for (int i = 0; i < m; ++i) {
      int k;
      cin >> k;
      for (int j = 0; j < k; ++j) {
        int x;
        cin >> x;
        --x;
        v[i] |= (1 << x);
      }
    }
    vector<int> p(m);
    cin >> p;

    int cnt = 0;
    for (int bit = 0; bit < (1 << n); ++bit) {
      bool f = true;
      for (int i = 0; i < v.size(); ++i) {
        int x = __builtin_popcount(bit & v[i]);
        f = f && (x % 2 == p[i]);
      }
      cnt += f;
    }
    cout << cnt << endl;
  }

  return 0;
}


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

using namespace std;

int main()
{
	int N, A;
	cin >> N >> A;
	vector<int> x(N);
	for (auto &x_i : x) {
		cin >> x_i;
	}
	vector<vector<long long>> dp(50 + 1, vector<long long>(2500 + 1));

	dp[0][0] = 1;
	for (int i = 0; i < N; ++i) {
		vector<vector<long long>> next(dp);
		for (int k = 0; k <= 50; ++k) {
			for (int s = 0; s <= 2500; ++s) {
				if (dp[k][s] != 0) {
					next[k + 1][s + x[i]] += dp[k][s];
				}
			}
		}
		dp.swap(next);
	}
	long long ans = 0;
	for (int k = 1; k <= 50; ++k) {
		for (int s = 0; s <= 2500; ++s) {
			if (s == k * A) {
				ans += dp[k][s];
			}
		}
	}
	cout << ans << endl;
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


int main(){
  string s;
  cin>>s;
  REP(i,s.length()){
    int j=i;
    while(s[j]=='R'){
      j++;
    }
    int x=1;
    //cout<<i<<" "<<j<<endl;
    if(j!=i){
      int tmp=j-1;
      for(int k=i;k<tmp;k++){
        cout<<0<<" ";
        x++;
      }
    }
    i=j;
    while(s[i]=='L'){
      i++;
    }
    int y=i-j;
    int mid=(x+y)/2;
    if((x+y)%2==0){
      cout<<mid<<" "<<mid<<" ";
    }else{
      int m=max(x,y);
      if(m==x){
        if(m%2==0){
          cout<<mid<<" "<<mid+1<<" ";
        }else{
          cout<<mid+1<<" "<<mid<<" ";
        }
      }else{
        if(m%2==0){
          cout<<mid+1<<" "<<mid<<" ";
        }else{
          cout<<mid<<" "<<mid+1<<" ";
        }
      }
    }
    for(int k=j+1;k<i;k++){
      cout<<0<<" ";
    }
    if(i>=s.length()){
      break;
    }
    i--;
  }
}

Measured memory_bytes: 640
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]


A = sorted(A)[::-1]
total = sum(A)

OK = True
for i in range(M):
    if (A[i] * 4 * M) < total:
        OK = False

if OK:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
data=[0]*n
count=0
if a[0]<=0:
    count=1-a[0]
    data[0]=1
else:
    data[0]=a[0]
for i in range(1,n):
    if i%2==1:
        if a[i]+data[i-1]>=0:
            count+=a[i]+data[i-1]+1
            data[i]=-1
        else:
            data[i]=a[i]+data[i-1]
    else:
        if a[i]+data[i-1]<=0:
            count+=1-a[i]-data[i-1]
            data[i]=1
        else:
            data[i]=a[i]+data[i-1]
ans=count
data=[0]*n
count=0
if a[0]>=0:
    count=a[0]+1
    data[0]=-1
else:
    data[0]=a[0]
for i in range(1,n):
    if i%2==0:
        if a[i]+data[i-1]>=0:
            count+=a[i]+data[i-1]+1
            data[i]=-1
        else:
            data[i]=a[i]+data[i-1]
    else:
        if a[i]+data[i-1]<=0:
            count+=1-a[i]-data[i-1]
            data[i]=1
        else:
            data[i]=a[i]+data[i-1]
ans=min(ans,count)
print(ans)

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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
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; }

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

    ll ans = 0;
    if (n * 2 <= m) {
        ans += n;
        m -= n * 2;
        ans += m / 4;
    }
    else {
        ans = m / 2;
    }

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define int long long int
const long long mod = 1000000007;
const int N = 2e5+5;
const int inf = 1e18;
int n;
int dp[2100000][21];
int v[25][25];
int helper(int bit_mask,int i)
{
    if(dp[bit_mask][i]!=-1)
    {
        return dp[bit_mask][i];
    }

    if(bit_mask== pow(2,n) - 1)
    {
        return 1;
    }

     if(i>=n)
     {
        return 0;
     }
    
     int ans = 0;
    
     for(int j=0;j<n;j++)
     {
        if(v[i][j] == 1 && (bit_mask & (1<<j)) == 0 )
        {
            ans+= helper(bit_mask|(1<<j),i+1);
            ans=ans%mod;
        }
     }

     return dp[bit_mask][i] = ans;
}
int32_t main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
        cin>>v[i][j];
        }
    }

    int ans = helper(0,0);
    cout<<ans<<endl;
}

Measured memory_bytes: 344832
#include <set>
#include <math.h>
#include <vector>
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
typedef long long ll;
using namespace std;
#define REP(i,n) for(int i=0; i<n;i++)

int main(void)
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a>b)
    {
        a = b;
    }
    if(c>d)
    {
        c = d;
    }
    cout << a+c << endl;
}

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

void Main() {
    // input
    int N, M;
    cin >> N >> M;
    u_int64_t H[N+1], nH[N+1];
    for (int i = 1; i <= N; i++) {
        cin >> H[i];
        nH[i] = 0;
    }

    for (int i = 0; i < M; i++) {
        int from, to;
        cin >> from >> to;
        nH[from] = max(nH[from], H[to]);
        nH[to] = max(nH[to], H[from]);
    }

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        // cout << "H: " << H[i] << ", nH: " << nH[i] << endl; 
        if (H[i] > nH[i]) {
            ans++;
        }
    }


    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 5176