akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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 a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int main(){
  int n,m; cin >> n >> m;
  int G[n][n];
  rep(i,n) rep(j,n) {
    if(i == j) G[i][j] = 0;
    else G[i][j] = G[j][i] = 1e9;
  }
  vi a(m),b(m),c(m);
  rep(i,m) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    G[a[i]][b[i]] = G[b[i]][a[i]] = c[i];
  }

  rep(k,n) rep(i,n) rep(j,n) chmin(G[i][j],G[i][k] + G[k][j]);
  int ans = 0;
  rep(i,m){
    bool ok = true;
    rep(s,n) if(G[s][b[i]] == G[s][a[i]] + c[i]) ok = false;
    if(ok) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int minus = 0;
  rep (i, 1, n) {
    if (s[i - 1] == s[i]) ++minus;
  }
  cout << n - minus << endl;
  return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline #入力行数が多いから高速化が必要
sys.setrecursionlimit(int(1E+7))
#小さすぎるデフォルト値を変え再起処理の上限を引き上げる(だいたい1000やから)
def main():
    n ,q = map(int,input().split())
    link = [[]  for i in range(n + 1)]
    for  i in range(n - 1):
        a,b = map(int,input().split())
        link[a].append(b)
        link[b].append(a)
    #print(link)
    V = [0] * (n + 1)
    for j in range(q):
        p, x = map(int,input().split())
        V[p] += x
    #print(V)

    def dfs(i, parent, acc): #深さ優先探索なり
        V[i] += acc #親ノードまでの累積値を加算
        for j in link[i]:
            if j != parent: # 親ノードを追加しない
                dfs(j, i, V[i])

    cur = 1
    parent = 0
    acc = 0
    dfs(cur, parent, acc) #親ノードを０としてスタート
    V = [str(i) for i in V]
    print(" ".join(V[1:]))#数字はjoinつかえないので

if __name__ == "__main__":
    main()


Measured memory_bytes: 283284
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    int n, l;
    cin >> n >> l;
    string str[n];
    for(int i = 0; i < n; i++)
        cin >> str[i];
    sort(str, str+n);
    for(int i = 0; i < n; i++)
        cout << str[i];
    cout << endl;
}



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();
		String S = sc.next();
		sc.close();
		int a = 0;
		for(int i=0; i<N; i++) {
			if(S.charAt(i)=='A' && i<N-2) {
				if(S.charAt(i+1)=='B' && S.charAt(i+2)=='C') {
					a++;
				}
			}
		}
		System.out.println(a);
	}

}

Measured memory_bytes: 23892
#A - Rainy Season
Si = []
Si = list(str(input()))
i = 0
if Si == ['S','S','S']: i = 0
if Si == ['R','S','S']: i = 1
if Si == ['S','R','S']: i = 1
if Si == ['S','S','R']: i = 1
if Si == ['R','R','S']: i = 2
if Si == ['S','R','R']: i = 2
if Si == ['R','S','R']: i = 1
if Si == ['R','R','R']: i = 3
# 出力
print(i)


Measured memory_bytes: 9036
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define db cout << " HERE " << endl;
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 2000001; // check the limits dummy
vi adj[MX];
int vis[MX];
int k = 1;
void dfs(int u) {
	for(auto i : adj[u])  {
		if(vis[i]) continue;
		k++;
		vis[i]=true;
		dfs(i);
	}
}
int main() {
	int n  , m ;
	cin >> n >> m;
	F0R(i,m) {
		int a , b ;
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	int ans = 0;
	FOR(i,1,n) {
		if(vis[i]) continue;
		else
		vis[i]=true;
		dfs(i);
		ans = max(k,ans);
		k = 1;
	}
	cout << ans << endl;
}



// template by benq 


Measured memory_bytes: 63764
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
//  ??¨?????????????????????
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      int a = in.nextInt();
      int b = in.nextInt();
      out.println(a*b+" "+(2*(a+b)));
    }
  }

  public static void main(String[] args) throws IOException {
//    ??????
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
//    ??\???
    public BufferedReader br;
    public StringTokenizer st;
    
    public InputReader(InputStream stream) {
//      ?????????????????????
      br = new BufferedReader(new InputStreamReader(stream));
    }
   
//    ????????????????????????
    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }
    
    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken()); 
    }
    
    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }
    
    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }
    
  }
  
}

Measured memory_bytes: 24552
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 

#define MAX 1000001
int64_t fac[MAX], finv[MAX], inv[MAX]; // n!, (n!)^-1, n^-1 の mod
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算。最悪 O(k).
int64_t COM(i64 n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    if (k >= MAX) {cout <<"k >= MAX\n"; return 0;}
    if (n >= MAX) { // O(k)
        i64 com = finv[k];
        rep(i, 0, k) (com *= (n - i)) %= MOD;
        return com;
    }
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//重複組み合わせ H
int64_t Hcom(int P_,int Q_) { return (P_==0&&Q_==0)?1:COM(P_+Q_-1,Q_);}

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

i64 n, k; cin >> n >> k;

COMinit();

if (k >= n){
    cout << Hcom(n, n) << "\n";
    return 0;
}
if (k == 1){
    cout << n * (n-1) << "\n";
}
else{
    i64 ans = 0;
    rep(i, 0, k+1){
        int lef = n - i;
        ans += COM(n, i) * Hcom(lef, i) %MOD;
    }
    cout << ans % MOD << "\n";
}


return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



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

int main()
{
    int n, sum = 0;
    cin >> n;
    int a[n];
    int b[n-1];
    for (int i = 0; i < n-1; i++)
    {
        cin >> b[i];
    }
    a[0] = b[0];
    sum += a[0];
    a[n-1] = b[n-2];
    sum += a[n-1];
    for (int i = 1; i < n-1; i++)
    {
        a[i] = min(b[i], b[i-1]);
        sum += a[i];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;
using namespace std;


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

char str[200005];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    scanf("%s", str);

    ll x0=0;
    int i;
    for(i=0; i<n; i++) {
        x0=(x0*2+(str[i]-'0'))%MOD;
    }

    vector<int> a;
    for(i=3; i<=n; i+=2) {
        if(n%i==0) {
            a.push_back(n/i);
        }
    }
    reverse(a.begin(), a.end());

    ll ans=n*2*(x0+1)%MOD;

    int siz=(int)a.size();
    vector<ll> ans0(siz);

    int t;
    for(t=0; t<siz; t++) {
        int kk=a[t];

        for(i=0; i<n; i++) {
            if(str[i]=='1') {
                int bad=0;
                if(i>=kk) {
                    int i0=i%kk;
                    int step=(i-i0)/kk;
                    if(step%2==0 && str[i0]=='1') {
                        bad=1;
                    }
                    if(step%2==1 && str[i0]=='0') {
                        bad=1;
                    }
                }
                if(bad==0) {
                    int defined=MIN(kk, i+1);
                    int not_defined=kk-defined;
                    ans0[t] = (ans0[t] + mpow(2, not_defined))%MOD;
                }
            }

            {
                int bad=0;
                if(i>=kk) {
                    int i0=i%kk;
                    int step=(i-i0)/kk;
                    if(step%2==0 && str[i0]!=str[i]) {
                        bad=1;
                    }
                    if(step%2==1 && str[i0]==str[i]) {
                        bad=1;
                    }
                }
                if(bad) {
                    break;
                }
            }
        }
        if(i==n) {
            ans0[t]=ans0[t]+1;
        }
    }

    for(t=0; t<siz; t++) {
        int t2;
        for(t2=t+1; t2<siz; t2++) {
            if(a[t2]%a[t]==0) {
                //printf("%d %d\n", a[t2], a[t]);
                ans0[t2]=(ans0[t2]-ans0[t]+MOD)%MOD;
            }
        }
    }

    for(t=0; t<siz; t++) {
        ans0[t] = ans0[t] * (n*2-a[t]*2) %MOD;
        ans = (ans - ans0[t] +MOD)%MOD;
    }

    printf("%lld\n", ans);
    return 0;
}


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

void traversal(ll pos, ll prev, vector<pair<ll, vector<ll>>> &tree)
{
    ll x = tree[pos].first;
    for (ll to : tree[pos].second)
    {
        if (prev == to)
            continue;
        tree[to].first += x;
        traversal(to, pos, tree);
    }
}

int main()
{
    ll N, Q;
    cin >> N >> Q;
    vector<pair<ll, vector<ll>>> tree(N, make_pair(0LL, vector<ll>(0)));
    ll a, b;
    rep(i, N - 1)
    {
        cin >> a >> b;
        tree[a - 1].second.push_back(b - 1);
        tree[b - 1].second.push_back(a - 1);
    }
    ll p, x;
    rep(i, Q)
    {
        cin >> p >> x;
        tree[p - 1].first += x;
    }

    traversal(0, -1, tree);

    cout << tree[0].first;
    rep(i, N - 1) cout << " " << tree[i + 1].first;
    cout << endl;

    return 0;
}

Measured memory_bytes: 27392
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int i,j,H,W,ans;
int A;
int c[10][10];

int main() {
	cin >> H >> W;
	
	REPI(0,10) REPJ(0,10) cin >> c[i][j];
	
	for (int k = 0; k < 10; k++)
	REPI(0,10) REPJ(0,10) c[i][j] = MIN(c[i][j], c[i][k] + c[k][j]);
	
	REPI(0,H) REPJ(0,W) {
		cin >> A;
		if (A != -1) ans+=c[A][1];
	}
	
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
vector<int>v;
int ans;
void dfs(){
	int last=v[sz(v)-1];
	int ans1=0;
	for (int i=0;i<sz(v);i++){
		ans1+=v[i];
	}
	ans+=ans1;//cout<<ans1<<'+';
	v.erase(v.end()-1);
	int num;
	for (num=10;;num*=10){
		if (num>=last)  break;
		int a=last/num;
		int b=last%num;
		v.pb(a), v.pb(b);
		dfs();
		v.erase(v.end()-1); 
		v.erase(v.end()-1); 
	}
	v.pb(last);
}
signed main()
{
	int s;
	cin>>s;
	v.pb(s);
	dfs();
	cout<<ans;
	re 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<ll,ll> P;

int n, m;
int a[300000];

int main(){
    I(n);
    rep(i,3*n) I(a[i]);
    sort(a,a+3*n);
    int pos = 3*n-2;
    ll ans = 0;
    rep(i,n){
        ans += a[pos];
        pos -= 2;
    }
    cout << ans << endl;
}
































Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int num[2][64];
const ll MOD=1e9+7;
ll ans=0;
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		ll x;cin>>x;
		for (int j=0;j<60;j++){
			if (((1ll<<j)&x)==0){
				ans=(ans+((1ll<<j)%MOD)*num[1][j])%MOD;
			}
			else{
				ans=(ans+((1ll<<j)%MOD)*num[0][j])%MOD;
			}
		}
		for (int j=0;j<60;j++){
			if (((1ll<<j)&x)==0)num[0][j]++;
			else num[1][j]++;
		}
	}
	cout<<ans;
}

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

using namespace std;

long long N, X;

long long f(long long a, long long b)
{
    if(a >= b)
    {
        swap(a, b);
    }

    if(b % a != 0)
    {
        return 2 * (b / a) * a + f(a, b % a);
    }
    else
    {
        return 2 * b - a;
    }
}

int main()
{
    cin >> N >> X;
    cout << N + f(N - X, X) << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int N, W;
    long long int w[105], v[105];

    cin >> N >> W;

    for(int i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
    }

    long long d[2][100020];

    for(int i = 0; i < N; i++)
    {
        for(int j = W; j >=0; j--)
        {
            if(i == 0 && j >= w[0])
                d[i%2][j] = v[0];
            else if(i == 0)
                d[i%2][j] = 0;
            else
            {
                if(j >= w[i])
                    d[i%2][j] = max(d[(i-1)%2][j], v[i] + d[(i-1)%2][j-w[i]]);
                else
                    d[i%2][j] = d[(i-1)%2][j];
            }
            
        }
    }


    cout << d[(N-1)%2][W];

    return 0;
}

Measured memory_bytes: 1792
import copy
from functools import reduce
N=int(input())
A=list(map(int,input().split()))

#print(N,A)

den=reduce(lambda x,y:x*y,A)

num=0
for i in range(0,N):
    B=copy.deepcopy(A)
    B[i]=1.0
    num+=reduce(lambda x,y:x*y,B)
#    print(i)

print(den/num)


Measured memory_bytes: 3700
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] h = new int[N];
    int[] a = new int[N];
    for (int i = 0; i < N; i++) h[i] = scanner.nextInt();
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();

    long[] bit = new long[N + 1];
    for (int i = 0; i < N; i++) {
      int hi = h[i] - 1;
      long max = 0;
      while (hi > 0) {
        max = Math.max(max, bit[hi]);
        hi -= hi & -hi;
      }
      max += a[i];
      hi = h[i];
      while (hi < bit.length) {
        bit[hi] = Math.max(bit[hi], max);
        hi += hi & -hi;
      }
    }

    long max = 0;
    for (int i = 0; i <= N; i++) if (bit[i] > max) max = bit[i];
    System.out.println(max);
  }
}


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

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

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

  long long ans = 0;
  map<vector<int>, int> m;
  for(int i = 0; i < N; i++){
    vector<int> c(26);
    for(size_t j = 0; j < s[i].size(); j++){
      c[s[i][j] - 'a']++;
    }
    ans += m[c];
    m[c]++;
  }

  cout << ans << endl;
}



  


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template <typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if(a < b) a = b;
}

template <typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if(a > b) a = b;
}

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  double r; cin >> r;

  cout << 2 * acos(-1) * r << endl;
  
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    ll a,b,x;
    cin>>a>>b>>x;
    cout<<(a>0?b/x-(a-1)/x:b/x+1)<<endl;
    return 0;
}

Measured memory_bytes: 256
void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);
    int hp = a[0];
    foreach (i; 1 .. n) {
        hp = gcd(hp, a[i]);
    }
    hp.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4276
#BFSにdpを乗っける
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

h,w=MI()
lis=[[0]*w for i in range(h)]
for i in range(h):
    s=SI()
    for j in range(w):
        if s[j]=="#":
            lis[i][j]=1
#print(lis)
Q=deque([[0,0]])
dp=[[-1]*w for i in range(h)]
dp[0][0]=1
step=[[1,0],[0,1]]
while Q:
    x,y=Q.popleft()
    for i,j in step:
        if x+i>=h or y+j>=w:
            continue
        if lis[x+i][y+j]==1:
            continue
        if dp[x+i][y+j]<0:
            dp[x+i][y+j]=dp[x][y]%mod
            Q.append([x+i,y+j])
        else:
            dp[x+i][y+j]+=dp[x][y]%mod
    #print(dp)
print(max(0,dp[-1][-1])%mod)
    

        

Measured memory_bytes: 99764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    VL C(N);
    VVL A(N, VL(M));
    rep(i, 0, N){
        cin >> C[i];
        rep(j, 0, M){
            cin >> A[i][j];
        }
    }

    ll ans = -1;
    for(int bit = 0; bit < (1<<N); bit++){
        VL sk(M, 0);
        ll pr = 0;
        for(int i = 0; i < N; i++){
            if(bit & (1<<i)){
                pr += C[i];
                rep(j, 0, M){
                    sk[j] += A[i][j]; 
                } 
            }
        }
        bool f = true;
        rep(i, 0, M){
            if(sk[i] < X) f = false;
        }
        if(f){
            if(ans == -1) ans = pr;
            else ans = min(ans, pr);
        }
    }
    cout << ans <<  endl;
    return 0;
}

Measured memory_bytes: 3636
N, Y = map(int, input().split())
ans = '-1 -1 -1'
for i in range(N + 1):
    for j in range(N + 1):
        k = N - (i + j)
        if k >= 0 and 10000 * i + 5000 * j + 1000 * k == Y:
            ans = '{} {} {}'.format(i, j, k)
            break
    else:
        continue
    break
print(ans)


Measured memory_bytes: 2940
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		long L = sc.nextLong();
		long T = sc.nextLong();
		int[] x = new int[N];
		boolean[] cw = new boolean[N];
		for(int i=0; i<N; i++) {
			x[i] = sc.nextInt();
			cw[i] = sc.nextInt()==1;
		}

		int[] pos = new int[N];
		for(int i=0; i<N; i++)
			pos[i] = (int)((x[i]+(cw[i] ? T%L : L-(T%L)))%L);
		Arrays.sort(pos);
			
		long cnt = 0;
		for(int i=1; i<N; i++) {
			if(cw[i]!=cw[0]) {
				long dis = ((x[i]-x[0])*(cw[0] ? 1 : -1)+L)%L;
				cnt = (cnt + (2*T + L-dis-1)/L)%N;
			}
		}
			
		int a = Arrays.binarySearch(pos, (int)((x[0]+(T%L)*(cw[0] ? 1 : -1) + L)%L));
		if(cw[0] && a>0 && pos[a-1]==pos[a])
			a--;
		if(!cw[0] && a<N-1 && pos[a+1]==pos[a])
			a++;
		int idx = (int)((a + cnt*(cw[0] ? -1 : 1) + N)%N);
		
		for(int i=0; i<N; i++)
			pw.println(pos[(idx+i)%N]);
		
		sc.close();
		pw.close();
	}
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll a,b,c; cin >> a >> b;
    c = a + b;
    if(c >=10)out("error");
    else out(c);
}

Measured memory_bytes: 3632
r, c = map(int, input().split())   #r, cを読み込む
l = [[0 for i in range(c + 1)] for i in range(r + 1)]
#0 for i in range(n)   n個の要素を0で初期化
for i in range(r) :
 l[i] = list(map(int, input().split()))   #行ごとに読み込み
 
for i in range(r) :
 s = sum(l[i])   #行ごとの和を求める
 l[i].append(s)   #sをi行目の最後に追加
 
for j in range(c) :   #列ごとの和を求める 横に1つずつ動く
 s = 0
 for i in range(r) :   #1行ずつ進む
   s += l[i][j]
 l[r][j] = s   #0行目から始まってる→r(r+1)行目にc列目の和
 
l[r][c] = sum(l[r])   #l[r][c] = l[r]の和
 
for i in range(r + 1) :   #range→(r+1)回
 for j in range(c + 1) :
   if(j == c) :
     print(l[i][j])
   else :
     print(str(l[i][j]) + " ", end = "")


Measured memory_bytes: 6216
#include <iostream>
using namespace std;
int main(){
    // Your code here!
    int n,x,cnt;
    while(1){
     cin>>n>>x;
     if(n==0 && x==0) break;
     cnt=0;
        for(int i=1; i<n-1; i++){
            for(int j=i+1; j<n; j++){
                for(int k=j+1; k<=n; k++){
                    if(i+k+j==x)
                        cnt++;
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxN = 2e5+7;
const int maxM = 1e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
//const ll INF = (1ll)<<60;
const int INF = 2e9+9;
const int MOD = 1e9+7;

int n,k;
 
int a[maxN];
int main()
{
	scanf("%d",&n);
	int cnt = 0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);	
	} 
	for(int i=2;i<n;i++)
	{
		if((a[i]>a[i-1] && a[i]<a[i+1]) || a[i]<a[i-1] && a[i]>a[i+1])
			cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


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

using namespace std;

using ll = long long;

#define MOD_NUMBER 1000000007

// ベクトル要素の列挙
template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

// エラトステネスの篩による素数配列の出力
vector<int> Eratosthenes(int N){
  vector<int> p = {2};
  int sqrtN = sqrt(N);
  for(int i = 3; i <= N; i++){
    p.push_back(i);
    for (int j = 0; p.at(j) <= sqrtN; j++) {
      if(i%p.at(j) == 0) {
        p.pop_back();
        break;
      }
    }
  }
  return p;
}

int main() {
  int n, m, x, c_cnt, flag, min = 1000000007;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  vector<int> a_cnt(m);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }

  for (int i = 0; i < (1<<n); i++) {
    flag = 1;
    c_cnt = 0;
    for (int j = 0; j < m; j++) {
      a_cnt[j] = 0;
    }

    for (int j = 0; j < n; j++) {
      if ((i>>j)%2) {
        c_cnt += c[j];
        for (int k = 0; k < m; k++) {
          a_cnt[k] += a[j][k];
        }
      }
    }

    for (int j = 0; j < m; j++) {
      if (a_cnt[j] < x) {
        flag = 0;
        break;
      }
    }
    if (flag && c_cnt < min) {
      min = c_cnt;
    }
  }
  if (min == 1000000007) {
    min = -1;
  }
  cout << min << endl;
  return 0;
}


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

ll dp[1003][20004];
int main() {
  ios::sync_with_stdio(false);
  // cin.tie(NULL);

  srand(time(NULL));

  int n;
  cin >> n;
  tuple<int,int,int> a[1003];
  for (int i = 1; i <= n; i++) {
    int w, s, v;
    cin >> w >> s >> v;
    a[i] = make_tuple(w, s, v);
  }

  sort(a + 1, a + n + 1, [](auto &x, auto &y){
    return get<0>(x) + get<1>(x) < get<0>(y) + get<1>(y);
  });

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= 2e4; j++) {
      dp[i][j] = -1e18;
    }
  }

  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    int w, s, v;
    tie(w, s, v) = a[i];
    for (int j = 0; j <= 2e4; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j >= w && j - w <= s)
        dp[i][j] = max(dp[i][j], dp[i - 1][j - w] + v);
    }
  }
  ll ans = 0;
  for (int i = 0; i <= 2e4; i++) {
    ans = max(ans, dp[n][i]);
  }
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 156672
def conv_bin(i, digit):
    if i & 1 << digit:
        return "+"
    else:
        return "-"


if __name__ == "__main__":
    abcd = input()
    bin_pattern_digit = len(abcd) - 1

    for i in range(1 << bin_pattern_digit):
        # 初期値:一番左の桁の値。
        result = int(abcd[0:1])
        for j in range(bin_pattern_digit):
            # +を入れた場合
            # 例：1234のパターン1「+」2の場合：i=0の時に+2(abcd[1:2])する必要がある。
            #                 3「-」4の場合：i=2の時に-4(abcd[3:4])する必要がある。
            if i & 1 << (bin_pattern_digit - j -1 ):
                # result += int(abcd[j + 1:j + 2])
                result += int(abcd[j + 1])
            # -を入れた場合
            else:
                # result -= int(abcd[j + 1:j + 2])
                result -= int(abcd[j + 1])

        # 合計が7なら終了
        if result == 7:
            break

    # 注意：
    # bit変数(i)の結果を確認する場合、文字列とスライスの併用(str(bit(i[0:1])))は使えない。
    # 数値と同じで、先頭0は消される = 桁数が可変であるため。
    # i & 1 << 0  # 1桁目が真か確認。
    # i & 1 << 1  # 2桁目が真か確認。
    # -dev-
    print(abcd[0:1] + conv_bin(i, 2) + abcd[1:2] + conv_bin(i, 1) + abcd[2:3] + conv_bin(i, 0) + abcd[3:4] + "=7")




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
	int n,m;
  	cin>>n>>m;
    int ans=0;	
  	if(n==1) ans+=300000;
  if(m==1) ans+=300000;
  if(n==2) ans+=200000;
  if(m==2) ans+=200000;
  if(n==3) ans+=100000;
  if(m==3) ans+=100000;
  if(n==1 && m==1) ans+=400000;
cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <functional>
#include <queue>
#include <cmath>
#include <string>
using namespace std;


int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	int cnt = 0;
	while (1)
	{
		
		b += a / 2;
		a /= 2;
		cnt++;
		if (cnt == k) break;
		a += b / 2;
		b /= 2;
		cnt++;
		if (cnt == k) break;
	}
	cout << a << ' ' << b;


}

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

int main() {
  int a,b,M;
  cin >> a >> b;
  
  M=a*b%2;

  if (M == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" <<endl;
  }
}

Measured memory_bytes: 256
def main():
    import sys 
    input= sys.stdin.readline
    n,m,v,p=map(int,input().split())
    a=list(map(int,input().split()))
    a.sort(reverse=True)
    cnt=p
    #from bisect import bisect_left
    #print(a[5]+m)
    s=sum(a[p-1:p])
    for i in range(p,n):
        if (a[i]+m )<a[p-1]:
            break
        # 3 2 2 1 1 0
        
        cnt+= ((a[i]+m)*(i-p+1)-s+(n-(i-p+1))*m)>=v*m
        try: s+=a[i]
        except: continue      
    print(cnt)

if __name__=='__main__':
    main()

Measured memory_bytes: 58840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    string S; cin >> S;
    ll ans = 0;
    if(S=="RRR") ans = 3;
    if(S=="RRS") ans = 2;
    if(S=="RSR") ans = 1;
    if(S=="RSS") ans = 1;
    if(S=="SRR") ans = 2;
    if(S=="SRS") ans = 1;
    if(S=="SSR") ans = 1;
    if(S=="SSS") ans = 0;
    cout << ans << "\n";
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans;
int main()
{
    int R,G,B,N;
    scanf("%d %d %d %d",&R,&G,&B,&N);
    for(int i=0;R*i<=N;i++)
    {
        for(int j=0;G*j<=N;j++)
        {
            int k = N-R*i-G*j;
            if(k>=0 && k%B ==0 ) ans++;
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define si(x)       scanf("%d",&x)
#define su(x)       scanf("%u",&x)
#define sll(x)      scanf("%lld",&x)
#define sl(x)       scanf("%ld",&x)     
#define sc(x)       scanf("%c",&x)
#define ss(x)       scanf("%s",x)
#define sf(x)       scanf("%f",&x)
#define slf(x)      scanf("%lf",&x)
#define pri(x)      printf("%d\n",x)
#define prl(x)      printf("%lld\n",x)
#define ll          long long int
#define mod(x,n)    (x+n)%n
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<long long,long long>
#define pil         pair<int,long long>
#define pli         pair<long long,int>
#define vi          vector<int>
#define vl          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define M           1000000007
 
 
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int n; si(n);
	int a=n%10;
	int b=n/10;
	if(a==9 || b==9) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
extern crate proconio;
use proconio::input;
use std::collections::VecDeque;

fn main() {
    input!{
        n: usize,
        mut array: [usize; n],
    };

    array.sort();
    array.reverse();

    let mut res = 0;
    res += array[0];
    let mut que = VecDeque::new();
    let mut counter = 0;
    let mut now = array[1];
    for i in 2..n {
        res += now;
        counter += 1;
        que.push_front(array[i]);
        if counter == 2 {
            counter = 0;
            now = que.pop_back().unwrap();
        }
    }

    println!("{}", res);
}


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

int main() {
  string s;
  cin>>s;
  int cnt_0=0,cnt_1=0;
  rep(i,s.size()){
    if(s[i]=='0')
    cnt_0++;
    else 
    cnt_1++;
  }
  int ans=s.size()-abs(cnt_0-cnt_1);
  cout<<ans<<endl;
}

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

int main() {
  int ans = 0, temp = -1, n;

  cin >> n;

  vector<int> p(n);

  for (int i = 0; i < n; i++) {
    cin >> p[i];
    ans += p[i];
    if (temp < p[i]) temp = p[i];
  }

  cout << ans - temp / 2;

  return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int n1 = 0, n2 = 0;
  for (int i = 0; i < n-1; i++) {
    if (s.at(i) != s.at(i+1)) {
      n1++;
    }
  }
  for (int i = 0; i < n-1; i++) {
    if (s.at(n-1-i) != s.at(n-1-(i+1))) {
      n2++;
    }
  }
  cout << min(n1, n2) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;
using P = pair<ll, 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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

  int h, w;
  cin >> h >> w;
  vector<string> maze(h);
  rep(i, h) cin >> maze[i];

  queue<pair<int, int>> q;
  q.push({0, 0});

  vector<vector<int>> d(h, vector<int>(w, INF));
  d[0][0] = 0;

  while (!q.empty()) {
    pair<int, int> p = q.front(); q.pop();
    int ch = p.first;
    int cw = p.second;
    rep(i, 4) {
      int nh = ch + dy[i];
      int nw = cw + dx[i];
      if (nh < 0 || nh >= h || nw < 0 || nw >= w) continue;
      if (maze[nh][nw] == '#') continue;
      if (d[nh][nw] != INF) continue;
      d[nh][nw] = d[ch][cw] + 1;
      q.push({nh, nw});
    }
  }

  if (d[h-1][w-1] == INF) {
    cout << -1 << endl;
    return 0;
  }

  int n_white = 0;
  rep(i, h) rep(j, w) if (maze[i][j] == '.') n_white++;

  cout << n_white - d[h-1][w-1] - 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
static string mark = "mcxi";
static int value[] = { 1000, 100, 10, 1 };
int decode(string source)
{
	int index = 0;
	int sum = 0;
	while (index < source.size())
	{
		if (isalpha(source[index]))
		{
			if (index - 1 < 0 || !isdigit(source[index - 1]))
			{
				int i = mark.find(source[index]);
				sum += value[i];
			}
			else
			{
				int i = mark.find(source[index]);
				sum += (value[i] * (source[index - 1] - '0'));
			}
		}
		index++;
	}
	return sum;
}

string encode(int n)
{
	string ret = "";
	int rank = 3;
	while (n > 0 && rank >= 0)
	{
		int mod = n % 10;
		if (mod == 1)
		{
			ret = mark[rank] + ret;
		}
		else if (mod != 0)
		{
			ostringstream stream;
			stream << mod;
			string res = stream.str();
			ret = res + mark[rank] + ret;
		}

		n /= 10;
		rank--;
	}
	return ret;
}
int main()
{
	int n;
	cin >> n;
	string a;
	string b;
	for (int i = 0; i < n; i++)
	{
		char c[9], h[9];
		cin >> c >> h;
		a = c;
		b = h;
		int x = decode(a);
		int y = decode(b);
		int sum = x + y;
		string ans = encode(sum);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=300005,MAXL=28;

int n;
int A[MAXN],B[MAXN];
int a[MAXN],b[MAXN];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",A+i);
	for(int i=1;i<=n;i++)
		scanf("%d",B+i);
	
	int ans=0;
	for(int k=0;k<=MAXL;k++)
	{
		memcpy(a,A,sizeof(int)*(n+1));
		memcpy(b,B,sizeof(int)*(n+1));
		int T=1<<k;
		for(int i=1;i<=n;i++)
		{
			a[i]%=2*T;
			b[i]%=2*T;
		}
		sort(b+1,b+n+1);
		int res=0;
		for(int i=1;i<=n;i++)
		{
			int *l=lower_bound(b+1,b+n+1,T-a[i]);
			int *r=lower_bound(b+1,b+n+1,T*2-a[i]);
			res^=((r-l)&1);
		}
		for(int i=1;i<=n;i++)
		{
			int *l=lower_bound(b+1,b+n+1,T*3-a[i]);
			int *r=lower_bound(b+1,b+n+1,T*4-a[i]);
			res^=((r-l)&1);
		}
		if(res)
			ans^=T;
	}
	
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 3968
import sys
import math

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

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

x = int(input())

if x == 2:
    print(x)
    sys.exit()

for i in range(x, 10**5+4):
    if i % 2 == 1 and is_prime(i):
        print(i)
        sys.exit()

Measured memory_bytes: 38896
n,capacity=map(int,input().split())
weights=[0]*n
values=[0]*n
for i in range(n):
    weights[i],values[i]=map(int,input().split())
maxValue=sum(values)
dp=[[float("inf")]*(maxValue+1) for i in range(n+1)]
for i in range(n+1):
    dp[i][0]=0
 
for i in range(1,n+1):
    for j in range(1,maxValue+1):
        if(values[i-1]<=j):
            dp[i][j]=min(weights[i-1]+dp[i-1][j- values[i-1]],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
 
ans=0
for i in range(maxValue+1):
    if(dp[n][i]<=capacity):
        ans=i
print(ans)

Measured memory_bytes: 315400
#include <iostream>

using namespace std;

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

    if(a>b){
        cout << "a > b" << endl;
    }else if(a<b){
        cout << "a < b" << endl;
    }else{
        cout << "a == b" << endl;
    }

    return 0;

}


Measured memory_bytes: 3064
S = input()
K = int(input())

numlist = list(map(int, list(S)))
count = 0
for i in range(len(numlist)):
    if numlist[i] != 1:
        count = i + 1
        break

if count > K:
    print(1)
else:
    print(numlist[count - 1])


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

int n;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    while(n){
        if(n%10==7){
            cout<<"Yes"<<endl;
            return 0;
        }
        n/=10;

    }
    cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int A = 0;
  int B = 0;
  int t = 0;
  int max = 0;
  int maxat = 0;
  cin >> N;
  vector<int> card(N);
  vector<bool> picked(N);
  for(int i = 0; i < N; i++){
    cin >> card.at(i);
  }
  while(t < N){
    for(int i = 0; i < N; i++){
    	if(!picked.at(i) && max < card.at(i)){
    	  max = card.at(i);
     	 maxat = i;
   		}
    }
    
    A += card.at(maxat);
    picked.at(maxat) = true;
    t++;
    if(t >= N){
      break;
    }
    max = 0;
    maxat = 0;
    for(int i = 0; i < N; i++){
    	if(!picked.at(i) && max < card.at(i)){
    	  max = card.at(i);
     	 maxat = i;
   		}
    }
    B += card.at(maxat);
    picked.at(maxat) = true;
    t++;
    
    max = 0;
    maxat = 0;
  }
  
  cout << A - B << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

int main(void) {
	LL n, ma = 0, ans = 0;
	double m, mi = 10000000000.0, mi2;

	cin >> n;
	vector<LL> a(n);

	for (LL i = 0; i < n; i++) {
		cin >> a[i];
		ma = max(ma, a[i]);
	}
	m = ma + 0.0;
	sort(a.begin(), a.end());

	for (LL i = 0; i < n; i++) {
		mi2 = mi;
		mi = min(mi, abs(a[i] - m / 2));
		if (mi2 != mi) {
			ans = i;
		}
	}
	cout << ma << " " << a[ans] << endl;


	return 0;
}


Measured memory_bytes: 1024
using System;

	public class Class1
	{
		public static void Main()
		{   
		
			
				string dataSet=Console.ReadLine();
				string[] data=dataSet.Split();
				int a=int.Parse(data[0]);
				int b =int.Parse(data[1]);
				
				int d=a/b;
				int r=a%b;
				double f =(double)a/(double)b;
				
			
				Console.WriteLine("{0} {1} {2:f5}",d,r,f);
			
			
		}
	

	}

Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int MOD=1000000007;

int main() {
  string s;
  cin >> s;
  int n=s.size();
  string t=s.substr(0,n/2);
  reverse(rng(s));
  string u=s.substr(0,n/2);
  int ans=0;
  rep(i,n/2) {
    if(s[i]!=t[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384