akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<list>

#define EPS (1e-10)
#define pb push_back
#define sz size()

using namespace std;

typedef complex<double> P;

const int dim = 2;
double dot(P x,P y){return real(conj(x)*y);}

struct min_ball{
  P center,v[dim+1],c[dim+1];
  double radius2,z[dim+1],r[dim+1];
  list<P> ps;
  list<P>::iterator sup;
  int m;

  void solve(vector<P> v){
    m = 0;
    center = P(0,0);
    radius2 = -1;
    ps.clear();
    for(int i=0;i<v.sz;i++)ps.pb(v[i]);
    make_ball(ps.end());
  }

  void push(const P& p){
    if(!m){
      c[0] = p; r[0] = 0;
    }else{
      double e = dot(p-c[m-1],p-c[m-1]) - r[m-1];
      P d = v[m] = p-c[0];
      for (int i=1;i<m;i++)v[m] -= v[i]*dot(v[i],d)/z[i];
      z[m] = dot(v[m],v[m]);
      c[m] = c[m-1] + e*v[m]*(1.0/z[m]/2.0);
      r[m] = r[m-1] + e*e/z[m]/4.0;
    }
    center  = c[m];
    radius2 = r[m]; m++;
  }
  void make_ball(list<P>::iterator i){
    sup = ps.begin();
    if(m == dim + 1)return;
    for(list<P>::iterator k = ps.begin();k!=i;){
      list<P>::iterator j = k++;
      if(dot(*j-center,*j-center) > radius2){
        push(*j);
	make_ball(j); m--;
	if(sup == j)++sup;
	ps.splice (ps.begin(),ps,j);
      }
    }
  }
};

int n,m,p;
int r[110];
double d[110];
bool use1[110],use2[110];
vector<P> ver;

int main(){
  cin >> n >> m;
  for(int i=0;i<n;i++){
    cin >> r[i];
    r[i] = r[i]*r[i];
  }

  for(int i=0;i<m;i++){
    cin >> p;
    ver.resize(p);
    for(int j=0;j<p;j++)cin >> ver[j].real() >> ver[j].imag();
    min_ball ball;
    ball.solve(ver);
    d[i] = ball.radius2;
  }

  for(int i=0;i<n;i++)use1[i] = false;

  for(int i=0;i<m;i++){
    int j;
    for(j=0;j<n;j++){
      if(!use1[j] && d[i] < r[j]+EPS){
	use1[j] = true;
	bool f = true;
	for(int k=0;k<n;k++)use2[k] = use1[k];
	for(int k=i+1;k<m;k++){
	  int id = -1;
	  for(int l=0;l<n;l++){
	    if(!use2[l] && d[k] < r[l]+EPS)
	      if( id<0 || r[l] < r[id] )id = l;
	  }
	  if(id<0){
	    f = false;
	    break;
	  }else use2[id] = true;
	}
	if(f){
	  cout << j+1 << endl;
	  break;
	}else use1[j] = false;
      }
    }
    if(j==n){
      cout << "NG\n";
      return 0;
    }
  }
}

Measured memory_bytes: 1248
# ABC135B - 0 or 1 Swap
def main():
    n = int(input())
    P = tuple(map(int, input().rstrip().split()))
    flg = sum(i != j for i, j in enumerate(P, 1)) <= 2
    print("YES" if flg else "NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll const maxn=1e3+5;
ll const inf=1e18;
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
bool prime(ll x){
    if(x<2)return false;
    for(int i=2;i<=sqrt(x);i++){
        if(x%i==0)return false;
    }
    return true;
}
int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<m;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            char ch;
            cin>>ch;
            if(ch=='#')dp[i][j]=-1;
        }
    }
    for(int i=0;i<m;i++){
        if(dp[0][i]==-1)break;
        else dp[0][i]=1;
    }
    for(int i=0;i<n;i++){
        if(dp[i][0]==-1)break;
        else dp[i][0]=1;
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(dp[i][j]==-1)continue;
            if(dp[i-1][j]>0)dp[i][j]=add(dp[i][j],dp[i-1][j]);
            if(dp[i][j-1]>0)dp[i][j]=add(dp[i][j],dp[i][j-1]);
        }
    }
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<m;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }
    if(dp[n-1][m-1]>=0)cout<<dp[n-1][m-1];
    else cout<<dp[n-1][m-1];

    return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
	ll a, b, c, d;
	cin>>a>>b>>c>>d;
	ll ans1=max(a*c, a*d);
	ll ans2=max(b*c, b*d);
	cout<<max(ans1, ans2)<<endl;
}

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

int main() {
  int a,b,c,x;
  cin >>a >> b >> c >>x;
  int ans;
  for (int i = 0;i<=a;i++){
    for(int j = 0;j<=b;j++){
      for(int k =0;k<=c;k++ ){
        int total = 500*i+100*j+50*k;
        if (total == x)ans +=1;
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;


int main() {
	int n; cin >> n;
	vector<double> a(n);

	double ans = 0.0;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ans += 1.0 / a[i];
	}

	cout << setprecision(10) << 1.0/ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
#include <queue>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    ll n;
    scanf("%lld",&n);
    if(n%2==1)
    {
        printf("0\n");
        return 0;
    }
    ll i=10,res=0;
    while(n/i>0)
    {
//        n=n/i;
        res+=n/i;
        i*=5;
    }
    printf("%lld\n",res);
    return 0;
}

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

namespace otameshi
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m;
            var word = Console.ReadLine().Split(' ');
            n = int.Parse(word[0]);
            m = int.Parse(word[1]);
            if (n == m)
            {
                Console.WriteLine("Yes");
            }
            else
                Console.WriteLine("No");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
var mod = 998244353;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[],pow2=[];
function fset(n){
  fac.length=n+1,fac[0]=fac[1]=1;
  for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  //invs.length=n+1,invs[0]=invs[1]=1;
  //for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
  //pow2.length=n+1,pow2[0]=1;
  //for(i=1;i<=n;i++)pow2[i]=pow2[i-1]*2%mod;
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],finv[r],finv[n-r]);}
function npr(n,r){return mul(fac[n],finv[r]);}
function mput(n){return (n%mod+mod)%mod;}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var [n,m,k] = nexts(3);
  var kx = m;
  var ans = 0;
  fset(n);
  for(var i = n-1; i > k; i--){
    kx = mul(kx,m-1);
  }
  for(var i = k; i >= 0; i--){
    var ki = mul(kx,ncr(n-1,i));
    ans += ki;
    kx = mul(kx,m-1);
  }
  return mput(ans);
}

Measured memory_bytes: 44852
import java.util.*;
import java.math.*;

class Main{
    
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        
        int n = in.nextInt();
        String s = in.next();
        
        int doc = 0;
        for (int i = 0; i < s.length(); ++i){
            if (s.charAt(i) == '.') ++doc;
        }
        int ans = doc;
        
        for (int i = 0; i < s.length(); ++i){
            if (s.charAt(i) == '#') ++doc;
            if (s.charAt(i) == '.') --doc;
            ans = Math.min(ans,doc);
        }
        
        System.out.print(ans);
    }
}


Measured memory_bytes: 26604
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (x-r >= 0 && y-r >= 0 && x+r <= W && y+r <= H) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    string S;
    cin >> S;
    if(S[0] == 'R' && S[1] == 'R' && S[2] == 'R') PR(3);
    else if((S[0] == 'R' && S[1] == 'R') || (S[1] == 'R' && S[2] == 'R')) PR(2);
    else if(S[0] == 'R' || S[1] == 'R' || S[2] == 'R') PR(1);
    else PR(0);   


    return 0;
}

/*



*/

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;

const int N = 55;
const int NM = 5e3 + 10;

int n, m, S;
int c[N], d[N];
int a[N][N], b[N][N];
long long f[N][NM], res[N];
vector<int> adj[N];

bool minimize(long long &x, const long long &y) {
    if (x > y) x = y; else return false;
    return true;
}

void dijkstra() {
    memset(f, 60, sizeof(f));
    memset(res, 60, sizeof(res));
    f[1][S] = 0;
    priority_queue<pair<long long, pair<int, int>>> P;
    P.push(mp(0, mp(1, S)));
    while (P.size()) {
        long long dist = -P.top().fi;
        int u = P.top().se.fi, curs = P.top().se.se;
        P.pop();
        if (f[u][curs] != dist)
            continue;
        minimize(res[u], f[u][curs]);
        for (int v: adj[u])
            if (curs >= a[u][v]) {
                if (minimize(f[v][curs - a[u][v]], dist + 1ll * b[u][v]))
                    P.push(mp(-f[v][curs - a[u][v]], mp(v, curs - a[u][v])));
            }
        for (int i = 1; i <= 5000; i++) {
            int news, flag = 0;
            if (1ll * i * c[u] + 1ll * curs > (long long)(5e3))
                news = 5000, flag = 1;
            else
                news = i * c[u] + curs;
            if (minimize(f[u][news], dist + 1ll * i * d[u]))
                P.push(mp(-f[u][news], mp(u, news)));
            else break;
            if (flag) break;
        }
    }
}

int main() {
    cin >> n >> m >> S;
    S = min(S, 5000);
    for (int i = 0; i < m; i++) {
        int x, y, z1, z2;
        cin >> x >> y >> z1 >> z2;
        adj[x].push_back(y);
        adj[y].push_back(x);
        a[x][y] = a[y][x] = z1; b[x][y] = b[y][x] = z2;
    }
    for (int i = 1; i <= n; i++)
        cin >> c[i] >> d[i];
    dijkstra();
    for (int i = 2; i <= n; i++)
        cout << res[i] << endl;
}


Measured memory_bytes: 71092
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}


int main() {
    long long a = 0, b = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'A'){
            a++;
        }
        if (s[i] == 'B'){
            b++;
        }
    }
    if (a > 0 && b > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

mint dp[110][100010];

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    dp[0][0] = 1;
    vector<mint> sum(K + 2);
    rep(i, K + 1) sum[i + 1] = sum[i] + dp[0][i];
    rep(i, N) {
        rep(j, K + 1) dp[i + 1][j] = sum[j + 1] - sum[max(0, j - a[i])];
        rep(j, K + 1) sum[j + 1] = sum[j] + dp[i + 1][j];
    }
    cout << dp[N][K].x << endl;
}

Measured memory_bytes: 86912
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

int main(){

  while(true){
    int n;
    cin >> n;
    if(n == 0)break;
    vector<int> vec;
    rep(i,n){
      int in; cin >> in;
      vec.pb(in);
    }
    int key,cnt = 0;
    cin >> key;
    int l,r,m;
    l = 0,r = n-1;
    while(l <= r){
      m = (l+r)/2;
      cnt++;
      if(vec[m] == key)break;
      if(vec[m] > key)r = m-1;
      else l = m+1;
    }
    cout << cnt << endl;


  }

return 0;
}

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

int main(){
  long long W,H;
  cin >> W >> H;
  long long x,y;
  cin >> x >> y;
  long long square = (W*H)/2;
  double square_sub = 0;
  if((W*H)%2 != 0){
    square_sub = 0.5000000000;
}
  int num = 0;
    if(W != 0 && H != 0 && W%2 == 0 && H%2 == 0 && x == W/2 && y==H/2){
      num = 1;
    }else{
      num = 0;
    }

    cout << std::fixed;
    cout << std::setprecision(9) << square+square_sub << " "<< num << endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define INF 1000000000000000000LL
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef pair<i64, i64> pi ;
typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 1005

i64 a[maxn] ;

int main()
{
    i64 i , j , k , l , m , n ;

    scanf("%lld",&n) ;

    for(i=1 ; i<=n ; i++) scanf("%lld",&a[i]) ;

    i64 sum = 0LL ;
    for(i=1 ; i<=n ; i++) sum += a[i] ;


    i64 idx = 0 , dif = abs( n*a[1] - sum ) ;

    for(i=2 ; i<=n ; i++)
    {
        if( dif > abs( n*a[i] - sum ) )
        {
            dif = abs( n*a[i] - sum ) ;
            idx = i-1 ;
        }
    }

    printf("%lld\n",idx) ;

    return 0 ;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,n) for(ll i=0;i<n;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define reff(i,a,b) for(ll i=a;i>=b;i--)
#define ll long long int
#define pll pair<ll,ll>
#define fill(a,x) memset(a,x,sizeof(a))
#define mb make_pair
#define pb push_back
#define F first
#define S second
#define M 1000000007
#define sc(x) scanf("%d",&x)
#define scc(x1,x2) scanf("%d%d",&x1,&x2)
#define sccc(x1,x2,x3) scanf("%d%d%d",&x1,&x2,&x3)
#define pr(x) printf("%lld ",x)
#define dbg(a)         std::cerr<<#a<<"="<<(a)<<"\n"
#define dbg1(a,b)       std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define dbg2(a,b,c)     std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define dbg3(a,b,c,d)   std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define co cout<<"fuck"<<endl;
#define all(v) v.begin(),v.end()
const int INF = 2034567891;
const ll INF64 = 4234567890123456789ll;
long long nc3(long long v){return (v * (v - 1ll) * (v - 2ll)) / 6ll;}
long long nc2(long long v){return (v * (v - 1ll)) / 2ll;}
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
const int N = 10+2e6;
bool isprime(ll n) {
    if (n < 2) return 0;
    if (n == 2) return 1;
    if (n % 2 == 0) return 0;
    for (ll i = 3; i*i <= n; i++) if (n%i == 0) return 0;
    return 1;
}
double dist(pll p1, pll p2)
 {
    return (p1. F - p2.F)*(p1.F - p2.F) +
          (p1.S - p2.S)*(p1.S - p2.S);
 }
int main()
{
   ll n;
   cin>>n;
   ll a[2][n];
   rep(i,2)
   {
     rep(j,n)
     cin>>a[i][j];
   }
   ll dp[2][n];
   fill(dp,0);
   dp[0][0]=a[0][0];
   repp(i,1,n-1)
   dp[0][i]=dp[0][i-1]+a[0][i];
   dp[1][0]=dp[0][0]+a[1][0];
   repp(i,1,n-1)
   dp[1][i]=max(dp[1][i-1],dp[0][i])+a[1][i];
   cout<<dp[1][n-1];
}

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

static const int MAX = 100000;

struct Node{
        int parent, left, right;
};

Node node[MAX];

int getDepth(int i){
        int j = i;
        int d = 0;
        while(node[j].parent!=-1){
                j = node[j].parent;
                d++;
        }
        return d;
}

int main(){
        int n,a,b,tmp;
        cin>>n;
        for(int i=0;i<n;i++){
                node[i].parent = -1;
                node[i].left = -1;
                node[i].right = -1;
        }
        for(int i=0;i<n;i++){
                cin>>a;
                cin>>b;
                for(int j=0;j<b;j++){
                        if(j==0) {
                                cin>>node[a].left;
                                tmp = node[a].left;
                        }else {
                                cin>>node[tmp].right;
                                tmp = node[tmp].right;
                        }
                        node[tmp].parent = a;
                }
        }

        for(int i=0;i<n;i++){
                cout<<"node "<<i<<": parent = "<<node[i].parent<<", depth = "<<getDepth(i);
                if(node[i].parent == -1) cout<<", root";
                else if(node[i].left == -1) cout<<", leaf";
                else cout<<", internal node";
                cout<<", [";
                tmp = node[i].left;
                bool flag = false;
                while(tmp!=-1){
                        if(flag) cout<<", ";
                        else flag = true;
                        cout<<tmp;
                        tmp = node[tmp].right;
                }
                cout<<"]"<<endl;
        }

        return 0;
}


Measured memory_bytes: 4264
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int tPrevious = 0;
        int xPrevious = 0;
        int yPrevious = 0;
        boolean can = true;
        for (int i=0;i<n;i++) {
            int t = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            int dt = t - tPrevious;
            int dist = Math.abs(x - xPrevious) + Math.abs(y - yPrevious);
            if (dt < dist) {
                can = false;
                break;
            }
            if (((dist & 1) ^ (dt & 1) ) == 1) {
                can = false;
                break;
            }
            tPrevious = t;
            xPrevious = x;
            yPrevious = y;
        }
        if (can)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

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

struct Eratosthenes {
	// 1-indexedで検索可能
  vector< bool > prime;
  Eratosthenes(int _size) {
    init(_size);
  }	
	
  void init(int n) {
    prime.resize(n + 1);
    for(int i=0; i<prime.size(); ++i) prime[i] = true;
    prime[0] = prime[1] = false;
    for(int i=2; i*i<=n; i++) {
      if (prime[i]) {
        for (int j=0; i*(j + 2)<n; ++j) {
					prime[i*(j+2)] = false;
				}
      }
    }
  }

	// 整数nを素因数分解して, その要素がいくつあるかを返す
	vector< pair< int, int > > prime_factorize(int n) {
		vector< pair< int, int > > res;
		for (int p=2; p*p<=n; ++p) {
			if (n%p != 0) continue;
			int num = 0;
			while (n%p == 0) ++num, n /= p;
			res.push_back(make_pair(p, num));
		}
		if (n != 1) res.push_back(make_pair(n, 1));
		return res;
	}
};

int main() {
	Eratosthenes e(1010101);
  int n;
	while(scanf("%d",&n) != EOF){
		int ans=0;
		for(int i=1;i<=n;++i){
			if(e.prime[i]) {
				++ans;
			}
		}
		cout<<ans<<endl;
	}
  return 0;
}


Measured memory_bytes: 3248
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int a, b;
string s;

int main()
{
	cin >> s;
	int ans = 0;
	for (int i = 0;i < 3;i++) {
		if (s[i] == '1') ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
edgeList = []
for i in range(n):
    a = list(map(int, input().split()))
    for j in range(a[1]):
        edgeList.append([a[2*j+3], i, a[2*j+2]])
 
 
rootList = [-1 for i in range(n)]
parent = [0 for i in range(n)]
lenList = [float("inf") for i in range(n)]
lenList[0] = 0
def getRoot(x):
    r = rootList[x]
    if r < 0:
        rootList[x] = x
    elif r != x:
        rootList[x] = getRoot(r)
    return rootList[x]
 
flag = True
while flag:
    flag = False
    edgeList.sort(key=lambda x: (x[0] + lenList[x[1]]))
    for e in edgeList:    # weight:e[0], e[1]->e[2]
        if e[2] == 0:
            continue
        x = getRoot(e[1])
        y = getRoot(e[2])
        if x == 0 != y:
            parent[e[2]] = e[1]
            lenList[e[2]] = lenList[e[1]] + e[0]
            rootList[y] = 0
            flag = True
            break
 
for i, j in zip(range(n), lenList):
    print(i, j)

Measured memory_bytes: 6428
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std; 
int main(int argc,char const* argv[])
{
  long long int n;
  long long int answer=0;
  int i=1;
  cin >> n;
  while (1)
    {
      if(i*i > n) break;
      else
	{	
	  answer=i*i;
	}
      i++;
    }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, raw_input().split())
v = [map(int, raw_input().split()) for i in range(M)]
w = [0 for i in range(N)]
for a, b in v:
    w[a-1] += 1
    w[b-1] += 1
for i in range(N):
    print w[i]

Measured memory_bytes: 2568
package main

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

var scanner *bufio.Scanner

func printIt() {
	cnt := nextInt()
	first := nextInt()
	min := first
	max := first
	sum := first
	for i := 1; i < cnt; i++ {
		num := nextInt()
		if num < min {
			min = num
		}
		if num > max {
			max = num
		}
		sum += num
	}
	fmt.Println(min, max, sum)
}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func nextFloat() float64 {
	scanner.Scan()
	num, err := strconv.ParseFloat(scanner.Text(), 10)
	if err != nil {
		panic(1)
	}
	return num
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009

map<PLL,int> mp;
VL visit;
vector<VL> adlist;
void dfs(ll index,ll notc)
{
	visit[index]=1;
	int color=1;
	fr(i,0,SZ(adlist[index]))
	{
		if(visit[adlist[index][i]]==0){
			if(color==notc)
				color+=1;
			mp[MP(index,adlist[index][i])]=color;
			mp[MP(adlist[index][i],index)]=color;
			dfs(adlist[index][i],color);
			color++;
		}
	}
	return;
}
void solve()
{
	ll n;
	rl(n);
	visit.assign(n+1,0);
	vector<PLL> arr;
	adlist.assign(n+1,VL());
	ll c=0;
	fr(i,0,n-1)
	{
		ll x,y;
		rl2(x,y);
		arr.PB(MP(x,y));
		adlist[x].PB(y);
		adlist[y].PB(x);
		c=max(c,max((ll)SZ(adlist[x]),(ll)SZ(adlist[y])));
	}
	visit[1]=1;
	int color=1;
	fr(i,0,SZ(adlist[1]))
	{
		mp[MP(1,adlist[1][i])]=color;
		mp[MP(adlist[1][i],1)]=color;
		dfs(adlist[1][i],color);
		color++;
	}

	cout<<c<<endl;
	fr(i,0,n-1)
	{
		cout<<mp[arr[i]]<<endl;
	}
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 21360
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var H = long.Parse(Console.ReadLine());
        long count = 0;
        var loop = 0;
        while(H != 0)
        {
            count += (long)Math.Pow(2, loop++);
            H /= 2;

        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 27820
t = int(input())
for _ in range(t):
    n, a, b, c, d = map(int, input().split())
    mem = {}
    def DFS(k):
        tmp = 10**20
        if k==0:
            return 0
        elif k==1:
            return d
        elif k in mem:
            return mem[k]
        if k%2==0:
            tmp = min(DFS(k//2)+min(a, k//2*d), tmp)
        else:
            tmp = min(DFS(k//2)+min(a+d, (k//2+1)*d), tmp)
            tmp = min(DFS(k//2+1)+min(a+d, k//2*d), tmp)
        if k%3==0:
            tmp = min(DFS(k//3)+min(b, k//3*2*d), tmp)
        elif k%3==1:
            tmp = min(DFS(k//3)+min(b+d, (k//3*2+1)*d), tmp)
        else:
            tmp = min(DFS(k//3+1)+min(b+d, (k//3*2+1)*d), tmp)
        if k%5==0:
            tmp = min(DFS(k//5)+min(c, k//5*4*d), tmp)
        elif k%5==1:
            tmp = min(DFS(k//5)+min(c+d, (k//5*4+1)*d), tmp)
        elif k%5==2:
            tmp = min(DFS(k//5)+min(c+2*d, (k//5*4+2)*d), tmp)
        elif k%5==3:
            tmp = min(DFS(k//5+1)+min(c+2*d, (k//5*4+2)*d), tmp)
        else:
            tmp = min(DFS(k//5+1)+min(c+d, (k//5*4+3)*d), tmp)
        mem[k] = tmp
        return tmp
    print(DFS(n))

Measured memory_bytes: 87808
N,A,B = map(int,input().split())
mod = 10**9+7
X = 210000
inv_t = [0]+[1]
for i in range(2,X):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

def fast_mod_pow(x, n, mod):
    r = 1
    while n>0:
        if n&1:
            r = (r * x) % mod
        x = (x * x) % mod
        n >>= 1
    return r

def comb(n,k):
    value = 1
    for i in range(n-k+1,n+1):
        value *= i
        value %= mod
    for i in range(1,k+1):
        value *= inv_t[i]
        value %= mod
    return value

ans = fast_mod_pow(2,N,mod)-1
ans -= comb(N,A)
ans -= comb(N,B)
print(ans%mod)

Measured memory_bytes: 53104
import java.util.*;

class Main{
    //149d
    static final int DIV = 100000007;
    static final int MAX = 2000000000;
    static long[] num = new long[20];
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int r = sc.nextInt();
        int s = sc.nextInt();
        int p = sc.nextInt();
        char[] t= sc.next().toCharArray();
        sc.close();
        long ans = 0;
        for(int i = 0;i < n;i++){
            switch(t[i]){
                case 'r':
                    ans += p;
                    break;
                case 's':
                    ans += r;
                    break;
                case 'p':
                    ans += s;
                    break;
                default:
                    break;
            }
            int tmp = i + k;
            if(tmp < n&&t[i]==t[tmp]){
                t[tmp] = 'k';
            }
        }
        System.out.println(ans);
    }
    
}

Measured memory_bytes: 26288
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1777777777;
// constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for(int i = 0; i < N; ++i)  cin >> a[i];

    vector<int> dp(K + 1);
    dp[0] = 0;
    for(int i = 1; i <= K; ++i){
        int c = 0;
        for(int j = 0; j < N; ++j){
            if(i - a[j] >= 0 && !dp[i - a[j]])  ++c;
        }
        dp[i] = c > 0;
    }

    if(dp[K])   cout << "First\n";
    else    cout << "Second\n";
}

Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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 (b < a) { a = b; return 1; } return 0; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vector<vpll> path;
int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	for (i = 0; i < N; i++) {
		for (j = i+1; j < N; j++) {
			for (k = j+1; k < N; k++) {
				if (A[i] + A[j] > A[k] && A[i] + A[k] > A[j] && A[j] + A[k] > A[i] && A[i]!=A[j] && A[j]!=A[k] && A[k]!=A[i]) ans++;
			}
		}
	}
	co(ans);
}

Measured memory_bytes: 3628
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import core.bitop;

const int segSize = 1 << 20;
int[segSize * 2] seg;

// a_i を v に上書き
void update(int ind, int v) {
    ind += segSize;
    seg[ind] = v;
    while (true) {
        ind /= 2; // 上にのぼる
        if (ind == 0) break;
        // 下の子の最小値で更新
        seg[ind] = seg[ind * 2] | seg[ind * 2 + 1];
    }
}

// [l, r) の最小値を取得
int find(int l, int r) {
    l += segSize;
    r += segSize;
    int ans = seg[l];
    while (l < r) {
        if (l % 2 == 1) {
            ans |= seg[l];
            l++;
        }
        l /= 2;
        if (r % 2 == 1) {
            ans |= seg[r - 1];
            r--;
        }
        r /= 2;
    }
    return popcnt(ans);
}

void main() {
    int n; scan(n);
    string s = read;
    for (int i = 0; i < s.length; i++) update(i + 1, 1 << (s[i] - 'a'));

    int q; scan(q);
    foreach (_; 0..q) {
        int a, b; string t; scan(a, b, t);
        if (a == 1) { // udpate
            update(b, 1 << (t[0] - 'a'));
        }
        if (a == 2) { // get
            int p = t.to!int;
            writeln(find(b, p + 1));
        }
    }
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


Measured memory_bytes: 12048
from collections import defaultdict

n = int(input())
s = input()

rgb = {'R': 0, 'G': 0, 'B': 0}
for i in s:
    rgb[i] += 1

c = 0
for i in range(0, n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        k = 2*j - i
        if j < k and k < n and s[i] != s[k] and s[j] != s[k]:
                c += 1

print(rgb['R']*rgb['G']*rgb['B'] - c)


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

using namespace std;


long long n,k,a,b,c;
int main() {
    while(cin >> n >> k) {
        long long ans = 0;
        ans = n / k;
        ans = ans * ans * ans;
        long long ans2  = 0;
//        cout << ans << endl;
        if(k % 2 == 0) {
            int flag = 0;
            if(n >=  k / 2) flag = 1;
            long long n1 = (n - k / 2) / k + flag;
//            cout << n1 << endl;
            n1 = n1 * n1 * n1;
            ans2 = n1;
        }
        cout << ans + ans2 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
N = int(input())
a = 0
w = 0
t = 0
r = 0

for i in range(N):
    s = input()
    if s == 'AC':
        a += 1
    elif s == 'WA':
        w += 1
    elif s == 'TLE':
        t += 1
    else:
        r += 1

print('AC x '+str(a))
print('WA x '+str(w))
print('TLE x '+str(t))
print('RE x '+str(r))

Measured memory_bytes: 9208
#include<stdio.h>
int main(void){
  int N;
  scanf("%d",&N);
  int i,j;
  char s[4];
   int C0,C1,C2,C3;
  C0=0;
  C1=0;C2=0;C3=0;
  for(j=0;j<N;j++){{scanf("%s",&s);}for(i=0;i<10000;i++)if(s[i]=='\0'){break;}
 if(s[0]=='A'&&s[1]=='C'){C0=C0+1;}
  else if(s[0]=='W'&&s[1]=='A'){C1=C1+1;}
  else if(s[0]=='T'&&s[1]=='L'&&s[2]=='E'){C2=C2+1;}
  else if(s[0]=='R'&&s[1]=='E'){C3=C3+1;}}
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",C0,C1,C2,C3);
  return 0;
}
  


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N;
  cin >> N;
  vector<i64> P(N), Q(N);
  rep(i,0,N) cin >> P[i];
  rep(i,0,N) cin >> Q[i];
  vector<i64> vec(N);
  rep(i,0,N) vec[i] = i + 1;
  i64 p = 0;
  i64 q = 0;
  i64 now = 0;
  do {
    if(vec == P) p = now;
    if(vec == Q) q = now;
  } while(now++, next_permutation(all(vec)));
  cout << std::abs(p - q) << endl;
}


Measured memory_bytes: 256
n_str = input()

op_count = len(n_str) - 1  # すき間の個数
for i in range(2 ** op_count):
    op_list = ["-"] * op_count    # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_count):    # iの右からj+1番目のbitが1かどうかを確認
        if ((i >> j) & 1):
            op_list[len(op_list) - 1 -j] = "+"

    op_list.append("")
    formula = ""
    for i in range(len(n_str)):
        formula += (n_str[i] + op_list[i])
    if eval(formula) == 7:
        print(formula + "=7")
        break

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

#define ll long long

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	if(n%5)
		n -= (n%5);

	int ans = (n/500)*(1000);
	n = n%500;
	ans += (n/5)*5;
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	cout << N * N * N;
	return 0;
}


Measured memory_bytes: 3524
a,b,c=[input() for _ in [0]*3];d='a'
while 1:
    try:
        if d=='a':d,a=a[0],a[1:]
        elif d=='b':d,b=b[0],b[1:]
        else:d,c=c[0],c[1:]
    except:print(d.upper());exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (1LL<<62)
#define NINF ((-1)*(INF))
#define MOD (1000000007)

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	#ifdef LOCAL_PROJECT
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	vector<int> h(n+5, INF), dp(n+5, INF);
	for(int i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	dp[0] = 0;
	for(int i = 0; i < n; i++)
	{
		dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1]-h[i]));
		dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i]));
	}
	cout << dp[n-1];
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const int m=1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<vector<int>> dp(n+1,vector<int>(k+1));
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    dp[0][0]=1;
    for(int i=1;i<=k;i++){
        dp[0][i]=0;
    }
    for(int i=1;i<=n;i++){
        vector<int> prefix(k+1);
        prefix[0]=dp[i-1][0];
        for(int j=1;j<=k;j++){
            prefix[j]=(prefix[j-1]+dp[i-1][j])%m;
        }
        for(int j=0;j<=k;j++){
            if(j<=a[i]){
                dp[i][j]=prefix[j];
            }
            else{
                dp[i][j]=(prefix[j]-prefix[j-a[i]-1]+m)%m;
            }
        }
    }
    cout<<dp[n][k]<<'\n';
    return 0;
}


Measured memory_bytes: 40192
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    long long x = 1000, y = 0;
    vector< long long > a(n+2, 0);
    a[0] = 200;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=1;i<=n;i++){
        if(i < n && a[i] <= a[i-1] && a[i] < a[i+1]){
            long long z = x / a[i];
            x -= z * a[i];
            y += z;
        }
        if(a[i] >= a[i-1] && a[i] > a[i+1]){
            x += y * a[i];
            y = 0;
        }
        // cout << x << " " << y << endl;
    }
    cout << x << endl;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> vv;


int main(){
  string S,T;
  cin >> S >> T;
  vv tab(26,vec(26));
  rep(i,S.size()){
    int tmp1 = S[i] - 'a';
    int tmp2 = T[i] - 'a';
    tab[tmp1][tmp2] = 1;
  }
  rep(i,26){
    int tmp1 = 0;
    int tmp2 = 0;
    rep(j,26){
      tmp1 += tab[i][j];
      tmp2 += tab[j][i];
    }
    if(tmp1 > 1 || tmp2 > 1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

const int N=1e7+1;
long c[N];
int main()
{
    for(int i=1; i<N; ++i) c[i]=1;

    for(int i=2; i<N; ++i) if (c[i]==1) {
        for(int j=i; j<N; j+=i) {
            int x=0, y=j;
            while (y%i==0) {
                ++x;
                y/=i;
            }
            c[j]*=(1+x);
        }
    }
    int n; cin>>n;
    long res=0;
    for(int k=1; k<=n; ++k) res+=k*c[k];
    cout<<res<<endl;
}


Measured memory_bytes: 81724
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for i in range(m):
        maxVal = heapq.heappop(a)*(-1)
        heapq.heappush(a, (maxVal//2)*(-1))

print((-1)*(sum(a)))


Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
const int mod = 200003;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define fr(s,n) for (int i=(int)(s);i<(int)(n);i++)
#define lc cout<<"\n"

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a[5];
    fr(0,5){
        cin>>a[i];
    }
    fr(0,5){
        if(a[i]==0){
            cout<<(i+1);
            break;
        }

    }
}





Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

class UnionFind {
  private:
    vector<int> parent;
    vector<int> rank;

  public:
    UnionFind(int size) : parent(size), rank(size, 0) {
      for (int i = 0; i < size; i++) {
        parent[i] = i;
      }
    }

    int find(int x) {
      if (parent[x] == x) {
        return x;
      } else {
        return parent[x] = find(parent[x]);
      }
    }

    void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x == y) return;

      if (rank[x] < rank[y]) {
        parent[x] = y;
      } else {
        parent[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
      }
    }

    bool same(int x, int y) {
      return find(x) == find(y);
    }
};

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

  int n, m;
  cin >> n >> m;

  UnionFind uf(n);

  rep(i, m) {
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    uf.unite(x, y);
  }

  set<int> s;
  rep(i, n) {
    s.insert(uf.find(i));
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 5760
import java.util.*;

public class Main{
   public static void main(String[] args) {
	  Scanner sc =new Scanner(System.in);
   while(sc.hasNext()){
	   double n=sc.nextDouble();
	   int i=1;
	   for(;;){
		   if(Math.sqrt((5*i-5)/4.9)*9.8>n)break;
	       i++;
	   }
	   System.out.println(i);
   }
   }
   }

Measured memory_bytes: 18596