akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 0;
		
		int A[] =new int[N];
		
		
        
        
        for(int i=0;i<N;i++){
            A[i]=sc.nextInt();
            count += A[i];
            
        }
        int m = sc.nextInt();
        int P[] =new int[m];
		int M[] =new int[m];
		int ans[] = new int[m];
        for(int i=0;i<m;i++){
            P[i]=sc.nextInt();
            M[i]=sc.nextInt();
            ans[i] = A[P[i] - 1] - M[i];
            
        }
		
		
		for(int i = 0;i < m;i++){
          System.out.println(count - ans[i]);
        }
		
		
		
	}
}


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

using namespace std;
  
int main(){
    
    int n;
    cin >> n;

    vector<int> h(n+1, 1000000);
    for(int i=1; i<=n; i++){
        cin >> h[i];
    }
    
    vector<int> dp(n+1, 1000000);
    dp[1] = 0;
    for(int i=2; i<=n; i++){
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),
                    dp[i-2] + abs(h[i]-h[i-2]));
    }

    cout << dp[n] << "\n";

    return 0; 
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
//#define D 1000000007

ull power(ull x,int n,int mod){
    ull res=1;
    x%=mod;
    while(n>0){
        if(n%2)res=(res*x)%mod;
        n>>=1;
        x=(x*x)%mod;
    }
    return res;
}

int main(){
    ull x;
    int n;
    cin>>x>>n;
//    cout<<power(x,n,D)<<endl;
    cout<<power(x,n,1000000007)<<endl;
}

Measured memory_bytes: 3096
#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 rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;
const int MOD=1e9+7;

int N, K;
int a[100];
void input(){
    cin>>N>>K;
    rep(i,N)cin>>a[i];
}

bool fwin[MAX];
void solve(){
    rep1(st,K){
        rep(i,N)if(st-a[i]>=0){
            if(!fwin[st-a[i]])fwin[st]=true;
        }
    }
}

void output(){
    if(fwin[K])cout<<"First";
    else cout<<"Second";
}

int main(){
    input();
    solve();
    output();
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
    int i,n,j,k,l;
    double a[3];
    cin >> n;
    while(n--)
    {
        for(i=0;i<3;i++)
            cin >> a[i];
        sort(a,a+3);
        if((sqrt(a[0]*a[0]+a[1]*a[1]))==(sqrt(a[2]*a[2])))
            cout << "YES" <<endl;
        else
            cout << "NO" <<endl;
    }
    return 0;



}

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

int main()
{
	long long  a[5];
	for (long long i=0;i<3;i++)
		cin>>a[i];
	sort(a,a+3);
	if(a[0]*a[1]*a[2]%2==0)
		cout<<0<<endl;
	else 
		cout<<a[0]*a[1]<<endl; 
} 

Measured memory_bytes: 256
#include<iostream>

int isThisOrThatOrThe(std::string s){
  int dif=0;
  char cro = s[0];
  while(true){
    if(cro == 't')break;
    cro+=1;
    if(cro > 'z')cro = 'a';
    dif++;
  }
  std::string cpys;
  for(int i=0;i<s.length();i++){
    if(s[i]+dif > (int)'z')cpys += (char)((s[i]+dif)%123+'a'); 
    else cpys += (char)(s[i] + dif);
  }
  if(cpys == "that" || cpys == "this" || cpys == "the")return dif;
  return -1;
}


int main(){
  std::string s;
  while(getline(std::cin,s,'\n')){
    
    bool piri = false;
    int st=0,dif = -12;
    for(int i=0;i<=s.length();i++){
      if(s[i] == ' ' || i == s.length() || s[i] == '.'){
	dif = isThisOrThatOrThe(s.substr(st,i-st));
	if(dif != -1){
	  break;
	}
	st = i+1;
      }
    }

    for(int i=0;i<s.length();i++){
      if(s[i] == ' ' || s[i] == '.'){
	std::cout << s[i];
	continue; 
      }
      s[i]+dif > (int)'z'?std::cout << (char)((s[i]+dif)%123+'a'):std::cout << (char)(s[i]+dif);
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)
using namespace std;

int main(){
    int n; cin >> n;
    bool ok = 0;
    repp(i,9){
        if(n%i==0 && (n/i)<=9) ok = 1;
    }
    if(ok) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define y1 my_y1
#define fi first
#define se second
#define lcm mylcm
 
using namespace std;
 
const ll mod = 998244353;
const ll inf = 2e9;
const int N = 1e5 + 5;

ll n, a, c, b, d[N][5];

int main () {
	//freopen("a.out", "w", stdout);
    cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a >> b >> c;
		d[i][1] = max(d[i - 1][2], d[i - 1][3]) + a;
		d[i][2] = max(d[i - 1][1], d[i - 1][3]) + b;
		d[i][3] = max(d[i - 1][1], d[i - 1][2]) + c;
	}
	cout << max(max(d[n][1], d[n][2]), d[n][3]);
	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define maxn 500000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

ll fac[maxn+5],ifac[maxn+5],inv[maxn+5];

ll C(int n,int m)
{
    if(m<0 || n-m<0) return 0;
    return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int main()
{
    fac[0]=ifac[0]=inv[1]=1;
    rep(i,2,maxn) inv[i]=inv[mod%i]*(mod-mod/i)%mod;
    rep(i,1,maxn) fac[i]=fac[i-1]*i%mod;
    rep(i,1,maxn) ifac[i]=ifac[i-1]*inv[i]%mod;

    int n,m;
	cin>>n>>m;
    ll ans=0;
    ll A=1;
    rep(i,1,n) A=A*(m-i+1)%mod;
    ll B=A;
    rep(i,0,n) 
    {
        ans=(ans+(i&1?-1:1)*C(n,i)*A%mod*B%mod+mod)%mod;
        B=B*inv[m-i]%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 15348
N = int(input())

def solve0(N):
    result = 0
    for i in range(2, N):
        if N % i == N // i:
            print("!", N // i, i, N % i)
            result += i
    return result

def solve(N):
    import math
    r = math.ceil(math.sqrt(N))
    result = 0
    for i in range(1, r + 1):
        d, m = divmod(N - i, i)
        if m == 0 and d > i:
            # print("*", i)
            result += d
    return result

#result0 = solve0(N)
result = solve(N)

#print(result0)
print(result)


Measured memory_bytes: 38640
e,s=gets
h=Hash[gets.split.map(&:to_i).sort.chunk{|e|e}.map{|k,v|s||=k;[e=k,v.size]}]
 
puts e+e%2 == s*2 && h[s]==e%2+1 && (s+1..e).all?{|e|h[e]&&h[e]>=2} ? "Possible" : "Impossible"

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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}

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

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

  ll H; cin >> H;
  ll A; cin >> A;
  ll ans = (H + A - 1) / A;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

int lsone(int n)
{
	return (n&-n);
}

ll pow1(ll a, ll b)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2);
		x *= x;
		x %= mod;
		if (b%2)
		{
			x *= a;
			x %= mod;
		}
		return x;
	}
}

int n; 
double p[4000], dp[2][4000];

int main()
{
	cin>>n;

	for (int i = 1; i <= n; i++)
		cin>>p[i];

	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i-1; j >= 0; j--)
		{
			dp[1][j] += dp[0][j]*(1-p[i]);
			dp[1][j+1] += dp[0][j]*p[i];
		}

		for (int j = 0; j <= i; j++)
		{
			dp[0][j] = dp[1][j];
			dp[1][j] = 0;
		}
	}
	double ans = 0;

	for (int i = (n+1)/2; i <= n; i++)
		ans += dp[0][i];

	printf("%.10F\n", ans);

	return 0;
}


Measured memory_bytes: 384
# include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k;
    cin>>n>>k;
    if(n==0)
        cout<<0<<endl;
    else if(k==0)
        cout<<n<<endl;
    else if(n<k)
    {
        if(abs(n-k)<n)
            cout<<abs(n-k)<<endl;
        else
            cout<<n<<endl;
    }
    else
    {
        long long int t;
        t=n/k;
        if(abs(n-t*k)<abs(n-(t+1)*k))
           cout<<abs(n-t*k)<<endl;
        else
            cout<<abs(n-(t+1)*k)<<endl;
    }
    return 0;
}


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

int main(){
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    int b = K-A[N-1]+A[0];
    for(int i=0; i+1<N; i++){
        b = max(b, A[i+1]-A[i]);
    }
    
    cout << K-b << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;

int m, n;
int dp[2001][2001][2];
int ans;

int main(){
	scanf("%d %d", &m, &n);
	char s[2002], t[2002];
	scanf("%s %s", s+1, t+1);

	if(s[1] == 'I') dp[1][0][1] = 1;
	if(t[1] == 'I') dp[0][1][1] = 1;
	for(int i=1; i<m+1; ++i)
		if(s[i] == 'I') dp[i][0][1] = dp[i-1][0][0]+1;
		else if(s[i-1] == 'I') dp[i][0][0] = dp[i-1][0][1]+1;
	for(int i=1; i<n+1; ++i)
		if(t[i] == 'I') dp[0][i][1] = dp[0][i-1][0]+1;
		else if(t[i-1] == 'I') dp[0][i][0] = dp[0][i-1][1]+1;

	for(int i=1; i<m+1; ++i){
		for(int j=1; j<n+1; ++j){
			int c = 0, d = 0;
			if(s[i] == 'I') c = max(c, dp[i-1][j][0]+1);
			else if(dp[i-1][j][1] != 0) d = max(d, dp[i-1][j][1]+1);
			if(t[j] == 'I') c = max(c, dp[i][j-1][0]+1);
			else if(dp[i][j-1][1] != 0) d = max(d, dp[i][j-1][1]+1);
			dp[i][j][1] = c;
			dp[i][j][0] = d;
			ans = max(ans, dp[i][j][1]);
		}
	}
/*
	for(int i=0; i<n+1; ++i){
		for(int j=0; j<m+1; ++j){
			printf("%d\t", dp[j][i][0]);
		}
		printf("\n");
	}
	printf("\n");
	for(int i=0; i<n+1; ++i){
		for(int j=0; j<m+1; ++j){
			printf("%d\t", dp[j][i][1]);
		}
		printf("\n");
	}
*/
	printf("%d\n", ans);
}

Measured memory_bytes: 34036
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll n,a,b;
  std::cin>>n>>a>>b;

  if(a>b){
    std::cout<<0<<"\n";
    return 0;
  }

  if(n==1){
    if(a!=b)std::cout<<0<<"\n";
    else std::cout<<1<<"\n";
    return 0;
  }

  std::cout<<((n-1)*b+a)-((n-1)*a+b)+1<<"\n";

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int d;
  cin >> d;
  arrll(c,26);
  vecll2(s, d, 26);
  rep(i,d){
    rep(j,26){
      cin >> s[i][j];
    }
  }

  srand(time(NULL));

  vecll human(26);
  vecll last(26);

  vecll ans;

  rep(i,d){
    ans.pb(rand()%26+1);
  }

  rep(i,d){
    prt(ans[i]);
  }
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<ll> L(N);
  rep(i,N)  cin >> L.at(i);
  sort(all(L));

  int ans=0;
  rep(i,N){
    REP(j,i+1,N){
      REP(k,j+1,N){
        if(L.at(i)==L.at(j) || L.at(j)==L.at(k))  continue;
        if(L.at(i)+L.at(j)>L.at(k)) ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)
#define rep(i,x,N) for(int i=x;i<=N;i++)
#define ar array

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;
using vd=vector<double>;
using vvi=vector<vi>;
int ctoi(char c) {return c-'0';}
int slen(string s) {return s.length();}
int vsize(vi a) {return (int)a.size();}
int in() {int x;cin>>x;return x;}
void tf(bool ok) {cout<<(ok ? "YES" : "NO")<<endl;}

//https://atcoder.jp/contests/abc178/tasks/abc178_a

void rrrrrrrrrrrrrresi() {
  int N;
  cin>>N;
  cout<<!N<<endl;
}

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int Q=1;
//cin>>Q;
while(Q--)
  rrrrrrrrrrrrrresi();
return 0;
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n;
    string s;
    cin >> n >> s;
    s.erase(unique(s.begin(),s.end()),s.end());
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
using namespace std;

char cs[4]={'A','C','G','T'};
string aaa = "AGC";
int N;
bool ok(string s) {
    char t;
    if(strstr(s.c_str(),aaa.c_str())){
        return false;
    }
    for(int i=0;i<3;i++){
        string ts=s;
        t=ts[i];
        ts[i]=ts[i+1];
        ts[i+1]=t;
        if(strstr(ts.c_str(),aaa.c_str())){
            return false;
        }
    }
    return true;
}
int d[101];
unordered_map<int,unordered_map<string, int> > mp;
int solve(int x,string last){
    if(mp.find(x) != mp.end() && mp[x].find(last) != mp[x].end()){
        return mp[x][last];
    }
    if(x==N)return 1;
    int res = 0;
    for(int i=0;i<4;i++){
        if(ok(last+cs[i])){
            res = (res + solve(x+1,last.substr(1)+cs[i])) % MOD;
        }
    }
    if(mp.find(x)==mp.end()){
        unordered_map<string, int> mmp;
        mp[x]=mmp;
    }
    mp[x][last]=res;
    return res;
}

int main() {
    cin>>N;
    d[0]=1;
    for(int i=1;i<=N;i++){
        d[i]=(d[i-1]*4)%MOD;
    }
    cout<<solve(0,"TTT");
    return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  string s;
  cin >> s;

  if (s[0] >= 'A' && s[0] <= 'Z') {
    cout << "A" << endl;
  } else {
    cout << "a" << endl;
  }
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int cnv(double x)
{
	return 1.1 <= x ? 0: 0.6 <= x ? 1 : 0.2 <= x ? 2 : 3;
}

int main()
{
	int x[2][4] = {0};
    for(double a, b; cin >> a >> b; x[0][cnv(a)]++) x[1][cnv(b)]++;
	rep(i, 4) cout << x[0][i] << " " << x[1][i] << endl;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < A.length; i++) {
			A[i] = 0;
		}
		for (int i = 0; i < A.length - 1; i++) {
			A[sc.nextInt() - 1]++;
		}
		for (int i = 0; i < A.length; i++) {
			System.out.println(A[i]);
		}
	}

}


Measured memory_bytes: 60428
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}

int main() {

	int n, k;
	std::cin >> n >> k;
	std::vector<int> p(n);
	rep(i, n) std::cin >> p[i];

	int minNum = inf;
	int maxNum = 0;
	std::priority_queue<int> pq; // 最大
	// 最小
	std::priority_queue<int, std::vector<int>, std::greater<int>> pq2;
	std::vector<bool> used(n, false);

	rep(i, k) {
		minNum = std::min(minNum, p[i]);
		maxNum = std::max(maxNum, p[i]);
		pq.push(p[i]);
		pq2.push(p[i]);
	}

	std::vector<bool> squnceSorted(n, false);
	int sortedNum = 0;
	{
		int cnt = 0;
		rep(i, n - 1) {
			if (p[i] < p[i + 1]) cnt++;
			else cnt = 0;

			if (cnt >= k - 1) {
				squnceSorted[i - k + 2] = true;
				sortedNum++;
			}
		}
	}

	// 連続するK個が昇順にソート済みのときに注意

	// なにもしない選択肢もある？

	int ans = 1;
	if (sortedNum >= 1) ans++;
	// 初期状態の先頭k連続がすでに昇順
	if (squnceSorted[0]) ans--;


	// out が最小値 かつ in が最大値の時はカウントしない
	rep(i, n - k) {
		// p[i] が out
		// p[i + k] が in

		used[p[i]] = true;
		bool isMin = false;
		bool isMax = false;
		pq.push(p[i + k]);
		pq2.push(p[i + k]);

		if (p[i] == minNum) { // out が最小値だった
			isMin = true;
			while (used[pq2.top()]) {
				pq2.pop();
			}
			minNum = pq2.top();
			//std::cout << i << "番目で最小値更新 (out) : " << minNum << std::endl;
		}
		if (p[i + k] <= minNum) { // in が最小値だった
			minNum = p[i + k];
			//std::cout << i << "番目で最大値更新 (in) : " << minNum << std::endl;
		}
		if (p[i] == maxNum) { // out が最大値だった
			while (used[pq.top()]) {
				pq.pop();
			}
			maxNum = pq.top();
			//std::cout << i << "番目で最大値更新 (out) : " << maxNum << std::endl;
		}
		if (p[i + k] >= maxNum) { // in が最大値だった
			isMax = true;
			maxNum = p[i + k];
			//std::cout << i << "番目で最大値更新 (in) : " << maxNum << std::endl;
		}

		if ((isMax && isMin) || squnceSorted[i + 1]) continue;
		ans++;
	}

	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 2920
import math


def is_prime(x):
    if x == 1:
        return False

    for y in range(2, math.ceil(math.sqrt(x)) + 1):
        if not x % y:
            return False
    return True


def submit():
    n = int(input())

    # 55555以下の素数を求める
    prime_cand = []
    for x in range(2, 55556):
        if is_prime(x):
            prime_cand.append(x)

    # mod 5で1のものに絞る
    prime_cand = [p for p in prime_cand if p % 5 == 1]
    print(*prime_cand[:n])
        

submit()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;
    vector<int> one(s.length(), 0), zero(s.length(), 0);
    int o = 0, z = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '0')
        {
            if (i == n - 1 || s[i + 1] == '1')
            {
                zero[z] = i;
                z++;
            }
        }
        else
        {
            if (i == n - 1 || s[i + 1] == '0')
            {
                one[o] = i;
                o++;
            }
        }
    }
    if (z <= k)
    {
        cout << n << endl;
    }
    else
    {
        int j = 0;
        while (zero[k - 1] > one[j])
            j++;
        int ans = 0;
        for (int i = k - 1; i < z; i++)
        {
            int tmp = (one[j] == 0 ? n - 1 : one[j]) - (i - k < 0 ? -1 : zero[i - k]);
            ans = max(ans, tmp);
            j++;
        }
        cout << ans << endl;
    }
}


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

using namespace std;

int main()
{
    int a,b,c,d,cnt=0;
    cin>>a>>b>>c>>d;
    while(c>0&&a>0)
    {
    	if(cnt%2==0)
    	{
    		c-=b;
		}
		else
		{
			a-=d;
		}
		cnt++;
	}
	if(cnt%2!=0)
	cout<<"Yes"<<endl;
	else
	 cout<<"No"<<endl;
	return 0;
	
}


Measured memory_bytes: 3636
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
class ProgramD
    {
        static void Main(string[] args)
        {
            
            //入力
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            var r = new List<int>();
            var g = new List<int>();
            var b = new List<int>();
            long count = 0;

            //RかBかでそれぞれリストを作る
            for(int i = 0;i < n;i++)
            {
                if(s[i] == 'R')
                    r.Add(i+1);
                else if(s[i] == 'G')
                    g.Add(i+1);
                else 
                    b.Add(i+1);
            }
            
            

            //Rの方を小さい順に取り出す
            foreach(var a1 in b)
            {
                var x = a1;
                foreach(var a2 in g)
                {
                    var y = a2;
                    
                    count += r.Count;
                    if(r.Contains(2 * y - x))
                        count--;
 
                    if((x+ y) % 2 == 0)
                      if(r.Contains((x + y) /2))
                          count--;
 
                    if(r.Contains(2 * x - y))
                        count--;   
                }
 
            }
                
            //Bの方を小さい順に取り出す
            
            Console.WriteLine(count);
            

        }
    }

Measured memory_bytes: 27752
N = int(input())
V = list(map(int, input().split()))
#N = len(V)

v1, v2 = {}, {}

for v in V[::2]:
	if not v in v1:
		v1[v] = 1
	else:
		v1[v] += 1

for v in V[1::2]:
	if not v in v2:
		v2[v] = 1
	else:
		v2[v] += 1

a1 = sorted(v1, key=lambda x:-v1[x])
a2 = sorted(v2, key=lambda x:-v2[x])

#print(v1, v2)
#print(a1, a2)

r = []
for k1 in a1[:2]:
	for k2 in a2[:2]:
		if k1 != k2:
			r += [N - v1[k1] - v2[k2]]

if not r:
	r += [N // 2]

#print(r)
print(min(r))


Measured memory_bytes: 18292
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	string str;
  	cin >> str;
  	string sum=""; 
  	int n=str.size();
  	for(int i=0;i<n;i++){
    	if(str.at(i)=='0' || str.at(i)=='1'){
        	sum += str.at(i);
        }
      	else{
          if(sum.size()>0){
        	sum.pop_back();}
        }
    }
  	cout << sum << endl;
}


Measured memory_bytes: 3616
w,h,n=map(int,input().split())
ux=w
lx=0
uy=h
ly=0
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    lx=max(lx,x)
  if a==2:
    ux=min(ux,x)
  if a==3:
    ly=max(ly,y)
  if a==4:
    uy=min(uy,y)
print(max(0,ux-lx)*max(0,uy-ly))

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


def main():
    x = int(input())
    result = x * 2 // 11

    if (x * 2 % 11 != 0) and ((x - 6) % 11 != 0):
        result += 1

    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <vector>


using namespace std;

int A;
int B;

int add;
int sub;
int mult;

int main () {

    priority_queue <int> max;

    cin >> A;
    cin >> B;

    add = A + B;
    sub = A - B;
    mult = A * B;

    max.push(add);
    max.push(sub);
    max.push(mult);

    cout << max.top();



    

    



}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){
  int A, B; cin >> A >> B;
  A--; B--;

  char ans[100][100];
  for (int i = 0; i < 100; i++){
    for (int j = 0; j < 100; j++){
      if (i < 50) ans[i][j] = '#';
      else ans[i][j] = '.';
    }
  }
  
  int cnt = 0, I = 0, J = 0;

  int di[3] = {-1, 0, 1}, dj[3] = {-1, 0, 1};
  while (cnt < A){
    bool flag = true;

    for (int i = 0; i < 3; i++){
      for (int j = 0; j < 3; j++){
        if (0 <= I + di[i] && I + di[i] < 100 && 0 <= J + dj[j] && J + dj[j] < 100){
          if (ans[I + di[i]][J + dj[j]] == '.'){
            flag = false;
          }
        }
      }
    }
    
    if (flag == true){
      cnt++; ans[I][J] = '.';
    }

    if (J == 99){
      I++; J = 0;
    }else{
      J++;
    }
  }
  
  cnt = 0; I = 51;
  while (cnt < B){
    bool flag = true;

    for (int i = 0; i < 3; i++){
      for (int j = 0; j < 3; j++){
        if (0 <= I + di[i] && I + di[i] < 100 && 0 <= J + dj[j] && J + dj[j] < 100){
          if (ans[I + di[i]][J + dj[j]] == '#'){
            flag = false;
          }
        }
      }
    }
    if (flag == true){
      cnt++;
      ans[I][J] = '#';
    }

    if (J == 99){
      I++; J = 0;
    }else{
      J++;
    }
  }
  cout << 100 << " " << 100 << endl;
  for (int i = 0; i < 100; i++){
    for (int j = 0; j < 100; j++){
      cout << ans[i][j];
    }
    cout << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Max=2e6+10, N=2e6+100, mod=1e9+7;

ll fct[N],k,ans,n;
string s;

ll qmi(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1) res=res*a%mod;
		b>>=1; a=a*a%mod;
	}
	return res;
}
ll C(ll a,ll b){
	if(a<b) return 0;
	return fct[a]*qmi(fct[b],mod-2)%mod*qmi(fct[a-b],mod-2)%mod;
}
void init(){
	fct[0]=1;
	for(ll i=1;i<=Max;i++) fct[i]=fct[i-1]*i%mod;
}


int main(){
	cin>>k;
	cin>>s;
	init();
// wa	
	ll len=s.size();
	n=len+k;
	ans=0;
	for(ll i=len;i<=n;i++){
		//C(i-1,len-1);
		//qmi(25,i-len);
		//qmi(26,n-i)%mod;
		//ans+C(i-1,len-1)*qmi(25,i-len)%mod;
		//ans+C(i-1,len-1)*qmi(25,i-len)%mod*qmi(26,n-i)%mod;
		//ll t=(C(i-1,len-1)*qmi(25,i-len)%mod*qmi(26,n-i)%mod)%mod;
		//ans = ((ans+t)%mod+mod)%mod;
		ans=(ans+C(i-1,len-1)*qmi(25,i-len)%mod*qmi(26,n-i)%mod)%mod;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 20056
#include<stdio.h>

int main(void)
{
	int n, m, i, j, sum=0;
	int a[100][100], b[100];

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for (i = 0; i < m; i++) scanf("%d", &b[i]);

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			sum+=a[i][j] * b[j];
		}
			printf("%d\n",sum);
			sum=0;
	}
return 0;
}


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

using namespace std;

const int INF = 100000000;

int main(){
	string step;
	int dp[2][2][3][3];
	while(cin >> step){
		if(step == "#") break;
		for(int i=0;i<2;i++)
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
					dp[0][i][j][k] = dp[1][i][j][k] = (j <= k ? 0 : INF);
		for(int i=0;i<step.size();i++){
			int cur = i%2, next = 1-cur;
			for(int j=0;j<3;j++)
				for(int k=j;k<3;k++)
					dp[next][0][j][k] = dp[next][1][j][k] = INF;
			int line = (step[i]-'1')%3;
			for(int j=0;j<3;j++){
				for(int k=j;k<3;k++){
					if(line <= k)
						dp[next][0][line][k] = min(dp[next][0][line][k], min(dp[cur][1][j][k], dp[cur][0][j][k]+1));
					if(j <= line)
						dp[next][1][j][line] = min(dp[next][1][j][line], min(dp[cur][1][j][k]+1, dp[cur][0][j][k]));
				}
			}
		}
		int ans = INF;
		for(int i=0;i<2;i++)
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
					ans = min(ans, dp[step.size()%2][i][j][k]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 1136
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = inpl()
c = Counter(a)
res = []
for key in list(c):
    res.append(c[key])
res.sort()
ans = 0
ln = len(res)
if ln > k:
    ans = sum(res[:ln-k])
print(ans)

Measured memory_bytes: 34764
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


signed main(){
	int A[3];
	rep(i, 0, 3) cin >> A[i];

	sort(RNG(A, 3));

	int ans = 0;
	rep(i, 1, 3) ans += abs(A[i]-A[i-1]);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
(a, b, c) = input().rstrip().split(' ')
a = int(a)
b = int(b)
c = int(c)

if a <= b <= c:
    print(a,b,c)
elif a <= c <= b:
    print(a,c,b)
elif b <= a <= c:
    print(b,a,c)
elif b <= c <= a:
    print(b,c,a)
elif c <= a <= b:
    print(c,a,b)
else:
    print(c,b,a)

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n)cin>>a[i];
	// 0項までの和を+にするか-にするか。
	ll hu = 0;
	ll sum = 0;
	rep(i,n){
		sum += a[i];
		if(i % 2 == 0){
			if(sum >= 0){
				// -1 にする
				hu += sum + 1;
				sum = -1;
			}
		} else {
			if(sum <= 0){
				hu += abs(sum) + 1;
				sum = 1;
			}
		}
	}

	ll sei = 0;
	sum = 0;
	rep(i,n){
		sum += a[i];
		if(i % 2 == 0){
			if(sum<=0){
				sei += abs(sum) + 1;
				sum = 1;
			} 
		} else {
			if(sum >= 0){
				sei += sum + 1;
				sum = -1;
			}
		}
	}
	cout << min(sei,hu) << endl;
}


Measured memory_bytes: 1024
C = [list(map(int, input().split())) for _ in range(3)]
for i in range(2):
    for j in range(2):
        if C[i+1][j] - C[i][j] != C[i+1][j+1] - C[i][j+1]:
            print('No')
            exit()
print('Yes')

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

int cnt=0;

void merge(int s[],int left,int mid,int right){
  int i,j,k;
  int a=mid-left;
  int b=right-mid;

  int* l=new int[a+1];
  int* r=new int[b+1];

  for(i=0; i<a; i++){
    l[i]=s[left+i];
  }
  for(i=0; i<b; i++){
    r[i]=s[mid+i];
  }

  l[a]=1000000001;
  r[b]=1000000001;

  i=0;
  j=0;
  for(k=left; k<right; k++){
    if(l[i]<=r[j]){
      s[k]=l[i];
      i++;
      cnt++;
    }else{
      s[k]=r[j];
      j++;
      cnt++;
    }
  }

  delete[] l;
  delete[] r;
}

void mergeSort(int s[],int left,int right){
  if(left+1>=right)return;

  int mid=(left+right)/2;
  mergeSort(s,left,mid);
  mergeSort(s,mid,right);
  merge(s,left,mid,right);
}

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

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

  mergeSort(s,0,n);

  for(int i=0; i<n; i++){
    if(i==n-1){
      cout << s[i] << "\n";
    }else{
      cout << s[i] << " ";
    }
  }

  cout << cnt << "\n";

  return 0;
}


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

int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  double sum = 0.0;
  for (int i=0; i<n; i++) {
    sum += 1.0 / a[i];
  }
  printf("%.9lf", 1.0 /sum);

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	if(k<(x/d)){
		cout<<(x-k*d)<<endl;
	}
	else {
		k=k-(x/d);
		if(k%2==0){
			cout<<abs(x%d)<<endl;
		}
		else 
		cout<<abs(d-x%d)<<endl;
	}
}

Measured memory_bytes: 3628
A=input().split()
H=int(A[0])
W=int(A[1])
if (W==1) or (H==1):
    R=1
elif (W%2==1) and (H%2==1):
    R=(W+1)*H/2-(H-1)/2
else:
    R=H*W/2
print(int(R))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <utility>
#define INF 100000000

using namespace std;
using llong = long long;

int dist[100][100];

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

  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      if(i!=j) dist[i][j] = INF;
    }
  }

  for(int i=0;i<M;++i){
    int s,t;
    cin >> s >> t;
    dist[s][t] = -1;
  }
  
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      for(int k=0;k<N;++k){
        if(dist[j][i]!=INF && dist[i][k]!=INF){
          dist[j][k] = min(dist[j][k],dist[j][i]+dist[i][k]);
        }
      }
    }
  }

  for(int i=0;i<N;++i){
    if(dist[i][i] < 0){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

ll gcd(ll n, ll m) { return n ? gcd(m % n, n) : m; }

ll lcm(ll n, ll m) {
  ll g = gcd(n, m);
  return n * m / g;
}

int main() {
  int n;
  ll m;
  cin >> n >> m;
  vl a(n);
  REP(i, n) { cin >> a[i]; }

  bool ok = true;
  int div2 = -1;
  REP(i, n) {
    ll tmp = a[i];
    int t2 = 0;
    while (tmp % 2 == 0) {
      tmp /= 2;
      t2++;
    }
    if (div2 == -1)
      div2 = t2;
    if (div2 != t2)
      ok = false;
  }
  if (!ok) {
    cout << 0 << endl;
    return 0;
  }

  ll l = a[0] / 2LL;
  REP(i, n) { l = lcm(l, a[i] / 2LL); }

  cout << ((m / l) + 1LL) / 2LL << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>


int main(void){
    int D, N, a;
    int count = 0;
    int i = 0;
    scanf("%d %d", &D, &N);

    do{
        i++;
        if(D == 1){
            a = i % 100;
            if(a == 0 && i%10000 != 0){
                count++;
            }
        }else if(D == 2 && i%1000000 != 0){
            
            a = i % 10000;
            if(a == 0){
                count++;
            }
        
        }else if(i%100 != 0){
            count++;
        }
    }while (count<N);
    printf("%d\n", i);

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }

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

	int d, c;
	cin >> d >> c;
	cout << d * c << "\n";

	return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 200005;
const ll MOD = 1000000007;

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

bool solve (ll val) {
    ll sum = 0;
    REP (i, n) {
        ll rem = val / f[i];
        sum += max(0LL, a[i] - rem);
        debug(a[i]-rem);
    }

    return sum <= k;
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> k;
    REP (i, n) {
        cin >> a[i];
    }
    REP (i, n) {
        cin >> f[i];
    }

    sort(a, a+n);
    sort(f, f+n, greater<int>());

    solve(2);

    ll L = -1, R = 1000000000012LL;
    while (L < R - 1) {
        ll M = (L + R) >> 1;
        if (solve(M)) {
            R = M;
        } else {
            L = M;
        }
    }

    cout << R << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> x(n+1), y(m+1);
    for(int i=1; i<=n; i++) cin >> x[i];
    for(int i=1; i<=m; i++) cin >> y[i];

    ll mod = 1e9+7;
    ll xs = 0, ys = 0;
    for(int i=1; i<=n; i++){
        xs += (2*i-n-1)*x[i];
    }
    for(int i=1; i<=m; i++){
        ys += (2*i-m-1)*y[i];
    }
    xs = xs%mod;  ys = ys%mod;
    cout << (xs*ys)%mod << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
  ll N;
  cin >> N;
  
  vector<ll> ans(0);
  while (N > 0){
    
    ll pos = 0, ruiseki = 0;
    while (ruiseki < N){
      pos++;
      ruiseki += pos;
    }
  
    ans.push_back(pos);
    N -= pos;
    
  }
  
  for (ll i = 0; i < ans.size(); i++){
    cout << ans.at(i) << endl;
  }
  
  
}

Measured memory_bytes: 3636
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10**9 + 7
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def combMod(n, r, p):
    numer = 1
    denom = 1
    for i in range(1, r+1):
        numer = numer * (n-r+i) % p
        denom = denom * i % p
    return numer * pow(denom, p-2, p) % p

def resolve():
    n, k = LI()

    if n <= k:
        ans = combMod(k, n, MOD)
    else:
        ans = 0

    print(ans)

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 6816
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    K = I()

    ans = ""

    for _ in range(K):
        ans+="ACL"
    
    print(ans)

    


if __name__ == '__main__':
    main()


Measured memory_bytes: 10000
n = gets.to_i
a = []
gets.chomp.split(' ').map(&:to_i).each { |i| a << i }

exp = []
(n - 1).step(0, -2) do |i|
  exp << i
end
exp += exp
exp.sort!

if n % 2 == 1
  exp.delete_at(0)
end

if exp == a.sort
  puts 2**(exp.size - exp.uniq.size) % (10**9 + 7)
else
  puts 0
end


Measured memory_bytes: 15224
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;

using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<ll, ll> pii;
typedef long double ld;

typedef pair<ld, ld> pld;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

typedef vector<ll> vi;
typedef vector<pii> vpii;
namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> &a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> &a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> &a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;
#define int ll
int bp(int a, int k) {
    int res = 1;
    rep(j, 0, k) res *= a;
    return res;
}
void solve() {
    int x;
    cin >> x;
    rep(i, -1000, 1000) rep(j, -1000, 1000) {
        if (bp(i, 5) - bp(j, 5) == x) {
            cout << i << " " << j;
            return;
        }
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;
    while (q--) solve();
}



Measured memory_bytes: 3200