akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long N, A, B, C, D;
long long r;
int main()
{
	long long ran = 0;
	scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);
	r = A;
	r += D*(N - 1);
	ran = (D - C)*(N-1);
	long long l = r - ran;
	bool flag = false;
	while (N--) {
		if (l <= B&&r >= B) {
			flag = true;
			break;
		}
		l -= C+D;
		r -= C+D;
	}
	if (flag)printf("YES\n");
	else printf("NO\n");
}

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

int abs(int x,int y){
  x-=y;
  if(x<0)
    x=-x;
  return x;
}

int main(){
  string s;
  cin >> s;
  int ans=999;
  for(int i=0;i<s.size()-2;i++){
    int x;
    int a=s[i]-'0',b=s[i+1]-'0',c=s[i+2]-'0';
    x=a*100+b*10+c;
    //cout << a << " " << b << " " << c << " " << x << endl;
    ans=min(ans,abs(x,753));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {if(a < b) {a= b;return 1;}return 0;}
template <class T> inline bool chmin(T &a, T b) {if(a > b) {a= b;return 1;}return 0;}
ll mod= 1e9 + 7;


int main(){
  int n;
  cin >>n;
  ll a[n];
  rep(i,n)cin >> a[i];
  ll ans=0;
  ll d=a[0];
  rep(i,n-1){
    if(d>a[i+1]){ans+=d-a[i+1];}
    else{d=a[i+1];}
  }
  cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

  vector<int> f(n + 1);
  f[0] = 1;
  for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i;

  double r = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      r += 2 * f[n - 1] * sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
    }
  }
  r /= f[n];
  cout << fixed << setprecision(7);
  cout << r << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s;
	cin >> s;
	s.at(3) = '8';
	cout << s<<endl;
} 

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c;cin>>a>>b>>c;
  if(a>=b&&a>=c)cout<<"A"<<endl;
  else if(b>=a&&b>=c)cout<<"B"<<endl;
  else cout<<"C"<<endl;
  return 0;
}



Measured memory_bytes: 3132
#include <stdio.h>

int main(void)
{
    long a, b;
    long tmp;
    long m, n;
    while (scanf("%ld %ld", &a, &b) != EOF) {
        if (b > a) {
            tmp = a;
            a = b;
            b = tmp;
        }
        m = a;
        n = b;
        while (n != 0) {
            tmp = n;
            n = m % n;
            m = tmp;
        }
        printf("%ld %ld\n", m, a * b / m);
    }

    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int is=1;
    while(n--)
    {
        int t=0;
        cin>>t;
        if(t%2==0)
        {
            if(t%3!=0&&t%5!=0)
                is=0;
        }
    }
    if(is)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
#include<math.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
int main(){
    int n; cin >> n;
    int x = log10(n)+1;
    int ans=0;
    if(x % 2 == 0){
        for(int i=0;2*i+1<x;i++){
            ans+=9*pow(10,2*i);
        }
    }else{
        for(int i=0;2*i+1<x;i++){
            ans+=9*pow(10,2*i);
        }
        ans+=n-pow(10,x-1)+1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int a, L;
        cin >> a >> L;
        if(L == 0)
            return 0;

        map<int, int> memo;
        memo[a] = 0;

        for(int i=1; ; ++i){
            ostringstream oss;
            oss << a;
            string s = oss.str();
            s = string(L-s.size(), '0') + s;

            sort(s.rbegin(), s.rend());
            int b = atoi(s.c_str());
            reverse(s.begin(), s.end());
            b -= atoi(s.c_str());

            a = b;
            if(memo.find(a) != memo.end()){
                cout << memo[a] << ' ' << a << ' ' << (i - memo[a]) << endl;
                break;
            }
            memo[a] = i;
        }
    }
}

Measured memory_bytes: 0
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=1e5+5;

int n,m,ans;
int dp[maxn],in[maxn];
vector<int> g[maxn];

inline int dfs(int u){
	if(~dp[u]) return dp[u];
	dp[u]=0;
	FOR(i,0,g[u].size()){
		int v=g[u][i];
		dp[u]=max(dp[u],dfs(v)+1);
	}
	return dp[u];
}

int main(){
	scanf("%d%d",&n,&m);
	memset(dp,-1,sizeof(dp));
	FOR(i,0,m){
		int u,v;
		scanf("%d%d",&u,&v);
		--u;--v;
		g[u].PB(v);
		++in[v];
	}
	FOR(i,0,n) if(!in[i]) ans=max(ans,dfs(i));
	printf("%d\n",ans);
	return 0;
}


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

int dig(int x)
{
  int sum=0;
  while(x>0){
    sum += x%10;
    x /= 10;
  }
 return sum;
}

int main(){
  int n;
  cin >> n;
  int f = dig(n);
  if(n%f==0)
    cout << "Yes" << endl;
  
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<queue>
#include<string>
#include<list>
using namespace std;
typedef long long ll;
const int maxn = 3e5+10;
int main()
{
	list<char> q;
	string s;
	cin>>s;
	int n;
	cin>>n;
	q.assign(s.begin(),s.end());
	int flag = 0;
	while(n--)
	{
		int t;
		cin>>t;
		if(t==1) flag++;
		else
		{
			int f;
			char c;
			cin>>f>>c;
			if(f==1)
			{
				if(flag%2==0)
				{
					q.push_front(c);
				}
				else
				{
					q.push_back(c);
				}
			}
			else
			{
				if(flag%2!=0)
				{
					q.push_front(c);
				}
				else
				{
					q.push_back(c);
				}
			}
		}
	}
	if(flag%2==0)
		{
			for(auto it = q.begin();it!=q.end();it++)
			{
				cout<<*it;
			}
		}
		else
		{
			auto it = q.end();
			for(it ;it!=q.begin();it--)
			{
				if(it==q.end()) continue;
				cout<<*it;
			}
			cout<<*it;
		}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin >> n;
	for(long long i=sqrt(n);i>=1;i--){
		if(n%i==0){
			printf("%lld\n",i+n/i-2);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void){
    /* input */
    int width   = 0;
    int height  = 0;
    int circleX = 0;
    int circleY = 0;
    int circleR = 0;
    int result  = 0;
    std::cin >> width >> height >> circleX >> circleY >> circleR;
    
    /* judge */
    if( (circleX - circleR) < 0 )           /* left side */
    {
        result = -1;
    }
    else if( (circleY - circleR) < 0 )      /* bottom side */
    {
        result = -1;
    }
    else if( (circleX + circleR) > width)   /* right side */
    {
        result = -1;
    }
    else if( (circleY + circleR) > height)  /* upper side */
    {
        result = -1;
    }
    else
    {
        /* Do nothing */
    }
    
    /* output */
    if(result == 0)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>>jobs(m);//二重配列、m日後まで
  rep(i,n){
    int a,b;
    cin>>a>>b;
    if(a>m)continue;//m日後までに終わらなければ、対象外
    jobs[m-a].push_back(b);//期限までの余裕日数毎に分類し、報酬を入力
  }
  priority_queue<int>q;//プライオリティ・キューで報酬の最大値を出力
  ll ans=0;//long longなので注意
  for(int i=m-1;i>=0;--i){//後ろからチェックしていく
    for(int b:jobs[i]){//余裕日数毎に報酬を取り出す
      q.push(b);//プライオリティ・キューに入れていく
    }
    if (!q.empty()){//プライオリティ・キューが空になるまで
      ans+=q.top();//報酬の最大値を取り出す
      q.pop();//最大値を捨てる
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
const ld pi = 3.141592653;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

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

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
                int t;
                cin>>t;
                t>=30 ? cout<<"Yes" : cout<<"No";
        }
        return 0;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<int32> t(n),v(n);
    REP(i,n)cin >> t[i];
    REP(i,n)cin >> v[i];
    vector<int32> w(n+1,inf);
    priority_queue<pii,vector<pii>,greater<pii>> que;
    REP(i,n){
        chmin(w[i], v[i]);
        chmin(w[i+1],v[i]);
    }
    REP(i,n+1){
        que.emplace(w[i],i);
    }
    w[0] = w[n] = 0;
    que.emplace(0,0);
    que.emplace(0,n);
    while(!que.empty()){
        int32 d,cur;
        tie(d,cur) = que.top();
        que.pop();
        if(w[cur] < d)continue;
        if(cur-1 >= 0 && chmin(w[cur-1], w[cur] + t[cur-1])){
            que.emplace(w[cur-1],cur-1);
        }
        if(cur+1 <= n && chmin(w[cur+1], w[cur] + t[cur])){
            que.emplace(w[cur+1],cur+1);
        }
    }
    // REP(i,n+1)cout << w[i] << " ";
    // cout << endl;

    double ans = 0;
    // 2 * x = 2 * v0 * t + a * t * t;
    REP(i,n){
        if(abs(w[i] - w[i+1]) > t[i]){
            ans += min<double>(w[i], w[i+1]) * t[i] + (double)t[i] * t[i] / 2;
        }else{
            double t0 = v[i] - w[i];
            double t1 = v[i] - w[i+1];
            if(t[i] - t0 - t1 < 0){
                double dt = -(t[i] - t0 - t1);
                t0 -= dt / 2;
                t1 -= dt / 2;
            }
            // cout << t0 << " " << t1 << endl;
            ans += w[i] * t0 + t0 * t0 / 2;
            ans += w[i+1] * t1 + t1 * t1 / 2;
            ans += v[i] * (t[i] - t0 - t1);
        }
    }
    cout << fixed << setprecision(15);
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
<?php

(new Main)->excute();

class Main
{
    public function excute()
    {
        $endNum = trim(fgets(STDIN));
        $Nabeatsu = (new Nabeatsu(3, $endNum))->get();
        
        echo ' ', implode(' ', $Nabeatsu), PHP_EOL;
    }
}

class Nabeatsu
{
    private $baseNum;
    private $endNum;
    
    public function __construct($baseNum, $endNum)
    {
        $this->baseNum = $baseNum;
        $this->endNum = $endNum;
    }
    
    public function get()
    {
        $result = [];
        for ($i = 1; $i <= $this->endNum; $i++) {
            if ($this->checkMultipleOfBaseNum($i) || $this->checkIncludingBaseNum($i)) {
                $result[] = $i;
            }
        }
        
        return $result;
    }
    
    private function checkMultipleOfBaseNum($num)
    {
        return $num % $this->baseNum == 0;
    }
    
    private function checkIncludingBaseNum($num)
    {
        return strpos((string)$num, (string)$this->baseNum) !== false;
    }
}

Measured memory_bytes: 16260
x,y=map(int,input().split())
INF=1000000007
if (x+y)%3!=0:
    print(0)
    exit(0)
if x>2*y or y>x*2:
    print(0)
    exit(0)
times_sum=(x+y)//3
x-=times_sum;y-=times_sum
def factorial_cor(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
        fact %= INF
    return fact
a=factorial_cor(x+y)
b=factorial_cor(y)
c=factorial_cor(x)
def modinv(a):
    b=INF;u=1;v=0
    while b:
        t=a//b
        a-=t*b
        a,b=b,a
        u-=t*v
        u,v=v,u
    u%=INF
    if u<0:
        u+=INF
    return u
b=modinv(b)
c=modinv(c)

print(a*b*c%INF)

Measured memory_bytes: 3064
// AOJ Volume 0 Problem 0021

#include <stdio.h>

void normalization(double *x1, double *y1, double *x2, double *y2)
{
	double t;
	
	if (*x1 > *x2){
		t = *x1;
		*x1 = *x2;
		*x2 = t;

		t = *y1;
		*y1 = *y2;
		*y2 = t;
	}
}

int main(void)
{
    int n;
	int i;
	double x1, y1, x2, y2, x3, y3, x4, y4;

	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
		scanf("%lf%lf%lf%lf", &x3, &y3, &x4, &y4);
	
		normalization(&x1, &y1, &x2, &y2);
		normalization(&x3, &y3, &x4, &y4);
	
		if (x1 == x2){
			if (x3 == x4){
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
			continue;
		}
		if (x3 == x4){
			if (x1 == x2){
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
			continue;
		}
		if (y1 == y2){
			if (y3 == y4){
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
			continue;
		}
		if (y3 == y4){
			if (y1 == y2){
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
			continue;
		}

//		printf("[%f][%f][%f][%f]", x1, y1, x2, y2);
//		printf("[%f][%f][%f][%f]", x3, y3, x4, y4);

//		printf("<%f><%f>", (y2 - y1) * (x3 - x4), (y4 - y3) * (x2 - x1));

		if ((y2 - y1) * (x4 - x3) == (y4 - y3) * (x2 - x1)){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}

    return (0);
}

Measured memory_bytes: 0
"use strict"
function Main(input){
    input = input.split("\n");
    var tmp = input[0].split(" ");

    var H = parseInt(tmp[0],10);
    var W = parseInt(tmp[1],10);

    var output = "";

    //配列作成
    var tbl = new Array(H + 2);
    var tbl1  = new Array(H + 2);
    for(let y = 0;  y < H + 2; y++) {
      tbl[y] = new Array(W + 2).fill(0);
      tbl1[y] = new Array(W + 2).fill(0);
    }
    
    for(let y = 0;  y < H ; y++) {
        var tmp1 = input[y + 1].split("");
        for (let x = 0; x < W; x++) {

            if (tmp1[x] != "#"){
                tbl[y + 1][x + 1] = 0;
            }else{
                tbl[y + 1][x + 1] = 1;
                tbl1[y + 1][x + 1] = "#";
            }
        }
    }
    //console.log(tbl1);

    for(let i = 0; i < H; i++){
        for(let j = 0; j < W; j++){
            if (tbl[i + 1][j + 1] != 1){
                //爆弾の数を計算                              
                tbl1[i + 1][j + 1] = tbl[i][j] + tbl[i][j + 1] + tbl[i][j + 2] + tbl[i + 1][j] + tbl[i + 1][j + 2]  + tbl[i + 2][j] + tbl[i + 2][j + 1] + tbl[i + 2][j + 2];
                output += tbl1[i + 1][j + 1];
            }else {
                output += tbl1[i + 1][j + 1];
            }
        }
        output += "\n";
    }
    console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;
  ll x = 800*n;
  ll y = n/15*200;
  cout << x-y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long s=0;
int main()
{
	multiset <int> a;
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		a.insert(x);
	}
	for(int i=1;i<=m;i++){
		int y=*a.rbegin();
		auto it = --a.end();
		a.erase(it);
		y=y/2;
		a.insert(y);
	}	
	for(auto u : a){
		s=s+u;
	}
		
	printf("%lld\n",s);
}

Measured memory_bytes: 4992
import math
N = int(input())
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]
OrderP = 1
OrderQ = 1
for T in range(0,N-1):
    OrderP += sorted(P[T:]).index(P[T])*math.factorial(N-1-T)
    OrderQ += sorted(Q[T:]).index(Q[T])*math.factorial(N-1-T)
print(abs(OrderP-OrderQ))

Measured memory_bytes: 9088
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <cstdlib>
#include <stdio.h>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define DBG 1

#define MAXN 3000
double a[MAXN][MAXN];

int main() {
  int n;
  cin >> n;
  double p[MAXN];
  forr(i,1,n)
  forr(j,0,i) a[i][j] = 0.0;
  forr(i,1,n)
    cin >> p[i];
  a[1][0] = 1.0 - p[1];
  a[1][1] = p[1];

  forr(i,2,n)
  forr(j,0,i) {
    if (j<i) a[i][j] += a[i-1][j] * (1.0-p[i]);
    if (j>0) a[i][j] += a[i-1][j-1] * p[i];
  }
  double sum = 0.0;
  forr(i,n/2+1,n) sum += a[n][i];
  //cout << sum;
  printf("%.10f", sum);

}


Measured memory_bytes: 68864
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n;
    IN n;
    P(24 + 24-n);
    
	return  0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<string>
#include<iomanip>

int main() {
	ll n, m;
	cin >> n >> m;
	vector<int>a(m);
	rep(i, m) {
		cin >> a[i];
	}
	ll sum(0);
	rep(i, m) {
		sum += a[i];
	}
	ll ans = n - sum;
	if (ans < 0) {
		cout << -1;
	}
	else {
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 3668
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

type City struct {
	num, pref, year int
	id              string
}

type ByYear []*City

func (a ByYear) Len() int { return len(a) }
func (a ByYear) Less(i, j int) bool {
	if a[i].pref == a[j].pref {
		return a[i].year < a[j].year
	} else {
		return a[i].pref < a[j].pref
	}
}
func (a ByYear) Swap(i, j int) { a[i], a[j] = a[j], a[i] }

type ByNum []*City

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	_, M := sc.nextInt(), sc.nextInt()
	cities := make([]*City, M)
	for i := 0; i < M; i++ {
		p, y := sc.nextInt(), sc.nextInt()
		cities[i] = &City{i, p, y, ""}
	}
	sort.Sort(ByYear(cities))
	indx := 1
	curPref := 1
	for _, c := range cities {
		if curPref != c.pref {
			curPref = c.pref
			indx = 1
		}
		c.id = fmt.Sprintf("%06d%06d", curPref, indx)
		indx++
	}
	sort.Sort(ByNum(cities))
	for _, c := range cities {
		fmt.Fprintln(wtr, c.id)
	}
	wtr.Flush()
}


Measured memory_bytes: 13184
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "numeric"
#include "iomanip"
using namespace std;
typedef long long ll;

int main() {
	vector<int> A;
	int q;
	cin >> q;
	int a, b;
	for (int i = 1; i <= q; i++) {
		cin >> a;
		if (a == 0) {//pushBack(x)
			cin >> b;
			A.push_back(b);
		}
		else if (a == 1) {//randomAccess(p)
			cin >> b;
			cout << A[b] << endl;
		}
		else {//popBack()
			A.pop_back();
		}
	}
}



Measured memory_bytes: 3836
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef complex<double> point;

#define X real()
#define Y imag()
#define angle(a) (atan2((a).imag(), (a).real()))
#define vec(a, b) ((b) - (a))
#define same(p1, p2) (dp(vec(p1, p2), vec(p1, p2)) < EPS)
#define dp(a, b) ((conj(a) * (b)).real())
#define cp(a, b) ((conj(a) * (b)).imag())
#define length(a) (hypot((a).imag(), (a).real()))
#define normalize(a) (a) / length(a)
#define rotateO(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotateO(vec(about, p), ang) + about)
#define reflectO(v, m) (conj((v) / (m)) * (m))
#define clr(a, b) memset(a, b, sizeof(a));

const ll N = 105;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

ll n, m, w[N], v[N];
ll memo[N][100005];

ll solve(int i, ll j)
{
	if(i == n)
		return 0;

	ll& ret = memo[i][j];
	if(~ret)
		return ret;

	ret = solve(i + 1, j);
	if(j - w[i] >= 0)
		ret = max(ret, solve(i + 1, j - w[i]) + v[i]);

	return ret;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin >> n >> m;
    for(int i = 0; i < n; i++)
    	cin >> w[i] >> v[i];
    clr(memo, -1);
    cout << solve(0, m) << endl;
}

Measured memory_bytes: 82304
# -*- coding: utf-8 -*-
n=int(input())
m=int(input())
ans=c=m
for i in range(n):
    a,b=[int(a) for a in input().split()]
    if c<0:
        continue
    c+=a-b
    if ans<c:
        ans=c
    if c<0:
        ans=0
print(ans)

Measured memory_bytes: 7708
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;
const ll INF=2e18;

ll N,M,K,C;
ll a,b,c,d;
string s;
ll p[200010];
int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>p[i];
    }
    sort(p,p+N);
    cout<<p[N/2]-p[N/2-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
  char s[4];
  int i;
  int sum=0;
  cin>>s;
  for(i=0;i<4;i++){
    if(s[i]=='+') sum++;
    if(s[i]=='-') sum--;
  }
  cout<<sum;
}

Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += gcd(a,b,c)
print(ans)


Measured memory_bytes: 74744
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#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 FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 4e18;

int main() {
    string s; cin >> s;
    if (s.size() % 2 == 0 ^ s[0] == s[s.size() - 1]) {
        puts("Second");
    }
    else {
        puts("First");
    }
    getchar(); getchar();
}

Measured memory_bytes: 512
fun main(args: Array<String>) = ABC051B.main()

object ABC051B {
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }

    fun main() {
        val (K, S) = readInts()

        var cnt = 0
        (0..K).forEach { x ->
            (0..K).forEach { y ->
                val z = S - x - y
                if (0 <= z && z <= K) cnt++
            }
        }

        println(cnt)
    }
}

Measured memory_bytes: 40420
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	if(a>MOD){
		a -= MOD;
	}
}

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	cout << ((a==b && b==c && c==a)?"Yes":"No") << endl;
	return 0;
}


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

int main(void)
{
    long long int n;
    cin>>n;
    long long a[n],i;
    long long h[n+1];
    for(i = 1; i <= n; i++)
    {
        h[i] = 0;
    }

    for(i = 0; i < n-1; i++)
    {
        cin>>a[i];
        h[a[i]]++;
    }

    for(i = 1; i <= n; i++)
    {
        cout<<h[i]<<endl;
    }

    return 0;
}


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

typedef long long ll;

using vi = vector<int>;
using vl = vector<long long int>;
using vii = vector<vector<int>>;
using vll = vector<vector<long long int>>;



int modd(int a)
{
return a>=0?a:-a;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    const int m=1e9+7;
int n,k;
cin>>n>>k;
vector<int>fill(k+1);
int arr[n];
for(int i=0;i<n;i++){
  cin>>arr[i];
  fill[arr[i]]=1;
}

//for(int i=0;i<arr[i];i++)fill[i]=2;

for(int i=1;i<=k;i++)
{
  if(fill[i])continue;
  else 
  {
    int flag=0;
    for(int j=0;j<n;j++)
    {
      if(i-arr[j]<0||flag==1)break;
      if(fill[i-arr[j]]==2)flag=1;
    }
    if(flag)fill[i]=1;
    else fill[i]=2;
  }

}
if(fill[k]==1)cout<<"First"<<"\n";
else cout<<"Second"<<"\n";

return 0;

}


Measured memory_bytes: 640
n=int(input())
a_list=list(map(int,input().split()))

# f(m)の最大値は、sum(ai-1)である。
# → m=a1*a2*...*aN -1 とすれば良い。

m=1
for a in a_list:
    m*=a
m-=1    

mod_all=0
for a in a_list:
    mod_all+=m%a
print(mod_all)

Measured memory_bytes: 3316
m,n=map(int,input().split())
j=0
for i in range(m,n+1):
    c=int(i/10000)
    d=int(i/1000%10)
    e=int(i/100%10)
    f=int(i/10%10)
    g=int(i%10)
    if((c+d*10+e*100+f*1000+g*10000)==i):
        j+=1
print("%d"% j)


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

int main() {
    int N; cin>>N;
    int t = 1, count = 0;
    vector<long long> a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
        if(a.at(i)==t){
            t++;
        }else{
            count++;
        }
    }

    if(t != 1){
        cout<<count<<endl;
    }else{
        cout<<-1<<endl;
    }

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define pbb pop_back
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
const int mod=1e9+7;
char a[1005][1005];
ll dp[1005][1005];
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
  //  memset(dp,0,sizeof(dp));
    dp[1][1]=1;
    for(int i=2;i<=m;i++){
        if(a[1][i]=='#')
        dp[1][i]=0;
        else
        dp[1][i]=dp[1][i-1];
    }
    for(int i=2;i<=n;i++){
        if(a[i][1]=='#')
        dp[i][1]=0;
        else
        dp[i][1]=dp[i-1][1];
    }
    for(int i=2;i<=n;i++){
        for(int j=2;j<=m;j++){
            if(a[i][j]=='.'){
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]%=mod;
            }
        }
    }
    cout<<dp[n][m]<<endl;
}
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   

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


string F(string a,string b)
{
    int i=0,CF=0,JG=0,loop=0;
    string c;
    char *pa,*pb;
    if (a.length()>b.length())
    {
        b.insert(b.begin(),a.length()-b.length(),0x30);
    }
    else
    {
        a.insert(a.begin(),b.length()-a.length(),0x30);
    }
    pb=(char*)a.c_str()+a.length()-1;
    pa=(char*)b.c_str()+b.length()-1;
    for (i=0;i<a.length() || i<b.length();i++)
    {
        JG=(*pa--)+(*pb--)+CF-0x60;
        CF=JG/10;
        JG%=10;
        c.insert(c.begin(),1,JG+0x30);
    }
    if (CF)
    {
        if (i<a.length())
        {
            JG=*pa+CF-0x30;
            CF=JG/10;
            JG%=10;
            c.insert(c.begin(),1,JG+0x30);
        }
        else
        {
            c.insert(c.begin(),1,CF+0x30);
        }
    }
    return c;
}
int main()
{
    int N,i;
    cin>>N;
    string a,b,sum;
    for (i=1;i<=N;i++)
    {
        cin>>a>>b;
        sum=F(a,b);
        if(sum.length()>80)
            cout<<"overflow"<<endl;
        else
            cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 1236
/* B - Substring */

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

int main(){
  string S, T;
  cin >> S >> T;
  int len_S = S.size(), len_T = T.size(), match = 0, max_match = 0;
  for(int i = 0; i <= len_S - len_T; i++){
    match = 0;
    int k = i;
    for(int j = 0; j < len_T; j++, k++){
      if(S.at(k) == T.at(j)) match++;
    }
    if(max_match < match) max_match = match;
  }
  cout << len_T - max_match << endl;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define eps 1e-67
#define pf printf
#define sf scanf
#define sd(n) scanf("%d",&n)
#define sd2(n1,n2) scanf("%d %d",&n1,&n2)
#define slf(n) scanf("%lf",&n)
#define slf2(n1,n2) scanf("%lf %lf",&n1,&n2)
#define sLf(n1) scanf("%Lf",&n1)
#define sLf2(n1,n2) scanf("%Lf %Lf",&n1,&n2)
#define sl(n) scanf("%lld",&n)
#define sl2(n1,n2) scanf("%lld %lld",&n1,&n2)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define repb(i,a,b) for(long long int i=a;i>=b;i--)
#define repa(i,a,b,c) for(long long int i=a;i<b;i=i+c)
#define reps(i,a,b,c) for(long long int i=a;i>b;i=i-c)
#define asort(a) sort(a.begin(),a.end())
#define asortb(a,comp) sort(a.begin(),a.end(),comp)
#define arev(a) reverse(a.begin(),a.end())
#define all(v) (v).begin(),(v).end()
#define allc(v,comp) (v).begin(),(v).end(),comp
#define allrc(v,a,b,comp) (v).begin()+a,(v).end()-b,comp
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define pbb pop_back
#define mp make_pair
#define mt make_tuple
#define bs(v,x) binary_search(v.begin(),v.end(),x)
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define tl(c) towlower(c)
#define root(x) sqrt(x)
#define power(a,n) (int)floor(pow(a,n))
#define tu(c) towupper(c)
#define sq(a) ((a)*(a))
#define cube(a) ((a)*(a)*(a))
#define mx 1000
#define MX 100000
#define mod 1000000007
using namespace std;
typedef string str;
typedef long long int ll;
typedef double lf;
typedef long double llf;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef char ch;
typedef map<ll,ll> mp;
void Solve()
{
    ll n;
    cin>>n;
    vll v;
    bool prime[100000];
    memset(prime, true, sizeof(prime));
    prime[0]=prime[1]=false;
    for (ll p=2; p<=n; p++)
    {

        if (prime[p] == true)
        {

            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    ll i,j,sum=0,ans=1;
    rep(i,0,n+1)
    {
        if(prime[i])
        {
            v.pb(i);

        }
    }

    rep(i,0,v.size())
    {
        rep(j,1,10){
            sum+=(n/power(v[i],j));
        }
        ans*=(sum+1);
        ans%=mod;
        sum=0;
    }
    cout<<ans<<endl;
}

int main()
{
    Solve();
    return 0;
}


Measured memory_bytes: 640
import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.conv;
import std.string;



void main()
{
	int w, n;
	readf("%d\n %d\n",&w,&n);
	int[] num = new int[w];
	foreach(i; 0 .. w)
		num[i] = i + 1;
	int buff, a, b;
	foreach(i; 0 .. n)
	{
		readf("%d,%d\n",&a,&b);
		buff = num[a - 1];
		num[a - 1] = num[b - 1];
		num[b - 1] = buff;
	}
	foreach(k; 0 .. w)
		writeln(num[k]);
}

Measured memory_bytes: 1064
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;

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

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
using namespace std;

double dist(double p, vector<double> x, vector<double> y){
    double sum = 0.0;
    int k = x.size();
    for(int i = 0; i < k; i++){
        sum += pow(fabs(x[i]-y[i]),p);
    }
    double ans = pow(sum,1/p);
    return ans;
} 

int main(){
    int n;
    cin >> n;
    vector<double> A(n),B(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
        A[i] *= 1.0;
    }
    for(int i = 0; i < n; i++){
        cin >> B[i];
        B[i] *= 1.0;
    }
    cout << fixed << setprecision(7);
    cout << dist(1,A,B) << endl;
    cout << dist(2,A,B) << endl;
    cout << dist(3,A,B) << endl;
    
    double dist_inf = -1.0;
    for(int i = 0; i < n; i++){
        dist_inf = max(dist_inf,fabs(A[i]-B[i]));
    }
    cout << dist_inf << endl;
    return 0;
}


Measured memory_bytes: 3440
//AtCoder Beginner Contest 175
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e6 + 5;
const double E = 1e-9;

//------------------------------------------------------------------------------
ll x, k, d;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*ifstream cin("input.txt");
	ofstream cout("output.txt");*/
	cin >> x >> k >> d;
	ll temp_x = abs(x);
	ll dist1 = temp_x / d;
	if (k > dist1)
	{
		ll ans1 = 0;
		if (x < 0)
			ans1 = x + dist1 * d;
		else
			ans1 = x - dist1 * d;
		if ((k - dist1) & 1)
		{
			if (x < 0)
				cout << abs(ans1 + d);
			else
				cout << abs(ans1 - d);
		}
		else
			cout << abs(ans1);
	}
	else
		cout << temp_x - k * d;
	return 0;
}
//15-08-2020 18:16:48
//------------------------------------------------------------------------------

Measured memory_bytes: 3636
from collections import defaultdict
N,K=map(int,input().split())
L=list(map(int,input().split()))
L.insert(0,-1)
path=[1]
ind=0
count=0
x=1
t=-1
flag=False
Hash=defaultdict(lambda:0)
for i in range(N+1):
    ne=L[x]
    if Hash[ne]:
        flag=True
        t=Hash[ne]
        break
    path.append(ne)
    ind+=1
    Hash[ne]=ind
    x=ne
if flag==True:
    loop=path[t::]
    if K<(len(path)):
        print(path[K])
    else:
        K=K-len(path)
        K=K%len(loop)
        print(loop[K])
else:
    print(path[K-1])

Measured memory_bytes: 134184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define pb push_back
#define mp make_pair
#define M 1000000007
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}

// #define ncr_nikalo
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll int t=1;
    //cin>>t;
    #ifdef ncr_nikalo
        initialvalues();
    #endif
        
    for(ll int g=0;g<t;g++)
    {
       ll int a,b,k;
       cin>>k>>a>>b;
       for(ll int i=a;i<=b;i++)
       {
        if(i%k==0)
        {
            cout<<"OK";
            return 0;
        }
       }
        cout<<"NG";

    }
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll X;
    cin >> X;
    ll a = 100;
    int cnt = 1;
    while(1) {
        a += a / 100;
        if(a >= X) {
            output(cnt);
            return 0;
        }
        cnt++;
    }
    
    return 0;
}


Measured memory_bytes: 3652
use std::io::{self, BufRead};

fn main() {
	let stdin = io::stdin();
	let sum: i64 = stdin.lock().lines().skip(1).map(|l|
		l.unwrap().split_whitespace().map(|s|
			s.parse::<i64>().unwrap()
		).fold(0, |a, b| b - a) + 1
	).sum();
	print!("{}", sum);
}


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

int main(){
  string s;
  cin >> s;
  rep(i, 1 << 3){
    int ans = s[0] - '0';
    rep(j, 3){
      if((i & (1 << j)) == 0) ans += s[j+1] - '0';
      else ans -= s[j+1] - '0';
    }
    if(ans == 7){
      cout << s[0];
      rep(j, 3){
        if((i & (1 << j)) == 0) cout << '+';
        else cout << '-';
        cout << s[j+1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

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

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    ll a, b, c, s;
    cin >> a >> b >> c;
    s = a + b + c;
    cout << max({a, b, c}) * 10 + s - max({a, b, c}) << endl;
}

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

int main(){
  int N;
  cin >>N;
  
  int ans;
  if(N<112) ans = 111;
  else if(N<223) ans = 222;
  else if(N<334) ans = 333;
  else if(N<445) ans = 444;
  else if(N<556) ans = 555;
  else if(N<667) ans = 666;
  else if(N<778) ans = 777;
  else if(N<889) ans = 888;
  else ans = 999;
  
  cout <<ans<< endl;
}

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


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

ll dp[100005],a[100005],n;

ll f(ll x)
{
	if(x==n-1)
		return 0;
	if(x>=n)
		return hell;
	if(dp[x]==-1)
	{
		dp[x]=min(f(x+1)+abs(a[x]-a[x+1]), f(x+2)+abs(a[x]-a[x+2]));
	}
	return dp[x];
}


int main()
{
	SPEED;
	ll k,t,c=0,i,j,m,cs=0;
	t=1;

	//cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		rep(i,n)
		{
			cin>>a[i];
			dp[i]=-1;
		}
		c=f(0);
		cout<<c;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;


int main(){
    
    int n, m, a;
    scan(n, m);
    print(n*(n-1)/2 + m*(m-1)/2);
    
    return 0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<bool> snuke(N + 1, false);
    REP(i, K) {
        int d;
        cin >> d;
        REP(j, d) {
            int x;
            cin >> x;
            snuke[x] = true;
        }
    }
    int res = count(snuke.begin() + 1, snuke.end(), false);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3596
n = int(input())
a_list = list(map(int, input().split()))
q = int(input())
change_list = [list(map(int, input().split())) for _ in range(q)]

cnt = [0] * 10**6
tot = sum(a_list)

for i in range(n):
    cnt[a_list[i]] += 1
#print(cnt)

for j in range(q):
    tot += cnt[change_list[j][0]] * (change_list[j][1]-change_list[j][0])
    cnt[change_list[j][1]] += cnt[change_list[j][0]]
    cnt[change_list[j][0]] = 0
    print(tot)

Measured memory_bytes: 39300