akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 2e5 + 5;
struct edge {
	int v, next;
} e[maxn << 1];
int head[maxn], cnt, n, u, v, dt[maxn];
void adde(const int &u, const int &v) {
	e[++cnt] = (edge) {v, head[u]};
	head[u] = cnt;
}

int stk[maxn], pre[maxn], top;

void dfs(int u, int p, int mxp, int s) {
	stk[++top] = u, pre[top] = max(pre[top - 1], u);
	int ch = stk[mxp];
	if (mxp < top) {
		ch = stk[mxp + 1];
		if (pre[mxp - 1] > s) {
			ch = stk[mxp];
		}
	}
	//printf("#%d\n", s);
	++dt[ch];
	for(register int i = head[u]; i; i = e[i].next) {
		int v = e[i].v;
		if(v == p) continue;
		if(stk[mxp] > v) dfs(v, u, mxp, max(v, s));
		else dfs(v, u, top + 1, 0);
	}
	--top;
}

void dfs2(int u, int p) {
	for(register int i = head[u]; i; i = e[i].next) {
		int v = e[i].v;
		if(v == p) continue;
		dt[v] += dt[u];
		dfs2(v, u);
	}
}

int main() {
	scanf("%d", &n);
	for(register int i = 1; i < n; ++i)
		scanf("%d%d", &u, &v), adde(u, v), adde(v, u);
	dt[1] = -1, dfs(1, 0, 1, 0);
	dfs2(1, 0);
	for(register int i = 2; i <= n; ++i)
		printf("%d ", dt[i]);
	return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


	int n; cin >> n;	


	vector <int> a(n);

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

	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(a[i] < 0){
			cnt++;
		}
	}

	if(!(cnt & 1)){
		int sum = 0;
		for(int i = 0; i < n; i++){
			sum += abs(a[i]);
		}

		cout << sum << endl;
	}else{
		int sum = 0, m = 1e9;
		for(int i = 0; i < n; i++){
			sum += abs(a[i]);
			m = min(m, abs(a[i]));
		}

		cout << sum - 2 * m << endl;
	}


	return 0;
}

Measured memory_bytes: 1024
S = input()
if S == 'SUN':
  print(7)
elif S == 'MON':
  print(6)
elif S == 'TUE':
  print(5)
elif S == 'WED':
  print(4)
elif S == 'THU':
  print(3)
elif S == 'FRI':
  print(2)
elif S == 'SAT':
  print(1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std; 
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string s;int ans=0;
	cin>>s;
	for(int i=0;i<s.size()/2;i++){
		if(s[i]!=s[s.size()-1-i])ans++;
	}
	cout<<ans<<endl;
    return 0; 
}/*
*/

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <math.h>
#include <numeric>
using namespace std;
typedef long long ll;


int main(void){
    
    string S;

    cin >> S;
    
    
    ll count = 0;
    for(int i=1; i<=4; i++){
        if(S[0]==S[i]){
            count++;
        }
    }
    for(int i=2; i<=4; i++){
        if(S[1]==S[i]){
            count++;
        }
    }
    for(int i=3; i<=4; i++){
        if(S[2]==S[i]){
            count++;
        }
    }
    
    if(count == 2){
        cout << "Yes" << endl;
    }
    
    else{
        cout << "No" << endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int i;
	char ch[20];
	gets(ch);
	for(i=0;ch[i]!='\0';i++)
	{
		int j;
		if(ch[i]==',')
		{
			j=i;
			ch[j]=' ';
		}
	}
	printf("%s\n",ch);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

#define LIMIT 1000000007

int main(void){
	int i,n;
	long long int m,ans=1;
	scanf("%lld %d",&m,&n);
	for(i=0;(1<<i)<=n;i++){
		if((1<<i)&n){
			ans*=m;
			if(ans>=LIMIT){
				ans%=LIMIT;
			}
		}
		m*=m;
		if(m>=LIMIT){
			m%=LIMIT;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    string name[1000];
    int eb[1000], we[1000], query;
    while (true) {
        cin >> n >> q;
        if(n == 0 && q == 0) break;
        for (int i = 0; i < n; ++i) {
            cin >> name[i] >> eb[i] >> we[i];
        }
        for (int i = 0; i < q; ++i) {
            cin >> query;
            int ind = 0;
            for (; ind < n; ++ind) {
                if(we[ind] >= query &&
                        we[ind] - eb[ind] + 1 <= query) {
                    break;
                }
            }
            if (ind < n) {
                cout << name[ind] << ' '
                     << eb[ind] - we[ind] + query
                     << endl;
            } else {
                cout << "Unknown" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1328
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath> 
using namespace std;
char s[1000];
int n, m, k, cnt[1000], num[10];
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++) {
		scanf("%s", s);
		for(int j = 0; j < m; j++) {
			cnt[s[j]]++;
		}
	}
	for(int i = 'a'; i <= 'z'; i++) if(cnt[i]) {
		if(cnt[i] & 1) num[1]++;
		else if(cnt[i] % 4 != 0) num[2]++;
		else num[4]++;
	}
//	printf("%d %d %d\n", num[1], num[2], num[4]);
	if(n % 2 == 1 && m % 2 == 1) {
		if(num[1] == 1 && num[2] <= (n + m - 2) / 2) printf("Yes"); else printf("No");
	} else if(n % 2 == 0 && m % 2 == 0) {
		if(num[1] == 0 && num[2] == 0) printf("Yes"); else printf("No");
	} else {
		int p = (n & 1) ? m : n;
		if(num[1] == 0 && num[2] <= p / 2) printf("Yes"); else printf("No");
	}
	return 0;	
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;


ll sum(ll n) {
  ll m=0;
  FOR(i,0,12){
    m+=n%10;
    n/=10;
  }
  return m;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

signed main() {
  ll n;
  	ci(n);
  vll A(n);
  vll B(n);
  vll C(n);
  
  FOR(i,0,n){
    ci(A[i])
    if(1<=i){
      A[i]+=A[i-1];
    }
  }
  
  FOR(i,0,n){
    ci(B[i])
    if(1<=i){
      B[i]+=B[i-1];
    }
  }
  C[0]=A[0]+B[n-1];
  FOR(i,1,n){
	C[i]=A[i]+B[n-1]-B[i-1];
  }
  ll ans=0;
  FOR(i,0,n){
    ans=M(ans,C[i]);
  }
  co(ans)
}

Measured memory_bytes: 256
s=input()
t=input()

t_l = len(t)
diff_min = 999999999

def diff_str(s1, s2):
    diff_c = 0
    for j in range(len(s1)):
        if s1[j] != s2[j]:
            diff_c += 1
    return diff_c

if len(s) == len(t):
    diff_min = diff_str(s, t)

for i in range(len(s)-t_l):
    seq=s[i:i+t_l]
    diff_c = diff_str(seq, t)
    if diff_c < diff_min:
        diff_min = diff_c


print(diff_min)





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

using namespace std;

double dp[3005][3005];

int main(){
	int n;
  	cin>>n;
  	double p;
  	double ans=0;
  	dp[0][0]=1;
  	for(int i=1;i<=n;++i){
      	cin>>p;
    	for(int j=0;j<=i;++j){
        	if(j){
              dp[i][j]+=dp[i-1][j-1]*p;
            }
          	dp[i][j]+=dp[i-1][j]*(1-p);
        }
    }
  	//cerr<<"testing\n";
  	for(int tails=0;tails<=n;++tails){
    	int heads=n-tails;
      	if(heads>tails){
          	//cout<<dp[n][heads]<<" ";
        	ans+=dp[n][heads];
        }
    }
  cout<<fixed<<setprecision(12)<<ans;
	return 0;
}

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

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

  int win = 0;

  for(int i=0;i<s.size();i++) {
    if(s[i] == 'o') win++;
  }

  if(win + 15 - s.size() >= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int K, T;
  while (cin >> K >> T) {
    vector<int> A(T);
    for (int i = 0; i < T; i++) cin >> A[i];
    int res = 0, pre = -1;
    for (int t = 0; t < K; t++) {
      int mx = 0, j = -1;
      for (int i = 0; i < T; i++) {
        if (i != pre && A[i] > mx) {
          mx = A[i];
          j = i;
        }
      }
      if (j == -1) j = pre;
      --A[j];
      res += j == pre;
      pre = j;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
H, W = gets.chomp.split.map(&:to_i)

arr = []
H.times do
  arr << gets.chomp
end

ans = []
for i in 0..(H + 1) do
  temp = ""
  for j in 0..(W + 1) do
    if i == 0 || i == H + 1 || j == 0 || j == W + 1
      temp += "#"
    else
      temp += arr[i - 1][j - 1]
    end
  end
  ans << temp
end

puts ans

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

using namespace std;
typedef long long ll;

int main(){
    string s;
    getline(cin, s);
    ll n0 = 0, n1 = 0;
    for(char c : s){
        if(c == '0'){
            n0++;
        }else{
            n1++;
        }
    }
    cout << min(n0, n1) * 2 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N, K;
vector<ll> a(5001, 0);

int main(void){
    
    scanf("%d %d", &N, &K);
    for(int i = 0; i < N; ++i) scanf("%lld", &a[i]);
    sort(a.begin(), a.begin() + N);
    
    int ans = N;
    ll sum = 0;
    for(int i = N - 1; i >= 0; --i){
        if((sum + a[i]) < K) sum += a[i];
        else ans = min(ans, i);
    }
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
def main():
	s = input()
	s+=" "
	n=len(s)

	ans=0
	c=0
	m=0
	a=s[0]
	for i in range(n):
		if s[i]!=a:
			if c%3==0:
				ans+=(c//3)*2;
			else:
				ans+=1+(c//3)*2
			if m==2 and c%3==2:
				ans+=1
				m=0
			elif c%3!=0:
				m=c%3
			c=1
		else:
			c+=1
		a=s[i]
	print(ans)
main()


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
typedef long long ll;

const int maxn = 110;

int w[maxn], v[maxn];
priority_queue<int> item[4];
int f[4][maxn];
int s[maxn];

int main()
{
	//freopen("D.in","r",stdin);
	int n,W;
	scanf("%d%d",&n,&W);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d",&w[i], &v[i]);
		if (i==1) 
		{
			item[0].push(v[1]);
			continue;
		}
		item[w[i] - w[1]].push(v[i]);
	}
	for (int i=0;i<=3;i++)
	{
		s[i] = item[i].size();
		f[i][0] = 0;
		int tmp = item[i].size();
		if (!item[i].empty()) f[i][1] = item[i].top(), item[i].pop();
		for (int j=2;j<=tmp;j++)
		{
			f[i][j] = f[i][j-1] + item[i].top();
			item[i].pop();
		}
	}
	
	int ans = 0;
	for (int i=0;i<=s[0];i++)
	{
		for (int j=0;j<=s[1];j++)
		{
			for (int k=0;k<=s[2];k++)
			{
				ll left = (ll)W - ((ll)i * (ll)w[1] + (ll)j * ((ll)w[1]+1ll) + (ll)k * ((ll)w[1]+2ll));
				//cout<<left<<endl;
				if (left < 0) continue;
				int l = (int)left / (w[1]+3);
				l = min(l,s[3]);
				ans = max(ans, f[0][i] + f[1][j] + f[2][k] + f[3][l]);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  ll N, C; cin >> N >> C;
  ll x[N+2]={}, v[N+2]={}; rep(i, N) cin >> x[i+1] >> v[i+1];
  x[N+1] = C; v[N+1] = 0;

  ll l[N+1]={}, r[N+1]={};
  ll ml[N+1]={}, mr[N+1]={};
  for (int i=1; i<=N; i++) { l[i] = l[i-1]+v[i]; ml[i] = max(ml[i-1], l[i]-x[i]); }
  for (int i=1; i<=N; i++) { r[i] = r[i-1]+v[N-(i-1)]; mr[i] = max(mr[i-1], r[i]-(C-x[N-(i-1)])); }

  // rep(i, N+1) cout << ml[i] << " "; cout << endl;
  // rep(i, N+1) cout << mr[i] << " "; cout << endl;
  ll result = 0;
  rep(i, N+1) result = max(result, ml[i]-x[i]+mr[N-i]);
  rep(i, N+1) result = max(result, mr[i]-(C-x[N-(i-1)])+ml[N-i]);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>


int bubbleSort(int A[], int N);

int main() {
  int N;
  int A[100];
  int result;
  int i;
  int count;

  scanf("%d", &N);
  for(i = 0; i < N; i++)
    {scanf("%d", A+i);
    }

  result = bubbleSort(A, N);
  
  for(i = 0; i < N; i++){
    if(i>0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
    printf("%d\n", result);

  return 0;
}

int bubbleSort(int A[], int N) {
  int j;
    
  int flag = 1;
  int tench;
    
  int result = 0;



  while(flag) {
    flag = 0;
    for(j = N-1; j > 0; --j) {
      
      if(A[j] < A[j-1]) {
	
        tench = A[j];
        A[j] = A[j-1];
	
        A[j-1] = tench;
        flag = 1;
	
        ++result;
      }
    }
  }
  return result;
}




Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
const double PI=3.14159265358979323846;
double a,b,x,y;

int main(void){
    cin >> a >> b >> x;    
    cout<<fixed<<setprecision(7);
    if(2.0*x<=a*a*b) cout << atan(a*b*b/(2.0*x)) / PI*180 << endl;
    else  cout << atan(2*b/a-2*x/(a*a*a)) /PI*180 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
int sz[200];
int kk[200];
vi grundy;
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n;cin >> n;
    FOR(i, n){
        cin >> sz[i];
        cin >> kk[i];
    }
    FOR(i, n){
        //computing grundy for ith pile
        int len = sz[i];
        int k = kk[i];
        while(len % k && len > k){
            int cycle = len/k + 1;
            int rem = len % k;
            if(rem % cycle == 0){
                len -= rem;
            }else{
               int times = rem/cycle; 
               len -= times*cycle;
               len -= cycle;
            }
        }
        if(len < k)grundy.pb(0);
        else grundy.pb(len/k);
    
    }
    int xr = 0;
    FOR(i, n){
        xr ^= (grundy[i]);
    }
    if(xr == 0)cout << "Aoki";
    else cout << "Takahashi";


}




Measured memory_bytes: 256
public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		long H = s.nextLong();
		long W = s.nextLong();
		System.out.println((H == 1 || W == 1) ? 1: (H*W+1)/2);
	}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
using namespace std;
#define MAX_N 100010

int main() {
  int N;
  cin >> N;
  int t[MAX_N];
  int a[MAX_N];
  int b[MAX_N];
  for (int i = 1; i <= N; i++) cin >> t[i] >> a[i] >> b[i];

  for (int i = 0; i < N; i++) {
    int T = t[i + 1] - t[i];
    int D = abs(a[i + 1] - a[i]) + abs(b[i + 1] - b[i]);
    if (T < D || T % 2 != D % 2) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;

int a, b;

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

  scan(a); scan(b);
//  vint s(n);
//  REP(i, n) scan(s[i]);

  if(a!=b) cout << 2*max(a,b)-1 << endl;
  else     cout << 2*a << endl;

  return 0;
}


Measured memory_bytes: 256
import java .util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	String inputS = sc.next();

	ArrayList<String>  slist = new ArrayList<>();
	ArrayList<String>  first = new ArrayList<>();
	ArrayList<String>  second = new ArrayList<>();

	for(int i = 0; i < inputS.length(); i++) {
		slist.add(inputS.substring(i, i+1));
	}

	for(int i = 0; i < (inputS.length() - 1) /2; i++) {
			first.add(slist.get(i));
	}

	for(int i = (inputS.length() + 3) / 2 -1; i < inputS.length(); i ++) {
		second.add(slist.get(i));
	}

	String str1 = String.join("", first);
	String str2 = String.join("", second);

	if(isPalindrome(str1) && isPalindrome(str2) && isPalindrome(inputS)) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	}

}

public static boolean isPalindrome(String sentence) {
    int minIdx = 0;
    int maxIdx = sentence.length() - 1;

    while(minIdx < maxIdx) {
        if(sentence.charAt(minIdx++) != sentence.charAt(maxIdx--)) {
            return false;
        }
    }
    return true;
}
}


Measured memory_bytes: 35748
while True:
    N,M=map(int,input().split())
    if N==0 and M==0:
        break
    allCards=[]
    for i in range(N+M):
        allCards.append(int(input()))
                        
    Taro=allCards[:N]
    Hanako=allCards[N:]
    Tsum=sum(Taro)
    Hsum=sum(Hanako)
    diff=Tsum-Hsum
    tempsum=1e8
    Tchange=-1
    Hchange=-1
    for i in range(N):
        for j in range(M):
            tempdiff=(Taro[i]-Hanako[j])*2
            if diff==tempdiff:
                if(tempsum>Taro[i]+Hanako[j]):
                    tempsum=Taro[i]+Hanako[j]
                    Tchange=Taro[i]
                    Hchange=Hanako[j]
    if Tchange==-1:
        print(-1)
    else:
        print(Tchange,Hchange)

Measured memory_bytes: 5612
def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


n, m, k = map(int, input().split())
MOD = 998244353
facts, invs = prepare(n, MOD)

ans = 0
for s in range(k + 1):
    p = n - s
    ans = (ans + m * pow(m - 1, p - 1, MOD) * facts[n - 1] * invs[s] * invs[n - s - 1]) % MOD
print(ans)


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

const long long mod = 1e9 + 7;

long long pow_mod(long long n, long long  k, long long m) {
  if ( k == 0 ) { return 1; }
  if ( k%2 == 0 ) {
    long long t = pow_mod(n, k/2, m);
    return t*t % m;
  }
  return n * pow_mod(n, k-1, m) % m;
}

long long comb_mod(long long n, long long r, long long m) {
  if ( r == 0 ) { return 1; }

  long long x = 1;
  for ( long long i = 1; i <= r; i++ ) {
    x *= n - r + i;
    x %= m;
  }

  long long y = 1;
  for ( long long i = 1; i <= r; i++ ) {
    y *= i;
    y %= m;
  }

  return x * pow_mod(y, m-2, m) % m;
}

int main() {
  long long x, y;
  cin >> x >> y;
  long long ans = 0;
  
  if ( (x+y)%3 == 0 ) {
    long long x1_y2 = (2*y - x) / 3;
    long long x2_y1 = y - 2*x1_y2;
    if ( x1_y2 >= 0 && x2_y1 >= 0 ) {
      ans = comb_mod(x1_y2+x2_y1, x1_y2, mod);
    } 
  }

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


Measured memory_bytes: 3568
#include <stdio.h>
int main() {
	int a[3];
	int tmp;
	for (int i = 0; i < 3; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < 3; i++) {
		for (int j = 2; j > i; j--) {
			if (a[j] < a[j-1]) {
				tmp = a[j-1];
				a[j-1] = a[j];
				a[j] = tmp;
			}
		}
	}
	for (int i = 0; i < 3; i++) {
		printf("%d", a[i]);
		if (i != 2) {
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
struct kkk{
	int lt,nt;
	char c;
}a[N];
int n,ans;
void clrs(int i,int j){
	a[a[i].lt].nt=a[j].nt;
	a[a[j].nt].lt=a[i].lt;
}
int main(){
	//freopen("in.txt","r",stdin);
	//freopen("data.txt","w",stdout);
	char ch;
	a[0].nt=1;
	for(int i=1,ch=getchar();ch!=EOF&&ch!='\n';++i,ch=getchar()){
		a[i].c=ch;
		a[i].lt=i-1;
		a[i].nt=i+1;
		++n;
	}
	a[n+1].lt=n;
	ans=n;
	for(int i=1;i<n;i=a[i].nt){
		if(a[i].c=='S'&&a[a[i].nt].c=='T'){
			i=a[i].lt;
			clrs(a[i].nt,a[a[i].nt].nt);
			i=a[i].lt;
			ans-=2;
		}
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>


template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


template< typename T >
vector<T> dijkstra(WG<T> &g,int s){
  const auto lim = numeric_limits<T>::max();
  vector<T> dist(g.size(),lim);
  using Pi = pair<T,int>;
  priority_queue<Pi,vector<Pi>,greater<Pi>> q;
  dist[s] = 0;
  q.emplace(dist[s],s);
  while(!q.empty()){
    T cost;
    int idx;
    tie(cost,idx) = q.top();
    q.pop();
    if(dist[idx] < cost) continue;
    for( auto &e : g[idx]){
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      q.emplace(dist[e.to],e.to);
    }
  }
  return dist;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int xs,ys,xt,yt;
  cin>>xs>>ys>>xt>>yt;
  vector<IP> v;
  v.PB(IP(0,P(xs,ys)));
  v.PB(IP(0,P(xt,yt)));

  int n;
  cin>>n;
  rep(i,n){
    int x,y,r;
    cin>>x>>y>>r;
    v.PB(IP(r,P(x,y)));
  }

  WG<double> es(n+2);

  rep(i,n+2){
    rep(j,n+2){
      if(i==j) continue;
      int x1=v[i].S.F,x2=v[j].S.F;
      int y1=v[i].S.S,y2=v[j].S.S;
      double dist=max(0.0,sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))-v[i].F-v[j].F);
      es[i].PB(edge<double>(i,j,dist));
    }
  }

  vector<double> dist = dijkstra(es,0);
  cout<<dist[1]<<endl;

}

Measured memory_bytes: 30468
#include <bits/stdc++.h>
using namespace std;
     
int main() {
    int N;
    cin >> N;
    int a;
    a=50;
    for(int i=0;i<N;i++){
        int b;
        cin>>b;
        for(int j=0;j<100;j++){
            if(b%2==1){
                if(a>j){
                    a=j;
                }
                //cout <<j<< endl;
                break;
            }
            else {
                b/=2;
            }
        }
    }
    cout << a <<endl;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	[a, b, c, k] <- readIntToList <$> BS.getLine
	print $ if k <= a
		then k
		else if k <= a + b
			then a
			else a - (k - a - b)

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

int main(){
  double a,b,c,d;
  double s,l,h;
  double pi = 3.141592653589793;
  
  cin>>a>>b>>c;
  d = a*a+b*b-2*a*b*cos(c*pi/180);
  
  l = a+b+sqrt(d);
  s = a*b*sin(c*pi/180)/2;
  h = b*sin(c*pi/180);
  
  cout<<fixed<<s<<endl<<l<<endl<<h<<endl;
  return 0;
}



Measured memory_bytes: 3496
// Problem : A - AtCoDeer and Paint Cans
// Contest : AtCoder - AtCoder Beginner Contest 046
// URL : https://atcoder.jp/contests/abc046/tasks/abc046_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	set<int> s;
	int a, b, c;
	cin >> a >> b >> c;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	cout << s.size();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
/*------------------------------------------------------------*/
int n,m;
int main(){
	int a,b;
	in3(n,a,b);
	out(min(b,a*n));
}
	

Measured memory_bytes: 764
#include<stdio.h>
int main()
{
	int n;
	int a[60];
	int b[60];
	int c[60];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=i+1;
	}
	int k=0;
	 for(int i=n-1;i>=0;i--)
	 {
	 	
	 	if(a[i]!=i+1)
	 	{
	 		for(int j=0;j<n;j++)
	 		{
	 			if(a[j]==i+1)
	 			{
	 				int t=a[j];
	 				a[j]=a[i];
	 				a[i]=t;
	 				break;
				 }
			 }
			 int sum1=0;
			 for(int j=0;j<n;j++)
			 {
			 	if(a[j]==b[j]) sum1++; 
			 }
			 if(sum1==n) printf("YES\n");
			 else printf("NO\n");
			 break;
		 }
	 	else k++;
	 }
	 if(k==n) printf("YES\n");
    return 0; 
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
bool DP(int n,int k,vector<int> &a,int ex){
    vector<vector<bool>> dp(n+1,vector<bool> (k+1,false));
    dp[0][0]=true;
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            dp[i+1][j]=dp[i+1][j]||dp[i][j];
            if(i!=ex) dp[i+1][min(k,j+a[i])]=dp[i+1][min(k,j+a[i])]||dp[i][j];
        }
    }
    for(int j=max(0,k-a[ex]);j<k;j++){
        if(dp[n][j]) return true;
    }
    return false;
}
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    int noneed=-1,need=n;
    while(noneed+1<need){
        int mid=(noneed+need)/2;
        auto itr=lower_bound(a.begin(),a.end(),a[mid]);
        if(DP(n,k,a,itr-a.begin()))need=itr-a.begin();
        else noneed=upper_bound(a.begin(),a.end(),a[mid])-a.begin()-1;
    }
    cout << need << endl;
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main(void) {
	string in;
	int countj, counti;
	int i;

	while(true) {
		cin >> in;
		if(cin.eof()) { break; }
		countj = counti = 0;
		for(i = 0; i < (int)in.size()-2; i++) {
			if(in[i] == 'J' && in[i+1] == 'O' && in[i+2] == 'I') {
				countj++;
			} else if(in[i] == 'I' && in[i+1] == 'O' && in[i+2] == 'I') {
				counti++;
			}
		}
		cout << countj << endl << counti << endl;
	}

	return 0;
}

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

using namespace std;

int main() 
{
    int n, x, y, z, i;
    scanf("%d", &n);
    
    multiset<int> s;
    
    for(i = 0; i < n; i++)
    {
        scanf("%d %d", &x, &y);
        
        if(x == 0)
        {
            s.insert(y);
            printf("%d\n", (int)s.size());
        }
        else if(x == 1)
        {
            printf("%d\n", (int)s.count(y));
        }
        else if(x == 2)
        {
            s.erase(y);
        }
        else if(x == 3)
        {
            scanf("%d", &z);
            
            auto L = s.lower_bound(y);
            auto R = s.upper_bound(z);
            
            while(L != R)
            {
                printf("%d\n", *L);
                L++;
            }
        }
    }
    
    return 0;
}


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

int main () {
    int N, M; cin >> N >> M;
    int C = N + 1;
    vector<int> T(N);
    for (int i = 0; i < N; i++) T[i] = i + 1;

    for (int i = 0; i < M; i++) {
        int x, y; cin >> x >> y;
        x = T[x-1], y = T[y-1];
        for (auto &j : T) {
            if (j == x || j == y) j = C;
        }
        C++;
    }

    set<int> u, l;
    for (auto i : T) {
        if (i > N) u.insert(i);
        else l.insert(i);
    }

    cout << abs((int)u.size() - (int)l.size()) << endl;

    return 0;
}

Measured memory_bytes: 3172
s = list(input())
t = list(input())
ls = len(s)
lt = len(t)
res = -1
for i in range(ls-lt, -1, -1):
    flag = True
    for j in range(lt):
        if s[i+j] == "?":
            pass
        elif s[i+j] == t[j]:
            pass
        elif s[i+j] != t[j]:
            flag = False
    if flag:
        res = i
        break
if res == -1:
    print("UNRESTORABLE")
else:
    s[res:res+lt] = t
    for i in range(ls):
        if s[i] == "?":
            s[i] = "a"
    print("".join(s))





Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    for (int i=a; i<a+k && i<=b; i++) cout<<i<<'\n';
    for (int i=b+1-k; i<=b; i++)
    {
        if (i>=a+k) cout<<i<<'\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int a[2];
    cin>>a[0]>>a[1];
    if(1!=a[0]&&1!=a[1]) cout<<1<<endl;
    else if(2!=a[0]&&2!=a[1]) cout<<2<<endl;
    else cout<<3<<endl;
    return 0;
}

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

using namespace std;

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

  return 0;
}

Measured memory_bytes: 3596
using System;

namespace B___Toll_Gates
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var m = int.Parse (input[1]);
            var x = int.Parse (input[2]);
            var a = new int[m];
            var count1 = 0;
            var count2 = 0;
            input = Console.ReadLine ().Split (' ');
            for (var i = 0; i < m; i++)
            {
                a[i] = int.Parse (input[i]);
            }
            for (var i = x; i < n; i++)
            {
                for (var j = 0; j < m; j++)
                {
                    if (i == a[j])
                    {
                        count1++;
                    }
                }
            }
            for (var i = x; i >= 0; i--)
            {
                for (var j = 0; j < m; j++)
                {
                    if (i == a[j])
                    {
                        count2++;
                    }
                }
            }
            Console.WriteLine (Math.Min (count1, count2));
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cmath>

using ll = unsigned long long;

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

ll calc( ll x, ll c, ll d, ll l ) {
    ll xc = x / c;
    ll xd = x / d;
    ll xl = x / l;
    return x - ( xc + xd - xl );
}

int main() {
    ll A, B, C, D;
    ll lb, ub, g, l;
    std::cin >> A >> B >> C >> D;
    g = gcd( C, D );
    l = (C * D) / g;
    ub = calc( B, C, D, l );
    lb = calc( A-1, C, D,  l );
    std::cout << ub - lb << std::endl;
    return 0;
}


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

int main(){
	int n,t,a ;
	cin >> n >> t >> a ;
	double mn = 100000 ;
	int pos = 1 ;
	for(int i=0;i<n;i++){
		double h ; cin >> h ;
		double tem = (double)t-h*0.006 ;
		if(tem>a) tem = tem-(double)a ;
		else tem = (double)a-tem ;
		if(mn>tem){
			mn = tem ;
			pos = i+1 ;
		}
	}
	cout << pos << endl ;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a[2000005],n,k;
int f(int t)//判断能否经过最多k次全部化为小于t的
{
    int cnt=0;
    for(int i=0; i<n; i++)
    {
        cnt+=(a[i]/t);
        if(a[i]%t==0&&a[i]>0)
            cnt--;
        if(cnt>k)
            return 0;
    }
    return 1;
}
int main()
{
    cin>>n>>k;
    int ans=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        ans=max(ans,a[i]);
    }
    int l=1,r=ans;
    while(l<r-2)
    {
        int mid=(l+r)/2;
        if(f(mid))
            r=mid;
        else l=mid;
    }
   for(l;l<=r;l++)
   {
       if(f(l))
       {
           cout<<l<<endl;
           break;
       }
   }

}


Measured memory_bytes: 4336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;


int main(void)
{
    bool is_p;
    vector<int> p;
    p.push_back(2);
    p.push_back(3);
    lpsbd(i, 5, 100, 2)
    {
        is_p = true;
        fa(j, p)
        {
            if (!(i % j))
            {
                is_p = false;
                break;
            }
            if (j*2 > i) break;
        }
        if (is_p) p.push_back(i);
    }
    int N;
    cin >> N;
    int s = p.size();
    auto count = vcd(int, s, 0);
    int temp;
    for (int i = 1; i <= N; i++)
    {
        lpn(j, s)
        {
            if (i < p[j]) break;
            temp = i;
            while (!(temp % p[j]))
            {
                count[j] ++;
                temp /= p[j];
            }
        }
    }
    int kind[5] = {2, 4, 14, 24, 74};
    int count2[5] = {0};
    fa(j, count)
    {
        lpn(i, 5)
        {
            if (j >= kind[i]) count2[i]++;
            else break;
        }
    }
    int ans = count2[1] * (count2[1]-1) * (count2[0]-2) / 2 + count2[2] * (count2[1]-1) + count2[3] * (count2[0]-1) + count2[4];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
array = list(input())
leng = len(array)
answer = ["" for i in range(leng)]
for i in range(leng):
    if array[i].isupper():
        answer[i] = array[i].lower()
    elif array[i].islower():
        answer[i] = array[i].upper()
    else:
        answer[i] = array[i]
        
print("".join(map(str, answer)))
        
            
    


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    
    ll ans = a*c;
    if(a*d > ans)
        ans = a*d;
    if(b*c > ans)
        ans = b*c;
    if(b*d > ans)
        ans = b*d;


    cout << ans << endl;    

}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var Q = ReadLong();
            var L = new long[Q];
            var R = new long[Q];
            for (int i = 0; i < Q; i++)
            {
                (L[i], R[i]) = Read2Longs();
            }

            var es = new EratosthenesSieve(100000);
            var like2017 = new bool[100001];
            for (int i = 1; i <= 100000; i++)
            {
                var m = (long)(i + 1) / 2;
                if (es.IsPrime[i] && es.IsPrime[m])
                {
                    like2017[i] = true;
                }
            }
            var ruiseki = new long[100001];
            for (int i = 1; i <= 100000; i++)
            {
                ruiseki[i] = ruiseki[i - 1] + (like2017[i] ? 1 : 0);
            }

            var sb = new StringBuilder();
            for (int i = 0; i < Q; i++)
            {
                var count = ruiseki[R[i]] - ruiseki[L[i] - 1];
                sb.AppendLine(count.ToString());
            }

            return sb.ToString().Trim();
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
    public class EratosthenesSieve
    {
        public List<long> Primes { get; private set; }
        public Dictionary<long, bool> IsPrime { get; private set; }

        public EratosthenesSieve(long max)
        {
            Primes = new List<long>();
            IsPrime = new Dictionary<long, bool>();
            for (long i = 1; i <= max; i++)
            {
                IsPrime.Add(i, false);
            }

            for (long i = 2; i <= max; i++)
            {
                IsPrime[i] = true;
            }

            for (long i = 2; i <= max; i++)
            {
                if (IsPrime[i])
                {
                    Primes.Add(i);
                    for (long j = 2 * i; j <= max; j += i)
                    {
                        IsPrime[j] = false;
                    }
                }
            }
        }
    }
}


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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int k = 0;
  int i = 0;
  int len = 2;
  int n = s.size();
  while (i < n) {
    if (len == 2) {
      len = 1;
      ++i;
    } else if (i == 0) {
      len = 1;
      ++i;
    } else if (s[i] != s[i - 1]) {
      len = 1;
      ++i;
    } else {
      if (i == n - 1) {
        --k;
      }
      len = 2;
      i += 2;
    }
    ++k;
  }
  cout << k << endl;
  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<string> grid(n);
	for (int i=0; i<n; i++) {
		cin >> grid[i];
	}
	vector< vector<int> > dp(n, vector<int>(m, 0));
	
	for(int i=0; i<n; i++) {
		if (grid[0][i]=='#')
			break;
		dp[0][i]=1;
	}
	
	for(int i=0; i<n; i++) {
		if (grid[i][0]=='#')
			break;
		dp[i][0]=1;
	}
	
	for(int i=1; i<n; i++) {
		for (int j=1; j<m; j++) {
			if (grid[i][j]=='.')
				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
		}
	}
	
	cout << dp[n-1][m-1] << endl;
}

Measured memory_bytes: 5248
import numpy as np


def main():
    n, x = map(int, input().split())
    ls = np.array(list(map(int, input().split())))
    ans = 1
    h = 0
    for l in ls:
        h += l
        if h <= x:
            ans += 1
        else:
            break
    print(ans)


if __name__ == "__main__":
    main()


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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  vector<int64_t>B(N);
  int64_t b=0;
  for(int i=0;i<N;i++){
  if(0<=A.at(i))b+=A.at(i);
    B.at(i)=b;
  }vector<int64_t>C(N-K+1);
  int64_t c=0;
  for(int i=0;i<K;i++)
    c+=A.at(i);
  C.at(0)=c;
  for(int i=1;i<=N-K;i++)
    C.at(i)=C.at(i-1)-A.at(i-1)+A.at(K+i-1);
  int64_t ans=0;
  for(int i=0;i<=N-K;i++){
  int64_t d=B[N-1]-B[K+i-1];
    if(0<=C[i])d+=C[i];
    if(0<=i-1)d+=B[i-1];
    if(ans<d)
      ans=d;
  }cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
int dp[100005][3];
int main()
{
    int n;
    cin >> n;
    
    
    for (int i = 1; i <= n; i++)
    {
        vector<int> c(3);

        for (int j = 0; j < 3; j++)
            cin >> c[j];

        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (j != k) //for currrent k find max of previous
                    dp[i][k] = max(dp[i][k], c[k] + dp[i - 1][j]);
            }
        }
    }
    cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << endl;

    return 0;
}

Measured memory_bytes: 1408
N = int(input())
h = list(map(int,input().split()))


dp = [float("inf")]*len(h)
dp[0] = 0


for i in range(1, len(h)):
    if(i == 1):
        dp[i] = h[i]
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))

print(dp[N-1])

Measured memory_bytes: 13980
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}


int main(void){
    int nums[3] = {0};
    int n, s;
    int cnt = 0;
    scanf("%d %d", &n, &s);
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= n; j++){
            nums[0] = i;
            nums[1] = j;
            nums[2] = s-i-j;
            if (nums[2] >= 0 && nums[2] <= n){
                cnt++;
            }
        }
    }

    printf("%d\n", cnt);
}



Measured memory_bytes: 128