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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
   fast;
   int n;
   cin >> n;
   map<int,int>m;
   f(i,0,n-1){
      int a;
      cin >> a;
      m[a]++;
   }

   f(i,1,n+1){
      cout << m[i] << "\n";
   }
}

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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	string s,t;
	cin>>s>>t;
	int n = s.size();
	int m = t.size();
	vector<vector<int>> l(26);
	for(int i=0;i<n;i++){
		l[s[i] - 'a'].push_back(i);
	}
	int at = -1;
	ll ans = 0;
	for(int i=0;i<m;i++){
		int cur = t[i] - 'a';
		if(l[cur].size() == 0){
			cout << -1 << endl;
			return 0;
		}
		auto it = upper_bound(l[cur].begin(),l[cur].end(),at);
		if(it == l[cur].end())
			it = l[cur].begin();
		int k = it - l[cur].begin();
		k = l[cur][k];
		ll dist = k - at;
		if(dist <= 0)
			dist += n;
		ans += dist;
		at = k;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1228
#include<iostream>
#include<vector>
#include<set>

using namespace std;

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

    int l;
    cin >> l;

    vector<int> v;
    set<int> st;

    int ans = -1;
    for(int i = 1 ; i <= l ; ++i){
        int c;
        cin >> c;

        if(c > 0){
            if(st.count(c)){
                ans = i;
                break;
            }
            v.emplace_back(c);
            st.insert(c);
        }else{
            if(v.empty() || v.back() != -c){
                ans = i;
                break;
            }
            v.pop_back();
            st.erase(-c);
        }
    }

    if(ans > 0){
        cout << ans << endl;
    }else{
        cout << "OK" << endl;
    }

    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    string s;
    cin >> s;
    int length = s.length();
    cout << s[0] << length - 2 << s[length - 1] << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

using ll = long long;
using P = pair<int,int>;

struct Hoge {
  int x, y, c;
  Hoge(int _x, int _y, int _c) : x(_x), y(_y), c(_c) {}
  bool operator < (const Hoge& a) const {
    return c > a.c;
  }
};

int main() {
  int h, w;
  int ch, cw;
  int dh, dw;

  cin >> h >> w;
  cin >> ch >> cw;
  cin >> dh >> dw;

  ch--; cw--;
  dh--; dw--;

  vector<string> t(h);
  vector<vector<int>> v(h, vector<int>(w, -1));
  rep(i, h) cin >> t[i];

  priority_queue<Hoge> que;

  que.push(Hoge(cw, ch, 0));
  while(!que.empty()) {
    Hoge cur = que.top();
    que.pop();

    int x = cur.x;
    int y = cur.y;
    int c = cur.c;

    // cout << x << ' ' << y << ' ' << c << endl;
    if(v[y][x] != -1) continue;
    v[y][x] = c;

    int dx[] = { 0, 1, 0, -1, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2 };
    int dy[] = { -1, 0, 1, 0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 };
    int dc[] = { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };

    rep(i, 28) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      int nc = c + dc[i];

      if(nx < 0 || nx >= w) continue;
      if(ny < 0 || ny >= h) continue;
      if(t[ny][nx] != '.') continue;
      if(v[ny][nx] != -1) continue;

      // cout << "-> " << nx << ' ' << ny << ' ' << nc << endl;

      que.push(Hoge(nx, ny, nc));
    }
  }

  // rep(y, h) {
  //   rep(x, w) {
  //     cout << v[y][x] << ' ';
  //   }
  //   cout << endl;
  // }

  cout << v[dh][dw] << endl;
  return 0;
}


Measured memory_bytes: 10776
S=input()

i=0
ans,temp=0,0
while(i<len(S)):
    if(S[i]=='A' or S[i]=='T' or S[i]=='G' or S[i]=='C'):
        temp+=1
        ans=max(ans,temp)
    else:
        temp=0
    i+=1

print(ans)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    string c1, c2, c3;
    cin >> c1 >> c2 >> c3;
    cout << c1[0] << c2[1] << c3[2] << endl;
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
 
const int N = int(2e5) + 2; 
const int LG = 20;
const ll mod = 998244353;
const int INF = 2147483647;
const ll linf = 1e18;
const ld pi = acos(-1);
const ld EPS = 1e-10;

int n;
int main (){
	scanf ("%d", &n);
	ll kek = n - 1;
	ll ans = (kek * (kek + 1)) / 2;
	return !printf ("%lld\n", ans);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] D = new long[5];
    for (int i = 0; i < N; i++) {
      String name = sc.next();
      if (name.charAt(0) == 'M') D[0]++;
      if (name.charAt(0) == 'A') D[1]++;
      if (name.charAt(0) == 'R') D[2]++;
      if (name.charAt(0) == 'C') D[3]++;
      if (name.charAt(0) == 'H') D[4]++;
    }
    long res = 0;
    for (int i = 0; i < 5; i++) {
      for (int j = i+1; j < 5; j++) {
        for (int k = j+1; k < 5; k++) {
          res += D[i] * D[j] * D[k];
        }
      }
    }
    System.out.println(res);
  }
}


Measured memory_bytes: 46944
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
answer = N
# 6円で払う部分と9円で払う部分を分ける
for i in range(N+1):
    temp = 0
    six_pay = i
    while six_pay:
        temp += six_pay%6
        six_pay //= 6
    nine_pay = N - i
    while nine_pay:
        temp += nine_pay%9
        nine_pay //= 9
    if temp < answer:
        answer = temp

print(answer)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
    ll ans=1;
    for(int i=1; i<=n; i++)
        ans*=a;
    return ans;
}

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

    ll n,m,k,ans=0,sum=0,left;
    cin>>n>>m>>k;
    left=0;
    for(int i=0; i<n; i++)
    {
        cin>>A[i];
    }
    for(int i=0; i<m; i++)
        cin>>B[i];
    for(int i=0; i<n; i++)
    {
        sum+=A[i];
        if(sum>k)
        {
            sum-=A[i];
            break;
        }
        left++;
    }
    ans=max(ans,left);
    for(int i=0; i<m; i++)
    {
        sum+=B[i];
        if(sum>k&&left>0)
        {
            sum-=A[left-1];
            left--;
        }
        if(sum<=k)
        {
            ans=max(ans,left+i+1);
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 6788
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
//
int main(){
    int W,H,N;
    cin>>W>>H>>N;
    int x, y, a;
    int yu=H, yd=0, xr=W, xl=0;
    FOR(i, 0, N){
        cin>>x>>y>>a;
        if(a==1) xl = max(x, xl);
        if(a==2) xr = min(x, xr);
        if(a==3) yd = max(y, yd);
        if(a==4) yu = min(y, yu);
    }
    cout << (xr-xl>0?xr-xl:0) * (yu-yd>0?yu-yd:0) << endl;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
c = Array.new(n, false)
x = 0
z = []
num = -1
f_loop1 = false
f_loop2 = false
k.times do
  if c[x] == false
    c[x] = true
    if f_loop1
      z << x
    else
      num += 1
    end
  else
    if f_loop1
      f_loop2 = true
      break
    else
      c = Array.new(n, false)
      f_loop1 = true
      c[x] = true
      z << x
    end
  end
  x = a[x] - 1
end
if f_loop1 && f_loop2
  x = (k - num - z.length) % z.length
  puts z[x - 1] + 1
else
  puts x + 1
end


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main() 
{
    int n;
    cin>>n;
    cout<<2*3.14*n<<endl;
   return 0;
}

Measured memory_bytes: 3772
import numpy as np


def f(n, k, a_s):
    md = 10 ** 9 + 7
    dp = np.zeros(k + 1, dtype=np.int64)
    dp[0] = 1
    for a in a_s[:-1]:
        dp = np.cumsum(dp) % md
        if k != a:
            dp[k:a:-1] = (dp[k:a:-1] - dp[k - a - 1::-1]) % md
    return np.sum(dp[k - a_s[-1]:]) % md


n, k = map(int, input().split())
a_s = list(map(int, input().split()))
print(f(n, k, a_s))


Measured memory_bytes: 14744
import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        long a=sc.nextLong();
        long b=sc.nextLong();
        long c=sc.nextLong();
        long m=4*a*b;
        long n=c*c+b*b+a*a+2*a*b-2*a*c-2*b*c;
        if(m>=n||c<=a+b)
            System.out.print("No");
        else
            System.out.print("Yes");

    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
int main() {
     int N;
     cin >> N;
     bool ans = true;
     vector<string> W(N);
     for(int i = 0; i < N; i++){
          cin >> W[i];
     }

     for(int i = 1; i < N; i++){
          if(W[i].front() != W[i - 1].back()){
               ans = false;
               break;
          }
          for(int j = 0; j < i; j++){
               if(W[j] == W[i]){
                    ans = false;
                    break;
               }
          }
          if(ans == false) break;
     }

     if(ans == true) cout << "Yes" << endl;
     else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
/* DSU 
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    rank[v] = 0;
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap(a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            rank[a]++;
    }
}
*/ 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
 
ll mod(ll a, ll b) {return (a % b + b) % b;}
 
ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
 
using namespace std;

int main()
{
	fast;
	ll n; cin>>n; string s; cin>>s;
	stack<char>sta; vector<ll>v;
	for(ll i = 0; i < s.size(); i++)
	{
		if(s[i] == '(') sta.push('(');
		else if(s[i] == ')')
		{
			if(sta.empty())
			{
				v.push_back(i);
			}
			else
			{
				sta.pop();
			}
		}
	}
	for(ll i = 0; i < v.size(); i++)
	{
		s = "(" + s;
	}
	while(!sta.empty())
	{
		s = s + ')';
		sta.pop();
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
const int N = 1e5 + 10;

int n;
vector<int> G[N];
vector<int> V;
bool used[N];
bool dfs(int u) {
	used[u] = 1;
	if (u == n) {
		V.push_back(n);
		return 1;
	}
	for (int i = 0; i < G[u].size(); ++i) {
		int t = G[u][i];
		if (!used[t] && dfs(t)) {
			V.push_back(u);
			return 1;
		}
	}
	return 0;
}

int col[N];

void dfs2(int u, int c) {
	col[u] = c;
	for (int i = 0; i < G[u].size(); ++i) {
		int v = G[u][i];
		if (col[v]) continue;
		dfs2(v, c);
	}
}

int main() {
	cin >> n;
	for (int i = 1; i < n; ++i)	{
		int u, v;
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}

	dfs(1);
	for (int i = 0; i < V.size() / 2; ++i) col[V[i]] = 2;
	for (int i = V.size() / 2; i < V.size(); ++i) col[V[i]] = 1;
	for (int i = 0; i < V.size(); ++i) dfs2(V[i], col[V[i]]);
	int cnt1 = 0, cnt2 = 0;
	for (int i = 1; i <= n; ++i) if (col[i] == 1) cnt1++; else cnt2++;
	if (cnt1 > cnt2) cout << "Fennec" << endl; else cout << "Snuke" << endl;
}

Measured memory_bytes: 9848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;

#define M 998244353

std::vector<ll> fac(300001); //n!(mod M)
std::vector<ll> ifac(300001); //k!^{M-2} (mod M)

//x^n(mod M)d
ll
mpow(ll x, ll n)
{
    ll ans = 1;
    while (n > 0){
        if (n & 1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

void
cominit()
{
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < 300000; i++){
        fac[i+1] = fac[i] * (i+1) % M; // n! mod M
        ifac[i+1] = ifac[i] * mpow(i+1, M-2) % M; // k!^{M-2} mod M
    }
}


ll
comb(ll a, ll b)  // aCb mod M
{
    if (a == 0 && b == 0) return 1;
    if (a < b || a < 0) return 0;
    ll tmp = ifac[a-b] * ifac[b] % M;
    return tmp * fac[a] % M;
}


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

    ll res = 0;
    for (ll i = 0; i <= k; ++i) {
        res += m * mpow(m-1, n-(i+1))%M * comb(n-1, i) % M;
        res = (res + M) % M;
    }
    cout << res << endl;
}


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

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(a) cout << #a << ": " << a << endl;

int main() {
  int N, M;
  cin >> N >> M;

  vector<pair<ll, int>> price_number(N);
  rep(i, N) {
    ll A;
    cin >> A;
    int B;
    cin >> B;
    price_number[i] = make_pair(A, B);
  }

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

  int m = M;
  ll sumPrice = 0;
  rep(i, N) {
    if (m >= price_number[i].second) {
      m -= price_number[i].second;
      sumPrice += price_number[i].first * price_number[i].second;
    } else {
      sumPrice += price_number[i].first * m;
      break;
    }
  }
  cout << sumPrice << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll n;
    cin>>n;
    ll ans = 0;
    forn(i, 1, n){
        ll x = n/i;
        if(i*x==n){
            x--;
        }
        ans+=x;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3676
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define pop pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define M  1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }
ll f(ll n,ll m,ll d){
    if(n>m){
        return I;
    }
    if(n==m){
        return d;
    }
    ll d1=f(n*2,m,d+1);
    ll d2=f(n*3,m,d+1);
    return min(d1,d2);
}
int main()
{
    jaldi
    #ifndef ONLINE_JUDGE 
    //TakeInput
    #endif
    ll n,m;
    cin>>n>>m;
    ll i,j,k;
    string a[n];
    in(i,n){
        cin>>a[i];
    }
    ll dp[n][m];
    in0(dp);
    in(i,m){

        if(a[0][i]=='#')break;
        dp[0][i]=1;
    }
    in(i,n){
        if(a[i][0]=='#')break;
        dp[i][0]=1;
    }
    fon(i,1,n){
        fon(j,1,m){

            if(a[i][j]=='#'){
                dp[i][j]=0;
            }
            
            else if(i-1>=0  && j-1>=0){
                dp[i][j]=(dp[i-1][j]%M+dp[i][j-1]%M)%M;
            }
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<dp[n-1][m-1];




}
 
 








 



Measured memory_bytes: 9088
#pragma GCC optimize "-O3"
#include <iostream>
unsigned long long ans(0);

int main() {
	std::string S;
	std::getline(std::cin,S);
	unsigned long long offset = 0;
	unsigned long long addnum = 0;
	for (auto itr : S) {
		if(itr == 'W'){
			ans += offset;
			ans += addnum;
			offset += addnum;
			addnum = 0;
		}
		if(itr == 'B'){
			addnum ++;
		}
	}
	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 640
S_list = list(input())
odd_list = S_list[0::2]
even_list = S_list[1::2]
ans = 'Yes'
for s in even_list:
    if s not in ['L', 'U', 'D']:
        ans = 'No'
for s in odd_list:
    if s not in ['R', 'U', 'D']:
        ans = 'No'
print(ans)


Measured memory_bytes: 2940
# given an array of Heights, jump from 1 to N with at most K sized jump to N
# each jump incurs abs(H[j] - H[i]) cost
# minimize cost of jumps from 1 to N
#
def frog(H, k):
    if k > len(H):
        k = len(H)
    n = len(H)
    K = [0] * n
    inf = float("inf")
    for i in range(n):
        cost = 0
        if i > 0:
            maxjump = i if i < k else k # min(i, k)
            cost = inf
            hi = H[i]
            # jump source going backwards from i-1 (smallest 1 sized jump) to i - maxjumps
            for j in range(i - 1, i - maxjump - 1, -1):
                jcost = abs(hi - H[j]) + K[j]
                if jcost < cost:
                    cost = jcost
        K[i] = cost
    return cost

assert frog([40, 10, 20, 70, 80, 10, 20, 70, 80, 60], 4) == 40
assert frog([10, 10], 100) == 0
assert frog([10, 20, 10], 1) == 20

if __name__ == "__main__":
    import sys
    s = sys.stdin.read()
    N, k, *H = map(int, s.split())
    ans = frog(H, k)
    print(ans)


Measured memory_bytes: 14612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, T;
vector<l_l> V;
ll dp[3005][3005];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> T;
    V.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> V[i].first >> V[i].second;
    }
    V.push_back({-1, -1});
    sort(V.begin(), V.end());
    ll ans = 0;
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j < T; j++) {
            chmax(ans, dp[i-1][j] + V[i].second);
            chmax(dp[i][j], dp[i-1][j]);
            if(j - V[i].first >= 0) chmax(dp[i][j], dp[i-1][j-V[i].first] + V[i].second);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 70784
#include<stdio.h>

int main (void){

int n;

int i;

int a[10000];

int max;

int min;

long int totall=0;

scanf("%d",&n);

for(i=0;i<n;i++){

scanf("%d",&a[i]);

}

max=min=a[0];

for(i=0;i<n;i++){

if(max<a[i]){

max=a[i];

}

if(min>a[i]){

min=a[i];

}

totall=totall+a[i];

}

printf("%d %d %ld\n",min,max,totall);

return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;
ll inf = 100000000007ll;

string s, t;
int ssz, tsz;

map<char,set<ll>> mcs;

ll succ(int from, char c)
{
  return *(mcs[c].upper_bound(from));
}

ll solve(int from, int t_ind)
{
  if(t_ind == tsz) return from;
  ll spos = succ(from, t[t_ind]);
  if(spos >= ssz) return solve(spos-ssz, t_ind+1) + ssz;
  else return solve(spos, t_ind+1);
}

int main(void)
{
  cin >> s >> t;
  ssz = s.size();
  tsz = t.size();

  ll exist[200]={};
  for(auto c:s) ++exist[c];
  for(auto c:t) {
    if(!exist[c]) {
      cout << -1 << endl;
      return 0;
    }
  }

  REP(i, ssz) {
    mcs[s[i]].insert(i);
    mcs[s[i]].insert(i+ssz);
  }

  cout << solve(-1, 0) + 1 << endl;

  return 0;
}


Measured memory_bytes: 12928
from collections import Counter
from functools import reduce
from math import sin, cos, pi, radians
a, b, x = map(int, input().split())
error = 10**-10
x /= a

def f(deg):
    rad = radians(deg)

    r_height = b * sin(pi/2 - rad)
    l_height = a * sin(rad)
    if r_height <= l_height:
        ceil = b / sin(rad)
        s = ceil*r_height/2
    else:
        floor = a / cos(rad)
        height = a * sin(rad)
        s = a * b - floor*height/2

    return s

l = 0
r = 90
while True:
    mid = (l + r) / 2
    s = f(mid)
    if abs(x - s) <= error:
        break
    elif s > x:
        l = mid
    else:
        r = mid

print(mid)
        

Measured memory_bytes: 3572
#include<stdio.h>
 
#define MAX 100

#define INF (1<<21)

int prim();

int n,G[MAX][MAX];
 
int main(){
 
  int i,j,e,p;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      G[i][j]=(e==-1)?INF:e;
    }
  }
   
  p=prim();
  printf("%d\n",p);
 
  return 0;
}
 
int prim(){
 
  int u,i,v,minv,sum=0;
  int d[MAX];
  int p[MAX];
  int color[MAX];
 
  for(i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
    color[i]=0;
  }
 
  d[0]=0;
  
  while(1){
    minv=INF;
    u=-1;
     
    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=2){
         u=i;
         minv=d[i];
      }
    }
     
    if(u==-1)break;
    color[u]=2;
     
    for(v=0;v<n;v++){
      if(color[v]!=2&&G[u][v]!=INF){
    if(d[v]>G[u][v]){
      d[v]=G[u][v];
      p[v]=u;
      color[v]=1;
    }
      }
    }
  }
  
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=G[i][p[i]];
  }
 
  return sum;
}

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

int main()
{
	int h, m, s;
	int t_3;

	while (scanf("%d%d%d", &h, &m, &s), h != -1){
		t_3 = 7200 - (h * 3600 + m * 60 + s);
		printf("%02d:%02d:%02d\n", t_3 / 3600, t_3 % 3600 / 60, t_3 % 60);
		t_3 *= 3;
		printf("%02d:%02d:%02d\n", t_3 / 3600, t_3 % 3600 / 60, t_3 % 60);
	}

	return (0);
}

Measured memory_bytes: 1200
u, o = gets.split.map(&:to_i)

a = false

w = 0
e = 0
r = 0

(0..u).each do |i|
  (0..u-i).each do |j|
      if 10000 * i + 5000 * j +1000 * (u-i-j)  == o
        w = i
        e = j
        r = u-i-j
        a = true
        break
      end

  end
end

b = -1, -1, -1
puts a ? "#{w} #{e} #{r}": b

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

int n,sum=0;
bool p[1000];

int main(){
	//freopen(".in","r",stdin);
	scanf("%d",&n);
	int c;
	for(int i=1;i<=n;i++){
		cin>>c;
		p[c]++;
	}
	for(int i=1;i<=1000;i++)sum+=p[i];
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int get(int n){
	if(n == 2) return 1;
	if(n == 4 || n == 6 || n == 9 || n == 11) return 2;
	return 3;
}

int main() {
	int x, y;
	cin >> x >> y;
	x = get(x);
	y = get(y);
	if(x == y) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int N = sc.nextInt();
        String S =sc.next();
        if(S.length()<=N) System.out.println(S);
        else System.out.println(S.substring(0,N)+"...");
    }
}

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

using namespace std;

void hawawa()
{
	int n;
	cin >> n;
	set<string> s;
	for (int i = 0; i < n; i++) {
		int a[3];
		for (auto&& j : a) {
			cin >> j;
		}
		sort(begin(a), end(a));
		s.insert(to_string(a[0]) + "-" + to_string(a[1]) + "-" + to_string(a[2]));
	}
	cout << n - s.size() << "\n";
}

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



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

#define ll long long int
#define VI vector<int>
#define lf(i,a,b) for(int i=a;i<=b;i++)

int main()
{   ll x,y;cin>>x>>y;
    ll cnt=0;
    while(x<=y)
    {   cnt++;
        x*=2;
    }
    cout<<cnt<<endl;
}

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

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


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

int main(){
  int x;
  cin >> x;
  const int v = 1000000007;
  long long l=1,m=1,n=1;
  for(int a=0;a<x;a++){
    l*=10;
    l%=v;
  }
  for(int a=0;a<x;a++){
    m*=9;
    m%=v;
  }
  for(int a=0;a<x;a++){
    n*=8;
    n%=v;
  }
  int k = (((l-m+v)%v-m+v)%v+n)%v;
  cout << k;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int N,M;
	cin>>N>>M;
	int t = 1<<M;
	cout << t*(1900*M+100*(N-M)) << endl;
}

Measured memory_bytes: 256
S = input()
A = [int(S[i]) for i in range(4)]
for i in range(8):
  p = A[0]
  s = []
  for j in range(3):
    if i % 2 == 0:
      p += A[j+1]
      s.append('+')
    else:
      p -= A[j+1]
      s.append('-')
    i //= 2
  if p == 7:
    print('{}{}{}{}{}{}{}=7'.format(A[0], s[0], A[1], s[1], A[2], s[2], A[3]))
    break

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(i+1, N):
        ans += bisect.bisect_left(L, L[i]+L[j]) -j-1
        #print(L[i]+L[j],L,bisect.bisect_left(L, L[i]+L[j]))
print(ans)


Measured memory_bytes: 3188
import java.util.*;
public class Main{
	public static boolean[] num=new boolean[10];
	public static int check(int a,int b,int c){
		if(b<0){
			return 0;
		}
		else if(a==1){
			if(b<10){
				if(num[b]==true&&b>c){
					return 1;
				}
				else{
					return 0;
				}
			}
			else{
				return 0;
			}
		}
		else{
			int tmp=0;
			for(int i=0;i<=9;i++){
				if(num[i]==true&&i>c){
					num[i]=false;
					tmp+=check(a-1,b-i,i);
					num[i]=true;
				}
			}
			return tmp;
		}
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		for(int i=0;i<10;i++){
			num[i]=true;
		}
		int n,s;
		while(true){
			n=sc.nextInt();
			s=sc.nextInt();
			if(n!=0||s!=0){
				System.out.println(check(n,s,-1));
			}
			else{
				break;
			}
		}
	}
}


Measured memory_bytes: 26384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, a,b,c,d;
  cin >> x;
  a = x / 100;
  b = x - a * 100;
//  cout << a << endl;
//  cout << b << endl;
  
  if (a*5 >= b) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
A = input().split()
even = []
odd = []
for i in range(len(A)):
  if i % 2 == 0:
    even.append(A[i])
  else:
    odd.append(A[i])
if N % 2 == 0:
    even, odd = odd, even
print(*(even[::-1]+odd))
# print(even, odd)


Measured memory_bytes: 26692
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

typedef long double ll;

#define  kak 1000000000000;


int main(){
    ll score;
    ll p;
    ll N;
    ll K;
    cin >> N;
    cin >> K;
    double ans = 0;

    for (int i = 1; i <=N ; ++i) {
        score = i;
        p = (ll) 1.0 / (ll)N ;
        for (int j = i; score < K ; ++j) {
            score = score * 2;
            p = (ll) p / 2;
        }

        ans += (ll) p;
    }

    printf("%.12f",ans);

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MOD 1000000007
#define MAX 1010
struct Matrix
{
	int s[3][3];
	void clear(){memset(s,0,sizeof(s));}
	void init(){clear();s[1][1]=s[2][2]=1;}
	int* operator[](int x){return s[x];}
}ans;
Matrix operator*(Matrix a,Matrix b)
{
	Matrix ret;ret.clear();
	for(int i=1;i<=2;++i)
		for(int j=1;j<=2;++j)
			for(int k=1;k<=2;++k)
				ret[i][j]=(ret[i][j]+1ll*a[i][k]*b[k][j])%MOD;
	return ret;
}
Matrix fpow(Matrix a,ll b)
{
	Matrix s;s.init();
	while(b){if(b&1)s=s*a;a=a*a;b>>=1;}
	return s;
}
ll K;
int h,w,s,t1,t2,p1,p2;
char g[MAX][MAX];
int fpow(int a,int b)
{
	int s=1;
	while(b){if(b&1)s=1ll*s*a%MOD;a=1ll*a*a%MOD;b>>=1;}
	return s;
}
int main()
{
	cin>>h>>w>>K;if(K<=1){puts("1");return 0;}
	for(int i=1;i<=h;++i)
	{
		scanf("%s",g[i]+1);
		for(int j=1;j<=w;++j)
			s+=g[i][j]=='#';
	}
	for(int i=1;i<=h;++i)
		if(g[i][1]=='#'&&g[i][w]=='#')++p1;
	for(int i=1;i<=w;++i)
		if(g[1][i]=='#'&&g[h][i]=='#')++p2;
	for(int i=1;i<=h;++i)
		for(int j=1;j<=w;++j)
			if(g[i][j]=='#')
			{
				if(j>1&&g[i][j-1]=='#')++t1;
				if(i>1&&g[i-1][j]=='#')++t2;
			}
	if(!p1&&!p2){printf("%d\n",fpow(s,(K-1)%(MOD-1)));return 0;}
	if(p1&&p2){puts("1");return 0;}
	if(!p1)swap(p1,p2),swap(t1,t2);
	ans[1][1]=s;ans[1][2]=0;ans[2][1]=t1;ans[2][2]=p1;
	ans=fpow(ans,K-1);
	printf("%d\n",(ans[1][1]-ans[2][1]+MOD)%MOD);
	return 0;
}


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

#define ll unsigned long long

int main() {
	int n, i = 0, f = 0;
	ll k, b = 1, out = 0, mx = 0;
	cin >> n >> k;
	mx = k;
	vector<ll> num(0);
	vector<ll> a(n);
	for (int j = 0; j < n; j++) {
		cin >> a.at(j);
		mx = max(mx, a.at(j));
	}
	if (k == 0) {
		for (int j = 0; j < n; j++)
			out += a.at(j);
		cout << out << endl;
		return 0;
	}
	while (mx >= b) {
		num.push_back(0);
		for (int j = 0; j < n; j++)
			if ((b ^ (b & a.at(j))) == b)
				num.at(i)++;
		b *= 2;
		i++;
	}
	for (int j = (int)num.size() - 1; j >= 0; j--) {
		b /= 2;
		if (f)
			out += b * max(num.at(j), n - num.at(j));
		else {
			if ((b & k) == b) {
				out += b * max(num.at(j), n - num.at(j));
				if (num.at(j) <= n / 2)
					f = 1;
			}
			else
				out += b * (n - num.at(j));
		}
	}
	cout << out << endl;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k,s ;
  cin >> k >> s;
  ll ans = 0;
  map<ll,ll> m;
  ++k;
  rep(i,k){
    rep(j,k){
      if(s - i - j < k && s - i - j >= 0){
        ++ans;
      }
    }
  }

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


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x

int main() {

  int N, i, ans=0, max = 0;
  long long H[100010];

  cin >> N;
  REP(i, N){
    cin >> H[i];
  }

  for(i = 0; i < N-1; i++){
    if(H[i] >= H[i+1]){
      ans++;
      if( max < ans )  max = ans;
    } else{
      ans = 0;
    }
  }

  cout << max << endl;


}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    int n, k; std::cin >> n >> k;
    vi p(n); rep(i, n) std::cin >> p[i];
    sort(rng(p));
    int ans = 0;
    rep(i, k) {
        ans += p[i];
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 3608
n,k,d=map(int,input().split())
n=abs(n)
q=n//d
r=n%d
if(k<=q):
    print(n-k*d)
else:
    rem=k-q
    if(rem%2==0):
        print(r)
    else:
        print(min(abs(r-d),abs(r+d)))

Measured memory_bytes: 9128
# import bisect
from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():

    N=int(input())
    S=[str(input())[0] for i in range(N)]
    cnt=[]

    SS=Counter(S)
    for i in SS:
        if i in 'MARCH':
            cnt.append(SS[i])
    ans=0
    for a,b,c in combinations(cnt,3):
        ans+=a*b*c



    print(ans)


resolve()

Measured memory_bytes: 4224
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
string trans(int N)
{
        string S;
        while (N != 0)
        {
                if (N % 2 == 1)
                {
                        N--;
                        S = '1' + S;
                }
                else
                {
                        S = '0' + S;
                }
                N /= 2;
        }
        return S;
}

int main() //input->compute->output
{
        int H, W;
        cin >> H;
        int ans = 0;
        int cnt = 0;

        for (int i = 0; i < H; i++)
        {
                char S;
                cin >> S;
                if (S == 'D')
                {
                        cnt--;
                }
                else
                {
                        cnt++;
                }
                ans = max(ans, cnt);
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 5000
#define MAX(a, b) ((a)>(b)?(a):(b))

int nail[N+1][N+1];

int main(void) {
    int m, n, a, b, x, i, j;
    int ans = 0;
    scanf("%d %d", &n, &m);
    for (i = 0; i < m; i++) {
        scanf("%d %d %d", &a, &b, &x);
        nail[a][b] = x + 1;
    }
    for (i = 1; i <= n; i++) {
        for (j = 1; j <= i; j++) {
            nail[i][j] = MAX(nail[i][j],
                    MAX(nail[i-1][j], nail[i-1][j-1])-1);
            if (nail[i][j] > 0) ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 96680