akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

const int INF = 100000;

int H, W;

int posToIndex(int h, int w) {
    return h * W + w;
}

int dp[400][400];


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

    cin >> H >> W;
    vector<string> S(H);
    rep(i, H) cin >> S[i];

    rep(s, 400) rep(d, 400) {
        if (s != d) {
            dp[s][d] = INF;
        }
    }

    bool prog = false;
    do {
        prog = false;
        rep(sy, H) rep(sx, W) {
            if (S[sy][sx] == '.') {
                int is = posToIndex(sy, sx);
                rep(dy, H) rep(dx, W) {
                    if (S[dy][dx] == '.') {
                        int id = posToIndex(dy, dx);
                        if (0 < dy) {
                            int c = dp[is][posToIndex(dy-1, dx)] + 1;
                            if (c < 400 && c < dp[is][id]) {
                                dp[is][id] = c;
                                prog = true;
                            }
                        }
                        if (0 < dx) {
                            int c = dp[is][posToIndex(dy, dx-1)] + 1;
                            if (c < 400 && c < dp[is][id]) {
                                dp[is][id] = c;
                                prog = true;
                            }
                        }
                        if (dx < W-1) {
                            int c = dp[is][posToIndex(dy, dx+1)] + 1;
                            if (c < 400 && c < dp[is][id]) {
                                dp[is][id] = c;
                                prog = true;
                            }
                        }
                        if (dy < H-1) {
                            int c = dp[is][posToIndex(dy+1, dx)] + 1;
                            if (c < 400 && c < dp[is][id]) {
                                dp[is][id] = c;
                                prog = true;
                            }
                        }
                    }
                }
            }
        }
    } while (prog);

    int ans = 0;
    rep(s, 400) rep(d, 400) {
        int c = dp[s][d]; 
        if (c < 400) {
            ans = max(ans, c);
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  int n, t, a, place;
  cin >> n >> t >> a;
  
  double min = 10000000.0;
  vector<int> h(n);
  for(int i = 0; i<n; i++){
    cin >> h.at(i);
    if(abs(t - h.at(i) * 0.006 - a) < min){
      min = abs(t - h.at(i) * 0.006 - a);
      place = i;
    }
  }
  cout << place+1 << endl;
}

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

using namespace std;

int main()
{
    int N;
    string bufS;
    cin >> N;
    cin >> bufS;
    vector<int> S(N);
    for(int i=0;i<N;++i){
        S[i] = bufS[i] == 'E' ? 1 : 0;
    }

    int sumL=0,sumR=0;
    for(auto s:S) if(s) sumR++;
    
    vector<int> score(N);
    int cnt = 0;
    for(auto s:S){
        if(s){
            sumR--;
            score[cnt] = sumL + sumR;
        }else{
            score[cnt] = sumL + sumR;
            sumL++;
        }
        cnt++;
    }
    
    int minI=0;
    int minElm=score[0];
    for(int i=0;i<N;++i){
        if(score[i] < minElm){
            minElm = score[i];
            minI = i;
        }
    }
    
    std::cout << minElm << std::endl;
    return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main(){
    string s;
    cin >> s;
    bool ans = true;
    for(int i=0;i<s.size();i++){
        if(i%2 == 0){
            if(s[i] == 'L'){
                ans = false;
            }
        }
        else{
            if(s[i] == 'R'){
                ans = false;
            }
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define li long long int
#define mod 1000000000+7
char a[1005][1005];
li h,w;
li dp[1005][1005];
void f()
{
    int i,j;
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(i=1;i<w;i++)
    {
        if(a[0][i]=='#')
        {
            break;
        }
        else  dp[0][i]=1;
    }
    for(i=1;i<h;i++)
    {
        if(a[i][0]=='#')
        {

            break;
        }
        else dp[i][0]=1;
    }

    for(i=1;i<h;i++)
    {
        for(j=1;j<w;j++)
        {
            if(a[i][j]!='#')
            {
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]%=mod;
            }
        }
    }

    cout<<dp[h-1][w-1];
    return;
}
int main()
{
    cin>>h>>w;
    li i;
    for(i=0;i<h;i++)
        cin>>a[i];
    f();
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
//const int mod= int(1e9)+7;
const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<mod>;

int main(){
    int n,s;cin >>n>>s;
    V a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    vector<vector<mint>>dp(n+1,vector<mint>(s+1,0));
    dp[0][0]=1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <=s; ++j) {
            dp[i+1][j]+=dp[i][j]*2;
            if(j+a[i]<=s){
                dp[i+1][j+a[i]]+=dp[i][j];
            }
        }
    }
    cout <<dp[n][s]<<endl;
}



Measured memory_bytes: 73676
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<iomanip>
#include <functional>
#include <sstream>

using namespace std;

int main() {
  int n; cin >> n;
  string p = "", q = "";
  for(int i=0; i<n; i++) {
      char tmp; cin >> tmp;
      p += tmp;
  }
  for(int i=0; i<n; i++) {
      char tmp; cin >> tmp;
      q += tmp;
  }
  vector<string> dic;
  vector<int> v(n);
    iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
    do {
        string tmp = "";
        for(int i=0; i<v.size(); i++) {
            ostringstream ss;
            ss << v[i];
            tmp = tmp + ss.str();
        }
        dic.push_back(tmp);
    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成
    sort(dic.begin(), dic.end());
    int a, b;
    for(int i=0; i<dic.size(); i++) {
        if(dic[i]==p) {
            a = i+1;
        }
        if(dic[i]==q) {
            b = i+1;
        }
    }
    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 2424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
void chmax(int &x,int y){if(x < y) x = y;}
void chmin(int &x,int y){if(x > y) x = y;}
ll n,a,b;
int main()
{
    fastio;
    cin>>a>>b>>n;
    if(n < b){
        ll x = n;
        cout<<(x * a / b) - a * (x / b);
    }
    else {
        ll x = b - 1;
        cout<<(x * a / b) - a * (x / b);
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pd(x) cerr<<"//"<<(x)<<endl;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,l,q;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005];
bool flag,dame;


int main(){
    cin >> n;
	cin >> s;
	for(i=0;i<n;i++){
		x[s[i] - 'a']++;
	}
	ans = 1;
	for(i=0;i<=26;i++){
		ans *= (x[i] + 1);
		ans %= mod;
	}
	ans += mod - 1;
	ans %= mod;
	p(ans);

	return 0;
}

Measured memory_bytes: 26240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n,m;
    cin>>n>>m;
    int ans=(1900*m+100*(n-m))*pow(2,m);
    cout<<ans<<endl;
}

Measured memory_bytes: 4080
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	vi t(n + 1, 0), x(n + 1, 0), y(n + 1, 0);
	erep(i, 1, n) cin >> t[i] >> x[i] >> y[i];

	erep(i, 1, n) {
		int time = t[i] - t[i - 1];
		int dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
		if (time < dist || time % 2 != dist % 2) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 1408
// g++ -std=c++11 test.cpp && ./a.out
// g++ -std=c++11 bfs.cpp && cat bfs.txt | ./a.out

#include <algorithm>
#include <iostream>
#include <queue>
#include <functional>
#include <numeric>
#include <math.h>

using namespace std;

#define PRINT(A) {for (int i = 0; i < A.size(); i++) { cout << A[i] << " ";} cout << endl;}
#define SUM(A) accumulate(A.begin(), A.end(), 0)
#define MAX(A) *max_element(A.begin(), A.end())
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int main() {
    int N;
    string C;
    cin >> N;
    cin >> C;

    int l = 0, r = N-1;
    int ans = 0;
    while (l < r) {
        if (C[l] == 'W' and C[r] == 'R') {
            ans += 1;
            l += 1;
            r -= 1;
        } else if (C[l] == 'W') {
            r -= 1;
        } else if (C[r] == 'R') {
            l += 1;
        } else {
            l += 1;
            r -= 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  int n;
  int cnt[2]={0,0};
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    int x;
    scanf("%d",&x);
    cnt[x%2]++;
  }
  if(cnt[1]%2==1)puts("NO");
  else puts("YES");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <map>
#include <algorithm>
#include <math.h>
#include <iostream>     // std::cout, std::fixed
#include <iomanip>
#include<queue>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <iostream>
#include <sstream>
typedef long long ll;
using namespace std;


vector<ll> mem;

ll loc(int x)
{
    if(x==1)
        return 2;
    if(x==2)
        return 1;
    if(mem[x]!=0)
        return mem[x];
    else
    {
        mem[x]=loc(x-1)+loc(x-2);
        return mem[x];
    }
}
int main () {
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    mem=vector<ll>(n+5,0);
    cout<<loc(n+1);
    return 0;
}


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

int main(){
	int n;
	cin>>n;
	double a[2][n];
	vector<double> ans(4);
	for(int i=0; i<2; i++) for(int j=0; j<n; j++) cin>>a[i][j];
	for(int p=1; p<=3; p++){
		double sum=0,max=0;
		for(int i=0; i<n; i++){
			double dis=abs(a[0][i]-a[1][i]);
			if(p==3 && max<dis) max=dis; 
			sum+=pow(dis,p);
		}
		ans[p-1]=pow(sum,(1.0/p));
		if(p==3) ans[3]=max;
	}
	for(int i=0; i<4; i++){
		cout<<fixed<<setprecision(10)<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3404
import sys
import time
import random
import math

t_start = time.perf_counter()

N = 26
D = int(input())

c_list = list(map(int, input().split()))

s_table = []
for _ in range(D):
	s_table.append(list(map(int, input().split())))

last = [-1] * N
data = []
satisfaction = 0
for i in range(D):
	max_c = 0
	max_s = None
	s_list = s_table[i]
	for j in range(N):
		s = s_list[j]
		for k in range(N):
			if k != j:
				s -= c_list[k] * (i - last[k])
		if max_s == None or s > max_s:
			max_s = s
			max_c = j
	data.append(max_c)
	satisfaction += max_s
	last[max_c] = i

print(satisfaction, file = sys.stderr)

def calc(data):
	last = [-1] * N
	satisfaction = 0
	for i in range(D):
		j = data[i]
		satisfaction += s_table[i][j]
		last[j] = i
		for k in range(N):
			satisfaction -= c_list[k] * (i - last[k])
	return satisfaction

def p(value_old, value_new, t):
	if value_new > value_old:
		return True
	else:
#		print(value_old - value_new, file = sys.stderr)
#		print(math.pow(math.e, (value_old - value_new) / t), file = sys.stderr)
		return math.pow(math.e, (value_new - value_old) / t) > random.random()

def optimize(satisfaction, data):
	value = 0
	count = 0
	tmp_data = list(data)
	for i in range(D):
#		for j in range(N):
			j = random.randrange(N)
			while data[i] == j:
				j = random.randrange(N)
			org = tmp_data[i]
			tmp_data[i] = j
			tmp_s = calc(tmp_data)
			if tmp_s < satisfaction:
				value += tmp_s - satisfaction
				count += 1
			tmp_data[i] = org
	
	T = (value / count) / math.log(0.1)
	print(T, value / count, math.log(math.e), math.log(0.5), file = sys.stderr)
	
	t_end = t_start + 1.8
	d = 0.9999
	best = satisfaction
	best_data = list(data)
#	tmp_data = list(data)
	
	c = 0
#	aves = []
	while True:
		if time.perf_counter() > t_end:
			print("count:", c, file = sys.stderr)
			return best, best_data
		i = random.randrange(D)
		j = random.randrange(N)
		while j == data[i]:
			j = random.randrange(N)
		org = tmp_data[i]
		tmp_data[i] = j
		tmp_s = calc(tmp_data)
#		if tmp_s < satisfaction:
#			print(best, T, satisfaction, satisfaction - tmp_s, math.pow(math.e, -(satisfaction - tmp_s) / T), file = sys.stderr)
		if p(satisfaction, tmp_s, T):
#			if p(best, tmp_s, T):
			satisfaction = tmp_s
			data[i] = j
			if satisfaction > best:
				best = satisfaction
				best_data = list(data)
#			print(T, tmp_s, file = sys.stderr)
		else:
			tmp_data[i] = org
#		if c < 100:
#			aves.append(math.pow(math.e, -(satisfaction - tmp_s) / T))
#		elif c == 100:
#			print("a:", sum(aves) / len(aves), file = sys.stderr)
		c += 1
		T *= d

satisfaction, data = optimize(satisfaction, data)

print(calc(data), file = sys.stderr)

for j in data:
	print(j + 1)


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

int main(){

  for(int i = 0;i < 9;i++){
    for(int j = 0;j<9;j++){
      printf("%dx%d=%d\n",i+1,j+1,(i+1)*(j+1));
    }
  }

    return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,l,t,x,w,ans[100001],p,s;
int main(){
	scanf("%d%d%d",&n,&l,&t);
	for(long long i=1;i<=n;i++){
		scanf("%d%d",&x,&w);
        if(w==2)p=x-t;
        else p=x+t;
        if(p>0)s=(s+p/l)%n;
        if(p<0)s=(s+(p+1)/l-1)%n;
        ans[i]=(p%l+l)%l;
    }
    sort(ans+1,ans+n+1);
    if(s>=0)s=s%n;
    else{
    	p=(s+1)/n+1;
    	s=s+p*n;
	}
    for(long long i=s+1;i<=n;i++)printf("%d\n",ans[i]);
    for(long long i=1;i<=s;i++)printf("%d\n",ans[i]);
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fio ios_base::sync_with_stdio(false)
using namespace std;
int main(){
  ll n;
  cin>>n;
  vector<int>vec(n);
  ll xo=0;
  for(int i=0;i<n;i++){
  cin>>vec[i];
  xo=xo^vec[i];
   }
  for(int i=0;i<n;i++){
    vec[i]=xo^vec[i];
  }
  for(int i=0;i<n;i++)
  cout<<vec[i]<<" ";

  }


Measured memory_bytes: 4032
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
    ll h,w,ans=0,a;
    cin>>h>>w;
    lol(i,h)lol(j,w){
	cin>>a;
	ans+=a*(i+1)*(h-i)*(j+1)*(w-j);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#include<atcoder/all>

using namespace std;
using namespace atcoder;

int main(){
    int T;
    cin>>T;
    for(int i=0;i<T;i++){
        long long N,M,A,B;
        cin>>N>>M>>A>>B;
        cout<<floor_sum(N,M,A,B)<<endl;
    }
}


Measured memory_bytes: 3672
#include <iostream>

using namespace std;

int N, M;
int maxv[105];

int main(void)
{
	while(1){
		cin >> N >> M;
		if( N == 0 && M == 0 ) break;
		
		for(int i = 1; i <= M; i++) maxv[i] = 0;
		
		int d, v;
		for(int i = 0; i < N; i++){
			cin >> d >> v;
			maxv[d] = max(maxv[d], v);
		}
		int ans = 0;
		for(int i = 1; i <= M; i++) ans += maxv[i];
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3048
n = int(input())
a = list(map(int, input().split()))

a_max = -10**7
a_max_idx = -1
a_min = 10**7
a_max_idx = -1
for i, ai in enumerate(a):
    if a_max < ai:
        a_max = ai
        a_max_idx = i
    if a_min > ai:
        a_min = ai
        a_min_idx = i

operation = []
if abs(a_max) > abs(a_min):
    for i, ai in enumerate(a):
        if ai < 0:
            operation.append((a_max_idx + 1, i + 1))
    # 全てが正になる
    for i in range(1, n):
        operation.append((i, i + 1))
else:
    for i, ai in enumerate(a):
        if ai > 0:
            operation.append((a_min_idx + 1, i + 1))
    # 全てが正になる
    for i in reversed(range(1, n)):
        operation.append((i + 1, i))

print(len(operation))
for opi in operation:
    print(*opi)


Measured memory_bytes: 3064
a,b,c,d=map(int,list(input()))
s = [list(map(int,bin(x)[2:].zfill(3))) for x in range(2**3)]
ans = a
op = []
for i in range(2**3):
    if s[i][0]==0:
        ans += b
        op.append('+')
    else:
        ans -= b
        op.append('-')
    if s[i][1]==0:
        ans += c
        op.append('+')
    else:
        ans -= c
        op.append('-')
    if s[i][2]==0:
        ans += d
        op.append('+')
    else:
        ans -= d
        op.append('-')
    if ans ==7:
        break
    ans = a
    op.clear()
t = str(a)+op[0]+str(b)+op[1]+str(c)+op[2]+str(d)+'=7'
print(t)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<vector<ll>> dp1(n, vector<ll>(16, INF));
    REP(i, 16) dp1[n-1][i] = i;
    for(ll i=n-2; i>=0; --i) {
        ll p1 = 1;
        REP(j, 16) {
            // a[i]*4^j <= a[i+1]*4^cnt を満たすcnt
            ll p2 = 1, cnt = 0;
            while(a[i] * p1 > a[i+1] * p2) {
                p2 *= 4;
                cnt++;
            }
            FOR(k, cnt, 16) chmin(dp1[i][j], dp1[i+1][k]+j);
            if(cnt>=16) chmin(dp1[i][j], dp1[i+1][15]+(cnt-15)*(n-i-1)+j);
            p1 *= 4;
        }
    }
    dump(dp1);

    REP(i, n) a[i] *= -2;
    vector<vector<ll>> dp2(n, vector<ll>(16, INF));
    REP(i, 16) dp2[0][i] = i;
    FOR(i, 1, n) {
        ll p1 = 1;
        REP(j, 16) {
            // a[i-1]*4^cnt <= a[i]*4^j を満たすcnt
            ll p2 = 1, cnt = 0;
            while(a[i-1] * p2 > a[i] * p1) {
                p2 *= 4;
                cnt++;
            }
            FOR(k, cnt, 16) chmin(dp2[i][j], dp2[i-1][k]+j);
            if(cnt>=16) chmin(dp2[i][j], dp2[i-1][15]+(cnt-15)*i+j);
            p1 *= 4;
        }
    }
    dump(dp2);

    ll ret = INF;
    REP(i, n-1) {
        ll vl = INF, vr = INF;
        REP(j, 16) {
            chmin(vl, dp1[i+1][j]);
            chmin(vr, dp2[i][j]);
        }
        chmin(ret, (vl+vr)*2+i+1);
    }
    REP(i, 16) chmin(ret, dp1[0][i]*2);
    REP(i, 16) chmin(ret, dp2[n-1][i]*2+n);
    cout << ret << endl;

    return 0;
}

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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    set<int> s;
    loop(i,3){
        int x;
        cin >> x;
        s.insert(x);
    }

    if(SZ(s) == 2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    int t;
    vector<int> score(n, k-q);
    REP(i, q){
        cin >> t;
        t--;
        score[t]++;
    }
    REP(i, n){
        cout << ((score[i] > 0) ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<long long, int>, // change type
//        null_type,
//        less<pair<long long, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

//template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)((x).size())
#define pb push_back
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
//#define debug(x) cerr << #x << " : " << (x) << " "
const double PI = 3.14159265358979323846;
const double eps = (1e-8);
int isGreater(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

ll cost[3], D;
ll val[3] = {2, 3, 5};
map<ll, ll> mem;

const ll MAX_ANSWER = 2LL * 60 * 1e9 + 5;

bool overflow(long double a, long double b)
{
    return a * b > MAX_ANSWER;
}

ll f(ll n)
{
    if (n == 1)
        return D;
    if (mem.count(n))
        return mem[n];
    ll &ret = mem[n];
    ret = LLONG_MAX;
    if (!overflow(n, D)) // no division
        ret = n * D;

    for (int i = 0; i < 3; ++i)
    {
        ll mod = n%val[i];
        ll to = (n - mod)/val[i];
        ret = min(ret, f(to) + mod * D + cost[i]);

        mod = val[i] - mod;
        to = (n + mod)/val[i];
        ret = min(ret, f(to) + mod * D + cost[i]);
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int tc;
    cin >> tc;
    while(tc--)
    {
        mem.clear();
        ll n;
        cin >> n >> cost[0] >> cost[1] >> cost[2] >> D;

        cout << f(n) << '\n';
    }

}

Measured memory_bytes: 4776
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define mdn 1000000007
#define N 1000100
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int f[N],n;
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
int main()
{
	n=read(); f[n]=n; f[n-1]=1ll*n*n%mdn;
	for(int i=n-2,s=0;i>0;i--)	upd(s,f[i+3]),f[i]=(s+1ll*(n-1)*(n-1)+f[i+1]+i+1)%mdn;
	printf("%d\n",f[1]);
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(a,min(b,c))<<" "<<max(a,max(b,c))<<endl;
    
    return 0;
}



Measured memory_bytes: 3104
#include <stdio.h>
#include <string.h>
#define M 36

typedef struct {
  char mark;
  int value;
}Card;

void BubbleSort(Card *, int);
void SelectionSort(Card *, int);
void disply(Card *, int);
int isStable(Card *, Card *, int);

int main(){
  Card C1[M+1], C2[M+1];
  int i, N;

  scanf("%d",&N);

//文字列と数字をそれぞれ格納
  for(i = 0; i < N; i++){
    scanf(" %c%d", &C1[i].mark, &C1[i].value);
  }

  for(i = 0 ;i < N; i++) C2[i] = C1[i];

  BubbleSort(C1, N);
  disply(C1, N);
  printf("Stable\n");

  SelectionSort(C2, N);
  disply(C2, N);

  if( isStable(C1, C2, N) == 0 ) printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}

/*1 BubbleSort(C, N)
2   for i = 0 to N-1
3     for j = N-1 downto i+1
4       if C[j].value < C[j-1].value
5         C[j] と C[j-1] を交換*/
void BubbleSort(Card C1[], int N){
  int i, j;
  Card tmp;
  for(i = 0;i < N; i++){
    for(j = N-1; j > i; j--){
      if(C1[j].value < C1[j-1].value){
        tmp = C1[j];
        C1[j] = C1[j-1];
        C1[j-1] = tmp;
      }
    }
  }
}

/*7 SelectionSort(C, N)
8   for i = 0 to N-1
9     minj = i
10    for j = i to N-1
11      if C[j].value < C[minj].value
12        minj = j
13    C[i] と C[minj] を交換*/
void SelectionSort(Card C2[], int N){
  int i, j, minj;
  Card tmp;
  for(i = 0; i < N; i++){
    minj = i;
    for(j = i; j < N; j++){
      if(C2[j].value < C2[minj].value) minj = j;
    }
    tmp = C2[i];
    C2[i] = C2[minj];
    C2[minj] = tmp;
  }
}

void disply(Card C[], int N)
{
  int i;

  for( i = 0 ; i < N ; i++ ){
    if( i > 0 ) printf(" ");
    printf("%c%d", C[i].mark, C[i].value);
  }
  printf("\n");
}

/*1 isStable(in, out)
2   for i = 0 to N-1
3     for j = i+1 to N-1
4       for a = 0 to N-1
5         for b = a+1 to N-1
6           if in[i] と in[j] の数字が等しい && in[i] == out[b] && in[j] == out[a]
7             return false
8 return true*/
int isStable(Card C1[], Card C2[], int N){
  int i;

  for(i = 0; i < N; i++)
  if(C1[i].mark != C2[i].mark ) return 1;
  return 0;
}



Measured memory_bytes: 2052
n = gets.to_i
1.upto(n) do
  a = gets.chomp
  b = gets.chomp
  if a.length > 80 || b.length > 80 || (a.to_i + b.to_i).to_s.length > 80
    puts "overflow"
  else
    puts a.to_i+b.to_i
  end
end

Measured memory_bytes: 8488
main = interact $ show . sol . map read . words

sol (n:a:as) = f (abs (a-t)) a t as
  where
  t = sum as
  f s _ _ [_] = s 
  f s l r (a:as) = f (min s $ abs (l-r+2*a)) (l+a) (r-a) as

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

const int INF = 1001001001;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> E(n);
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        E[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;
    s--; t--;
    vector<vector<int>> dist(n, vector<int>(3, INF));
    queue<P> q;
    q.push(make_pair(s, 0));
    dist[s][0] = 0;
    while (!q.empty()) {
        int u = q.front().first;
        int l = q.front().second;
        q.pop();
        int a = (l+1) % 3;
        for (int v: E[u]) {
            if (dist[v][a] != INF) continue;
            dist[v][a] = l+1;
            q.push(make_pair(v, l+1));
        }
    }
    int ans = dist[t][0];
    if (ans == INF) ans = -1;
    else ans /= 3;
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<char, int> mp;
    vector<char> march = {'M', 'A', 'R', 'C', 'H'};
    for (char c : march) mp[c] = 0;
    rep(i,n) {
        string s;
        cin >> s;
        mp[s.at(0)]++;
    }

    ll ans = 0;
    for (int i = 0; i < 5; ++i) {
        for (int j = i + 1; j < 5; ++j) {
            for (int k = j + 1; k < 5; ++k) {
                ans += (ll) mp.at(march.at(i)) * mp.at(march.at(j)) * mp.at(march.at(k));
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
#include<iostream>
using namespace std;
#define MAX 100
#define INF 1 << 30
int n, A[MAX + 1][MAX + 1], d[MAX + 1];
bool vis[MAX + 1];

int prim(int s){
  int sum = 0;
  for ( int i = 1; i <= n; i++){
    d[i] = A[s][i];
    vis[i] = false;
  }
  d[s] = 0;
  vis[s] = true;

  while ( 1 ){
    int minCost = INF;
    for ( int i = 1; i<=n; i++){
      if ( minCost > d[i] && !vis[i]){
        minCost = d[i];
        s = i;
      }
    }

    if ( minCost == INF)break;

    sum += minCost;
    vis[s] = true;

    for ( int i = 1; i <= n; i++){
      if ( d[i] > A[s][i] && !vis[i]){
        d[i] = A[s][i];
      }
    }
  }

  return sum;
}

int main(){
  cin >> n;
  int a;
  for ( int i = 1; i <= n; i++){
    for ( int j = 1; j <= n; j++){
      cin >> a;
      A[i][j] = ( a == -1 ) ? INF : a;
    }
  }

  cout << prim(1) << endl;

  return 0;
}


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

int main(void){
  string s,t;
  cin >> s >> t;
  int p=0;
  bool flag=false;
  for(int i=0;i<s.length();i++){
    for(int j=0;j<t.length();j++){
      if(s[i+j]=='?'||s[i+j]==t[j]){
        if(j==t.length()-1){
          flag=true;
          p=i;
        }
      } else{
        break;
      }
    }
  }
  int k=0;
  if(flag){
    for(int i=p;i<p+t.length();i++){
      s[i]=t[k++];
    }
    for(int i=0;i<s.length();i++){
      if(s[i]=='?') s[i]='a';
    }
    cout<<s<<endl;
  } else {
    cout<<"UNRESTORABLE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MINUS(a) memset(a,0xff,sizeof(a))

long long N, K;
vector<long long> A;

long long dp[44][2];

long long rec(int digit, bool strict, long long result = 0) {

  if (digit < 0) return result;

  auto& ret = dp[digit][strict];
  // if (ret != -1) return ret = max(ret, val);

  long long mask = 1LL << digit;

  int cnt = 0;
  for (auto& e: A) if (e & mask) ++cnt;
  long long score0 = mask * cnt, score1 = mask * (N - cnt);

  if (strict) {
    if (K & mask) {
      // 1に遷移した場合, strict = true
      // 0に遷移した場合, strict = false
      return ret = max(rec(digit - 1, true, result + score1), rec(digit - 1, false, result + score0));
    } else {
      // 0にしか遷移できず, strict = true
      return ret = rec(digit - 1, true, result + score0);
    }
  } else {
      // 0と1どちらに遷移しても良い (strict = false)
      return ret = rec(digit - 1, false, result + max(score1, score0));
  }

}

signed main() {

  cin >> N >> K;
  A.resize(N); for (auto& e: A) cin >> e;

  MINUS(dp);

  cout << rec(43, true) << endl;

}


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

int main() {
    int n,d;
    cin >> d >> n;
    long long answer = 1;
    for(int i = 1;i<=d;i++){
        answer *= 100;
    }
  	answer*=n;
  	if(n==100 && d == 0)answer++;
  	if(n==100 && d == 1)answer += 100;
  	if(n == 100 && d == 2)answer += 1e4;
    cout << answer;
    return 0;
}

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

typedef long double ld;
typedef long long ll;

using namespace std;

const int inf = 1e9 + 1;
const ld pi = acos(-1);
const ll p = 998244353;

const int maxsz = 1e7 + 2;

ll factorial[maxsz];
ll invfact[maxsz];

ll POWER(ll x, ll y) {
    if (y == 0) return 1;
    ll f = POWER(x, y / 2);
    f *= f;
    f %= p;
    if (y % 2 == 1) {
        f *= x;
        f %= p;
    }
    return f;
}

ll Pow(ll x, ll y) {
    ll x1 = x % p;
    x1 += p;
    x1 %= p;
    ll y1 = y % (p - 1);
    y1 += (p - 1);
    y1 %= (p - 1);
    return POWER(x1, y1);
}

ll inverse(ll x) {
    return Pow(x, p - 2);
}

void podfact() {
    factorial[0] = 1;
    for (int i = 1; i < maxsz; i++) {
        ll k = i;
        factorial[i] = factorial[i - 1] * k;
        factorial[i] %= p;
    }
    invfact[maxsz - 1] = inverse(factorial[maxsz - 1]);
    for (int i = maxsz - 2; i >= 0; i--) {
        ll k = i;
        invfact[i] = (k + 1) * invfact[i + 1];
        invfact[i] %= p;
    }
}

ll C(int n, int k) {
    ll x = factorial[n] * invfact[k];
    x %= p;
    x *= invfact[n - k];
    return x % p;
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    cout << setprecision(20);

    podfact();
    int n;
    cin >> n;
    int k = n / 2;
    ll x = 1;
    for (int i = 0; i < k; i++) {
        x *= 2;
        x %= p;
    }
    ll ans = (x * C(n, k)) % p;
    // cout << ans;
    for (int i = 0; i < k; i++) {
        ll y = x * 2;
        y -= C(k + i, i);
        x = y % p;
        ans += (x * C(n, k - i - 1)) % p;
        ans %= p;
    }
    cout << (ans + p) % p;
    return 0;
}


Measured memory_bytes: 156544
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define LL long long

 
 int main(){
 	int N, K, X, Y;
 	cin >> N >> K >> X >> Y;
 	if(N >= K){
	 	cout << K*X + (N-K)*Y << endl;
	 }
	 else {
	 	cout << N*X << endl;
	 }
 }

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

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        double a = Double.parseDouble(st.nextToken());
        double result = a + Math.pow(a, 2) + Math.pow((double)a, 3); 

        pw.println((int)result);
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 33372
#include <bits/stdc++.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
 
using namespace std;

const int N = 500;
const ll mod = 1e9 + 7;             

int n;
ll a[N], pr[N];
ll dp[N][N];

ll rec(ll l, ll r){
	if(l == r)
		return 0;
	if(l > r)
		return 0;
	if(dp[l][r] != -1)
		return dp[l][r];
	//cerr << l << " " << r << "\n";
	ll res = mod * 1ll * mod;
	for(ll mid = l;mid < r;mid++){
		//cerr << l << " " << mid << " " << r << endl;
		res = min(res, rec(l, mid) + rec(mid + 1, r) + pr[r] - pr[l - 1]);
	}
	dp[l][r] = res;
	return res;
}

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

	memset(dp, -1, sizeof(dp));
	cin >> n;
    for(int i = 1;i <= n;i++){ 
    	cin >> a[i];
    	pr[i] = pr[i - 1] + a[i];
    }
    cout << rec(1, n);
}

Measured memory_bytes: 2304
#include <iostream>
 
using namespace std;
 
int main( void ){
  int i,j;
   
  for(i = 1;i <= 9;i++){
    for(j = 1;j <= 9;j++){
      cout << i << "x" << j << "=" << i*j << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1116
#include <stdio.h>
#include <string.h>

int main(void){
    int map[5]={5,7,5,7,7},num,sum,i,o,sign,count[40];
    char line[11];
    while(1){
s:
        scanf("%d",&num);
        if(num == 0)
            break;
        for(i=0;i<num;i++){
            scanf("%s",line);
            count[i]=strlen(line);
        }
        for(i=0;i<num;i++){
            for(sign=0,sum=0,o=i;o<num;o++){
                sum+=count[o];
                if(sum > map[sign]){
                    sign=0;
                    break;
                }
                if(sum == map[sign]){
                    sum=0;
                    sign++;
                }
                if(sign == 5){
                    printf("%d\n",i+1);
                    goto s;
                }
            }
        }
    }
    return 0;
}

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

int main()
{
	int N;
	int n[3];
	int count = 0;
	std::cin >> N;
	n[0] = N / 100;
	n[1] = N / 10 - (n[0] * 10);
	n[2] = N - (n[0] * 100) - (n[1] * 10);
	for (int i = 0; i < 3; i++) {
		if (n[i] == 1)count++;
		if (i == 3)goto hoge;
	}hoge:
	std::cout << count;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	char array[8][8];
	
	for(int i = 0; i < 8; i++){
		for(int j = 0; j < 8; j++){
			cin >> array[i][j];
		}
	}
	
	
	cout << "90" << endl;
	for(int i = 0; i < 8; i++){
		for(int j = 7; j >= 0; j--){
			cout << array[j][i];
		}
		cout << endl;
	}
	
	cout << "180" << endl;
	for(int i = 7; i >= 0; i--){
		for(int j = 7; j >= 0; j--){
			cout << array[i][j];
		}
		cout << endl;
	}
	
	cout << "270" << endl;
	for(int i = 7; i >= 0; i--){
		for(int j = 0; j < 8; j++){
			cout << array[j][i];
		}
		cout << endl;
	}
	
	return 0;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, i;
  cin >> n >> i;
  cout << (n - i + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] arr = new int[n];

		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}

		int temp = 0;
		int count = 0;
		for (int i = 0; i < n; i++) {
			int index = i;
			for (int j = i; j < n; j++) {
				if (arr[index] > arr[j]) {
					index = j;
				}
			}
			if (index != i) {
				temp = arr[index];
				arr[index] = arr[i];
				arr[i] = temp;
				count++;
			}
		}

		for (int i = 0; i < n; i++) {
			System.out.print(i == 0 ? arr[i] : " " + arr[i]);
		}
		System.out.println("\n" + count);

	}
}


Measured memory_bytes: 26232
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
#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 reall(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()
const double pi = acos(-1.0);

typedef vector<int> vi;
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;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

ll n, w, m, k, h, ans = 0;
double dp[310][310][310];

double calc(ll i, ll j, ll k) {
	if (dp[i][j][k] >= 0) return dp[i][j][k];
	if (i == 0 && j == 0 && k == 0) return 0.0;

	double res = 0.0;
	if (i > 0) res += calc(i - 1, j, k) * i;
	if (j > 0) res += calc(i + 1, j - 1, k) * j;
	if (k > 0) res += calc(i, j + 1, k - 1) * k;
	res += n;
	res *= 1.0 / (i + j + k);
	return dp[i][j][k] = res;
}


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

	cin >> n;
	vll v(4);
	rep(i, n) {
		cin >> k;
		v[k]++;
	}
	memset(dp, -1, sizeof dp);
	ll a = v[1], b = v[2], c = v[3];
	//cout << a << " " << b << " " << c << endl;
	cout << fixed << setprecision(10) << calc(a, b, c) << endl;
	return 0;
}


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

using namespace std;

struct node
{
    double x;
    double y;
};

double cal(double x1, double y1, double x2, double y2)
{
    double temp = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
    temp = sqrt(temp);

    return temp;
}

int main()

{
   int n;
   cin>>n;

   node arr[n];

   for(int i=0;i<n;i++)
   {
       cin>>arr[i].x>>arr[i].y;
   }

   double sum = 0;
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<n;j++)
       {
           sum = sum+cal(arr[i].x,arr[i].y,arr[j].x,arr[j].y);
       }
   }

    printf("%.15f\n",sum/n);




    return 0;
}


Measured memory_bytes: 256