akhauriyash/Code-Regression huggingface dataset:
n = int(input())
h = list(map(int, input().split()))
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

dp = [float('inf')] *(10**5+10)
dp[0] = 0
for i in range(1, n):
    dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i > 1 :
        dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[n - 1])

Measured memory_bytes: 13904
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N,D,X,Y,count=0,i;
  cin >> N>>D;
  D=D*D;
  for(i=0;i<N;i++){
    cin >> X>>Y;
    if(X*X+Y*Y<=D){
      count++;
    }

  }

  cout << count;
}

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

constexpr int LEN = 105;
bool ga[LEN][LEN];
int d[LEN], f[LEN];

int dfs(int id, int time, const int n){
	int	t = ++time;
	if(d[id] < 0) d[id] = t;
	rep(i, n)
		if(ga[id][i] && (d[i] < 0)) t = dfs(i, t, n);
	if(f[id] < 0) f[id] = ++t;

	return t;
}

int main(){
	memset(d, -1, LEN*sizeof(int));
	memset(f, -1, LEN*sizeof(int));
	memset(ga, 0, LEN*LEN*sizeof(bool));
	int n; cin >> n;
	rep(i, n){
		int u, k; cin >> u >> k;
		rep(j, k){
			int v; cin >> v;
			ga[u-1][v-1] = 1;
		}
	}

	int t = 0;
	rep(id, n) if(d[id] < 0) t = dfs(id, t, n);
	rep(i, n) cout << i+1 << ' ' << d[i] << ' ' << f[i] << endl;

	return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int n, m, ans, d;

int main(){
    cin >> n >> m;
    vector<int> x(m), l(m - 1);
    for (int i = 0; i < m; i++) cin >> x[i];
    sort(x.begin(), x.end());
    for (int i = 0; i + 1 < m; i++) d = abs(x[i] - x[i + 1]), ans += d, l[i] = d;
    sort(l.begin(), l.end(), greater<ll>());
    d = min(n - 1, m - 1);
    for (int i = 0; i < d; i++) ans -= l[i];
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;


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

  cin >> N;

  cout << (N+1)/2 << "\n";
  return 0;
}

Measured memory_bytes: 256
def knapsack1(weight_value, w):
    cur = [0] * (w + 1)
    nxt = [0] * (w + 1)

    for weight, value in weight_value:
        for i in range(1, weight):
            nxt[i] = cur[i]
        for i in range(weight, w + 1):
            nxt[i] = max(cur[i], cur[i - weight] + value)
        cur, nxt = nxt, cur
    return cur[w]


def main():
    n, w = [int(x) for x in input().split()]
    weight_value = [None] * n
    for i in range(n):
        weight_value[i] = [int(x) for x in input().split()]
    return knapsack1(weight_value, w)


print(main())


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

int main(){

  int a, b;
  cin >> a >> b;

  if ((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0){
    cout << "Possible" << endl;
  }
  else{
    cout << "Impossible" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.txt");ofstream coutt("out.txt");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Use __builtin_popcountll for ll;
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 
int n,m,k;
vi a,b;

bool f(int num){
    
    for(int i=0;i<=num;i++){
        int j=num-i;
        if(i>n || j>m)continue;
        int sum1=(i?a[i-1]:0);
        int sum2=(j?b[j-1]:0);
        if(sum1+sum2<=k)return 1;
    }
    
    return 0;
}

signed main(){
    FASTER;
    cin>>n>>m>>k;
    a=vi(n);
    b=vi(m);
    cin>>a>>b;
    for(int i=1;i<n;i++)a[i]+=a[i-1];
    for(int i=1;i<m;i++)b[i]+=b[i-1];
    
    int s=0,e=n+m,ans=0;
    while(s<=e){
        int mid=(s+e)/2;
        if(f(mid))s=mid+1,ans=mid;
        else e=mid-1;
    }
    cout<<ans;
}



Measured memory_bytes: 6248
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
N, A, B = ri_()
print(min(A * N, B))

Measured memory_bytes: 63084
#include<bits/stdc++.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}

lg sol(vector<vector<lg>>& gr, vector<bool>& visited, lg in)
{
    visited[in]=true;
    vector<lg>nodes(1,in);
    lg ans=1;
    while(!nodes.empty())
    {
        vector<lg>temp;
        lg l = nodes.size();
        for(lg i=0;i<l;i++)
        {
            lg now = nodes[i];
            lg k = gr[now].size();
            for(lg j=0;j<k;j++)
            {
                lg at = gr[now][j];
                if(!visited[at])
                {
                    ans++;
                    visited[at]=true;
                    temp.pb(at);
                }
            }
        }
        nodes=temp;
    }
    return ans;
}

int main()
{
    lg n;
    cin>>n;
    vector<lg>a(n,0);

    for(lg i=0;i<n;i++)
        cin>>a[i];

    lg ans=a[0];
    for(lg i=1;i<n;i++)
        ans=__gcd(ans,a[i]);
    if(ans==1)
    {
        sort(a.begin(),a.end());
        bool p=false;
        lg ct=0;
        for(lg i=0;i<n;i++)
            if(a[i]%2==0)
                ct++;
        if(ct>1)
            p=true;
        if(p)
        {
            cout<<"setwise coprime"<<endl;
        }
        else
        {
            vector<lg>nums(a[n-1]+1, 0);
            for(lg i=0;i<n;i++)
                nums[a[i]]++;

            for(lg i=3;i<=a[n-1];i+=2)
            {
                lg k=i;
                lg now=0;
                while(k<=a[n-1])
                {
                    now+=nums[k];
                    if(now>1)
                        break;
                    k+=i;
                    if(k>a[n-1])
                        break;
                }
                if(now>1)
                {
                    p=true;
                    break;
                }
            }
            if(p)
            {
                cout<<"setwise coprime"<<endl;
            }
            else
            {
                cout<<"pairwise coprime"<<endl;
            }
        }
    }
    else
    {
        cout<<"not coprime"<<endl;
    }
}


Measured memory_bytes: 18608
#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 a;
    int i = 1;
    while(cin >> a, a) {
        cout << "Case " << i << ": " << a << endl;
        i++;
    }
    return 0;
}

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

using System.Collections;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        var v = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int[] v1 = new int[n / 2];
        int[] v2 = new int[n / 2];

        for (int i = 0; i < n; i++)
        {
            var val = v[i];
            
            if(i % 2 == 0)
            {
                v1[i / 2] = val;
            }
            else
            {
                v2[i / 2] = val;
            }
        }

        //v1の中で最も多い数値と2番目に多い数値
        var xx1 = v1.GroupBy(val => val).OrderByDescending(grp => grp.Count()).Take(2);
        var xx2 = v2.GroupBy(val => val).OrderByDescending(grp => grp.Count()).Take(2);

        if(xx1.First().Key != xx2.First().Key)
        {
            //それぞれ最も多い数で統一させれば良い
            Console.WriteLine(n - xx2.First().Count() - xx1.First().Count());
        }
        else
        {
            var val1 = n - xx1.First().Count() - (xx2.Count() == 2 ? xx2.Skip(1).First().Count() : 0);
            var val2 = n - xx2.First().Count() - (xx1.Count() == 2 ? xx1.Skip(1).First().Count() : 0);

            Console.WriteLine(Math.Min(val1, val2));
        }

    }
    
    
}

Measured memory_bytes: 62292
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

const INF: usize = 1001001001001;

fn main() {
   input! {
      n: usize,
      m: usize,
      abc: [(usize, usize, usize); m]
   }

   let mut dp = vec![vec![INF; n]; n];
   for &(a, b, c) in abc.iter() {
      dp[a - 1][b - 1] = c;
      dp[b - 1][a - 1] = c;
   }
   for i in 0..n {
      dp[i][i] = 0;
   }
   for k in 0..n {
      for i in 0..n {
         for j in 0..n {
            dp[i][j] = std::cmp::min(dp[i][j], dp[i][k] + dp[k][j]);
         }
      }
   }
   let mut ans = 0;
   for &(a, b, c) in abc.iter() {
      if dp[a - 1][b - 1] != c {
         ans += 1;
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 4352
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pm(m) for(auto itr=(m).begin();itr!=(m).end();itr++){itr->first<<" "<<itr->second<<"\n";}
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
#define bug(x) cout<<(x)<<" ";exit(0);
int mod = 1000000007;
int mod1 = 998244353;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


const int mx = 1000000+2;
vector<int> spf(mx);
void sieve(){
    
    for(int i=2;i<=1000000;i+=2)spf[i]=2;
    for(int i=3;i<=1000000;i+=2)spf[i]=i;
    for(int i=3;i*i<=1000000;i+=2){
        
        if(spf[i]==i){
            
            for(int j=2*i;j<=1000000;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}
map<int,int> mp;
bool good(int n){
    
    
    while(n!=1){

        int pf = spf[n];
        if(mp.find(pf)!=mp.end())return 0;
        mp[pf] = 1;
        while(n%pf==0){
            n/=pf;
        }
        
    }
    return 1;
}


int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
	
	sieve();

    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    bool c1=1,c2=1;
    int g = __gcd(v[0],v[1]);
    for(int i=0;i<n;i++){
        if(c1 and !good(v[i])){
            c1=0;
            
        }
        g = __gcd(g,v[i]);
    }
    if(g!=1)c2=0;
    if(c1==1){
        cout<<"pairwise coprime";
    }
    else if(c1==0 and c2==1){
        cout<<"setwise coprime";
    }
    else{
        cout<<"not coprime";
    }
    
    
}

Measured memory_bytes: 18772
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }
int neg(int a) { return sub(0, a); }

int dp[1000005][2][2];
int n;

int f(int x, int p, int q)
{
    if (x == n)
        return p + q == 2;
    if (dp[x][p][q] != -1)
        return dp[x][p][q];
    
    int sol = 0;
    for (int i = 0; i <= 9; ++i)
        adds(sol, f(x + 1, p || (i == 0), q || (i == 9)));
    return dp[x][p][q] = sol;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    memset(dp, -1, sizeof dp);
    cout << f(0, 0, 0);
}


Measured memory_bytes: 97352
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,dp[N],ans[N],dp2[N],pre[N];
string s,s1;
vi adj[N];
//Variables End
ll sub(ll a, ll b){return (a-b+MOD)%MOD;}
ll add(ll a, ll b){return (a+b)%MOD;}
ll mul(ll a, ll b){return (a*b)%MOD;}
void dfs(ll ver,ll par)
{
	dp[ver]=1;
	ll prod=1;
	for(auto i:adj[ver])
	{
		if(i!=par)
		{
			dfs(i,ver);
			pre[i]=prod;
			prod=mul(prod,dp[i]);
		}
	}
	vi temp=adj[ver];
	reverse(all(temp));
	prod=1;
	for(auto i:temp)
	{
		if(i!=par)
		{
			pre[i]=mul(pre[i],prod);
			prod=mul(prod,dp[i]);
		}
	}
	dp[ver]=add(dp[ver],prod);
}

void dfs2(ll ver,ll par)
{
	dp2[ver]=add(mul(dp2[par],pre[ver]),1);
	for(auto i:adj[ver])
	{
		if(i!=par)
		{
			dfs2(i,ver);
		}
	}
}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n>>MOD;        
    	rep(i,0,n-1)
    	{
    		ll x,y;cin>>x>>y;
    		adj[x].pb(y);
    		adj[y].pb(x);
    	}

    	dfs(1,0);
    	dfs2(1,0);

    	rep(i,1,n+1)cout<<mul(dp2[i],sub(dp[i],1))<<endl;

    }
    return 0;
        
}

Measured memory_bytes: 40832
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#define MOD 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
signed main(){
    int n,m;
    cin>>n>>m;
    int x[114514];
    vector<int> h;
    for(int i=0;i<m;i++){
        cin>>x[i];
    }
    sort(x,x+m);
    int sum=0;
    for(int i=1;i<m;i++){
        h.push_back(x[i]-x[i-1]);
        sum+=h[i-1];
    }
    sort(h.begin(),h.end(),greater<int>());
    for(int i=0;i<min({(ll)h.size(),m,n-1});i++){
        sum-=h[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S;
	string T = "CODEFESTIVAL2016";
	cin >> S;
	int count = 0;
	for (int i = 0; i < 16; i++) {
		if (S[i] != T[i]) {
			count++;
		}
	}
	cout << count << endl;
}

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

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

int main() {
  int n;
  cin >> n;
  int t = 10000000;
  int ans = 0;
  rep(i,0,n) {
    int p;
    cin >> p;
    if (chmin(t,p)) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<string>s(3);
  rep(i,3)cin>>s[i];
  int id=0;
  while(1){
    int nid=s[id][0]-'a';
    if(s[id].size()>1)s[id]=s[id].substr(1,s[id].size()-1);
    else if(s[id].size()==1)s[id]="";
    id=nid;
    if(s[id].size()==0){
      //cout<<id<<endl;
      cout<<(char)(id+'A')<<endl;
      return 0;
    }
  }

  return 0;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1


def main():
    d=[0]*M
    for i in range(N):
        for j in range(N):
            d[i*N+j]=min(min(i,N-1-i),min(j,N-1-j))
    used=[1]*M
    ans=0
    que=[]
    for p in P:
        ans+=d[p]
        used[p]=0
        que.append(p)
        while que:
            x=que.pop()
            for ddx in (-1,1,-N,N):
                nx=x+ddx
                if 0<=nx<M:
                    if used[x]==0 and d[nx]-d[x]>=1:
                        d[nx]-=1
                        que.append(nx)
                    elif used[x]==1 and d[nx]-d[x]>=2:
                        d[nx]-=1
                        que.append(nx)
    print(ans)

if __name__ == '__main__':
    N=int(input())
    M=N**2
    P=tuple(map(int1,input().split()))
    main()


Measured memory_bytes: 171000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextInt();
		double b = sc.nextInt();
		double h = sc.nextInt();
		double m = sc.nextInt();
		double ax, ay, bx, by, arad, brad;
		arad = (1/2 - h/6 - m/360)*Math.PI;
		brad = (1/2 - m/30)*Math.PI;
		ax = a * Math.cos(arad);
		bx = b * Math.cos(brad);
		ay = a * Math.sin(arad);
		by = b * Math.sin(brad);
		System.out.println(Math.sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by)));
	}
}


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

int main() {
    string S;
    cin >> S;
    int A = S.at(0) - '0' , B = S.at(1) - '0' , C = S.at(2) - '0' , D = S.at(3) - '0';
    if(A + B + C + D == 7){
        cout << A << '+' << B << '+' << C << '+' << D << "=7" << endl;
    }
    else if(A + B + C - D == 7){
        cout << A << '+' << B << '+' << C << '-' << D << "=7" << endl;
    }
    else if(A + B - C + D == 7){
        cout << A << '+' << B << '-' << C << '+' << D << "=7" << endl;
    }
    else if(A - B + C + D == 7){
        cout << A << '-' << B << '+' << C << '+' << D << "=7" << endl;
    }
    else if(A + B - C - D == 7){
        cout << A << '+' << B << '-' << C << '-' << D << "=7" << endl;
    }
    else if(A - B + C - D == 7){
        cout << A << '-' << B << '+' << C << '-' << D << "=7" << endl;
    }
    else if(A - B - C + D == 7){
        cout << A << '-' << B << '-' << C << '+' << D << "=7" << endl;
    }
    else if(A - B - C - D == 7){
        cout << A << '-' << B << '-' << C << '-' << D << "=7" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define repi(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) repi(i, 0, a)
#define repd(i, a, b) for(int i = (a); i >= (b); i--)
#define repit(i, a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)

#define all(u) (u).begin(), (u).end()
#define rall(u) (u).rbegin(), (u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)), (u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

const int N = 1200;

int dp[N][16] = {1}, c[N] = {1, 1};

void gen()
{
    for (int i = 2; i < N; ++i) {
	if (!c[i]) {
	    for (int j = N - 2; j >= i; --j) {
		for (int k = 1; k < 16; ++k) {
		    dp[j][k] += dp[j - i][k - 1];
		}
	    }
	    for (int j = i + i; j < N; j += i) {
		c[j] = 1;
	    }
	}
    }
}

int main(){
    gen();

    int n, k;
    while (cin >> n >> k && n) {
	cout << dp[n][k] << endl;
    }

    return 0;
}

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

int main() {
  ll a,b,c,A,B,C,count=0;
  cin >> a>> b >> c;
  if(a%2==1||b%2==1||c%2==1)cout<<0<<endl;
  else if(a==b&&b==c)cout<<-1<<endl;
  else{
    while(1){
      if(a%2==1||b%2==1||c%2==1)break;
      A=b/2+c/2;
      B=a/2+c/2;
      C=a/2+b/2;
      a=A; b=B; c=C;
      count++;
    }   
    cout<<count<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <iomanip>
#include <cstdio>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <queue>
using namespace std;






int main()
{
	int harray[101] = { 0 };
	int warray[101] = { 0 };
	int H, W, N;
	cin >> H >> W >> N;
	int hight = H;
	int width = W;

	int count = 0;
	int paint = 0;
	while (paint<N){

		if (hight<width) {
			paint += width;
			hight -= 1;
			count += 1;
		}
		else {
			paint += hight;
			width -= 1;
			count += 1;
		}
	}
	
	cout << count;

    return 0;
}


Measured memory_bytes: 256
def main():
  N,M = map(int, input().split())
  # PY = [list(map(int, input().split())) for _ in range(M)]
  PY = []
  for _ in range(M):
    PY.append(list(map(int,input().split())))  
  id = 1
  for row in PY:
    row.append(id)
    id += 1
  #print(PY)
  PY.sort(key = lambda x: (x[0], x[1]))
  #print(PY)

  tempP = 0
  for row in PY:
    if row[0] != tempP: 
      id = 1
    row.append(id)
    id += 1
    tempP = row[0]
  #print(PY)
  PY.sort(key = lambda x: x[2])
  #print(PY)

  for row in PY:
    print('{:0>6}{:0>6}'.format(row[0],row[3]))
  
main()

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

using namespace std;
typedef long long ll;

int n;
ll m , v, p;
const int maxn = 100000+5;
ll a[maxn];
ll s[maxn];

bool C(int k)
{
  if(k < p) return true;
  if(a[k]+m < a[p-1]) return false;
  ll sum = (p-1+n-k)*m; //biggest p-1 and smaller then u all vote
  for(int i=p-1; i<k; ++i) sum += min(m, a[k]+m-a[i]);
  return sum >= m*v;
}

int main()
{
  cin >> n >> m >> v >> p;
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a, a+n, greater<ll>());
  int L = -1;
  int R = n;
  int M;
  while(L < R-1) //index
  {
    M = (L+R)/2;
    if(C(M)) L = M;
    else R = M;
  }
  cout << L+1 << endl;
  return 0;
}


Measured memory_bytes: 1024
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    L = [i+A[i-1] for i in range(1,N+1)]
    R = [i-A[i-1] for i in range(1,N+1)]
    import collections
    Lcnter = collections.Counter(L)
    Rcnter = collections.Counter(R)
    values = set(Lcnter.keys()) & set(Rcnter.keys())
    ans = 0
    for i in values:
        ans += Lcnter[i]*Rcnter[i]
    print(ans)
    


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 196528
N, K = map(int, input().split())

kari = list()
count = 0
for i in range(2*10**5+1):
    count += i
    kari.append(count)
    
amount = 0
mod = 10**9+7
if K > N:
    print(1)
else:
    for i in range(K, N+2):
        if N-i >= 0:
            max_count = kari[N] - kari[N-i]
        else:
            max_count = kari[N]
        min_count = kari[i-1]
        count = max_count - min_count + 1 
        amount += count % mod
    print(amount%mod)

Measured memory_bytes: 82444
package main

import (
	"fmt"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	var c [3]int
	var p int
	for i := 0; i < n; i++ {
		fmt.Scan(&p)
		if p <= a {
			c[0]++
		} else if a < p && p <= b {
			c[1]++
		} else {
			c[2]++
		}
	}
	ans := min(c[0], min(c[1], c[2]))
	fmt.Println(ans)
}


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

int main(){
    int N;
    cin >> N;
    int odds;
    if( N % 2 == 0){
        odds = N / 2;
    }else {
        odds = N / 2 + 1;
    }
    double ans = (double)odds / (double)N;
    cout << fixed << setprecision(7) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
 class Main {
	public static void main(String[]args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int count = 0 ;
		Main m = new Main();
		
		ArrayList<Var>  a = new ArrayList<>();
		for(int i = 0 ; i < n ; i++) {
			
			 a.add(m.new Var(scan.next() , scan.nextInt() , i+1));
			 //System.out.println(a.get(i).s);
		}
		
		Collections.sort(a,new Comparator<Var>() {

			@Override
			public int compare(Var o1, Var o2) {
				if(o1.s.compareTo(o2.s) != 0)
					return o1.s.compareTo(o2.s) ;
				else {
					return o1.a < o2.a ? 1:-1;
				}
			      
			}
			
		});
		//System.out.print(a);
		
		for(int i = 0 ; i < n ; i++) {
			System.out.println(a.get(i).id);
		}

	 
		
	}
	class Var{
		String s ; 
		int  a ;
		int id ;
		Var(String s  , int a , int id){
			this.a =a ; 
			this .s =s ; 
			this.id = id ;
		}
	}


}	

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll, ll>
using namespace std;

const ll INF = 1e18+7;
const int maxN = 300005;


main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    set<pair<int, pii>>  a, b;
    for (int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        a.insert({max(x,y), {x,y}});
    }
    for (int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        b.insert({min(x,y), {x,y}});
    }
    int res = 0;
    for (auto it = a.rbegin();it!=a.rend();it++)
    {
        for (auto p:b)
        {
            auto pp = (*it);
            if (pp.ss.ff<p.ss.ff&&pp.ss.ss<p.ss.ss)
            {
                b.erase(p);
                res++;
                break;
            }
        }

    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 202;
int n, l;

int main() {
    cin >> n >> l;
    int ans = -1, v = 1e5;
    for(int i=1; i<=n; i++) {
        int u = abs(i+l-1);
        if(u < v) {
            v = u;
            ans = n*(n+1)/2 - i + (n-1)*(l-1);
        }
    }
    cout << ans;
}


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

int main() {
    int h,w;cin>>h>>w;
    string s[h];
    for (int i=0;i<h;i++)
        cin>>s[i];
    int l[h][w]{},r[h][w]{},u[h][w]{},d[h][w]{};
    for (int i=0;i<h;i++)
        for (int j=1;j<w;j++)
            if (s[i][j-1]=='.'&&s[i][j]=='.')
                l[i][j]=l[i][j-1]+1;
    for (int i=0;i<h;i++)
        for (int j=w-2;j>=0;j--)
            if (s[i][j+1]=='.'&&s[i][j]=='.')
                r[i][j]=r[i][j+1]+1;
    for (int i=0;i<w;i++)
        for (int j=1;j<h;j++)
            if (s[j-1][i]=='.'&&s[j][i]=='.')
                u[j][i]=u[j-1][i]+1;
    for (int i=0;i<w;i++)
        for (int j=h-2;j>=0;j--)
            if (s[j+1][i]=='.'&&s[j][i]=='.')
                d[j][i]=d[j+1][i]+1;
    int mx=0;
    for (int i=0;i<h;i++)
        for (int j=0;j<w;j++)
            if (s[i][j]=='.')
                mx=max(mx,l[i][j]+r[i][j]+u[i][j]+d[i][j]+1);
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 66816
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> //Policy Based Data Structure
// using namespace __gnu_pbds;              //Policy Based Data Structure
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; //Policy Based Data Structure
// #define gc              getchar_unlocked
// #define pqb             priority_queue<int>
// #define pqs             priority_queue<int, vi, greater<int> >
// #define mk(arr,n,type)  type *arr = new type[n]
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int             long long
#define endl            '\n'
#define w(t)            int t; cin>>t; while(t--)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x,y)       cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define tr(it,a)        for(auto it = a.begin(); it != a.end(); it++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define PI              3.1415926535897932384626
#define inf             1e18
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());  //Random Shuffler
typedef pair<int, int>   pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
typedef map<int, int>    mii;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
// const int N = 3e5, M = N;
// vi g[N];
//=======================

void sol()
{
	int n;
	cin >> n;
	if (n == 1)
		cout << 0;
	else
		cout << 1;
}

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	sol();

	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = (result * base) % mod;
		base = (base * base) % mod;
		exp >>= 1;
	}
	return result;
}

// void ipgraph(int n, int m){
//     int i, u, v;
//     while(m--){
//         cin>>u>>v;
//         g[u-1].pb(v-1);
//         g[v-1].pb(u-1);
//     }
// }
//
// void dfs(int u, int par){
//     for(int v:g[u]){
//         if (v == par) continue;
//         dfs(v, u);
//     }
// }

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void dfs(int now, vi &list, const vii &f, vb &seen) {
  list.push_back(now);
  seen[now] = true;
  for(int ne : f[now]) {
    if(seen[ne]) continue;
    dfs(ne,list,f,seen);
  }
}

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

  int n, m, k;
  cin >> n >> m >> k;
  vii f(n), b(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    f[a].push_back(b);
    f[b].push_back(a);
  }
  rep(i,k) {
    int c, d;
    cin >> c >> d;
    c--; d--;
    b[c].push_back(d);
    b[d].push_back(c);
  }
  vi ans(n);
  vb seen(n);
  rep(i,n) {
    if(seen[i]) continue;
    vi list;
    dfs(i,list,f,seen);
    sort(all(list));
    for(int j : list) {
      int tmp = sz(list) - (sz(f[j]) + 1);
      for(int l : b[j]) {
        tmp -= (binary_search(all(list), l)?1:0);
      }
      ans[j] = tmp;
    }
  }

  rep(i,n) {
    cout << ans[i] << ' ';
  }
}

Measured memory_bytes: 13696
n=int(input())
xy=[list(map(int,input().split()))for _ in range(n)]
from itertools import permutations
ans=0
for i in permutations(range(n),n):
	for j in range(1,n):
		x,y=j-1,j
		ans+=((xy[i[x]][0]-xy[i[y]][0])**2+(xy[i[x]][1]-xy[i[y]][1])**2)**0.5
for i in range(n):ans/=i+1
print(ans)

Measured memory_bytes: 3064
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
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	var allDone bool
	var min int
	for !allDone {
		sort.Ints(A)
		min = A[0]
		allDone = true
		for i := 1; i < N; i++ {
			if A[i]%min != 0 {
				A[i] = A[i] % min
				min = A[i]
				allDone = false
			}
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 3072
import math
a, b, h, m = (int(x) for x in input().split())

hour = h * (360/12) + m * 1/2
minute = m * (360/60)

ang = abs(minute - hour)
ang = 360 - ang

x = a*a + b*b -2*b*a * math.cos(math.radians(ang))
print(math.sqrt(x))

Measured memory_bytes: 9572
#include<stdio.h>
#include<string.h>
#define N 1001
 
int n;
 
int lcs(char x[],char y[]){
  int i,j,a[N][N];
  int m=strlen(x);
  int n=strlen(y);
 
  for(i=1;i<=m;i++) a[i][0]=0;
  for(j=0;j<=n;j++) a[0][j]=0;
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i-1]==y[j-1]) a[i][j]=a[i-1][j-1]+1;
      else if(a[i-1][j]>=a[i][j-1]) a[i][j]=a[i-1][j];
      else a[i][j]=a[i][j-1];
    }
  }
  return a[m][n];
}
 
int main(){
  int i,A[N];
  char x[N],y[N];
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%s",&x);
    scanf("%s",&y);
    A[i]=lcs(x,y);
  }
  for(i=0;i<n;i++) printf("%d\n",A[i]);
 
  return 0;
}


Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  int n;
  cin >> n;
  VI a(n);
  ll ans=0;
  rep(i,n){
    cin >> a.at(i);
  ans+=a.at(i)-1;
}
  cout << ans << endl;
}

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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     ll n,m;
     cin >> n >> m;
     if(n<m)swap(n,m);
     if(n > m+1)cout << 0;
     else{
        if(n==m+1){
          ll prod=1;
          for(ll i=1;i<=n;i++){
             prod = (prod%MOD*i%MOD)%MOD;
          }
          for(ll i=1;i<=m;i++){
             prod = (prod%MOD*i%MOD)%MOD;
          }
          cout << prod;
        }
        else{
          ll prod=2;
          for(ll i=1;i<=n;i++){
             prod = (prod%MOD*i%MOD)%MOD;
          }
          for(ll i=1;i<=m;i++){
             prod = (prod%MOD*i%MOD)%MOD;
          }
          cout << prod;
        }
     }
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c=0,d,i;
  scanf("%d %d %d",&a,&b,&d);
  for(i=a;i<=b;i++){
    if(i%d==0)c++;
  }
  printf("%d\n",c);
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int fif = n/15;
  cout << 800*n - 200*fif << endl;
  return 0;
}


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

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int x = sc.nextInt();
    int sum = 0;
    int count = 0;

    for (int i = 0; i <= a; i++) {
      for (int j = 0; j <= b; j++) {
        for (int k = 0; k <= c; k++) {
          sum = 500*i + 100*j + 50*k;
          if (sum == x) {
            count++;
          }
        }
      }
    }

    System.out.println(count);

  }

}


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

int main() {
  string S;
  cin >> S;
  long ans = 0;
  for (int i = 0, cnt = 0; i < S.size(); i++) {
    if (S.at(i) == 'B') cnt++;
    else ans += cnt;
  }
  cout << ans << "\n";
}

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


int main() {
  
  int N;
  cin >> N;
  
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,nl,i=0,k=0;
  char s[100],t[100],str[200];
     cin>>n;
  nl=2*n;
  
  while((getchar())!='\n');
  for(i=0;i<n;i++)
      cin>>s[i];
      
      
  while((getchar())!=' ');
  for(i=0;i<n;i++)
      cin>>t[i];
      
      
  for(i=0,k=0;k<n;i=i+2,k++)
    str[i]=s[k];
  for(i=1,k=0;k<n;i=i+2,k++)
    str[i]=t[k];
  for(i=0;i<nl;i++)
  cout<<str[i];
  return 0;
}


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

int main (){
  int N;
  cin >> N;
  int sum = 0;
  int minused = N;
  for(int i = 8; i >= 0 ; i--){
    int powered = std::pow(10, i);
    
    int quotient = minused / powered;
    //cout <<"i : " << i << "-" <<" powered : "<< powered << " quotient : " << quotient << endl;
    sum += quotient;
    minused -= quotient * powered;
    
    //cout <<"minused : " <<minused << endl;
  }
  //cout << "sum : " << sum <<endl;
  
  if(N % sum == 0){
    cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}

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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

int main() {
    int n;
    cin >> n;
    int x[n];
    int y[n];
    for(int i = 0;i<n;i++) {
        cin >> x[i] >> y[i];
    }
    double leng = 0;
    VI flag(n,0);
    LL count = 0;

    for(int i = 0;i<n;i++) {
        for(int j = 0;j<n;j++) {
            if(i != j) {
                leng += sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
                count++;
            }
        }
    }
    //cout << leng;
    //cout << endl;

    //cout << n << endl;
    leng *= n-1;

    //cout << leng << endl;

    leng /= count;

    printf("%.16f", leng);
    cout << endl;

}

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

int main() {
  int N, D, Y=0, cnt=0;
  cin >> N >> D;
  vector<vector<int>> X(N,vector<int>(D));
  rep(i, N){
    rep(j, D){
    cin >> X.at(i).at(j);
    }
  }
  rep(i, N-1){
    for(int k=i+1; k<N; k++){
      rep(j, D) Y=Y+(X.at(i).at(j)-X.at(k).at(j))*(X.at(i).at(j)-X.at(k).at(j));
      for (int l=0; l*l<=Y; l++){
        if(l*l==Y) cnt++;
      }
      Y=0;
    }
  }
  cout << cnt << endl;
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

inline int Query(int x) {
  char s[10];
  printf("%d\n", x);
  fflush(stdout);
  scanf("%s", s);
  return s[0] == 'V' ? -1 : s[0] == 'F';
}

int main() {
#ifdef wxh010910
#endif
  int n, l, r, u, v;
  Read(n), l = 0, r = n, u = v = Query(0);
  if (~u) {
    while (true) {
      int m = l + r >> 1, t = Query(m);
      if (!~t) {
        break;
      } else if ((m ^ l ^ u ^ t) & 1) {
        r = m, v = t;
      } else {
        l = m, u = t;
      }
    }
  }
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 852
a,b = gets.split.map(&:to_i)

if a == b
  puts a + b
end

if (a > b) && ((a - b) >=2)
  puts a + (a-1)
elsif  (a > b) && (a - b) < 2
  puts a + b
end

if b > a && (b - a) >=2
  puts b + (b-1)
elsif  (b > a) &&  ((b - a) < 2)
  puts b + a
end


Measured memory_bytes: 1788
# coding: utf-8

N = int(input())
S = input()

east = S.count("E")
west = 0


res = 1000000
for i in range(len(S)):
    if S[i] == "E":
        east -= 1
    res = min(res, east + west)
    if S[i] == "W":
        west += 1

print(res)


Measured memory_bytes: 9592
from math import fabs, sqrt

n = int(input())
x = list(map(float, input().strip().split()))
y = list(map(float, input().strip().split()))

sum1 = 0
sum2 = 0
sum3 = 0
pil = []

for i in range(n):
    sum1 += fabs(x[i] - y[i])
    sum2 += fabs(x[i] - y[i]) ** 2
    sum3 += fabs(x[i] - y[i]) ** 3
    pil.append(fabs(x[i] - y[i]))

pil = sorted(pil)
p1 = sum1
p2 = sqrt(sum2)
p3 = sum3 ** (1 / 3)
pi = pil[n-1]

print(round(p1, 8))
print(round(p2, 8))
print(round(p3, 8))
print(round(pi, 8))


Measured memory_bytes: 5724
#include <stdio.h>
#define N 100

int A[N+1][N+1], s[N+1], b[N+1], c[N+1], n, t;

void d(int p){
  int i;
  
  b[p] = t++;
  
  for(i=1;i<=s[p];i++) if(!b[A[p][i]]) d(A[p][i]);
  c[p] = t++;
}

int main(){
  int i, j, u, v;
  
  scanf("%d", &n);
  t = 1;
  
  for(i=1;i<=n;i++){
    b[i] = c[i] = 0;
    scanf("%d", &u);
    scanf("%d", &s[u]);
    
    for(j=1;j<=s[u];j++) scanf("%d", &A[u][j]);
  }
  
  for(i=1;i<=n;i++) if(!b[i]) d(i);
  for(i=1;i<=n;i++) printf("%d %d %d\n", i, b[i], c[i]);

  
  return 0;
}



Measured memory_bytes: 2088