akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

void warshall_floyd(int n, vector<vector<ll>> &distances) {
    for (int k = 0; k < n; k++) {       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                if (distances[i][j] == INF && (distances[i][k] == INF || distances[k][j] == INF)) {
                    distances[i][j] = INF;
                } else {
                    distances[i][j] = min(distances[i][j], distances[i][k] + distances[k][j]);
                }
            }
        }
    }
}

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<ll>> magic_point(10, vector<ll>(10));
    rep(y, 10) rep(x, 10) cin >> magic_point[y][x];
    warshall_floyd(10, magic_point);
    vector<vector<int>> wall(h, vector<int>(w));
    rep(y, h) rep(x, w) cin >> wall[y][x];

    ll ans = 0;
    rep(y, h) rep(x, w) if (wall[y][x] != -1) ans += magic_point[wall[y][x]][1];
    cout << ans << endl;
}

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

int main(){
  int n,m,c;
  cin >> n >> m >> c;
  
  vector<int> b(m);
  for(int i = 0; i < m; ++i){
    cin >> b[i];
  }
  
  int a[n][m];
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      cin >> a[i][j];
    }
  }
  
  int res = 0;
  
  for(int i = 0; i < n; ++i){
    int p = 0;
    for(int j = 0; j < m; ++j){
      p += a[i][j] * b[j];
    }
    p += c;
    
    if(p > 0){
      ++res;
    }
  }
  
  cout << res;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

ll powmod(ll x,ll n,ll mod){
    if(n == 0)return 1;
    if(n%2)return x*powmod(x*x%mod,n/2,mod)%mod;
    return powmod(x*x%mod,n/2,mod)%mod;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    string s; cin >> s;
    ll count = 0; rep(i,n)if(s[i] == '1')count++;
    ll x_p= 0,x_m = 0;
    rep(i,n){
        if(s[i] == '1'){
        x_p += powmod(2,n-i-1,count+1);
        x_p %= count+1;
        }
    }
     if(count >= 2){
        rep(i,n){
            if(s[i] == '1'){
            x_m += powmod(2,n-i-1,count-1);
            x_m %= count-1;
            }
        }
    }
    rep(i,n){
        if(s[i] == '1'){
            if(count == 1){
                cout << 0 << endl;
                continue;
            }
            ll x_ = (x_m - powmod(2,n-i-1,count-1)+count-1)%(count-1);
            ll ans = 1;
            while(x_ != 0){
                ll p = 0,r = x_;
                while(r != 0){
                    if(r%2 != 0)p++;
                    r /= 2;
                }
                x_ %= p;
                ans++;
            }
            cout << ans << endl;
        }
        else{
            ll x_ = (x_p + powmod(2,n-i-1,count+1))%(count+1);
            ll ans = 1;
           while(x_ != 0){
                ll p = 0,r = x_;
                while(r != 0){
                    if(r%2 != 0)p++;
                    r /=2;
                }
                x_ %= p;
                ans++;
            }
            cout << ans << endl;
        }
    }

}

Measured memory_bytes: 3784
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll K;
  cin>>K;
  ll a[50];
  for(int i=0;i<50;++i) {
    if(K%50>i) {
      a[i] = 50 - 1 + 50*(K/50+1)+(K/50+1)-K;
    }
    else {
      a[i] = 50 - 1 + 50*(K/50)+(K/50)-K;
    }
  }
  cout<<50<<endl;
  for(int i=0;i<50;++i) cout<<a[i]<<" ";
  cout<<endl;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  cin >> n >> m;
  vector<ll> h(n);
  REP(i,n) cin >> h[i];
  vector<int> highest(n, 1);
  REP(i,m){
    int a,b;
    cin >> a >> b;
    a--, b--;
    if(h[a]<=h[b]) highest[a] = 0;
    if(h[a]>=h[b]) highest[b] = 0;
  }
  int ans = 0;
  REP(i,n) ans += highest[i];
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4520
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
const ll INF = 1e18L + 5;

void max_self(ll &a, ll b){
	a = max(a,b);
	}
void min_self(ll &a, ll b){
	a = min(a,b);
	}
	
int main(){
	int n,W;
	scanf("%d%d",&n,&W);
	int max_val = 0;
	vector<int> w(n), v(n);
	for(int i = 0 ; i < n; ++i){
		scanf("%d%d",&w[i],&v[i]);
		}
	for(int i = 0; i < n; ++i){
		max_val += v[i];
		}
	vector<ll> dp(max_val + 1,INF);
	dp[0] = 0;
	for(int i = 0; i < n; ++i){
		for(int j = max_val - v[i]; j >= 0; --j ){
			min_self( dp[j + v[i]] , dp[j] + w[i] );
			}
		}
	ll answer = 0;
	for(int i = 0 ; i <= max_val; ++i){
		if( dp[i] <= W){
			max_self(answer, (ll) i);
			}
	}
		
	printf("%lld",answer);
		
}

Measured memory_bytes: 1024
#include<cstdio>
using namespace std;
int n,h[100010],dp[100010];
int abss(int a,int b){
	return a>b?a-b:b-a;
}
int minn(int a,int b){
	return a>b?b:a;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&h[i]),dp[i]=0x3f3f3f3f;
	dp[1]=0;
	for(int i=1;i<n;i++)
	dp[i+1]=minn(dp[i+1],dp[i]+abss(h[i],h[i+1])),
	dp[i+2]=minn(dp[i+2],dp[i]+abss(h[i],h[i+2]));
	printf("%d",dp[n]);
}

Measured memory_bytes: 896
import datetime
while 1:
    lis = list(map(int, input().split()))
    if min(lis) < 0: break
    y1,m1,d1,y2,m2,d2 = lis
    a = datetime.date(y1,m1,d1)
    b = datetime.date(y2,m2,d2)
    c = b - a
    print(c.days)


Measured memory_bytes: 6032
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

#define M 1000000007LL

int isp[1000];
int a[10000];
vector<int> p;
int np;
map<int, int> m;

void dc(int a) {
    for (int i = 0; i < np && a > 1; i++) {
        int c = 0;
        while (a%p[i] == 0) {
            a /= p[i];
            c++;
        }
        if (c && m[p[i]] < c)
            m[p[i]] = c;
    }
    if (a > 1 && m[a] == 0)
        m[a] = 1;
}

int pw(int a, int b) {
    int r = 1;
    for (int i = 0; i < b; i++)
        r *= a;
    return r;
}

ll pw2(ll a, ll b) {
    if (b == 0)
        return 1LL;
    ll x = pw2(a, b/2);
    x = (x*x)%M;
    if (b%2)
        return (x*a)%M;
    return x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(isp, -1, sizeof(isp));
    p.push_back(2);
    for (int i = 3; i < 1000; i+=2)
        if (isp[i]) {
            p.push_back(i);
            for (int j = i*3; j < 1000; j+=2*i)
                isp[j] = 0;
        }
    np = p.size();

    int n = gi();
    for (int i = 0; i < n; i++) {
        a[i] = gi();
        dc(a[i]);
    }

    ll b = 1;
    for (auto &it : m) {
        b *= pw(it.first, it.second);
        b %= M;
    }

    ll r = 0;
    for (int i = 0; i < n; i++) {
        r += b*pw2(a[i], M-2);
        r %= M;
    }

    cout << r << endl;

    return 0;
}


Measured memory_bytes: 768
fun main(args:Array<String>): Unit {
    val n = readLine()!!.toInt()
    val nums = Array(n){readLine()!!.toLong()}.sortedArray()
    if (n % 2 == 1){
        val min = nums.take(n / 2)
        val mid = nums[n / 2]
        val max = nums.takeLast(n / 2)
        val minMax = min.last()
        val maxMin = max.first()
        println(
                if (mid - minMax < maxMin - mid) max.sum() * 2 - min.sum() * 2 - mid + minMax
                else max.sum() * 2 - min.sum() * 2 + mid - maxMin
        )
    }else {

        println(
                nums.takeLast(n / 2).sum() * 2 - nums.take(n / 2).sum() * 2 - nums.takeLast(n / 2).min()!! + nums.take(n / 2).max()!!
        )
    }
}

Measured memory_bytes: 44320
import java.io.*;
import java.util.*;
 class Main
{
public static void main(String arg[])
{
Scanner s=new Scanner(System.in);
int a=s.nextInt();
boolean flag=true;
for(int i=1;i<=9;i++)
{if(a%i==0)
{int k=a/i;
if(k>=1 && k<=9)
{flag=true;break;}
else
flag=false;}}
if(flag)
System.out.println("Yes");
else
System.out.println("No");}}


Measured memory_bytes: 22740
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <cmath>



using namespace std;
typedef long long unsigned int ll;





#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {
	int N;
	scanf("%d", &N);
	int k;
	scanf("%d", &k);
	int answer = N - k+1;
	printf("%d", answer);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
void init(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main()
{
  init();
  int n; 
  cin >> n;
  vecint h(n,0); REP(i,n){cin >> h[i];}
  vecint dp(n,0);
  REP(i,n - 1){
    if(i == 0){
      dp[i + 1] = dp[i] + abs(h[i + 1] - h[i]);
    }else{
      dp[i + 1] = min(dp[i] + abs(h[i + 1] - h[i]),dp[i - 1] + abs(h[i +1] - h[i - 1]));
    }
  }
  cout << dp[n - 1] << endl;
}


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

void add(vector<int> &p, int x) {
  if (p.at(x) == -1) p.at(x) = 0;
}

int root(vector<int> &p, int x) {
  add(p, x);
  while (p.at(x) != 0) {
    x = p.at(x);
  }
  return x;
}

void merge(vector<int> &p, int x, int y) {
  int rx = root(p, x), ry = root(p, y);
  if (rx != ry) p.at(ry) = rx;
}

/*
bool isallsame(vector<int> p) {  
  rep2(i, 1, p.size()) {
    if (root(p, 1) != root(p, i)) return false;
  }
  return true;
}
*/

void show(vector<vector<int>> L) {
  rep(i, L.size()) {
    rep(j, L.at(i).size())
      cout << L.at(i).at(j) << " ";
    cout << endl;
  }
}

void show(vector<int> p) {
  rep(i, p.size()) cout << p.at(i) << " ";
  cout << endl;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> L(N); // 0-indexed
  int K, Lij;
  rep(i, N) {
    cin >> K;
    rep(j, K) {
      cin >> Lij; // 1-indexed
      L.at(i).push_back(Lij);
    }
  }

  vector<int> p(M + 1, -1); // 1-indexed
  // show(p); //DB
  rep(i, N) {
    rep(j, L.at(i).size()) {
      merge(p, L.at(i).at(0), L.at(i).at(j));
      // show(p); //DB
    }
  }

  int k, r;
  rep2(i, 1, p.size()) {
    if (p.at(i) != -1) {
      k = i;
      r = p.at(i);
      // cout << "k:" << k << ",r:" << r << endl;
      break;
    }
  }

  bool f = true;
  rep2(i, k, p.size()) {
    if (p.at(i) != -1 && root(p, i) != root(p, k)) {
      f = false;
      break;
    }
  }
      
  if (f) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 6144
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

#define MAX_V 1000

using namespace std;

// quoted from "Programming Contest Challenge Book" (Takuya Akiba)
struct edge {
    int to;
    int cap;
    int rev;
};

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, int cap) {
    // 正方向のedge 負方向のedgeのitを追加 (次の行でpush_backされる要素のitはsize())
    G[from].push_back((edge){to, cap, (int)(G[to].size())});

    // 負方向のedge capacity = 0, (前の行でpush_backされた要素のitはsize() - 1)
    G[to].push_back((edge){from, 0, (int)(G[from].size() - 1)});
}

// sからの最短距離をBFSで計算する
void bfs(int s) {
    memset(level, -1, sizeof(level));
    queue<int> que;

    // s->sの距離は0
    level[s] = 0;
    que.push(s);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        // vに接続されている全てのエッジe
        for (auto& e : G[v]) {
            // まだ流せる && 未到達
            // (幅優先なので，後ろの訪問で，よりlevelが小さくなることはない)
            if (e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

int dfs(int v, int t, int f) {
    if (v == t) return f;

    for (int& i = iter[v]; i < G[v].size(); ++i) {
        edge& e = G[v][i];
        // まだ流せる && パスをたどる経路
        if (e.cap > 0 && level[v] < level[e.to]) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }

    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;

    while (true) {
        bfs(s);
        if (level[t] < 0) {
            // 増加パスで，tに到達可能なものがない
            return flow;
        }
        memset(iter, 0, sizeof(iter));
        int f;
        while ((f = dfs(s, t, 1 << 30)) > 0) flow += f;
    }
}

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

int main(void) {
    int N;
    cin >> N;
    int source = 2 * N;
    int sink = 2 * N + 1;

    vector<pair<int, int>> red, blue;

    REP(i, N) {
        int a, b;
        cin >> a >> b;
        red.emplace_back(a, b);
    }

    REP(i, N) {
        int a, b;
        cin >> a >> b;
        blue.emplace_back(a, b);
    }

    REP(i, N) {
        REP(j, N) {
            if (red[i].first < blue[j].first && red[i].second < blue[j].second) {
                add_edge(i, N + j, 1);
            }
        }
    }

    REP(i, N) {
        add_edge(source, i, 1);
        add_edge(i + N, sink, 1);
    }

    cout << max_flow(source, sink) << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std ;

const int maxn = 1e5 + 100 ;
int a[maxn] ;

int main()
{
        int n  ,t ;
        int minn = 1e6 ;
        int temp ,ans =0;
        cin >> n ;

        memset(a ,0 ,sizeof a) ;
        while(n--)
        {
                cin >> t ;
                minn = min(minn ,t) ;
                a[t]++ ;
        }

        for(int i =1; i <=n ;i++) cout << a[i] << ' ' ;
        cout << endl ;

        for(int i =minn ;i  <=maxn ;i++)
        {
                if(i >=2 + minn)
                {
                     temp = a[i] + a[i-1] +a[i-2] ;
                     ans = max(ans ,temp) ;
                }
        } cout << ans << endl ;
        /*for(int i=0;i<n;i++)
                cin>>a[i];
        sort(a,a+n);
        int ans=0;
        for(int i=0;i<n;i++)
        {
                int l=i,r=n-1;
                int m;
                while(l<r)
                {
                        cout<<l<<" "<<r<<endl;
                         m=(l+r)/2;
                        if(a[m]-a[i]>2)
                        {
                                r=m-1;
                        }
                        else
                                l=m;
                }
                ans=max(ans,m-i+1);
        }
        cout<<ans<<endl;*/

        return 0 ;
}


Measured memory_bytes: 640
#include<cstdio>
#include<map>
#include<algorithm>
#define N 1000400
using namespace std;
int n,v2[N],fa[N];
long long v[N],sz[N],ds[N];
map<long long,int> tp;
bool cmp(int a,int b){return v[a]<v[b];}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&v[i]),tp[v[i]]=i,v2[i]=i,sz[i]=1;
	sort(v2+1,v2+n+1,cmp);
	for(int i=n;i>1;i--)
	{
		long long tp2=v[v2[i]]-n+sz[v2[i]]*2;
		if(!tp[tp2]){printf("-1\n");return 0;}
		int sb=tp[tp2];
		ds[sb]+=ds[v2[i]]+sz[v2[i]];
		sz[sb]+=sz[v2[i]];
		fa[v2[i]]=sb;
	}
	if(ds[v2[1]]!=v[v2[1]]){printf("-1\n");return 0;}
	for(int i=1;i<=n;i++)if(fa[i])printf("%d %d\n",i,fa[i]);
}

Measured memory_bytes: 20736
#include <iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<cmath>
#include<iomanip>
using namespace std;

const double PI  =3.141592653589793238463;
#define pb push_back
#define pf push_front
#define sz(v)  ((int)(v).size());
#define all(v) ((v).begin()),((v).end())
typedef unsigned long long ull;
typedef long long ll;

typedef vector<int> vi;
typedef pair<int,int> pi;
//2 7 3 4 9

void printVec(vi v1)
{
    for(int i=0; i<v1.size(); i++)
        cout<<v1[i]<<" ";
    cout<<endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);


 int n;cin>>n;
 int a;
 int cnt=0;
 for(int i=1;i<=n;i++){
    cin>>a;
    if(a%2!=0 && i%2!=0){
cnt++;
    }
 }

 cout<<cnt<<endl;
    return 0;

}


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

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int result=max(a*10+b+c, a+b*10+c);
    result=max(result, a+b+10*c);
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
lis = [0] + list(map(int, input().split())) + [0]
tmp = []
for j in range(len(lis)-1):
    tmp.append(lis[j+1] - lis[j])
lis = list(map(abs,tmp))
preans = sum(lis)
for i in range(len(tmp)-1):
    print(preans - lis[i] - lis[i+1] + abs(tmp[i] + tmp[i+1]))


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

#define MAX_N (100)
#define SIZE_BUF (30)

int main(int argc, char *argv[]) {
  // read inputs
  int N;
  char s[MAX_N], buf[SIZE_BUF];
  scanf("%d", &N);
  fgets(buf, SIZE_BUF, stdin);
  for (int i = 0; i < N; i++) {
    s[i] = fgetc(stdin);
  }

  // move to working space
  char str[3 * MAX_N];
  int b = N, e = b + N;
  for (int i = 0; i < N; i++) {
    str[b + i] = s[i];
  }

  // solve
  while (1) {
    int count_open = 0;
    for (int i = b; i < e; i++) {
      if (str[i] == '(') {
        count_open++;
      } else {
        count_open--;
        if (count_open < 0) {
          break;
        }
      }
    }
    if (count_open > 0) {
      str[e++] = ')';
    } else if (count_open < 0) {
      str[--b] = '(';
    } else {
      break;
    }
  }
  for (int i = b; i < e; i++) {
    printf("%c", str[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Switches solver = new Switches();
        solver.solve(1, in, out);
        out.close();
    }

    static class Switches {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[][] s = new int[m + 1][n + 1];
            int[] p = new int[m + 1];

            // 電球m
            for (int i = 1; i <= m; i++) {
                int k = in.nextInt();
                // スイッチn
                for (int j = 1; j <= k; j++) {
                    int sw = in.nextInt();
                    s[i][sw] = 1;
                }
            }

            for (int i = 1; i <= m; i++) {
                // 電球mの条件
                p[i] = in.nextInt();
            }

            long result = 0;
            for (int bit = 0; bit < (1 << n); bit++) {
                int[] judge = new int[m + 1];
                for (int j = 1; j <= m; j++) {
                    for (int k = 0; k < n; k++) {
                        if ((1 & (bit >> k)) == 1) {
                            if (s[j][k + 1] == 1) {
                                judge[j]++;
                            }
                        }
                    }
                }
                boolean is_on = true;
                for (int i = 1; i <= m; i++) {
                    if (judge[i] % 2 != p[i]) {
                        is_on = false;
                        break;
                    }
                }
                if (is_on) {
                    result++;
                }
            }

            out.print(result);
        }

    }
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

const int MAX_N = 212345;

struct UnionFind {
  vector<int> data; // 根の場合は集合の大きさ*-1、子の場合は親の番号が入る
  UnionFind(int size) : data(size, -1) { }
  bool link(int x, int y) { //新たな併合を行うとtrue
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int root(int x) { // 代表元を返す
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) { // 要素xが含まれる集合の大きさ
    return -data[root(x)];
  }
  bool same(int x, int y) { // 同じ集合ならtrue
    return root(x) == root(y);
  }
};

struct Edge {
  int a;
  int b;
  ll w;
  bool operator < (const Edge& o) const {
    return w < o.w;
  }
};

const ll INF = 1LL << 61;
struct RMQ {
  typedef pair<ll, int> Val;
  int n;
  vector<Val> vs;
  void clear(int N) {
    for (n = 1; n < N; n <<= 1);
    vs.assign(n * 2, {INF, -1} );
  }
  Val get(int pos) {
    return vs[n+pos];
  }
  void update(int pos, Val val) {
    vs[n+pos] = val;
    for (int k = (n+pos)/2; k > 0; k >>= 1)
      vs[k] = min(vs[2*k], vs[2*k+1]);
  }
  // [l, r) の最小値を返す
  Val query(int l, int r) {
    return query(0, n, 1, l, r);
  }
  Val query(int nl, int nr, int k, int l, int r) {
    if (r <= nl || nr <= l) return { INF, -1 } ;
    if (l <= nl && nr <= r) return vs[k];
    Val x = query(nl, (nl+nr)/2, 2*k  , l, r);
    Val y = query((nl+nr)/2, nr, 2*k+1, l, r);
    return min(x, y);
  }
};


int nextInt() { int x; scanf("%d", &x); return x;}

ll A[MAX_N];
pair<ll, int> P[MAX_N];

int main2() {
  int N = nextInt();
  ll D = nextInt();
  REP(i, N) A[i] = nextInt();
  REP(i, N) P[i] = {A[i], i};
  sort(P, P+N);

  RMQ rmq_l, rmq_r;
  rmq_l.clear(MAX_N);
  rmq_r.clear(MAX_N);

  vector<Edge> es;
  REP(iii, N) {
    int i = P[iii].second;
    {
      auto res = rmq_l.query(0, i);
      int j = res.second;
      if (j != -1)
        es.push_back((Edge) {i, j, A[i] + A[j] + abs(i-j) * D});
    }
    {
      auto res = rmq_r.query(i+1, N+1);
      int j = res.second;
      if (j != -1)
        es.push_back((Edge) {i, j, A[i] + A[j] + abs(i-j) * D});
    }
    rmq_l.update(i, { A[i] - i * D, i } );
    rmq_r.update(i, { A[i] + i * D, i } );
  }
  sort(ALL(es));

  ll ans = 0;
  UnionFind uf(N);
  for (Edge e : es) {
    // cout << e.a << " " << e.b << " " << e.w << endl;
    if (uf.link(e.a, e.b)) {
      ans += e.w;
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 31724
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define PI acos(-1)

using namespace std;




int main(void)
{
	//変数の宣言
	int n;
	static int a[200010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	int ok,ng;



	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
//		scanf_s("%d",&a[i]);
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理
	if(n==1){
		if(a[0]==0){
			printf("0");
		}else{
			printf("-1");
		}
		return 0;
	}
	for(i=n-1;i>=0;i--){
		a[i]=i-a[i];
		if(i==n-1){
			ans=ans+i-a[i];
		}else{
			if(a[i]>a[i+1]||a[i]<0){
				printf("-1");
				return 0;
			}else if(a[i]<a[i+1]){
				ans=ans+i-a[i];
			}
		}
	}

	//	printf("計算部分終了\n");

	//出力


	printf("%lld",ans);


	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()

N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
N = int(input())
print(3 * N ** 2)




# def main():

# if __name__ == '__main__':
#     main()


Measured memory_bytes: 3568
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;

int n,f[11000],ha,ans=-(1<<30);

int main(){
    scanf("%d",&n);
    f[0]=1;
    for(int i=1;i<=n;i++){
        scanf("%d",&ha);
        for(int j=10000;j>=0;j--){
            if(f[j]==1)f[j+ha]=1;
        }
    }for(int i=0;i<=10000;i++){
        if(f[i]){
            if(i%10==0)ans=max(ans,0);
            else ans=max(ans,i);
        }
    }printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
n, c = map(int, input().split())
list_rec = [[0] * 10**5 for _ in range(c)]

list_tv = [tuple(map(int, input().split())) for _ in range(n)]
for start, end, ch in list_tv:
  list_rec[ch-1][(start-1):end] = [1] * (end - (start - 1))

count = max(map(sum, zip(*list_rec)))
print(count)

Measured memory_bytes: 40940
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,c=LI()

  if c-a-b<=0:
    return 'No'

  if 4*a*b<(c-a-b)**2:
    return 'Yes'
  return 'No'

# main()
print(main())


Measured memory_bytes: 65004
import Control.Applicative

main :: IO ()
main = solve <$> getLine >>= putStrLn

solve :: String -> String
solve [c0, c1, c2, c3]
  | c0 == c1 && c1 == c2 = "Yes"
  | c1 == c2 && c2 == c3 = "Yes"
  | otherwise = "No"


Measured memory_bytes: 380
//ICPC2016 domestic D ??????????????¨???
//dp[l][r] := //??????[l, r)??§????????§?????¨???????????¢????????°???????????????
//?????¬???????????????????????????????????°??§????????§?????????w[l]??¨w[r - 1]??????????°??????????????????¨?¶??????§????????¨???????????????????£??????\????????????
//????£?30?????????????????°30????????????
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);++i)
#define rep(i,n) REP(i, 0, n)
int dp[301][301];
int w[301];
int calc(int l, int r) {//??????[l, r)??§????????§???
    int& res = dp[l][r];
    if(dp[l][r] != -1) return res;
    res = 0;
    if(r - l <= 1) return res;
    if(r - l == 2)
      return abs(w[l] - w[l + 1]) <= 1 ? res = 2 : res;
    //?????????
    REP(mid, l + 1, r - 1)
      res = max(res, calc(l, mid) + calc(mid, r));
    //??????????????¨?¶??????§??????????????§??????
    int temp = calc(l + 1, r - 1);
    if(temp == r - l - 2 && abs(w[l] - w[r - 1]) <= 1) temp += 2;
    res = max(res, temp);
    return res;
}
int main() {
    int N;
    while(~scanf("%d", &N) && N) {
        memset(dp, -1, sizeof(dp));
        memset(w, 0, sizeof(w));
        rep(i, N) scanf("%d", w + i);
        printf("%d\n", calc(0, N));
    }
    return 0;
}

Measured memory_bytes: 3524
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

f = factorization(int(input()))
c=0
for _,i in f:
    if _ == 1:
        print(0)
        exit()
    a=1
    while a*-~a//2 <= i:
        a+=1
    c+=~-a
print(c)

Measured memory_bytes: 9476
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=1e8;
const ll oo=1e17;
const double eps=1e-10;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n;
const int Maxn=405;
ll sum[Maxn];
ll dp[Maxn][Maxn];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>sum[i];
		sum[i]+=sum[i-1];
	}
	for(int i=1;i<=n;i++)for(int j=i;j<=n;j++){
		dp[i][j]=oo;
	}
	for(int i=1;i<=n;i++)dp[i][i]=0;
	for(int i=1;i<n;i++)dp[i][i+1]=sum[i+1]-sum[i-1];
	for(int len=3;len<=n;len++){
		for(int i=1;i+len-1<=n;i++){
			int j=i+len-1;
			for(int k=i;k<j;k++){
				chkmin(dp[i][j],dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1]);
			}
		}
	}
	cout<<dp[1][n]<<endl;
	return 0;
}

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


typedef long long ll;
typedef pair<ll,int> P;

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  for(ll i=1; i<=n; i++){
    ans += i*(1+n/i)*(n/i)/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
int main(){
  long int A,B,C,K,sum;
  scanf("%ld %ld %ld %ld",&A,&B,&C,&K);
  if(A>K) sum=K;
  else if(A+B>K) sum=A;
  else sum=A*2+B-K;
  printf("%ld",sum);
  return 0;
}

Measured memory_bytes: 1732
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int n, m;
	cin >> n >> m;
	ans = n;
	REP(i, m){
		cin >> tmp;
		ans -= tmp;
	}
    cout << max(-1, ans) << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MP make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N= 3e5+10;


char s[N];
int n;
int main(){
	#ifdef che
	#endif
	scanf("%d", &n);scanf("%s", s);
	int e=0,w=0,ans=n;
	for (int i=0; i<n; i++) if ( s[i]=='E') e++;
	for (int i=0; i<n; i++){
		if( s[i]=='E') e--;
		ans= min(ans, e+w);
		if ( s[i]=='W') w++;
	}
	printf("%d\n", ans);
	return 0;
}

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

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

    int free = l;
    const int lang = ceil((float)a / c);
    const int math = ceil((float)b / d);
    free -= max(lang, math);

    cout << free << endl;
}


Measured memory_bytes: 3100
extern crate core;

use std::collections::HashSet;
use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:i64));
    for x in n.. {
        if x.to_string().chars().collect::<HashSet<_>>().len() == 1 {
            return x.to_string();
        }
    }
    panic!();
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "111" => "111",
    test2: "112" => "222",
    test3: "750" => "777",
}


Measured memory_bytes: 4352
data = gets.strip.split.map(&:to_i).sort
@step = 0

def next_step(data)
  a, b, c = data
  # 10 10 10
  if a == b && b == c
    return data
  end
  # 9 10 10
  if b == c && b - a == 1
    data[0] += 2
    data[1] += 1
    data[2] += 1
    @step += 2
    return data
  end

  # 8 10 10
  if b == c && b - a == 2
    data[0] += 2
    @step += 1
    return data
  end

  # 9 9 10
  if a == b && c - b == 1
    data[0] += 1
    data[1] += 1
    @step += 1
    return data
  end

  # 8 8 10
  if a == b && c - b == 2
    data[0] += 2
    data[1] += 2
    @step += 2
    return data
  end

  # 7 9 10
  if c - b == 1 && b - a > 1
    data[0] += 1
    data[1] += 1
    @step += 1
    return data
  end

  # 5 8 10
  if b < c - 1 && a < b
    data[0] += 2
    @step += 1
    return data
  end

  if a < b && b < c
    data[0] += 1
    data[1] += 1
    @step += 1
    return data
  end

  # 1 8 10
  if b < c - 1
    data[1] += 2
    @step += 1
    return data
  end

  if a == b
    data[0] += 1
    data[1] += 1
    @step += 1
    return data
  end

  if b == c && b - a > 2
    data[0] += 2
    @step += 1
  end

  data[0] += 2
  @step += 1
  return data

end

while true
  a, b, c = data
  # p data
  # puts "step = #{@step}"
  if a == b && b == c
    break
  end
  data = next_step(data).sort
end

puts @step


Measured memory_bytes: 3836
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>

using namespace std;
int main(){
	int n;
	long long  l[100];
	l[0]=2;
	l[1]=1;
	scanf("%d",&n);
	for(int i = 2; i <= n; i++)
		l[i] = l[i-1] + l[i-2];
	printf("%lld\n",l[n]);
	return 0;
}

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

const int N=333;
typedef long long LL;
int A[N][N],idx[N][N];

int main(){
	int n,flag=1;
	LL ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	cin>>A[i][j],idx[i][j]=0;
	
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(i==j||i==k||j==k) continue;
				if(A[i][k]+A[k][j]<A[i][j]) flag=0;
				if(A[i][k]+A[k][j]==A[i][j]) idx[i][j]=1;
			}
		}
	}
	
	if(!flag) {cout<<-1<<endl;return 0;}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(!idx[i][j]) ans+=A[i][j];
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;cin>>n;
    vector<vector<pair<int,int>>> tree(n);
    for(int i=0;i<n-1;i++){
        int u,v,w;
        cin>>u>>v>>w;
        u--;
        v--;
        tree[u].push_back(make_pair(v,w));
        tree[v].push_back(make_pair(u,w));
    }
    vector<long> dist(n,-1);
    dist[0]=0;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        auto i=que.front();
        que.pop();
        for(auto p:tree[i]){
            if(dist[p.first]>0) continue;
            dist[p.first]=dist[i]+p.second;
            que.push(p.first);
        }
    }
    for(int i=0;i<n;i++){
        cout<<dist[i]%2<<endl;
    }
}


Measured memory_bytes: 9216
import math

a,b,h,m = map(int, input().split())


Asin = a*math.sin(math.radians(h*360/12+m*30/60))
Acos = a*math.cos(math.radians(h*360/12+m*30/60))
Bsin = b*math.sin(math.radians(m*360/60))
Bcos = b*math.cos(math.radians(m*360/60))

#print(Asin,Acos,Bsin,Bcos)

ret = math.sqrt((Asin-Bsin)**2+(Acos-Bcos)**2)
print(ret)

Measured memory_bytes: 62512
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


int fac[100];
void init(){
  fac[0] = 1;
  repi(i,1,20)fac[i] = fac[i-1]*2;
}

int low(int s, int t){
  int cnt = 0;
  rep(i,20)if(s*fac[i] >= t){
    cnt = i;
    break;
  }
  return cnt;
}


signed main(){
  init();
  int n, k;cin >> n >> k;
  double ans = 0;
  vector<int> v;
  rrep(i,n){
    int cnt = low(i, k);
    v.pb(cnt);
  }
  
  int a = 1, m = v[0], b = fac[m];
  repi(i,1,v.size()){
    int d = m-v[i];
    a += fac[d];
  }
  printf("%.13lf\n", (double)a/b/n);
  return 0;
}






Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  int h, a;

  scanf("%d", &h);
  scanf("%d", &a);

  int n = ceil((double)h / a);

  printf("%d\n", n);

  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    cout << fixed << setprecision(15);
    ll K, N;
    cin >> K;
    cin >> N;

    vector<ll> A(N);
    vector<ll> B(N);

    REP(i, N){
        cin >> A[i];
    }
    B[0] = (K - A[N-1]) + A[0];

    ll maxB = B[0];
    for(ll i=1; i<N; i++){
        B[i] = A[i] - A[i-1];
        maxB = max(maxB, B[i]);
    }
    cout << K - maxB << endl;
    return 0;
}

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

int main(){
  long long int n,k;
  cin>>n>>k;
  if(n%k==0){
    cout<<"0"<<endl;
  }
  else{
    if(n%k*2<k){
      cout<<n%k<<endl;
    }
    else{
      cout<<k-n%k<<endl;
    }
  }
}

Measured memory_bytes: 3636
N = int(input())
lst = list(map(int,input().split()))
ans = 0
for i in range(N-2):
  hako = []
  hako.extend([lst[i],lst[i+1],lst[i+2]])
  hako.sort()
  if hako[1] == lst[i+1]:
      ans += 1
print(ans)

Measured memory_bytes: 3060
ans = [0 for i in range(10**4 + 1)]

N = int(input())
for x in range(1, int(N**1 / 2) + 1):
    if x**2 > N:
        break
    for y in range(1, int(N**1 / 2) + 1):
        if x**2 + y**2 > N:
            break
        for z in range(1, int(N**1 / 2) + 1):
            temp = x**2 + y**2 + z**2 + x * y + y * z + z * x
            if temp > N:
                break
            else:

                ans[temp] += 1
for i in range(1, N + 1):
    print(ans[i])

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

using namespace std;

int main() {
    string s;
    cin >> s;
    long long k;
    cin >> k;

    for (int i = 0; i < k; ++i) {
        if (s[i] != '1') {
            cout << s[i] << '\n';
            return 0;
        }
    }
    cout << "1\n";
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let nx = read_vec::<usize>();
    let n = nx[0];
    let x = nx[1];
    let mut l = read_vec::<usize>();
    l.push(x);
    let answer = solve(n, x, &l);

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

fn solve(n: usize, x:usize, l:&[usize]) -> i32 {
    let mut count  = 0;
    let mut pos = 0;
    for i in 0..n+1 {
        //println!("{}, {}, {}, {}", i, pos, count, x);
        if pos > x {
            break;
        }
        pos += l[i];
        count += 1;
        //println!("--> {}, {}, {}", i, pos, count);
    }
    
    return count;
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main(void){
    int a, b;
    cin >> a >> b;
    if(a<b){
        cout << "a < b\n";
    }
    else if(a>b){
        cout << "a > b\n";
    }
    else{
        cout << "a == b\n";
    }

    return 0;
}


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

int main() {
    // 入力受け取り
    int N, K; cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    
    // DP
    vector<int> dp(K+1, 0);
    for (int i = 1; i <= K; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i - a[j] >= 0) dp[i] |= !dp[i - a[j]];
        }
    }
    
    // 答え
    if (dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
}


Measured memory_bytes: 640