akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

ll dp[1010][1010];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	vector<ll> b(n);
	REP(i,n) cin>>a[i];
	REP(i,n) cin>>b[i];
	bitset<32> ans(0);
	for(ll i=31; i>=0; i--) {
		vector<ll> v1;
		vector<ll> v2;
		REP(j,n) v1.pb(a[j]%(1ll<<(i+1)));
		REP(j,n) v2.pb(b[j]%(1ll<<(i+1)));
		sort(ALL(v2));
		ll cnt=0;
		REP(j,n) {
			auto ite1=lower_bound(ALL(v2),(1ll<<i)-v1[j]);
			auto ite2=lower_bound(ALL(v2),(1ll<<(i+1))-v1[j]);
			auto ite3=lower_bound(ALL(v2),(1ll<<(i+1))+(1ll<<i)-v1[j]);
			cnt+=(ite2-ite1)+(v2.end()-ite3);
		}
		if(cnt%2) ans[i]=1;
	}
	cout<<ans.to_ullong()<<endl;
}




Measured memory_bytes: 9712
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
template<typename T>
T ncr(T left, T right) {
	right = min(left - right, right);
	T ans = 1;
	for (T i = 1; i <= right; i++) {
		ans = ans * (left - right + i) / i;
	}
	return ans;
}

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int N;
	cin >> N;
	vector<lli> v(N);
	bool b = true;
	lli minD = (int)MOD;
	lli sum = 0;
	for(int i=0;i<N;i++){
		cin >> v[i];
		minD = min(minD, abs(v[i]));
		if (v[i] < 0) {
			b = !b;
		}
		sum += abs(v[i]);
	}
	
	cout << (b ? sum : (sum - minD*2)) << endl;
	
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m,X,Y;
    cin >> n >> m >> X >> Y;
    int max_x = -100;
    int min_y = 100;
    int x;
    for(int i = 0;i < n;i++) {
        cin >> x;
        if(x > max_x) {
            max_x = x;
        }
    }
    int y;
    for(int i = 0;i < m;i++) {
        cin >> y;
        if(y < min_y) {
            min_y = y;
        }
    }
    if(max_x < min_y && max_x < Y && X < min_y) {
        cout << "No War" << endl;
    }else {
        cout << "War" << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<vector<ll>> dp(n + 1, vector<ll>(2, 0));
    ll INF = 1e15;
    dp[0][1] = -INF;
    rep(i, n)rep(j, 2){
        dp[i + 1][j % 2] = max(dp[i][j % 2] + a[i], dp[i][(j + 1) % 2] - a[i]);
    }
    cout << dp[n][0] << endl;
}

Measured memory_bytes: 9544
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  bool ok = false;
  REP(i,10) REP(j,10) {
    if(i*j == N) ok = true;
  }
  YesNo(ok);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

ll dup(ll a, ll b) { return (a+b-1)/b;}


int main() {
  int n;
  scanf("%d",&n);
  vl a(n);
  cin>>a;
  ll l = 2, r = 2;
  reverse(rng(a));
  for (ll x : a) {
    l = dup(l,x)*x;
    r = r/x*x;
    if (l > r) dame;
    // l = l;
    r = r+x-1;
  }
  cout<<l<<" "<<r<<endl;
  return 0;
}






















Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	long number;
	long prefecture;
  long year;
  long id;
} S_CITY;

int cmpAscPre(const void * n1, const void * n2) {
	if (((S_CITY *)n1)->prefecture > ((S_CITY *)n2)->prefecture) {
		return 1;
	}
	else if (((S_CITY *)n1)->prefecture < ((S_CITY *)n2)->prefecture) {
		return -1;
	}
	else {
		if (((S_CITY *)n1)->year > ((S_CITY *)n2)->year) {
      return 1;
    }
    else if (((S_CITY *)n1)->year < ((S_CITY *)n2)->year) {
      return -1;
    }
    else {
      return 0;
    }
	}
}

int cmpAscNum(const void * n1, const void * n2) {
	if (((S_CITY *)n1)->number > ((S_CITY *)n2)->number) {
		return 1;
	}
	else if (((S_CITY *)n1)->number < ((S_CITY *)n2)->number) {
		return -1;
	}
	else {
		return 0;
	}
}

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  S_CITY cities[m];
  for (long i = 0; i < m; i++) {
    cities[i].number = i;
    scanf("%ld %ld", &cities[i].prefecture, &cities[i].year);
  }
  qsort(cities, m, sizeof(S_CITY), cmpAscPre);
  long latter = 1;
  cities[0].id = 1;
  for (long i = 1; i < m; i++) {
    if (cities[i].prefecture == cities[i-1].prefecture) {
      latter++;
    } else {
      latter = 1;
    }
    cities[i].id = latter;
  }
  qsort(cities, m, sizeof(S_CITY), cmpAscNum);
  int id_12[12];
  long former;
  for (long i = 0; i < m; i++) {
    former = cities[i].prefecture;
    latter = cities[i].id;
    for (int j = 5; j >= 0; j--) {
      id_12[j] = former%10;
      former /= 10;
    }
    for (int j = 11; j >= 6; j--) {
      id_12[j] = latter%10;
      latter /= 10;
    }
    for (int j = 0; j < 12; j++) {
      printf("%d", id_12[j]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 7752
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll a,b; cin >> a >> b;
    for(int i=1;i<=100000;i++){
        int x = i * 0.08;
        int y = i * 0.10;
        if(x==a && y==b){
            cout << i << endl;
            return 0 ;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        
        int min = 1001;
        for(int i=0;i<n;i++){
            int c = sc.nextInt();
            int time = sc.nextInt();
            
            if(time<=t){
                min = Math.min(c, min);
            }
        }
        
        
        System.out.println(min>1000 ? "TLE" : min);
     }
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

struct task{
    ll a,b;
};

bool asc( const task& left, const task& right ) {
    return left.b == right.b ? left.a < right.a : left.b < right.b;
}

int main() {
   

    vector <task> taskList;
    ll n;
    cin >> n;
    for(ll i=0;i<n;i++){
        task tmp{};
        cin >> tmp.a >> tmp.b;
        taskList.push_back(tmp);
    }
    sort(taskList.begin(), taskList.end(), asc);
    ll now = 0;
    int flag = 0;
    for (ll i=0;i<n;i++){
        now += taskList[i].a;
        if(now > taskList[i].b){
            flag = 1;
            break;
        }
    }
    if(flag){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

}

Measured memory_bytes: 6384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    int n,m;
    cin >> n >> m;
    vector<vector<bool>> a(n,vector<bool>(m,false));

    for(int i=0;i<n;i++){
        int k; cin >> k;
        for(int j=0;j<k;j++){
            int p; cin >> p;
            p--;
            a[i][p] = true;
        }
    }

    int ans = 0;
    for(int j=0;j<m;j++){
        int crn = 0;
        for(int i=0;i<n;i++){
            if(a[i][j] == true) crn++;
        }
        if(crn == n) ans++;
    }

    cout << ans <<endl;

    return 0;
}



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

int main(){
  int a,b;
  cin >> a >> b;
  
  int cnt=0;
  
  for (int i=a; i<=b; i++){
    if (i%10 == i/10000 && (i%100)/10 == (i/1000)%10){
      cnt++;
    }
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
import sys


def _i(): return int(sys.stdin.readline().strip())


def main():
    x = _i()
    if x <= 599:
        return 8
    elif x <= 799:
        return 7
    elif x <= 999:
        return 6
    elif x <= 1199:
        return 5
    elif x <= 1399:
        return 4
    elif x <= 1599:
        return 3
    elif x <= 1799:
        return 2
    elif x <= 1999:
        return 1


if __name__ == "__main__":
    print(main())


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string S;
    cin >> S;
    S[5] = ' ';
    S[13] = ' ';
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

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

    string T;
    cin >> T;
    for (auto& c : T) {
        if (c == '?')
            c = 'D';
    }

    cout << T << endl;


    solve();
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <string.h>
#include <map>
#include <iomanip>
#include <time.h>
using namespace std;
typedef long long ll;

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

    ll p[505][505], s = 0, mx = 1e9, k;
    if (mx % (c * d) == 0) k = mx / (c * d) - 1;
    else k = mx / (c * d);

    for (int i = 0; i < a; i++) {
        for (int j = 0; j < b; j++) {
            if (i % c == c - 1 && j % d == d - 1) {
                p[i][j] = - k * (c * d - 1) - 1;
            }
            else p[i][j] = k;
            s += p[i][j];
        }
    }

    if (s > 0) {
        cout << "Yes" << endl;
        for (int i = 0; i < a; i++) {
            for (int j = 0; j < b; j++) {
                if (j != 0) cout << " ";
                cout << p[i][j];
            }
            cout << endl;
        }
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 4736
import collections
import fractions

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)


A, B = list(map(int, input().split()))
print(len(prime_factorize(fractions.gcd(A, B))) + 1)


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

using namespace std;

int main()
{
    int n;
    string s;

    cin >> n;
    cin >> s;

    int x = 0;
    int Max = 0;

    for (int i = 0; i < s.size(); i++){
        if (s[i] == 73){
            x++;
        }else if (s[i] == 68){
            x--;
        }

        if (x > Max){
            Max = x;
        }
    }

    cout << Max << endl;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(){
  int n; cin >> n;
  vector<int> x(n), y(n); rep(i,n) cin >> x[i] >> y[i];

  vector<int> perm;
  rep(i,n) perm.push_back(i);

  double sum = 0.0;
  do{
    double dist = 0.0;
    rep(i,n-1){
      dist += sqrt(pow(x[perm[i]]-x[perm[i+1]], 2) + pow(y[perm[i]]-y[perm[i+1]], 2)); 
    }
    sum += dist;
  }while(next_permutation(all(perm)));

  double stair = 1;
  rep(i,n) stair *= i+1;

  cout << fixed << setprecision(10);
  cout << sum / stair << endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        s: chars
    }
    let n: Vec<i64> = s.iter().map(|c| c.to_digit(10).unwrap() as i64).collect();
    for i in 0..8 {
        let mut a = n[0];
        let mut op = vec![];
        for j in 0..3 {
            if i & 1 << j != 0 {
                a += n[j + 1];
                op.push('+');
            } else {
                a -= n[j + 1];
                op.push('-');
            }
        }
        if a == 7 {
            println!("{}{}{}{}{}{}{}=7", s[0], op[0], s[1], op[1], s[2], op[2], s[3]);
            return;
        }
    }
}


Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<cstdlib>
#include<cmath>
#define range(i,a,b) for(int i = (a); i <= (b); i++)
#define rrange(i,a,b) for(int i = (a); i >= (b); i--)
#define rep(i,b) for(int i = 1; i <= (b); i++)
#define rrep(i,b) for(int i = (b); i >= 1; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long ll;
const int N=5e5+11;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001LL;
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int n,f[N],l[N],r[N],a[N],point[N],tot;
char s[N];
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
void solve(){
	rep(i,n+1){
		if(a[i]==0){
			if(a[i-1]==0||a[i+1]==0) continue;
			int j;
			tot++;
			j=i-1;
			while(a[j]&&j>=1) j--,l[tot]++;
			j=i+1;
			while(a[j]&&j<=n) j++,r[tot]++;
			point[i]=tot;
		}
	}
//	rep(i,tot){
//		printf("%d %d\n",l[i],r[i]);
//	}
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();
	scanf("%s",s+1);
	rep(i,n) a[i]=s[i]-'0';
	solve();
	rep(i,n){
		f[i]=max(f[i],f[i-1]);
		if(point[i]){
			int x=point[i];
			f[i+1]=max(f[i+1],max(f[i-l[x]-1]+l[x],f[i-l[x]]+l[x]-1));
			f[i+r[x]]=max(f[i+r[x]],f[i-2]+r[x]);
			f[i+r[x]-1]=max(f[i+r[x]-1],f[i-2]+r[x]-1);
		}
	}
	printf("%d",f[n]);
	return 0;
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>n;
	ll a[n];
	rep(i,0,n) cin>>a[i],ans+=abs(a[i]);
	cnt=0;
	vll v;
	rep(i,0,n){
		if(a[i]<0) cnt++;
		else if(cnt!=0) v.pb(cnt),cnt=0;
	}	
	if(cnt!=0) v.pb(cnt);
	// pcont(v)
	rep(i,0,v.size()){
		if(v[i]%2!=0){
			if(i+1<v.size() && v[i+1]%2==0) v[i+1]--;
			else if(i+1<v.size() && v[i+1]%2==1) i++;
			else if(i==v.size()-1) break;
		}
	}
	if(i==v.size()-1){
		rep(i,0,n){
			if(a[i]<0) a[i]*=-1;
		}
		sort(a,a+n);
		// parr(a,n)
		ans-=2*a[0];
		ret(ans)
	}
	ret(ans)
	return 0;
}

Measured memory_bytes: 1660
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
        }
        int tmp = 0;
        int ans = sum * 2;
        for (int i = 0; i < n - 1; i++) {
            tmp += a[i];
            ans = Math.min(Math.abs(sum - 2 * tmp), ans);
        }
        System.out.println(ans);
    }
}

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

int main(){
    int N;
    cin >> N;
    vector<pair<ll, ll>> secl, secr;
    for (int i = 0; i < N; i++) {
        ll L, R;
        cin >> L >> R;
        secl.push_back({L, R});
        secr.push_back({R, L});
    }
    
    sort(secl.begin(), secl.end());
    sort(secr.begin(), secr.end());
    for (int i = 0; i < N; i++) {
        swap(secr[i].first, secr[i].second);
    }
    
    int M = N/2;
    ll cand = 0;
    ll now = 0;
    
    for (int i = 0; i < M; i++) {
        if (secl[N-1-i].first <= now) {
            cand += abs(now);
            now = 0;
            break;
        }
        cand += secl[N-1-i].first-now;
        now = secl[N-1-i].first;
        if (now <= secr[i].second) {
            cand += abs(now);
            now = 0;
            break;
        }
        cand += now-secr[i].second;
        now = secr[i].second;
        if (i == M-1 && M%2 == 1 && now < secl[N-2-i].first) {
            cand += secl[N-2-i].first-now;
            now = secl[N-2-i].first;
            cand += abs(now);
            now = 0;
        }
    }
    
    ll ans = cand;
    cand = 0;now = 0;
    
    for (int i = 0; i < M; i++) {
        if (now <= secr[i].second) {
            cand += abs(now);
            now = 0;
            break;
        }
        cand += now-secr[i].second;
        now = secr[i].second;
        
        if (secl[N-1-i].first <= now) {
            cand += abs(now);
            now = 0;
            break;
        }
        cand += secl[N-1-i].first-now;
        now = secl[N-1-i].first;
        
        if (i == M-1 && M%2 == 1 && secr[i+1].second < now ) {
            cand += now-secr[i+1].second;
            now = secr[i+1].second;
            cand += abs(now);
            now = 0;
        }
    }
    ans = max(ans, cand);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;
    for (int i = 0; i < n; i++) {
        if (s[i] != s[k - 1]) s[i] = '*';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int H, N; cin >> H >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    repp(i,0,N) cin >> A[i] >> B[i];

    ll dp[H+1];
    dp[0] = 0;
    repp(i,1,H+1) dp[i] = 1000000007;
    repp(i,1,H+1) {
        repp(j,0,N) {
            if (A[j] >= i) dp[i] = min(dp[i], B[j]);
            else dp[i] = min(dp[i], dp[i-A[j]] + B[j]);
        }
    }
    cout << dp[H] << endl;

}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>


int yukurid(long long int, long long int);

int main()
{
	long long int a, b, tmp;
	while (scanf("%lld %lld", &a, &b) != EOF)
	{
		tmp = a;
		a = a < b ? b : a;
		b = tmp < b ? tmp : b;
		printf("%lld %lld\n", yukurid(a, b),((a*b)/yukurid(a,b)));
	}
	return 0;

}

int yukurid(long long int a, long long int b)
{
	long long int tmp;
	if (a%b == 0)return b;
	else
	{
		tmp = a;
		a = b;
		b = tmp%b;
		return yukurid(a, b);
	}
}

Measured memory_bytes: 1024
/* Coached by Dukkha */
#include <stdio.h>

int main() {
	int l, r, i, j, x, ans;

	scanf("%d%d", &l, &r);
	if (r - l - 1 >= 2019)
		ans = 0;
	else {
		ans = 2019;
		for (i = l; i <= r; i++)
			for (j = i + 1; j <= r; j++) {
				x = (long long) i * j % 2019;
				if (ans > x)
					ans = x;
			}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>

using namespace std;

static int N, M;
typedef pair<long long, int> City;
static vector<vector<City>> P;

void solve() {
  vector<int> id1(M + 1);
  vector<int> id2(M + 1);
  for (int i = 1; i < N + 1; i++) {
    sort(P[i].begin(), P[i].end());
    for (int j = 1; j < P[i].size(); j++) {
      id1[P[i][j].second] = i;
      id2[P[i][j].second] = j;
    }
  }
  for (int i = 1; i < M + 1; i++) {
    printf("%06d%06d\n", id1[i], id2[i]);
  }
}

int main() {
  cin >> N >> M;
  P.resize(N + 1);
  for (int i = 0; i < N + 1; i++) {
    vector<City> v(1);
    P[i] = v;
  }
  for (int i = 0; i < M; i++) {
    int p;
    long long y;
    cin >> p >> y;
    P[p].push_back(City(y, i + 1));
  }
  solve();
  return 0;
}

Measured memory_bytes: 11128
# kaisetsu
n,m=map(int,input().split())
ab=[tuple(map(int,input().split())) for _ in range(m)]
ab.sort(key=lambda x:x[1])
# print(ab)
ans=0

right=-1
for a,b in ab:
  if a<right:
    continue
  ans+=1
  right=b
print(ans)

Measured memory_bytes: 18248
// I am Nothing, You Are Nothing!
// Krishna is Everything ...
// Jai Shree Krishna

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e3 + 5, mod = 1e9 + 7;

int a[N][N] = {0}, dp[N][N];
int n, m;

int solve(int i, int j) {
	if (i<1 or j<1 or i>n or j>m or a[i][j])
		return 0;
	if (i == n and j == m)
		return 1;
	if (dp[i][j] != -1)
		return dp[i][j];

	return dp[i][j] = (solve(i + 1, j) + solve(i, j + 1)) % mod;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> n >> m;

	char ch;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> ch;
			if (ch == '#')
				a[i][j] = 1;
		}
	}

	memset(dp, -1, sizeof dp);

	cout << solve(1, 1) << endl;

	return 0;
}


Measured memory_bytes: 19376
#include <stdio.h>
#include <string.h>
int main(void){
    char a[11],b[11],c[11];
    int alen,blen,ans=0;
    scanf("%s %s %s",a,b,c);
    alen=strlen(a);
    blen=strlen(b);
    if(a[alen-1]!=b[0]){
        ans=-1;
    };
    if(b[blen-1]!=c[0]){
        ans=-1;
    };
    if(ans==0){
        printf("YES");
    }
    else{
        printf("NO");
    };
    return 0;
};


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back

int a[26] = {1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,0,1};

int main(void){
  string str;
  while(cin >> str){
    if(str.sz == 1 && str[0]=='#')break;
    int ans = 0;
    int status = a[str[0]-'a'];
    reps(i,1,str.sz-1){
      if(a[str[i]-'a'] != status){
        ans++;
        status = a[str[i]-'a'];
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3036
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int ta[100010],nt[200010],to[200010],co[200010],g;
int bfs(int v,int s){
  int q[1000000],C[100010], t=0,r,i,max=0;
  for(i=0;i<v;i++)C[i]=1000000000;
  C[q[0]=s]=0;//printf("a\n");
  for(r=1;r-t;t++){
    for(i=ta[q[t]];i+1;i=nt[i]){//printf("%d %d %d\n",q[t],to[i],co[i]);
      if(C[to[i]]>C[q[t]]+co[i])C[q[r++]=to[i]]=C[q[t]]+co[i];
      if(max<C[to[i]])max=C[g=to[i]];//printf("m%d\n",max);
    }
  }
  return max;
}//*/
int tyokkei(int v,int e,int *a,int *b){
  int i,max=0;
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i]=ta[a[i]];
    ta[a[i]]=i;
    nt[i+e]=ta[to[i]];
    to[i+e]=a[i];
    co[i+e]=co[i];
    ta[to[i]]=i+e;    
  }
  bfs(v,0);
  return bfs(v,g);
}
int main(){
  int n,a[100010],b[100010],i;
  scanf("%d",&n);
  for(i=0;i<n-1;i++)scanf("%d %d %d",&a[i],&to[i],&co[i]);
  printf("%d\n",tyokkei(n,n-1,a,b));
  return 0;
}

Measured memory_bytes: 6516
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

int  m[110];

int main() {
	
	int n, x;
	cin >> n>>x;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
	}
	int mi = INF;
	for (int i = 0; i < n; i++) {
		x -= m[i];
		mi = min(mi, m[i]);
	}

	cout << n + (x / mi) << endl;




	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;

ll a,b;

int main(){
FLASH;
cin>>a>>b;
cout<<a*(a-1)/2+b*(b-1)/2<<endl;







return 0;
} 


Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.List;
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 B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		String S = sc.next();
		List<Integer> stone = new ArrayList<>();
		List<Integer> skip = new ArrayList<>();
		boolean sto = false;
		int count = 0;
		for(int i = 0; i < S.length(); i++) {
			if(S.charAt(i) == '.') {
				count++;
				if(count >= 3) {
					skip.add(i);
				}
				sto = false;
			} else {
				count = 0;
				if(sto) {
					stone.add(i);
				} else {
					sto = true;
				}
			}
		}
		boolean overstone = true;
		boolean AoverB = false;
		for(Integer i : stone) {
			if((A < i && i < C) || (B < i && i < D)) {
				overstone = false;
				break;
			}
		}
		for(Integer i : skip) {
			if(B <= i && i <= D) {
				AoverB = true;
				break;
			}
		}
		if(overstone && (C < D || AoverB)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 28504
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int H, W;
    cin >> H >> W;
    vv<int> A = vvec(H, W, 0), B = vvec(H, W, 0);
    rep(i, H) rep(j, W) cin >> A[i][j];
    rep(i, H) rep(j, W) cin >> B[i][j];

    vv<int> C = vvec(H, W, 0);
    rep(i, H) rep(j, W) {
        C[i][j] = abs(A[i][j] - B[i][j]);
    }

    constexpr int offset = 2 * 80 * 80;
    vv<bitset<2 * offset + 1>> dp = vvec(H, W, bitset<2 * offset + 1>());
    dp[0][0][offset - C[0][0]] = 1;
    dp[0][0][offset + C[0][0]] = 1;
    rep(i, 1, H) {
        dp[i][0] |= dp[i - 1][0] << C[i][0];
        dp[i][0] |= dp[i - 1][0] >> C[i][0];
    }
    rep(j, 1, W) {
        dp[0][j] |= dp[0][j - 1] << C[0][j];
        dp[0][j] |= dp[0][j - 1] >> C[0][j];
    }
    rep(i, 1, H) rep(j, 1, W) {
        dp[i][j] |= dp[i - 1][j] << C[i][j];
        dp[i][j] |= dp[i - 1][j] >> C[i][j];
        dp[i][j] |= dp[i][j - 1] << C[i][j];
        dp[i][j] |= dp[i][j - 1] >> C[i][j];
    }

    int ans = INF;
    rep(i, 2 * offset + 1) {
        if (dp[H - 1][W - 1][i]) ans = min(ans, abs(i - offset));
    }
    write(ans);
}

Measured memory_bytes: 20736
#!/usr/bin/env python
# -*- coding: utf-8 -*-

H, W = map(int, input().split())
# 2次元配列を作る
grid = []
for _n in range(H):
    grid.append(list(input()))


def is_bomb(h, w):
    """指定されたマスが爆弾か調べる"""
    try:
        # マイナス位置は全部0扱い
        if h < 0 or w < 0:
            return 0
        if grid[h][w] == "#":
            return 1
        else:
            return 0
    except IndexError:
        return 0


def search_bomb(h, w):
    """指定されたマスの周囲8マスが爆弾か調べて爆弾の数を返す"""
    if grid[h][w] == "#":
        return "#"
    bomb_count = sum(
        [
            is_bomb(h - 1, w - 1),
            is_bomb(h - 1, w),
            is_bomb(h - 1, w + 1),
            is_bomb(h, w - 1),
            is_bomb(h, w + 1),
            is_bomb(h + 1, w - 1),
            is_bomb(h + 1, w),
            is_bomb(h + 1, w + 1),
        ]
    )
    from logging import getLogger, DEBUG, basicConfig

    logger = getLogger(__name__)
    logger.setLevel(DEBUG)
    basicConfig()
    logger.info(bomb_count)
    return str(bomb_count)


# 置換後の2次元配列作成
for h in range(H):
    for w in range(W):
        print(search_bomb(h, w), end="")
    # 行が終わったら改行
    print()


Measured memory_bytes: 4684
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,i,res,sum=0;
cin>>n>>m;
int a[m];
for(i=0;i<m;i++){
    cin>>a[i];
    sum+=a[i];
}
if(sum<=n){
    cout<<n-sum;
}
else{
    cout<<-1;
}




}


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

using namespace std;

const long long int INF = 1LL<<60;

int main() {
  int N;
  cin >> N;
  vector<double> p(N+1);
  for(int i=1; i<=N; i++) {
    cin >> p.at(i);
  }
  p[0] = 0;

  // N = 2K + 1
  int K = (N - 1) / 2;
  vector<vector<double>> dp(2*K+2, vector<double>(2*K+2, 0.0));
  dp[1][0] = 1 - p[1];
  dp[1][1] = p[1];

  for(int i=3; i<=2*K+1; i+=2){
    double p2 = p[i] * p[i-1];
    double p1 = p[i] * (1 - p[i-1]) + (1-p[i]) * p[i-1];
    double p0 = (1 - p[i]) * (1 - p[i-1]);
    for(int j=0; j<=i; ++j) {
      dp[i][j] = dp[i-2][j-2] * p2 + dp[i-2][j-1] * p1 + dp[i-2][j] * p0;
    }
  }
  double res = 0.0;
  for(int i=K+1; i<=N; ++i) {
    res += dp[N][i];
  }

  printf("%.10f\n", res);

  return 0;
}

Measured memory_bytes: 70656
import sys, re, os
from collections import deque, defaultdict, Counter
from math import gcd, ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
# from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
K = INT()
 
ans = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            ans += gcd(gcd(i, j), k)
print(ans)
 

Measured memory_bytes: 10072
from bisect import bisect_left as bl

N = int(input())
a = list(map(int, input().split()))

for i in range(1, N):
  a[i] += a[i-1]

half = a[-1] / 2
index = bl(a, half)

print(int(min(half - a[index - 1], a[index] - half) * 2))

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

int main()
{
	vector<int> as = {1,
					  1,
					  1,
					  2,
					  1,
					  2,
					  1,
					  5,
					  2,
					  2,
					  1,
					  5,
					  1,
					  2,
					  1,
					  14,
					  1,
					  5,
					  1,
					  5,
					  2,
					  2,
					  1,
					  15,
					  2,
					  2,
					  5,
					  4,
					  1,
					  4,
					  1,
					  51};

	int k;
	cin >> k;

	cout << as[--k] << endl;

	return 0;
}

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

const int N = 1e5 + 5;
const int M = N * 6;

int fa[M], n, m, can[2][1000005], q, u[M], v[M], w[M], mod;

int getf(int x) {
	return (fa[x] == x) ? x : fa[x] = getf(fa[x]);
}

void init() {
	for(int i = 1; i < M; ++ i) fa[i] = i;
}

int gcd(int x, int y) {
	return (!y) ? x : gcd(y, x % y);
}

int id(int x, int y, int z) {
	return x * 6 + y * 3 + z;
}

void merge(int x, int y) {
	fa[getf(x)] = getf(y);
}

int main() {
	init();
	scanf("%d%d%d", &n, &m, &q);
	cin >> mod;
	for(int i = 1; i <= m; ++ i) {
		scanf("%d%d%d", &u[i], &v[i], &w[i]);
	}
	int g = 0;
	for(int i = 1; i < m; ++ i) {
		g = gcd(g, abs(w[i] - w[i + 1]));
	}
	if(!g) g = mod;
	int M = gcd(3 * g, mod);
	int z = w[1] % g;
	for(int i = 1; i <= m; ++ i) 
	w[i] = (w[i] + 3 * g - z) % M;
	mod = gcd(3 * g, mod);
	for(int i = 1; i <= m; ++ i) {
		w[i] /= g;
		for(int a = 0; a < 2; ++ a) {
			for(int b = 0; b < 3; ++ b) {
				merge(id(u[i], a, b), id(v[i], (1 - a), (b * 2 + w[i]) % 3));
				merge(id(v[i], a, b), id(u[i], 1 - a, (b * 2 + w[i]) % 3));
			}
		}
	}
	int now = z;
	for(int i = 0; i < M * 2; ++ i, now = (now + now) % mod) can[i & 1][now] = 1;
	for(; q --;) {
		int s, t, r;
		scanf("%d%d%d" ,&s, &t, &r);
		r = (r + z) % mod;
		bool ok = 0;
		for(int a = 0; a < 2; ++ a) {
			for(int b = 0; b < 3; ++ b) {
				if(getf(id(s, a, b)) == getf(id(t, 0, 0))) {
					//cerr << s <<" " << 0 <<" " << 0 <<" " << t <<" " << a << " " << b << endl;
					ok |= can[a][(r + (3 - b) * g) % mod];
				}
			}
		}
		if(ok) puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 15744
n = int(input())
alist = [int(i) for i in input().split()]
blist = [int(i) for i in input().split()]
clist = [int(i) for i in input().split()]

bcount =0
ccount=0

for x in alist:    
    bcount+=blist[x-1]


for x in range (len(alist)-1):
    if alist[x+1]-alist[x]==1:
        temp = alist[x]-1
        ccount+=clist[temp]
        
print (bcount+ccount)

        
    


Measured memory_bytes: 3064
import java.awt.*;
import java.io.*;
import java.net.StandardSocketOptions;
import java.util.*;

public class Main {
    Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        new Main();
    }
    public Main(){
        new TestE().doIt();
    }
    class TestE{
        void doIt() {
            int H = sc.nextInt();
            int W = sc.nextInt();
            int M = sc.nextInt();
            int arrayH[] = new int[H+1];
            int arrayW[] = new int[W+1];
            TreeSet<String> ts = new TreeSet<String>();
            for(int i = 0;i < M;i++) {
                int HM = Integer.parseInt(sc.next());
                int WM = Integer.parseInt(sc.next());
                String str = HM+","+WM;
                arrayH[HM]++;
                arrayW[WM]++;
                ts.add(str);
            }
            int maxH = 0;
            int maxW = 0;
            for(int i = 0;i <= H;i++) {
                maxH = Math.max(arrayH[i],maxH);
            }
            for(int i = 0;i <= W;i++) {
                maxW = Math.max(arrayW[i],maxW);
            }
            ArrayList<Integer> aH = new ArrayList<Integer>();
            ArrayList<Integer> aW = new ArrayList<Integer>();
            for(int i = 0;i <= H;i++) {
                if(arrayH[i] == maxH)aH.add(i);
            }
            for(int i = 0;i <= W;i++) {
                if(arrayW[i] == maxW)aW.add(i);
            }
            int cc = 1;
            for(int i = 0;i < aH.size();i++) {
                for(int j = 0;j < aW.size();j++) {
                    int cnt = 0;
                    if(cc == 0)break;
                    String str = aH.get(i)+","+aW.get(j);
                    if(ts.contains(str)) {
                        cnt++;
                    }
                    cc = cnt;
                }
            }
            int ans = maxH+maxW-cc;
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 103236
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {      
     ll a;
     cin>>a;
     cout<<a+(a*a)+(a*a*a)<<"\n";
   }
}

Measured memory_bytes: 3644