akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

using value = long double;
const value id = 0.;
value marge(value a, value b) { return a + b; }

int main() {
	int n; scanf("%d", &n);
	std::vector<int> a(n - 1), b(n - 1);
	std::vector<std::vector<int>> g(n);
	for(int i = 0; i < n - 1; i++) {
		scanf("%d%d", &a[i], &b[i]);
		a[i]--; b[i]--;

		g[a[i]].push_back(i);
		g[b[i]].push_back(i);
	}

	std::vector<std::map<int, value>> dp(n);
	auto solve = [&](auto&& solve, int v, int par, bool flag) -> value {
		if(dp[v].count(par)) return dp[v][par];
		
		value res = id;
		const int deg = g[v].size() - (par != -1);
		if(par == -1 or flag) {
			std::vector<value> ret;
			for(int i = 0; i < g[v].size(); i++) {
				int id = g[v][i];
				int to = a[id] ^ b[id] ^ v;
				if(to == par) continue;
				
				ret.push_back(solve(solve, to, v, flag) + 1.);
			}
			
			std::vector<value> R(ret.size() + 1, id);
			for(int i = (int)R.size() - 1; i > 0; i--) R[i - 1] = marge(R[i], ret[i - 1]);
			if(par == -1) {
				value L = id;
				for(int i = 0; i < g[v].size(); i++) {
					int id = g[v][i];
					int to = a[id] ^ b[id] ^ v;
					
					long double tmp = marge(L, R[i + 1]);
					if(deg - 1) tmp = tmp / (deg - 1);
					dp[v][to] = tmp;
					L = marge(L, ret[i]);
				}
			}

			if(deg) res = R[0] / deg;
		} else {
			solve(solve, v, -1, flag);

			return solve(solve, v, par, flag);
		}

		return dp[v][par] = res;
	};
	solve(solve, 0, -1, true);

	for(int i = 0; i < n; i++) printf("%.12Lf\n", solve(solve, i, -1, false));
	return 0;
}


Measured memory_bytes: 68096
#include <bits/stdc++.h> 
using namespace std; 
int main() {
  int A,B;
  cin >> A >> B;
  int N = A+B;
  if(N%2 == 0){
  cout << N/2 <<endl;
  }
  else{
  cout << "IMPOSSIBLE" << endl;
  }
  return 0;
} 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, k, M=1e9+7;
string a, b;

ll f(ll p, ll q) {
	k += p;
	q %= M;
	if(k>=n) return q;
	if(p==1) {
		if(a[k]==b[k]) f(1, q*2);
		else f(2, q*2);
	} else {
		if(a[k]==b[k]) f(1, q);
		else f(2, q*3);
	}
}

int main() {
	cin>>n>>a>>b;
	cout<<(a[k]==b[k] ? f(1,3) : f(2,6));
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char ch;

    scanf("%c", &ch);

    if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
    {
        printf("vowel\n");
    }

    else
    {
        printf("consonant\n");
    }

    return 0;
}


Measured memory_bytes: 128
// ABC161
// b.cs

using System;
using System.Collections;

class B
{
    public static void Main()
    {
        string[] str1 = Console.ReadLine().Split(' ');
        int N = int.Parse(str1[0]);
        int M = int.Parse(str1[1]);

        string[] str2 = Console.ReadLine().Split(' ');
        int[] A = new int[N];
        int sum = 0;
        for (int i = 0; i < N; i++)
        {
            A[i] = int.Parse(str2[i]);
            sum += A[i];
        }

        Array.Sort(A);
        Array.Reverse(A);

        double min = (double)sum / (4.0 * (double)M);
        if (A[M-1] < min)
        {
            Console.WriteLine("No");
        }
        else
        {
            Console.WriteLine("Yes");
        }
    }
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#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 pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    ll a,b;
    cin >> a >> b;
    cout << max(a+b,max(a-b,a*b)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

struct L {
  double A, B, C;

  double y(double x) const {
    // y = (-Ax + C) / B
    return (-A * x + C) / B;
  }
  double x(double y) const {
    // x = (-By + C) / A;
    return (-B * y + C) / A;
  }
};

using F = double (L::*)(double) const;

const double INF = 1ll << 30;

template <class T>
struct fenwick_tree {
  vector<T> x;
  fenwick_tree(int n) : x(n + 1) {}
  void add(int k, T a) {
    for (++k; k < x.size(); k += k & -k) x[k] += a;
  }
  T sum(int k) {
    T s = 0;
    for (; k > 0; k &= k - 1) s += x[k];
    return s;
  }
  T sum(int a, int b) { return sum(b) - sum(a); }
  int lower_bound(T a) {
    if (a <= 0) return 0;
    int k = x.size() - 1;
    for (int s : {1, 2, 4, 8, 16}) k |= (k >> s);
    for (int p = ++k; p > 0; p >>= 1, k |= p)
      if (k < x.size() && x[k] < a)
        a -= x[k];
      else
        k ^= p;
    return k + 1;
  }
};

double solve(const vector<L>& ls, F f) {
  const int N = ls.size();
  const int M = (N * (N - 1) / 2 + 1) / 2;
  double ng = -INF, ok = INF;
  for (int i = 0; i < 100; i++) {
    double x = (ng + ok) / 2;
    vector<pair<double, int>> ys(N);
    for (int i = 0; i < N; i++) ys[i] = make_pair((ls[i].*f)(x), i);
    sort(ys.begin(), ys.end());
    ll cnt = 0;
    fenwick_tree<int> bit1(N), bit2(N);
    for (int i = 0; i < N; i++) {
      cnt += bit1.sum(ys[i].snd);
      bit1.add(ys[i].snd, 1);
    }
    for (int i = N - 1; i >= 0; i--) {
      cnt += bit2.sum(ys[i].snd + 1, N);
      bit2.add(ys[i].snd, 1);
    }
    if (cnt >= M * 2) {
      ok = x;
    } else {
      ng = x;
    }
  }
  return ok;
}

int main() {
  int N;
  while (cin >> N) {
    vector<L> ls(N);
    for (int i = 0; i < N; i++) {
      double A, B, C;
      cin >> A >> B >> C;
      ls[i] = {A, B, C};
    }
    sort(ls.begin(), ls.end(),
         [&](auto& a, auto& b) { return -a.A / a.B < -b.A / b.B; });
    double x = solve(ls, &L::y);
    sort(ls.begin(), ls.end(),
         [&](auto& a, auto& b) { return -a.B / a.A < -b.B / b.A; });
    double y = solve(ls, &L::x);
    printf("%.20f %.20f\n", x, y);
  }
  return 0;
}


Measured memory_bytes: 2252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll limit = 1000000000000000000;

int main() {
    //入力
    ll N;
    cin >> N;
    vector<ll> vec(N);
    for (ll i = 0; i < N; i++) {
      cin >> vec.at(i);
    }

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

    ll ans = 1;
    for(ll i = 0; i < N; i++) {
        if(vec.at(i) <= limit / ans) {
            ans *= vec.at(i);
        } else {
            ans = -1;
            break;
        }
        if(ans == 0) {
            break;
        }
    }

    cout << ans << endl;
}

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

int main()
{
    int n,a=0,b=0,c=0,d=0;
    char inp;

    cin>>n;

    while(n--){
        cin>>inp;
        if(inp=='P')a=1;
        else if(inp=='W')b=1;
        else if(inp=='G')c=1;
        else if(inp=='Y')d=1;
    }

    if((a+b+c+d)==3)cout<<"Three"<<endl;
    else cout<<"Four"<<endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

#define Endl endl

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


int main() {
    cin >> n >> m;
    if (n <= 8 && m <= 8) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << Endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    int n = S.size();

    int ans = 0;
    int r = n/2;
    for(int i=0;i<r;i++){
      if(S.at(i)!=S.at(n-1-i)){
       ans++;
       //cout << i <<endl;
      }
      //ans++;
    }
    cout << ans << endl;
}

// //配列
// vector<int> vec(N);
// for (int i = 0; i < N; i++) {
// cin >> vec.at(i);
// }

// //配列の要素数
// 配列変数.size();

// //初期値の指定
// vector<型> 配列名(要素数, 初期値);

// //要素の追加
// vec.push_back(10);

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

using namespace std;
using   ll=long long;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve()
{
	int num = 1;
	
	int n;
	
	int b;
	
	cin >> n >> b;
	
	while(n--) {
		if(num*2 <= num+b) {
			num *= 2;
		}
		else {
			num += b;
		}
	}
	
	cout << num;
}

signed main() {
    fast;
    
    int t = 1;
    
	//cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3656
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>

using namespace std;
typedef long long int ll;


ll n,q,h,s,d,nh,ns,nd,sm=0;

int main(){
    scanf("%lld %lld %lld %lld",&q,&nh,&ns,&nd);
    h=min(q*2,nh);
    s=min(h*2,ns);
    d=min(s*2,nd);
    scanf("%lld",&n);
    n*=4;
    while(n>=8){
        sm+=d;
        n-=8;
    }
    while(n>=4){
        sm+=s;
        n-=4;
    }
    printf("%lld\n",sm);
}

Measured memory_bytes: 256
s = input()
t = input()
dp = [[0] * (len(t)+1) for _ in range(len(s)+1)]

for s_i in range(len(s)):
    for t_i in range(len(t)):
        if s[s_i] == t[t_i]:
            dp[s_i+1][t_i+1] = dp[s_i][t_i] + 1
        else:
            dp[s_i+1][t_i+1] = max(dp[s_i][t_i+1], dp[s_i+1][t_i])

ans = []
s_i = len(s)
t_i = len(t)
while s_i > 0 and t_i > 0:
    if dp[s_i][t_i] == dp[s_i][t_i-1]:
        t_i -= 1
    elif dp[s_i][t_i] == dp[s_i-1][t_i]:
        s_i -= 1
    else: #dp[s_i][t_i]  dp[s_i-1][t_i] == 1:
        s_i -= 1
        t_i -= 1
        if t_i >= 0:
            ans.append(t[t_i])


print("".join(ans[::-1]))

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


int main() {
  string s;
  cin >> s;
  
  int hui=0, ans=0;
  for(int i=0; i<s.size(); ++i) {
    if (s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
      ++hui;
    }
    else{
      ans=max(ans,hui);
      hui=0;
    }
  }
  cout << max(ans,hui)<<'\n';
  return 0;
}

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

int main() {
  int x,y;
  cin>>x>>y;
  int a=0;
  int b=x;
  for(int i=0;i<x+1;i++){
    if(4*a+2*b==y){
      cout<<"Yes";
      return 0;
    }
    a++;
    b--;
  }
  cout<<"No";
}

Measured memory_bytes: 3596
s = input()
k = int(input())


lis = []
i = 0
cnt = 1

for i in range(0, len(s)-1):
    if s[i] == s[i+1]:
        cnt += 1
    else:
        lis.append(cnt)
        cnt = 1
else:
    lis.append(cnt)

res = 0

if len(lis) == 1:
    res += (lis[0]*k)//2
else:
    if s[0] == s[len(s)-1]:
        for a in lis[1:-1]:
            res += ((a)//2)*k
        res += ((lis[0])//2)*1
        res += ((lis[-1])//2)*1
        res += ((lis[0]+lis[-1])//2)*(k-1)
    else:
        for a in lis:
            res += ((a)//2)*k

print(res)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
using namespace std;
#define int long long
typedef pair<int, int> P;
int dp[4][19000];
int ar(int a) {
	a += 4; return a % 4;
}
int rst(int r) {
	for (int i = 0; i < 19000; i++)dp[r][i] = 0;
	return 0;
}

signed main() {
	string s;
	cin >> s;
	int x, y;
	cin >> x >> y;
	vector<int>V;
	int f = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'F')f++;
		else {
			V.push_back(f);
			f = 0;
		}
	}
	V.push_back(f);

	dp[0][9000 + V[0]] = 1;
	int ax = 0, ay = 0;
	int Z = V.size();
	int mx = 0, my = 1;

	for (int i = 2; i < Z; i += 2) {
		mx = i;
		for (int j = 0; j < 18000; j++) {
			if (j + V[i] < 18000) {
				dp[ar(i)][j] += dp[ar(i - 2)][j + V[i]];
				dp[ar(i)][j] = min(dp[ar(i)][j], 114LL);
			}
			if (j >= V[i]) {
				dp[ar(i)][j] += dp[ar(i - 2)][j - V[i]];
				dp[ar(i)][j] = min(dp[ar(i)][j], 114LL);
			}
		}
		rst(ar(i - 2));
	}

	if (dp[ar(mx)][9000 + x])ax++;

	if (V.size() >= 2) {
		dp[1][9000 + V[1]] = 1;
		dp[1][9000 - V[1]] = 1;
		for (int i = 3; i < Z; i += 2) {
			my = i;
			for (int j = 0; j < 18000; j++) {
				if (j + V[i] < 18000) { dp[ar(i)][j] += dp[ar(i - 2)][j + V[i]]; 
				dp[ar(i)][j] = min(dp[ar(i)][j], 114LL);
				}
				if (j >= V[i]) {
					dp[ar(i)][j] += dp[ar(i - 2)][j - V[i]];
					dp[ar(i)][j] = min(dp[ar(i)][j], 114LL);
				}
			}
			
		rst(ar(i - 2));
		}
		if (dp[ar(my)][9000 + y])ay++;
	}
	else {
		if (y == 0)ay++;
	}
	if (ax&&ay)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

int div(int N){
	int count = 0;
	for(int j=1; j*j<=N; j++){
		if(N%j==0){
			if(j==(N/j)) count++;
			else count+=2;
		}
	}
	return count;
}


int main(){
	int N, sum=0;
	cin>>N;
	for(int i=1; i<=N-1; i++){
		sum+=div(N-i);
	}
	cout<<sum;
	return 0;
	
	
	
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, j, k, D[100001], cnt[100001]={0}, max=0;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> D[i];
        cnt[D[i]]++;
        chmax(max, D[i]);
    }

    if(D[1]!=0 || cnt[0]>=2){
        cout << 0 << endl;
    }

    else if(N==1){
        cout << 1 << endl;
    }

    else{
        i = 0;
        while(cnt[i]>=1){
            i++;
        }
        i--;

        if(i==max){
            if(max<=1){
                cout << 1 << endl;
            }
            else{
                ll ans = 1;
                for(j=2; j<=max; j++){
                    //ans *= powl(cnt[j-1],cnt[j]);
                    //ans %= 998244353;
                    for(k=1; k<=cnt[j]; k++){
                        ans *= cnt[j-1];
                        ans %= 998244353;
                    }
                }
                cout << ans << endl;
            }
        }

        else{
            cout << 0 << endl;
        }
    }

    return 0;
}

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

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

    int n, k;
    cin >> n >> k;
    vector<long long> e(n);
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        e[i] = p + 1;
    }
    long long nax = 0, tmp;
    for (int i = 0; i < k; i++) nax += e[i];
    tmp = nax;
    for (int i = 0; i < n - k; i++) {
        tmp -= e[i];
        tmp += e[i + k];
        nax = max(nax, tmp);
    }
    cout << nax / 2 << (nax & 1 ? ".5" : ".0") << endl;
}


Measured memory_bytes: 1792
(defun solve (q h s d n &optional (ans 0))
  (setq s (min (* 4 q)
               (* 2 h)
               s))
  (setq ans (* (floor n 2) (min (* s 2) d)))
  (when (oddp n)
    (setq ans (+ ans s)))
  (floor ans))

(defun main ()
  (let ((q (read))
        (h (read))
        (s (read))
        (d (read))
        (n (read)))
    (princ (solve q h s d n))
    (fresh-line)))

(main)


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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  
  int ans=0;
  
  sort(A.begin(),A.end());
  
  for(int i=0;i<K;i++)ans+=A[i];
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3668
#include<stdio.h>
int main() {

    int n, j, key;
    int arr[1000+5];
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d",&arr[i]);
    for ( int i = 0; i < n; i++ ) {
        j = i - 1;
        key = arr[i];

        while( j >= 0 && arr[j] > key) {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = key;

        for(int k = 0; k < n; k++) {
            if( k > 0 ) printf(" ");
            printf("%d", arr[k]);
        }
        printf("\n");
    }
    return 0;
}




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

int main(){

    int n,m;
    cin>>n>>m;
    int ac=0,pe=0;
    vector<string> a(n,"WA");
    vector<int> penalty(n);
    for(int i=0;i<m;i++){
        int p; string s;
        cin>>p>>s;
        if(a[p-1]=="WA"){
            if(s=="WA") penalty[p-1]++;
            else{
                ac++; 
                pe+=penalty[p-1];
                a[p-1]="AC";
            }
        }

    }
    cout<<ac<<" "<<pe<<endl;



    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REP2(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,n) REP(i,0,n)
#define SORT(d) sort(d.begin(),d.end())
#define pb push_back
#define mp make_pair

int M;

vector<pair<int,int>> ans;

void dasu(int a,int b){
    ans.pb(mp(a,b));
    return;
}

void dasu2(int a,int b){
    dasu(a,b);
    dasu(a,M-b);
    dasu(M-a,b);
    dasu(M-a,M-b);
    //cout<<"arrived"<<endl;
    return;
}

int main(){
    int N; cin>>N;
    M=N; if(N%2==0) M++;
    //cout<<"M"<<M<<endl;
    int K=M/2;
    if(K>1) REP(i,1,K) dasu2(i,i+1);
    if(N%2==0 && N>4) dasu2(K,1);
    if(N%2){
        dasu(M,1);
        dasu(M,M-1);
        if(M>3)dasu(M,K);
        if(M>3)dasu(M,M-K);
    }
    cout<<ans.size()<<endl;
    rep(i,ans.size()) cout<<ans.at(i).first<<' '<<ans.at(i).second<<endl;


    
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in);) {
			
			int n = sc.nextInt();
			int x[] = new int[n];
			int y[] = new int[n];
			
			for(int i = 0; i < n; i++) {
				x[i] = sc.nextInt();
			}
			for(int i = 0; i < n; i++) {
				y[i] = sc.nextInt();
			}
			
			double pOneSigma = 0;
			double pTwoSigma = 0;
			double pThreeSigma = 0;
			double max = 0;
			
			for(int i = 0; i < n; i++) {
				double abs = Math.abs(x[i] - y[i]);
				pOneSigma += abs;
				pTwoSigma += Math.pow(abs, 2);
				pThreeSigma += Math.pow(abs, 3);
				
				if(max < abs) {
					max = abs;
				}
			}
			
			System.out.format("%.6f\n", pOneSigma);
			System.out.format("%.6f\n", Math.sqrt(pTwoSigma));
			System.out.format("%.6f\n", Math.cbrt(pThreeSigma));
			System.out.format("%.6f\n", max);
		}
	}
}


Measured memory_bytes: 26576
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

a,b,t=I()


print(t//a*b)


Measured memory_bytes: 10280
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int

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

    llong n, W;
    cin >> n >> W;
    vector<llong> V1, V2, V3, V4;
    llong w0;
    for (int i = 0; i < n; ++i) {
        int check, v;
        if (i == 0) {
            cin >> w0 >> v;
            V1.push_back(v);
        } else {
            cin >> check >> v;
            if (check - w0 == 0) V1.push_back(v);
            else if (check - w0 == 1) V2.push_back(v);
            else if (check - w0 == 2) V3.push_back(v);
            else if (check - w0 == 3) V4.push_back(v);
        }
    }

    sort(V1.begin(), V1.end());
    sort(V2.begin(), V2.end());
    sort(V3.begin(), V3.end());
    sort(V4.begin(), V4.end());
    V1.push_back(0);
    V2.push_back(0);
    V3.push_back(0);
    V4.push_back(0);
    reverse(V1.begin(), V1.end());
    reverse(V2.begin(), V2.end());
    reverse(V3.begin(), V3.end());
    reverse(V4.begin(), V4.end());
    for(int i = 1; i <= V1.size(); ++i) {
        V1[i] += V1[i - 1];
    }
    for(int i = 1; i < V2.size(); ++i) {
        V2[i] += V2[i - 1];
    }
    for(int i = 1; i < V3.size(); ++i) {
        V3[i] += V3[i - 1];
    }
    for(int i = 1; i < V4.size(); ++i) {
        V4[i] += V4[i - 1];
    }

    llong ans = 0;
    llong w = 0;
    for (int i = 0; i < V1.size(); ++i) {
        for (int j = 0; j < V2.size(); ++j) {
            for (int k = 0; k < V3.size(); ++k) {
                for (int l = 0; l < V4.size(); ++l) {
                    w = w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l;
                    if (w <= W) ans = max(ans, V1[i] + V2[j] + V3[k] + V4[l]);
                }
            }
        }
    }

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define F first
#define S second
#define mp make_pair
#define um unordered_map
#define all(x) (x).begin(), (x).end() 
#define reps(i, j, k) for(auto i = j; i < k; ++i)
#define rep(i, j) reps(i, 0, j)
#define decs(i, j, k) for(auto i = j; i >= k; --i)
#define dec(i, j) decs(i, j, 0)
using namespace std;
bool comp(const pi &l, const pi &r)
{
	if(l.F != r.F) return l.F < r.F;
	else return l.S < r.S;
}
int main()
{
	int n; cin >> n;
	vector<pi> c(n);
	rep(i, n) cin >> c[i].F >> c[i].S;
	sort(all(c), comp);
	double avg = 0;
	do
	{
		rep(i, n - 1)
			avg += sqrt((c[i].F - c[i + 1].F) * (c[i].F - c[i + 1].F) + (c[i].S - c[i + 1].S) * (c[i].S - c[i + 1].S));		
	}while(next_permutation(all(c)));
	int fact = 1;
	reps(i, 1, n + 1) fact *= i;
	printf("%.15f", avg / (double)fact);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#include <bitset>

#define mod 1e9+7
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

 
int main(){
	int A, B;
	cin >> A >> B;
	if (A != 1 && B != 1){
		cout << 1;
	}
	else if(A != 2 && B != 2){
		cout << 2;
	}
	else cout << 3;
	return 0;
}

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

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	int ans = 0;
	if(k == 0){
		ans = n * n;
		cout << ans << endl;
		return 0;
	}
	rep(i, 1, n + 1){
		if(i <= k) continue;
		int q = n / i;
		ans += q * (i - k);
		int r = n % i;
		ans += max(0LL, r - k + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
const long long mod = 1000000007;
long long pow(long long i, long long exp){
    if(exp==0) return 1;
    return i*pow(i, exp-1)%mod;
}
int main(){
    long long n; cin>>n; long long answer=0;
    vector<long long> v;
    for(long long i =0; i< n; i++){
        long long temp; cin>>temp;
        v.push_back(temp);
    }
    for(long long i =0; i<64; i++){
        vector<long long> bits; long long ones=0;
        for(long long z=0; z<v.size(); z++){
            bits.push_back(v[z]%2);
            ones += v[z]%2;
            v[z] /= 2;
        }
        answer+=pow(2,i)*ones%mod*(n-ones);
        answer%=mod;
    }
    cout<<answer;


    return 0;
}

Measured memory_bytes: 12028
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const ll MOD = 1000000007;
const int MSIZE = 100007;
const double Pi = 3.14159265358979323146;

int main(){
  int dy[2]={0, 1};
  int dx[2]={1, 0};
  int h, w; cin >> h >> w;
  vector<vi> vec(h, vi(w));
  vi cy, cx, cny, cnx;
  REP(y, h) REP(x, w){
    cin >> vec[y][x];
  }
  int cnt=0;
  REP(y, h) REP(x, w){
    if(vec[y][x]%2==0)  continue;
    bool find=false;
    REP(i, 2){
      int ny = y+dy[i];
      int nx = x+dx[i];
      if(ny<0 || ny>=h || nx<0 || nx>=w)  continue;
      vec[y][x]--;
      vec[ny][nx]++;
      cnt++;
      cy.pb(y);
      cx.pb(x);
      cny.pb(ny);
      cnx.pb(nx);
      break;
    }
  }
  cout << cnt << endl;
  REP(i, cnt){
    cout << cy[i]+1 << " " << cx[i]+1 << " " << cny[i]+1 << " " << cnx[i]+1 << endl;
  }
}


Measured memory_bytes: 5224
a,b=map(int,input().split())
ans=[['#' for i in range(100)] for j in range(50)]
ans+=[['.' for i in range(100)] for j in range(50)]
for i in range(a-1):
    ans[(i//50)*2][(i%50)*2]='.'
for i in range(b-1):
    ans[(i//50)*2+52][(i%50)*2]='#'
print(100,100)
for i in range(100):
    print(''.join(ans[i]))

Measured memory_bytes: 3064
N = int(input())
S = [input(), input()]
MOD = 1000000007

i = 0
ans = 3
prev_n = 0
while i < N:
    if S[0][i] == S[1][i]:
        n = 1
        i += 1
    else:
        n = 2
        i += 2
    if prev_n == 0 and n == 2:
        ans *= 2
    elif prev_n == 1:
        ans = (ans * 2) % MOD
    elif prev_n == 2 and n == 2:
        ans = (ans * 3) % MOD
    prev_n = n
print(ans)


Measured memory_bytes: 3064
use num::Integer;
use whiteread::Reader;

fn main() {
    let mut rdr = Reader::from_stdin_naive();
    let a: u64 = rdr.p();
    let b: u64 = rdr.p();
    let x: u64 = rdr.p();
    println!(
        "{}",
        (b / x) - (a / x) + if a.is_multiple_of(&x) { 1 } else { 0 }
    );
}


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

int main(){
  int n; cin >> n;
  vector<long long> c(n);
  for(int i = 0; i < n; i++){
    cin >> c.at(i);
  }
  sort(c.rbegin(), c.rend());
  long long a = 0, b = 0;
  for(int i = 0; i < n - 1; i++){
    if(c.at(i) == c.at(i+1)){
      if(!a){
        a = c.at(i);
        i = i + 1;
      }
      else if(!b){
        b = c.at(i);
        break;
      }
    }
  }
  cout << a * b << endl;
}
      
    



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

using namespace std;

#define deb(x) cout << #x << " " << x << endl;

typedef long long ll;
const ll mod = 1000000007;

#define ffor(i,n) for(i=0;i<n;++i)

int main(){
    
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    int a,b,i,temp,q,t,f;
    string c;
    string s;
    cin>>s;
    cin>>q;
    int start=0;
    int end=s.length();
    while(q--){
        cin>>t;
        if(t==1){
            temp=start;
            start=end;
            end=temp;
            //cout<<s<<'\n';
        }
        else if(t==2){
            cin>>f;
            cin>>c;
            if(f==1){
                s.insert(start,c);
                if(start<end)
                    end++;
                else
                {
                    start++;
                }
                
            }
            else{
                s.insert(end,c);
                if(start<end)
                    end++;
                else
                {
                    start++;
                }
            }
        }
    }
    if(start<end)
        cout<<s;
    else
    {
        reverse(s.begin(),s.end());
        cout<<s;
    }
    cerr << "\n\nTime elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}

Measured memory_bytes: 912
//AtCoder ABC060 C - Sentou
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N,T;
    cin>>N>>T;
    vector<ll> tbl(N,0);
    for(auto&& t:tbl){
        cin>>t;
    }
    ll ans=T;//最後の人
    for(ll i=1;i<N;++i){
        ans += min(T,tbl[i]-tbl[i-1]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sum := make([]int, n+1) // 累積和
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sum[0] = 0
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
		sum[i+1] = sum[i] + a[i]
	}
	ans := 10000000000
	for i := 1; i < n; i++ { // snukeくんが1~i枚目、アライグマがi+1~n枚目をとったとする。
		s := sum[i] - sum[0]
		a := sum[n] - sum[i]
		ans = min(ans, abs(s-a))
	}
	fmt.Println(ans)
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}


Measured memory_bytes: 4608
import sys
import math

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


# def factorization(n):
#     factor = []
#     tmp = int(math.sqrt(n)) + 1
#     for i in range(2, tmp):
#         while n % i == 0:
#             n //= i
#             factor.append(i)
#         if len(factor) != 0:
#             factor.append(n)
#             return factor
#     return []


def solve(inputs):
    N = int(inputs[0])
    # factors = factorization(N)
    min_diff = None
    for i in range(1, 1000001):
        if N % i == 0:
            a = N // i
            diff = a + i - 2
            if min_diff is None or min_diff > diff:
                min_diff = diff
    return min_diff


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 38896
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

struct HL {
    int h, p, q;
};

bool comp(const HL& a, const HL& b) {
    if (a.h == b.h) { return a.p > b.p; }
    else { return a.h > b.h; }
}

int main() {
    int n, m, a;
    HL hl[1001];
    int ans;

    while (cin >> n >> m >> a) {
        if (!n && !m && !a) { break; }
        memset(hl, 0, sizeof(hl));

        for (int i = 0; i < m; i++) {
            cin >> hl[i].h >> hl[i].p >> hl[i].q;
        }

        sort(hl, hl+m, comp);

        ans = a;

        for (int i = 0; i < m; i++) {
            if (ans == hl[i].p) {
                ans = hl[i].q;
            } else if (ans == hl[i].q) {
                ans = hl[i].p;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
 
#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef long long ll;
typedef unsigned long long ull;
 
using namespace std;
ll mxn = 1e9+1;
ll n;
ll dp[200001];
ll arr[200001];
 
int main() {FIN;
  
    int k;
    cin>>n>>k;
    arr[n];
    fore(i,0,n)cin>>arr[i];
    fill(dp,mxn);
    dp[0] = 0;
    fore(i,0,n){
 
        fore(j,i+1,i+k+1){
 
            if(j<n)
                dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[j]));
        }
 
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}
 
 

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

using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

void solve(){
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);

	ll ans;

	ll needed = x / d;
	if(needed >= k){
		ans = x - k * d;
	}
	else{
		k -= needed;
		if(k & 1) ans = min(x - (needed - 1) * d, abs(x - (needed + 1) * d));
		else ans = x - needed * d;
	}

	cout << ans << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'

using namespace std;

int main()
{
    int t,ans=0,ma=0;
    cin>>t;
    
    while(t--){
        int a,b;
        cin>>a>>b;
        
        if(a == b) ans++;
        
        else ans=0;
        
        ma= max(ans,ma);
        
    }
    
    //cout<<ma;
    
    if(ma>2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int MN = 100100;
vi g[MN];
int dp[MN];
int rt,b;
int ds(int u, int p) {
	if(dp[u] != -1) return dp[u];
	vi w;
	for(int i=0;i<g[u].size();i++) {
		int v = g[u][i];
		if(v == p) continue;
		w.push_back(ds(v,u));
	}
	if(!(w.size()&1)) {w.push_back(0);}
	sort(w.begin(),w.end());
	int s = 0,e = w.size()-1;
	int ls = -1;
	while(s <= e) {
		int st = 0,ed = w.size()-1;
		int m = (s+e)/2;
		bool pp = true;
		while(1) {
			if(st == m) {st++;}
			if(ed == m) {ed--;}
			if(st > ed) break;
			if(w[st]+w[ed] > b) {
				pp = false;break;
			}
			st++;ed--;
		}
		if(pp) {
			ls = m;e = m-1;
		} else {
			s = m+1;
		}
	}
	if(ls < 0) {dp[u] = MN*9;} else {
		dp[u] = w[ls]+1;
	}
	return dp[u];
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	for(int i=0;i<n-1;i++) {
		int a,b;
		cin >> a >> b;a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int no = 0;
	for(int i=0;i<n;i++) {
		if(g[i].size() == 1) {rt = i;}
		if(g[i].size()&1) {no++;}
	}
	int s = 1,e = n;
	int ls = n;
	while(s <= e) {
		memset(dp,-1,sizeof(dp));
		int m = (s+e)/2;
		b = m;
		ds(rt,-1);
		bool po = true;
		for(int i=0;i<n;i++) {
			if(dp[i] > b + (i==rt?1:0)) {
				po = false;break;
			}
		}
		if(po) {
			ls = m;e = m-1;
		} else {
			s = m+1;
		}
	}
	cout << no/2 << " " << ls << '\n';
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> N;

    ll a = N % 10;

    if(a==3){
        cout << "bon" << endl;
    }
    else if (a==0||a==1||a==6||a==8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<cstdio>

using namespace std;

#define rep(i, n) for(long int i = 0; i < n; i++)
#define P pair<long int, long int>


int main(){
    int m, k;
    cin >> m >> k;
    int n = (1 << (m+1));
    if (k >= (1 << m)){
        cout << -1 << endl;
    }else if (m == 1){
        if (k == 0){
            cout << "0 0 1 1" << endl;
        }else{
            cout << -1 << endl;
        }
        
    }else{
        int a[n];
        int num = 0;
        for (int i = 0; i < k; i++){
            a[i] = i;
        }
        for (int i = k; i < n / 2 - 1; i++){
            a[i] = i + 1;
        }
        a[n/2-1] = k;
        a[n-1] = k;
        for (int i = 0; i < k; i++){
            a[n-2-i] = i;
        }
        for (int i = k; i < n / 2 - 1; i++){
            a[n-2-i] = i + 1;
        }

        rep(i, n) cout << a[i] << " ";
        cout << endl;
    }

}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define trav(x, v) for(auto &x : v)
#define all(v) v.begin(),v.end()
#define sz(v) int(v.size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll mod = 998244353;

ll modpow(ll a, ll e){
        ll res = 1;
        do {
                if(e % 2) res = res * a % mod;
                a = a * a % mod;
        } while(e >>= 1);
        return res;
}

int main(){
        cin.tie(0);
        cin.sync_with_stdio(0);
        cin.exceptions(cin.failbit);

        int n;
        cin >> n;

        vector<ll> fs(n+1,1);
        rep(i,0,n) fs[i+1] = fs[i] * (i+1) % mod;

        auto bin = [&](int n, int k){
                return fs[n] * modpow(fs[k] * fs[n-k] % mod, mod-2) % mod;
        };

        ll sub = 0;

        rep(i,n/2+1,n+1) sub += bin(n, i) * modpow(2, n-i) % mod;

        ll ans = modpow(3, n) - 2*sub;
        ans %= mod;

        if(ans < 0) ans += mod;

        cout << ans << endl;
}

Measured memory_bytes: 78336
#include <functional>  
#include <algorithm>  
#include <iostream>  
#include <fstream>  
#include <sstream>  
#include <iomanip>  
#include <numeric>  
#include <cstring>  
#include <cassert>  
#include <cstdio>  
#include <string>  
#include <vector>  
#include <bitset>  
#include <queue>  
#include <stack>  
#include <cmath>  
#include <ctime>  
#include <list>  
#include <set>  
#include <map>  
#include <climits>

using namespace std;

#define PB push_back  
#define MP(A, B) make_pair(A, B)  
#define fi first  
#define se second  

#define gcd(a,b) __gcd(a,b)
#define pi acos(-1.0)
#define pii pair<int,int>
#define ll long long  
#define MAX 1000005  
#define MOD 1000000007  
#define INF 0x3f3f3f3f  
#define EXP 1e-8  
#define lowbit(x) (x&-x)  
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

ll GCD(ll a, ll b)  
{  
    return b ? GCD(b, a % b) : a;  
}  
const int PRIMERANGE = 1000000;  
int prime[PRIMERANGE + 1];  
int getPrime()  
{  
    memset (prime, 0, sizeof (int) * (PRIMERANGE + 1));  
    for (int i = 2; i <= PRIMERANGE; i++)  
    {  
        if (!prime[i]) prime[++prime[0]] = i;  
        for (int j = 1; j <= prime[0] && prime[j] <= PRIMERANGE / i; j++)  
        {  
            prime[prime[j]*i] = 1;  
            if (i % prime[j] == 0) break;  
        }  
    }  
    return prime[0];  
}  
/*************************************** 
get factor of n 
O(sqrt(n)) 
factor[][0] is prime factor 
factor[][1] is factor generated by this prime 
factor[][2] is factor counter 

need: Prime Table 
***************************************/  
///you should init the prime table before  
int factor[100][3], facCnt;  
int getFactors(int x)  
{  
    facCnt = 0;  
    int tmp = x;  
    for(int i = 1; prime[i] <= tmp / prime[i]; i++)  
    {  
        factor[facCnt][1] = 1, factor[facCnt][2] = 0;  
        if(tmp % prime[i] == 0)  
            factor[facCnt][0] = prime[i];  
        while(tmp % prime[i] == 0)  
            factor[facCnt][2]++, factor[facCnt][1] *= prime[i], tmp /= prime[i];  
        if(factor[facCnt][1] > 1) facCnt++;  
    }  
    if(tmp != 1)  
        factor[facCnt][0] = tmp, factor[facCnt][1] = tmp, factor[facCnt++][2] = 1;  
    return facCnt;  
}  

ll a, b, x;
int main()
{
    cin >> x;
    // getPrime();
    // getFactors(x);
    // // for (int i = 0; i < facCnt; ++i) cout << factor[i][0] << ' ' << factor[i][1] << ' ' << factor[i][2] << endl;
    // // dfs(0, 1, 1);
    // // ll ans = x==1?0:qpow(2, ((ll)(log(x-1)/log(2))/5));
    // ll ans = x==1?0:pow(x+1, 1/5.0);
    // cout << ans << ' ' << -1 << endl;
    for (int i = -120; i <= 120; ++i)
        for (int j = -120; j <= 120; ++j) {
            if (qpow(i, 5) - qpow(j, 5) == x) {
                cout << i << ' ' << j << endl;
                return 0;
            }
        }

    return 0;
}

Measured memory_bytes: 3640
X = str(input())

# 文字列を4つのintに分裂
# 二分検索でヒットしたらタス、そうでなければ引く、listに履歴を残しておく

for i in range(2**3):
  ans = int(X[0])
  list = []
  for j in range(3):
    if (i>>j & 1) == 1:
      ans += int(X[j+1])
      list.append("+")
    else:
      ans -= int(X[j+1])
      list.append("-")
  if ans == 7:
    break

ans = X[0]
for i in range(3):
  ans += list[i]
  ans += X[i+1]
print(ans+"=7")

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    string s;
    cin>>s;
    string t=s;
    sort(t.begin(),t.end());
    t.erase(unique(t.begin(),t.end()),t.end());
    if(t.size()==s.size()) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int h, w, n;
    int[] as;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        h = sc.nextInt();
        w = sc.nextInt();
        n = sc.nextInt();
        as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        int[] sums = new int[n];
        sums[0] = as[0];
        for (int i = 1; i < n; i++) {
            sums[i] = as[i] + sums[i - 1];
        }
        int[][] board = new int[h][w];
        int index = 0;
        int count = 0;
        for (int i = 0; i < h; i++) {
            if (i % 2 == 0) {
                for (int j = 0; j < w; j++) {
                    if (count >= sums[index]) {
                        index++;
                    }
                    board[i][j] = index + 1;
                    count++;
                }
            } else {
                for (int j = w - 1; j >= 0; j--) {
                    if (count >= sums[index]) {
                        index++;
                    }
                    board[i][j] = index + 1;
                    count++;
                }
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                System.out.print(board[i][j]);
                if (j < w - 1) {
                    System.out.print(" ");
                } else {
                    System.out.println();
                }
            }
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 27088