akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
    int n, i, x;
    cin >> n;
    for(i=1; i<=n; i++){
        if(i % 3 == 0){
            cout << " " << i;
        }
        else {
            x = i;
            while(x){
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3096
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var D = myconv(input[1],4)[0];
  var X = myconv(input[1],4)[1];
  var output = 0;
  input.shift();
  input.shift();
  input = input.map((a)=>Number(a));
  for(var i = 0; i < N; i++){
    var tmp = 1;
    while(tmp <= D){
      output++;
      tmp += input[i];
    }
  }
  myout(output + X);
}
Main(myin());

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

int main(){
    vector<vector<int>> lst(3);
    vector<vector<int>> check(3);
    rep(i,3){
        rep(j,3){
            int tmp;cin>>tmp;
            lst[i].push_back(tmp);
            check[i].push_back(0);
        }
    }
    int N;cin>>N;

    auto judge=[&](int a){
        rep(i,3){
            rep(j,3){
                if(a == lst[i][j])return P(i,j);
            }
        }
        return P(3,3);
    };
    rep(i,N){
        int b;cin>>b;
        P x;
        x = judge(b);
        if(x == P(3,3))continue;
        else{
            check[x.first][x.second] = 1;
        }
    }
    if(check[0][0]+check[0][1]+check[0][2] == 3 ||
       check[1][0]+check[1][1]+check[1][2] == 3 ||
       check[2][0]+check[2][1]+check[2][2] == 3 ||
       check[0][0]+check[1][0]+check[2][0] == 3 ||
       check[0][1]+check[1][1]+check[2][1] == 3 ||
       check[0][2]+check[1][2]+check[2][2] == 3 ||
       check[0][0]+check[1][1]+check[2][2] == 3 ||
       check[2][0]+check[1][1]+check[0][2] == 3){
           cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;   
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,sum1=0,sum2=0;
	cin >> n;
	vll a(n);
	rep(i,n) cin >> a[i];
	vll b=a;
	for(ll i=0;i<n;i++){
		if(i%2){
			if(a[i]>=0){
				sum1+=a[i]+1;
				a[i]-=a[i]+1;
			}
		}
		else{
			if(a[i]<=0){
				sum1+=1-a[i];
				a[i]+=1-a[i];
			}
		}
		if(i!=n-1) a[i+1]+=a[i];
	}
	for(ll i=0;i<n;i++){
		if(i%2==0){
			if(b[i]>=0){
				sum2+=b[i]+1;
				b[i]-=b[i]+1;
			}
		}
		else{
			if(b[i]<=0){
				sum2+=1-b[i];
				b[i]+=1-b[i];
			}
		}
		if(i!=n-1) b[i+1]+=b[i];
	}
	cout << min(sum1,sum2) << endl;
	return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	string s;
	ll a, b;

	cin >> a >> b >> s;

	REP(i, a) {
		if (s[i] == '-') {
			cout << "No" << endl;
			return 0;
		}
	}

	if (s[a] != '-') {
		cout << "No" << endl;
		return 0;
	}

	REP(i, b) {
		if (s[a + 1 + i] == '-') {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = 1000000007;
ll mpow(ll a,ll b){ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
/*template*/

int main()
{
  string s;cin>>s;
  string a[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  for(ll i=0;i<7;i++){
    if(a[i]==s){
      ll ans=7-i;
      cout<<ans<<endl;
      return 0;
    }
  }
  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 A = sc.nextInt();
		int[]x = new int[N];
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
		}
		sc.close();
		long sum = 0;
		int l = 50 * 50 ;
		long[][][] d= new long[N + 1][N + 1][l + 1];
		d[0][0][0] = 1;
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				for(int k = 0; k <= l; k++) {
					if(d[i][j][k] != 0) {
						d[i + 1][j + 1][k + x[i]] += d[i][j][k];
						d[i + 1][j][k] += d[i][j][k];
					}
				}
			}
		}
		for(int j = 1; j <= N; j++) {
			sum += d[N][j][j * A];
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 85200
#include <bits/stdc++.h>
using namespace std;
int main(){ 
	int MOD=1000000007;
	long long n,k,cnt=0;
	cin>>n>>k;
	for(long long i=k;i<=n+1;i++){
		cnt+=(i*(n-i+1)+1)%MOD;
		cnt=cnt%MOD;
	}
	cout<<cnt<<endl;
	return 0;
}

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

const int N = 1e3 + 10;

int black[N][N], white[N][N];
int k;

int get_sumb(int x1, int y1, int x2, int y2) {
	if(x2 < x1 || y2 < y1) {
		return 0;
	}
	int ans = black[x2][y2];
	if(x1) {
		ans -= black[x1-1][y2];
	}
	if(y1) {
		ans -= black[x2][y1-1];
	}
	if(x1 && y1) {
		ans += black[x1-1][y1-1];
	}
	return ans;
}

int get_sumw(int x1, int y1, int x2, int y2) {
	if(x2 < x1 || y2 < y1) {
		return 0;
	}
	int ans = white[x2][y2];
	if(x1) {
		ans -= white[x1-1][y2];
	}
	if(y1) {
		ans -= white[x2][y1-1];
	}
	if(x1 && y1) {
		ans += white[x1-1][y1-1];
	}
	return ans;
}

int get_cost(int i, int j) {
	return get_sumb(i, j, k-1, k-1) + get_sumb(0,0, i-1, j-1) + 
		get_sumw(0, j, i-1, k-1) + get_sumw(i,0,k-1,j-1);
}

int main() {
	int n;
	scanf("%d %d", &n, &k);
	for(int i = 0; i < n; i++) {
		int x, y;
		char c;
		scanf("%d %d %c", &x, &y, &c);
		bool is_white = c == 'W';
		x %= 2*k;
		y %= 2*k;
		if(x >= k && y >= k) {
			x -= k;
			y -= k;
		} else if(x >= k) {
			x -= k;
			is_white = !is_white;
		} else if(y >= k) {
			y -= k;
			is_white = !is_white;
		}
		if(is_white) {
			white[x][y]++;
		} else {
			black[x][y]++;
		}
	}
	for(int i = 0; i < k; i++) {
		for(int j = 0; j < k; j++) {
			if(i) {
				black[i][j] += black[i-1][j];
			}
			if(j) {
				black[i][j] += black[i][j-1];
			}
			if(i && j) {
				black[i][j] -= black[i-1][j-1];
			}
			if(i) {
				white[i][j] += white[i-1][j];
			}
			if(j) {
				white[i][j] += white[i][j-1];
			}
			if(i && j) {
				white[i][j] -= white[i-1][j-1];
			}
		}
	}
	int mx = -1;
	for(int i = 0; i < k; i++) {
		for(int j = 0; j < k; j++) {
			int t = get_cost(i, j);
			// cout << i << " " << j << " " << t << endl;
			mx = max(mx, max(t, n-t));
		}
	}
	printf("%d\n", mx);
}

Measured memory_bytes: 8192
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long


int main() {
    string s;
    cin >> s;
    int o = 0, e = 0;
    for (int i=0; i < s.length(); i++) {
        if (i % 2 == 0 && s[i] == '0') {
            e++;
        } else if (i % 2 == 1 && s[i] == '0') {
            o++;
        }
    }
    int l = s.length();
    int a1 = ceil((double)l / 2 - e) + o;
    int a2 = e + ((l / 2) - o);
    if (a1 < a2) {
        cout << a1 << endl;
    } else {
        cout << a2 << endl;
    }
    return 0;
}

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

int a,b,c;

int main()
{
    scanf("%d %d %d",&a,&b,&c);

    if(a>=-100 && a<=100 && b>=-100 && b<=100 && c>=-100 &&c <=100)
    {
            if(c>=a && c<=b)
            {
                printf("Yes");
            }

            else
            {
                printf("No");
            }
    }
}



Measured memory_bytes: 256
words = ['dream','dreamer', 'erase', 'eraser']
s = raw_input()
dp = [False for _ in range(len(s))]

for j in range(len(s)):
	for w in words:
		b = dp[j - len(w)] if j - len(w) -1 >= 0 else True
		b &= j-len(w) +1 >= 0 and s[j- len(w)+1:j+1] == w
		if b:
			dp[j] = True
			break
print 'YES' if dp[-1] else 'NO'

Measured memory_bytes: 85036
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
// #define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}
int countFreq(string t, string s)
{
    int m = 7;
    int n = s.length();
    int ans = 0;
    for (int i = 0; i < n - 6; i++)
    {
        string str = s.substr(i, 7);
        ans += (str == t);
    }
    return ans;
}
string prefix(string s, string t)
{
    int n = s.length();
    int m = t.length();
    string res = "";
    for (int i = 0; i < min(n, m); i++)
    {
        if (s[i] == t[i])
        {
            res += s[i];
        }
        else
        {
            break;
        }
    }
    return res;
}
int main()
{
    fastio();
    ll x;
    cin >> x;
    if (x >= 400 and x <= 599)
    {
        cout << "8\n";
    }
    else if (x >= 600 and x <= 799)
    {
        cout << "7\n";
    }
    else if (x >= 800 and x <= 999)
    {
        cout << "6\n";
    }
    else if (x >= 1000 and x <= 1199)
    {
        cout << "5\n";
    }
    else if (x >= 1200 and x <= 1399)
    {
        cout << "4\n";
    }
    else if (x >= 1400 and x <= 1599)
    {
        cout << "3\n";
    }
    else if (x >= 1600 and x <= 1799)
    {
        cout << "2\n";
    }
    else if (x >= 1800 and x <= 1999)
    {
        cout << "1\n";
    }
}

Measured memory_bytes: 3648
s = gets.chomp.split('')
k = gets.chomp.to_i

chain_cnt = 1
chain_cnt_list = []

if s.length == 1
    puts k/2
    exit
end

1.upto(s.length-1) do |i|
    if s[i] == s[i-1]
        chain_cnt += 1
    else
        chain_cnt_list << chain_cnt
        chain_cnt = 1
    end
    if i == s.length - 1
        chain_cnt_list << chain_cnt
    end
end

if chain_cnt_list.length == 1
    puts (s.length * k)/2
    exit
end

tmp = chain_cnt_list.map do |c|
    c > 1 ? c/2 : 0
end.inject(:+)

if s[0] != s[-1]
    puts tmp * k
else
    ans = tmp * k - (k - 1) * ((chain_cnt_list[-1]/2 + chain_cnt_list[0]/2 )- (chain_cnt_list[-1] + chain_cnt_list[0])/2)
    puts ans
end

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

//ABC 141 D
//貪欲法でとける？
int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<ll> q;
    ll a;
    for(int i=0;i<n;i++){
        cin >> a;
        q.push(a);
    }
    for(int i=0;i<m;i++){
        int d = q.top();
        q.pop();
        q.push(d/2);
    }
    ll ans = 0;
    while(!q.empty()){
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
   
}


Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define chmin(a,b) a=min(a,b)
ll f[66][66][3333];
ll n,k,v[66],va[66],vb[66];
int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>v[i];
  sort(v,v+n,greater<ll>());
  for(int i=0;i<k;i++)cin>>va[i];
  sort(va,va+k,greater<ll>());
  for(int i=0;i<k;i++)cin>>vb[i];
  sort(vb,vb+k,greater<ll>());
  for(int i=0;i<=k;i++)for(int j=0;j<=k;j++){
      for(int p=0;p<3333;p++)f[i][j][p]=1e17;
  }
  
  ll sum=0;
  for(int i=0;i<n;i++)sum+=v[i];
  ll sa=0;
  for(int i=0;i<k;i++)sa+=va[i];
  ll sb=0;
  for(int i=0;i<k;i++)sb+=vb[i];
  ll ans=1e17;
  
  f[0][0][0]=0;
  for(int i=0;i<=k;i++)for(int j=0;j<=k&&i+j<=n;j++){
      for(int p=0;p<3333;p++){
	  if(i+j==n){
	      if(p<=sa&&sum-p<=sb){
		  chmin(ans,f[i][j][p]);
	      }
	      continue;
	  }
	  if(f[i][j][p]==1e17)continue;
	  //cout<<i<<" "<<j<<" "<<p<<" "<<f[i][j][p]<<endl;
	  if(i<k){
	      chmin(f[i+1][j][p+v[i+j]],f[i][j][p]+max(0LL,v[i+j]-va[i]));
	  }
	  if(j<k){
	      chmin(f[i][j+1][p],f[i][j][p]+max(0LL,v[i+j]-vb[j]));
	  }
      }
  }
  if(ans==1e17)ans=-1;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 100288
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll power(ll x,ll n)
{
	ll res =1;
	while(n>0)
	{
		if(n%2==1)
	res=res*x;
	x=x*x;
	n=n/2;
	}
	return res;
	
}

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,i;
    cin>>n;
    int a[n],sum=0;
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
    	sum+=a[i];
	}
	
		ll sum1=0,sum2=0;
		int x=sum/n;
		for(i=0;i<n;i++)
		{
			sum1=sum1+(a[i]-x)*(a[i]-x);
			sum2+=(a[i]-x-1)*(a[i]-x-1);
		}
		cout<<min(sum1,sum2);
	

}


Measured memory_bytes: 256
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

x1,y1,x2,y2 = readInts()
dx = x2-x1
dy = y2-y1

print(x2-dy,y2+dx,x1-dy,y1+dx)

Measured memory_bytes: 9404
package main

import (
	"fmt"
)

func main() {
	var s []byte
	fmt.Scan(&s)

	switch s[0] {
	case 97:
		fallthrough
	case 105:
		fallthrough
	case 117:
		fallthrough
	case 101:
		fallthrough
	case 111:
		fmt.Println("vowel")
	default:
		fmt.Println("consonant")
	}
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
	int n, a;

	cin >> n >> a;

	if (n % 500 <= a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
unsigned nChoosek(unsigned n, unsigned k) {
    if (k > n) return 0;
    if (k * 2 > n) k = n - k;
    if (k == 0) return 1;

    int result = n;
    for (int i = 2; i <= k; ++i) {
        result *= (n - i + 1);
        result /= i;
    }
    return result;
}

int main() {
    long long a, b;
    string s;
    long long s0 = 0, s1 = 0, s2 = 0;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != s[s.size() - i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    // cout << "hoge" << endl;
    for (int i = 0; i < (s.size() - 1) / 2; i++) {
        if (s[i] != s[(s.size() - 1) / 2 - i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    // cout << "hoge" << endl;
    for (int i = (s.size() + 3) / 2; i < s.size() / 2; i++) {
        if (s[(s.size() + 3) / 2 + i] != s[s.size() - i]) {
            cout << "No" << i << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int top,s[101];
void push(int x){
  s[++top]=x;
}
int pop(){
  --top;
  return s[top+1];
}
int main(){
  int a,b;
  char c[101];
  while(cin>>c){
    if(c[0]=='+'){
      a=pop();
      b=pop();
      push(b+a);
    }else if(c[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }else if(c[0]=='*'){
      a=pop();
      b=pop();
      push(b*a);
    }else{
      push(atoi(c));
    }
  }
  cout<<pop()<<endl;
  return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
cin >> N >> K;

vector<int> h(N);
vector<int> ans(N);
for(int i=0; i<N ;i++){
    cin >> h[i];
    ans[i] = 1000000000;
}

ans[0] = 0;
for(int i = 0; i < N; i++){
    for (int j = 1; j < K + 1; j++){
        ans[i+j] = min(ans[i + j], ans[i] + abs(h[i] - h[i + j]));
    }
}
cout << ans[N - 1];
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int N = sc.nextInt();
    char[][] f = new char[N * 2][N * 2];
    for (int i = 0; i < N; i++) {
      char[] row = sc.next().toCharArray();
      for (int j = 0; j < N; j++) {
        f[i][j] = f[i + N][j] = f[i][j + N] = f[i + N][j + N] = row[j];
      }
    }
    boolean[][] a = new boolean[2 * N][2 * N];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        boolean ok = true;
        for (int k = 1; k < N; k++) {
          ok &= f[i][j + k] == f[i + k][j];
        }
        a[i][j] = a[i][j + N] = a[i + N][j] = a[i + N][j + N] = ok;
      }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        boolean ok = true;
        for (int k = 0; k < N; k++) {
          ok &= a[i + k][j + k];
        }
        if (ok) ++ans;
      }
    }
    System.out.println(ans);
  }

}


Measured memory_bytes: 28608
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <deque>

using namespace std;

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

	string S;
	cin >> S;
	
	deque<char> dS;
	for (char ch : S) dS.emplace_back(ch);

	int Q;
	cin >> Q;

	bool reverse_s = false;

	while (Q--)
	{
		int c;
		cin >> c;

		if (c == 1)
		{
			reverse_s = !reverse_s;
		}
		else
		{
			int f;
			char ch;
			cin >> f >> ch;

			if (f == 1)
			{
				if (!reverse_s) dS.emplace_front(ch);
				else dS.emplace_back(ch);
			}
			else
			{
				if (!reverse_s) dS.emplace_back(ch);
				else dS.emplace_front(ch);
			}
		}
	}

	if (reverse_s)
	{
		for (auto it = dS.rbegin(); it != dS.rend(); it++)
		{
			cout << *it;
		}
	}
	else
	{
		for (auto it = dS.begin(); it != dS.end(); it++)
		{
			cout << *it;
		}
	}

	return 0;
}

Measured memory_bytes: 976
#include <cstdio>
#include <cstring>
using namespace std;
int dp[501][10][3][2][500];
char a[502],b[502],*s;
int alen,blen,slen,m;
int solve(int n,int pv,int ud,int ok,int md) {
	if(n==slen)return !md;
	if(dp[n][pv][ud][ok][md]>=0)return dp[n][pv][ud][ok][md];
	int ret=0;
	for(int i=0;i<=(ok?9:s[n]-'0');i++) {
		if(ud==0 && pv<=i)continue;
		if(ud==1 && pv>=i)continue;
		if(ud==2 && pv!=0 && pv==i)continue;
		int u;
		if(ud==2) {
			if(pv==0)u=2;
			else if(pv>i)u=1;
			else u=0;
		}else{
			u=ud^1;
		}
		ret+=solve(n+1,i,u,ok||(i!=(s[n]-'0')),(md*10+i)%m);
	}
	return dp[n][pv][ud][ok][md]=ret%10000;
}
int main() {
	scanf("%s",a);
	alen=strlen(a);
	for(int i=alen-1;i>=0;i--) {
		if(a[i]>='1') {
			a[i]--;
			for(int j=i+1;j<alen;j++)a[j]='9';
			break;
		}
	}
	scanf("%s",b);
	blen=strlen(b);
	scanf("%d",&m);
	int aa,bb;
	s=b,slen=blen;
	memset(dp,-1,sizeof(dp));
	bb=solve(0,0,2,0,0);
	s=a,slen=alen;
	memset(dp,-1,sizeof(dp));
	aa=solve(0,0,2,0,0);
	printf("%d\n",(bb+10000-aa)%10000);
}

Measured memory_bytes: 59796
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,i,j,k,n,h,m,x,y;
	string	s;
	cin >> a >> b >> h >> m;
	double hh,mm,deg,ans;

	hh = (double)(h*60+m) / 2;
	mm = m*6;

	deg = abs(hh-mm);
	if (deg > 180) deg = 360 - deg;
	//printf("%f\n",deg);

	deg = deg * (M_PI/180);
	//printf("%f\n",deg);
	ans = sqrt( a*a + b*b - 2*a*b*cos(deg));

	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));
	printf("%.10f\n",ans);
	//cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4232
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <iomanip>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
    cout << fixed;
    cout << setprecision(11);
    double n;
    cin >> n;
    double t = 0, c = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 2 == 0) t += 1;
        else c += 1;
    }

    // cout << c << endl;
    cout << c / n << endl;
}


Measured memory_bytes: 256
def halfandhalf(A,B,C,X,Y):
    if X >= Y:
        if A+B > 2*C:
            sum = min(C*2*Y + A*(X-Y), C*2*X)
        else:
            sum = A*X + B*Y
        
    else:
        if A+B > 2*C:
            sum = min(C*2*X + B*(Y-X), C*2*Y)
        else:
            sum = A*X + B*Y
    return sum




if __name__ == "__main__":
    A,B,C,X,Y = map(int, input().split())
    print(halfandhalf(A,B,C,X,Y))
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string n;
	cin>>n;
	int ans=0;
	for(int i=0;i<n.size();i++)
		ans+=(n[i]-'0');
	cout<<(ans%9?"No":"Yes")<<endl;
	return 0;
}

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

int main()
{
    string a, b;
    cin >> a >> b;

    if (a.size() > b.size())
    {
        cout << "GREATER" << endl;
    }
    else if (a.size() < b.size())
    {
        cout << "LESS" << endl;
    }
    else
    {
        for (auto i = 0; i < a.size(); i++)
        {
            if (int(a[i]) > int(b[i]))
            {
                cout << "GREATER" << endl;
                return 0;
            }else if(int(a[i]) < int(b[i])){
                cout << "LESS" << endl;
                return 0;
            }else{
                continue;
            }
        }

        cout << "EQUAL" << endl;
    }
}

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

using ll = long long;

const int MAX_N = (int) 2e5 + 1;
const int MOD = (int) 1e9 + 7;

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

    int N;
    cin >> N;
    int C[N + 1];

    for (int i = 0; i < N; ++i) {
        cin >> C[i];
    }
    C[N] = -1;
    ll dp[N + 1];
    dp[0] = 1;
    int left[MAX_N];
    fill(left, left + MAX_N, -1);
    left[C[0]] = 0;
    for (int i = 1; i < N; ++i) {
        dp[i] = dp[i - 1];
        dp[i] %= MOD;
        int c = C[i];
        if (C[i - 1] != c && left[c] >= 0) {
            dp[i] += dp[left[c]];
            dp[i] %= MOD;
        }
        left[c] = i;
    }

    cout << dp[N - 1] << '\n';
    
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

struct show{
  int s,t,c;
};

int us[200020],sum[200020];

int main(){
  int i,j,n,C,ret=0;
  cin >> n >> C;
  struct show sh[n];
  for(i=0;i<n;i++){
    cin >> sh[i].s >> sh[i].t >> sh[i].c;
  }
  for(i=1;i<=C;i++){
    for(j=0;j<=200020;j++)us[j]=0;
    for(j=0;j<n;j++)if(sh[j].c==i){
      us[sh[j].s*2-1]++;
      us[sh[j].t*2]--;
    }
    for(j=1;j<=200020;j++)us[j]+=us[j-1];
    for(j=0;j<=200020;j++)if(us[j])sum[j]++;
  }
  for(i=0;i<200020;i++)if(ret<sum[i])ret=sum[i];
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 2944
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll K, A, B;
    cin >> K >> A >> B;

    if(B / K - A / K >= 1 || A % K == 0){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000LL;
constexpr auto MOD = 1000000007;

int main() {

	string s;
	cin >> s;
	map<char, int> mp;
	int ok = 0;
	rep(i, s.size()) {
		if (mp[s[i]] == 1)ok++;
		mp[s[i]]++;
	}
	if (ok == 2)cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100100
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N, A;
    cin >> N >> A;
    ll x[55];
    ll i, j, k;
    for(i=0; i<N; i++) {
        cin >> x[i];
    }
    
    
    ll dp[N+5][N*A+5][N+5];
    memset(dp, 0, sizeof(dp));
    
    dp[0][0][0]=1;
    for(i=1; i<=N; i++) {
        for(j=0; j<=N*A; j++) {
            for(k=0; k<i; k++) {
                if(j+x[i-1]<=N*A)
                    dp[i][j+x[i-1]][k+1]+=dp[i-1][j][k];
                dp[i][j][k]+=dp[i-1][j][k];
            }
        }
    }
    
    
    ll ans=0;
    for(k=1; k<=N; k++) {
        ans+=dp[N][k*A][k];
    }
    
    pr(ans);
}













Measured memory_bytes: 59392
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  ll ans = INT_MAX;

  auto lf = [](ll x, ll y, ll z)->ll{
    ll mx = max({x, y, z});
    ll mn = min({x, y, z});
    return mx - mn;
  };

  rep2(i, 1, h){
    ll m1 = (ll)i*w;
    ll hh = h-i;
    ll m2 = hh*(w/2), m3 = hh*((w+1)/2);
    ans = min(ans, lf(m1, m2, m3));
    m2 = hh/2*w, m3 = (hh+1)/2*w;
    ans = min(ans, lf(m1, m2, m3));
  }

  rep2(i, 1, w){
    ll m1 = (ll)i*h;
    ll ww = w-i;
    ll m2 = ww*(h/2), m3 = ww*((h+1)/2);
    ans = min(ans, lf(m1, m2, m3));
    m2 = ww/2*h, m3 = (ww+1)/2*h;
    ans = min(ans, lf(m1, m2, m3));
  }

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

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

int main() {
	int N;
	int cnt = 0;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	for (;;) {
		bool flag = true;
		for (int i = 0; i < N; i++) {
			if (v[i]%2) {
				flag = false;
				break;
			}
			v[i] /= 2;
		}
		if (!flag)
			break;
		cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#最小公倍数(least common multiple)
import fractions
from functools import reduce
def lcm_base(x, y):
    return ((x * y) // fractions.gcd(x, y))

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def solve():
    n,m = list(map(int,input().split()))

    a = list(map(int,input().split()))
    a = list(set(list(map(lambda x:x//2,a))))
    div_cnt = 0
    a0 = a[0]
    while a0%2==0:
        div_cnt+=1
        a0//=2
    two_pow_divcnt = 2**div_cnt
    for i in a:
        if i%two_pow_divcnt!=0 or i%(two_pow_divcnt*2)==0:
            return 0
    base = lcm(*a)
    if base > m:
        return 0
    else:
        return (m+base)//(base*2)

if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 16308
from collections import deque

K = int(input())

q = deque(list(range(1, 10)))
ctr = 0
while ctr < K:
    val = q.popleft()
    ctr += 1
    for i in range(-1, 2):
        add = (val % 10) + i
        if 0 <= add <= 9:
            q.append(val * 10 + add)
            
print(val)


Measured memory_bytes: 45148
#include<bits/stdc++.h>
#define For(i , j , k) for (int i = (j) , _##end_ = (k) ; i <= _##end_ ; ++ i)
#define Fordown(i , j , k) for (int i = (j) , _##end_ = (k) ; i >= _##end_ ; -- i)
#define Set(a , b) memset(a , b , sizeof(a))
#define pb push_back
#define INF (0x3f3f3f3f)
#define Mod (1000000007)
using namespace std;
typedef long long LL;

template <typename T> inline bool chkmax(T &a , T b) { return a < b ? (a = b , 1) : 0; }
template <typename T> inline bool chkmin(T &a , T b) { return b < a ? (a = b , 1) : 0; }

int _ , __;
char c_;
inline int read()
{
	for (_ = 0 , __ = 1 , c_ = getchar() ; !isdigit(c_) ; c_ = getchar()) if (c_ == '-') __ = -1;
	for ( ; isdigit(c_) ; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
	return _ * __;
}

inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("a.in" , "r" , stdin);
	freopen("a.out" , "w" , stdout);
#endif
}

char s[1000];

int main()
{
	scanf("%s" , s);
	For(i , 0 , strlen(s) - 9)
		putchar(s[i]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  for(ll i=1;i<=n;i++) {
    ll ans=0;
    for(ll j=1;6*j*j<=i;j++) {
      for(ll k=j;j*j+k*k+2*j*k+2*k*k<=i;k++) {
        for(ll l=k;j*j+k*k+l*l+j*k+k*l+l*j<=i;l++) {
          if(j*j+k*k+l*l+j*k+k*l+l*j==i) {
            if(j==l) ans++;
            else if(j==k||k==l) {
              ans+=3;
            }
            else {
              ans+=6;
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

int n;

int main(){
	cin >> n;
	
	if(n < 1000){
		cout << "ABC" << endl;
	}
	else cout << "ABD"	<< endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for(ll i=a;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
  ll d,t,s;
  cin>>d>>t>>s;
  if(d<=s*t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  ll n, m;
  cin >> n >> m;
  if(n==m){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
    int N;
    cin >> N ;
    switch (N % 10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
          cout << "hon";
          break;
        case 0:
        case 1:
        case 6:
        case 8: 
          cout << "pon" ;
          break;
        case 3:
          cout << "bon" ;
          break;
    }      
	return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<iostream>
using namespace std;
int yom;
//AOJ2740??¨???(??´???????????????????????????????????£???????????¨?????????)
class tree{
public:
	int val,now;
	tree *left;
	tree *right;
	tree(){
		val=0;now=0;
		left=NULL;;
		right=NULL;
	}
	void setval(int a){
		val=a;
	}
	void make_left(void){
		if(this->left!=NULL){cout<<"??°???"<<endl;throw(1);}
		this->left=new tree;
	}
	void make_right(void){
		if(this->right!=NULL){cout<<"??°???"<<endl;throw(1);}
		this->right=new tree;
	}
	~tree(){
		//cout<<"??????????????????"<<endl;
		delete left;
		delete right;
	}
	void confi_tree(string str){
		while(-1){
			yom++;
			if(str[yom]==')'){return;}
			else if(str[yom]=='('&&now==0){make_left();left->confi_tree(str);}
			else if(str[yom]=='('&&now==1){make_right();right->confi_tree(str);}
			else if(str[yom]=='['){
				now++;
				while(-1){
					yom++;
					if(str[yom]==']'){break;}
					val*=10;
					val+=str[yom]-'0';
				}
			}
		}
	}
	void plus_tree(tree *Aki,tree *Bki){
		this->val=Aki->val+Bki->val;
		if(Aki->left!=NULL&&Bki->left!=NULL){make_left();left->plus_tree(Aki->left,Bki->left);}
		if(Aki->right!=NULL&&Bki->right!=NULL){make_right();right->plus_tree(Aki->right,Bki->right);}
	}
	void show_tree(){
		if(this->left==NULL&&right==NULL){return;}
		printf("(");
		if(this->left!=NULL){this->left->show_tree();}
		printf(")");
		printf("[%d]",this->val);
		printf("(");
		if(this->right!=NULL){this->right->show_tree();}
		printf(")");
	}
};

int main(void){
	string A,B,C;
	tree Aki;
	tree Bki;
	tree Cki;
	yom=-1;
	cin>>A>>B;
	A.push_back(')');
	B.push_back(')');
	yom=-1;
	Aki.confi_tree(A);
	yom=-1;
	Bki.confi_tree(B);
	Cki.plus_tree(&Aki,&Bki);
	Cki.show_tree();
	printf("\n");
	return 0;
}

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

bool prime(int n){
  if(n%2==0) return false;
  for(int i=3;i<sqrt(n);i+=2){
    if(n%i==0) return false;
  }
  return true;
}

int focount(int h,int w){
  if(h<=1||w<=1) return 0;
  return h/2+w/2-1+focount(h-2,w-2);
}

int main(){
  int h,w;
  cin >> h >> w;
  char a;
  int count[26];
  int forcount,twocount,onecount;
  for(int i=0;i<26;i++) count[i]=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a;
      count[a-97]++;
    }
  }
  
  forcount=focount(h,w);
  twocount=(h*w-4*forcount)/2;
  onecount=h*w-4*forcount-2*twocount;
  for(int i=0;i<26;i++){
    if(count[i]>=4){
      forcount-=count[i]/4;
      count[i]=count[i]%4;
      if(forcount<0) {
	count[i]-=4*forcount;
	forcount=0;
      }
    }
    if(forcount==0) break;
  }
  if(forcount!=0) {
    cout << "No" << endl;
    return 0;
  }
  for(int i=0;i<26;i++){
    if(count[i]>=2){
      twocount-=count[i]/2;
      count[i]=count[i]%2;
      if(twocount<0) {
	count[i]-=twocount;
	twocount=0;
      }
    }
    if(twocount==0) break;
  }
  if(twocount!=0) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}


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

int min(int x, int y){
    if(x<=y)  return x ;
    return y ;
}

int max(int x, int y){
    if(x<=y)  return y ;
    return x ;
}

int main()
{
   int n ;
   cin >> n ;
   long long a[n+1],b[n] ;
   for(int i=0;i<n+1;i++) cin >> a[i] ;
   for(int i=0;i<n;i++) cin >> b[i] ;
  
   long long ans = 0 ;
   for(int i=0;i<n;i++)
   {
       if(a[i]>=b[i]){
           ans+=b[i] ;
           //ans+=b[i] ;
       }else{
           b[i]-= a[i] ;
           ans+=a[i] ;
           ans += min(b[i],a[i+1]) ; 
           a[i+1] = max(0,a[i+1]-b[i]) ;
       } 
   }
   cout << ans << endl ;
      
    return 0;
}



Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

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

  int N;
  long long K;

  cin >> N >> K;
  K--;
  int a, b;
  vector<pair<int, int>> v;
  for (int i = 0; i < N; ++i) {
    cin >> a >> b;
    v.emplace_back(a, b);
  }
  sort(v.begin(), v.end());

  long long j = 0;
  for (const auto& p : v) {
    if (j <= K && K < j + p.second) {
      cout << p.first << endl;
      break;
    }
    j += p.second;
  }

  return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define int long long

using namespace std ;

string s ;
int dp[100001][13];

int32_t main(){
        ios_base::sync_with_stdio(0); cin.tie(0);

        cin >> s ;
        dp[0][0]=1;
        for(int i=0;i<(int)s.size();i++){
                int c;
                if(s[i]=='?'){
                        c = -1;
                }else {
                        c = s[i]-'0';
                }
                for(int j=0;j<10;j++){
                        if(c!=-1 and c != j) continue;
                        for(int k=0;k<13;k++){
                                dp[i+1][(k*10+j)%13] += dp[i][k];
                        }
                }
                for(int j=0;j<13;j++)
                        (dp[i+1][j])%=1000000007;
        }

        cout << dp[s.size()][5] << endl;

        return 0;

}


Measured memory_bytes: 10704
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define int long long
#define pi pair < int, int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"

int32_t main(){
	boost;
	int n, m;
	cin >> n >> m;
	vector < int > a (n);
	for(int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	
	auto check  = [&](int mid) {
		int cur_cnt = 0;
		for(int i = 0; i < n; i++) {
			int it = a.end() - lower_bound(a.begin(), a.end(), mid - a[i]);
			cur_cnt += it;
		}
		return cur_cnt >= m;
	};

	int l = 0 , r = a.back() + a.back(),ans = 0;
	while(l <= r) {
		int mid = (l + r) / 2;
		if(check(mid)) {
			l = mid + 1;
			ans = mid;
		}
		else 
			r = mid - 1;
	}
	int sf[n + 1] = {0};
	for(int i = n - 1; i >= 0; i--)
		sf[i] = a[i] + sf[i + 1];
	int res = 0, cnt = 0;
	for(int i = 0; i < n; i++) {
		int it = a.end() - lower_bound(a.begin(), a.end(), ans - a[i]);
		cnt += it;
		res += it * a[i] + sf[n - it];
	}
	cout << res - (cnt - m) * ans << endl; 
}

Measured memory_bytes: 4784
import math
import fractions
import copy
import numpy as np
#以下てんぷら
def j(q):
    if q==1: print("POSSIBLE")
    elif q == 0:print("IMPOSSIBLE")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
n,m= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(m)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#a.pop(0)は10^5あるときTLEしやすい!注意!抜くなら逆ソート!
#これを消すとなぜかWAになる呪い
if n%m==0:
    print(0)
else:
    print(n%m)


Measured memory_bytes: 23152
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include<math.h>
typedef long long int ll;
int main()
{
   double n;
   cin>>n;
   double q=0.0;
   for(int i=1;i<=n;i++)
   {
       if(i%2==1)
        q++;
   }
   q/=n;
   cout<<fixed<<setprecision(10)<<q;

}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 998244353;
ll INF = 11451419194545;

ll fast_pow(ll a, ll n){
    if(n == 0) return 1;
    //べき数nが奇数, aを前にだして, a^n-1の気持ちに
    if(n % 2 == 1){
        return a * fast_pow(a, n - 1) % MOD;
    }else{
        //べき数nが偶数のとき，べき数を半分にして, aをまとめる. べき数を半分にする
        return fast_pow(a * a % MOD, n / 2) % MOD;
    }
}


int main(){
    ll N;
    cin >> N;

    map<ll, ll> mp;
    for(ll i = 0; i < N; i++){
        ll t = 0; cin >> t;
        if(i == 0 && t > 0){
            cout << 0 << endl;
            return 0;
        }
        if(i != 0) mp[t]++;
    }

    ll cn = 1;
    ll ans = 1;
    ll tmp = 1;
    auto begin = mp.begin(), end = mp.end();
    for (auto iter = begin; iter != end; iter++) {
        if(iter -> first != cn){
            cout << 0 << endl;
            return 0;
        }
        cn++;
        ans = ans * fast_pow(tmp, iter->second) % MOD;
        //cout << iter->second << endl;
        tmp = iter->second;
    }

    cout << ans << endl;


}

Measured memory_bytes: 6528
#include<stdio.h>
int main(void){
int b,r,g,c,s,t,point;

while(scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),b+r+g+c+s+t){
point=100;
point+=(b*6+r*4)*15+g*7+c*2+s*3;
point-=(b*5+r*3)*2+(t-b*5-r*3)*3;
printf("%d\n",point);
}
return 0;}

Measured memory_bytes: 1028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _164A
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] input = Console.ReadLine().Split(' ').Select(tmp => long.Parse(tmp)).ToArray();
            if (input[0] > input[1])
            {
                Console.WriteLine("safe");
            }
            else
            {
                Console.WriteLine("unsafe");
            }

        }
    }
}


Measured memory_bytes: 28052
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

struct st{
    ll dataa;
    ll datab;
};
bool cmp(st a,st b){
    return a.dataa<b.dataa;
}

int main(){
    int n,m;
    cin>> n>>m;
    st *data = new st [n];
    for(int i=0;i<n;i++){
        cin>>data[i].dataa>>data[i].datab;
    }
    sort(data,data+n,cmp);
    ll cnt=0;
    // start=start->next;
    for(int i=0;i<n&&m>0;i++){
        if(data[i].datab<m){
            cnt+=data[i].dataa * data[i].datab;
            m-=data[i].datab;
        }else{
            cnt+=data[i].dataa *m;
            m=0;
        }
    }
    cout<<cnt<<"\n";
    return(0);
}

Measured memory_bytes: 1792