akhauriyash/Code-Regression huggingface dataset:
import math

def getPosition(Num, n, i):
    Num_buff = Num[i:]
    # print(Num_buff)
    Num_buff.sort()
    return Num_buff.index(n)



N = int(input())
P = list(map(int,input().split())) 
Q = list(map(int,input().split())) 

a = 0
b = 0

# print(P)
# print(Q)
# print("---")

for i in range(N):
    a += (getPosition(P, P[i], i))*math.factorial(N-(i+1)) 
    b += (getPosition(Q, Q[i], i))*math.factorial(N-(i+1)) 
a += 1
b += 1
if a > b:
    print(a-b)
else:
    print(b-a)
# print(a)
# print(b)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();

		// ?????? A ??\???
		int[][] A;
		A = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				A[i][j] = scan.nextInt();
			}
		}
		// ?????? B ??\???
		int[][] B;
		B = new int[m][l];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < l; j++) {
				B[i][j] = scan.nextInt();
			}
		}

		// ?????? C ??\???
		long[][] C;
		C = new long[n][l];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				for (int k = 0; k < m; k++) {
					C[i][j] = C[i][j] + A[i][k] * B[k][j];
				}
			}
		}
		
		
		

		for (int i = 0; i < n; i++) {

			int j = 0;
			System.out.print(C[i][j]);
			
			for (j = 1; j < l; j++) {
				System.out.print(" " + C[i][j]);
			}
			System.out.println();
		}

	}

}

Measured memory_bytes: 53444
#include<stdio.h>

int main(void)
{
    int h,n,i;

    scanf("%d%d",&h,&n);
    int a;
    for(i=0;i<n;i++){
        scanf("%d",&a);
        h=h-a;}
    if(h<=0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

template <typename T>
struct SegmentTree {
  int SEG_LEN = 1;
  std::vector<T> node;
  SegmentTree(int n) {
    while (SEG_LEN < n) { SEG_LEN <<= 1; }
    node.assign(SEG_LEN*2, 0);
  }
  void add(int idx, T v) {
    idx += SEG_LEN;
    node[idx] += v;
    while (true) {
      idx /= 2;
      if (idx == 0) { break; }
      node[idx] = node[idx*2] + node[idx * 2 + 1];
    }
  }
  T sum(int l, int r) {
    l += SEG_LEN; r += SEG_LEN;
    T ret = 0;
    while (l < r) {
      if (l & 1) { ret += node[l++]; }
      if (r & 1) { ret += node[r-1]; r--; }
      l /= 2; r /= 2;
    }
    return ret;
  }
};

int main() {
  std::cout << std::setprecision(20) << std::fixed;
  int n, k; std::cin >> n >> k;
  SegmentTree<double> seg_tree(n);

  for (int i = 0; i < n; i++) {
    int p; std::cin >> p;
    seg_tree.add(i, (1+p)/2.0);
  }
  double ans = 0;
  for (int i = 0; i <= n-k; i++) {
    ans = std::max(ans, seg_tree.sum(i, i+k));
  }
  std::cout << ans << std::endl;
}

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

int main(){
  int N,W;
  cin >> N >> W;
  int w,v;
  cin >> w >> v;
  vector<int> w0,w1,w2,w3;
  w0.push_back(v);

  for (int i = 1; i < N; i++){
    int wi,vi;
    cin >> wi >> vi;

    if(wi==w) w0.push_back(vi);
    if(wi==w+1) w1.push_back(vi);
    if(wi==w+2) w2.push_back(vi);
    if(wi==w+3) w3.push_back(vi);
  }
  sort(w0.begin(),w0.end(),greater<int>());
  sort(w1.begin(),w1.end(),greater<int>());
  sort(w2.begin(),w2.end(),greater<int>());
  sort(w3.begin(),w3.end(),greater<int>());

  long long ans = 0;
  for (long long i = 0; i <= (long long)w0.size(); i++)
  {
    for (long long j = 0; j <= (long long)w1.size(); j++)
    {
      for (long long k = 0; k <= (long long)w2.size(); k++)
      {
        for (long long l = 0; l <= (long long)w3.size(); l++)
        {
          long long sumw = i*w + j*(w+1) + k*(w+2) + l*(w+3);
          if(sumw<=W){
            long long sumv = 0;
            for (int I = 0; I < i; I++) sumv+=w0[I];
            for (int J = 0; J < j; J++) sumv+=w1[J];
            for (int K = 0; K < k; K++) sumv+=w2[K];
            for (int L = 0; L < l; L++) sumv+=w3[L];
            ans = max(ans,sumv);            
          }
          else break;
        }
      }
    }
  }
  cout << ans << endl;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  const ll T = 100000000;
  ll N;
  cin >> N;
  vector<ll> x(N), y(N);
  rep(i,N)
    cin >> x[i] >> y[i];
  //ll N=100;
  //vector<ll> x(N), y(N);
  //rep(i,N)
  //  x[i]=y[i]=1000000;


  vector<double> cx, cy; // candinate
  rep(i,N) {
    rep(j,N) {
      cx.push_back(x[i] + x[j]);
      cy.push_back(y[i] + y[j]);
    }
  }

  //cout<<"can:"<<endl;
  //rep(i, cx.size()){
  //  cout<<cx[i] << " " << cy[i]<<endl;
  //}

  ll ans = 0;
  rep(i, cx.size()){
    ll curx = 0, cury = 0;
    rep(j, N) {
      if (cx[i]*x[j] + cy[i]*y[j] > 0) { // 90度未満
        curx += x[j];
        cury += y[j];
      }
    }
    ans = max(ans, curx * curx + cury * cury);
  }
  printf("%.20f\n", sqrt(ans));
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;
const int MOD = 1e9+7;

int n;

bool prime[1010];
vector<int> primes;
void init() {
  for (int i=0;i<1005;i++) {
    prime[i] = true;
  }
  prime[0] = prime[1] = false;
  for (int i=2;i<1005;i++) {
    if (prime[i]) {
      primes.push_back(i);
      for (int j=i*2;j<1005;j+=i) {
        prime[j] = false;
      }
    }
  }
}

void solve() {
  map<int, int> cnt;
  for (int i=2;i<=n;i++) {
    int m = i;
    for (int j=0;j<primes.size();j++) {
      while (m % primes[j] == 0) {
        cnt[primes[j]]++;
        m /= primes[j];
      }
    }
  }
  ll ans = 1;
  for (auto& c : cnt) {
    ans = ans * (c.second + 1) % MOD;
  }
  cout << ans << endl;
}

int main() {
  init();
  cin >> n;
  solve();
}


Measured memory_bytes: 256
// May this submission get accepted
#pragma GCC optimize ("O3")
#pragma GCC target("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll h = inp1;
    ll n = inp1;
    vector<ll> a = inp(n);
    ll asum = accumulate(ALL_OF(a), 0LL);

    cout << Yes(asum >= h) << endl;
    
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    int x, y;
    char op;
    scanf("%d %c %d", &x, &op, &y);
    while (op != '?')
    {
        switch (op)
        {
        case '-':
            printf("%d\n", x - y);
            break;
        case '+':
            printf("%d\n", x + y);
            break;
        case '*':
            printf("%d\n", x * y);
            break;
        case '/':
            printf("%d\n", x / y);
            break;
        }
        scanf("%d %c %d", &x, &op, &y);
    }
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    string s = get<string>(), t = get<string>();

    vector<char> abc(128);
    char next = 1;
    for (int i = 0; i < s.size(); i++) {
        if (abc[s[i]] == 0)
            abc[s[i]] = next++;
        s[i] = abc[s[i]];
    }

    fill(abc.begin(),abc.end(),0);
    next = 1;
    for (int i = 0; i < t.size(); i++) {
        if (abc[t[i]] == 0)
            abc[t[i]] = next++;
        t[i] = abc[t[i]];
    }

    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int s; cin >> s;
    set<int> st;
    st.insert(s);
    int ans = 1;
    while (1) {
        ans++;
        if (s%2 == 0) s /= 2;
        else s = 3*s+1;
        auto it = st.find(s);
        if (it != st.end()) {
            cout << ans << endl;
            return 0;
        }
        st.insert(s);
    }
}

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

int main(void){
    int N;
    cin >> N;
    string S;
    cin >> S;
    ll r = 0,g = 0,b = 0;
    REP(i,N){
        if(S[i]=='R') r++;
        else if(S[i]=='G') g++;
        else b++;
    }
    ll res = r*g*b;
    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            int k = 2*j - i;
            if(k<N){
                if(S[i]!=S[j] && S[j]!=S[k] && S[k]!=S[i]){
                    res--;
                }
            }
        }
    }
    if(res<0) res=0;
    cout << res << endl;
}

Measured memory_bytes: 3628
N,M = map(int,input().split())
if M == 0:
  print(N)
else:
  c=list(map(int, input().split()))
  for i in range(N+1):
    for s in [-1,1]:
      a = N+s*i
      if c.count(a)==0:
      	print(a)
      	exit(0)

Measured memory_bytes: 9172
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//?§????????????????S?????????
		int time = sc.nextInt();
		//h??????
		int hour = time / 60 / 60;
		//??????
		int minutse = time / 60 % 60;
		//s?§?
		int second = time % 60;
		//???????????¨???
		System.out.println(hour + ":"+ minutse + ":" + second);

	}
}

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

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  int ans = 0;
  int count = 0;
  for(int i = min(a, b); i >= 1; i--){
    if(a%i == 0 && b%i == 0){
      count++;
      if(count == k){
        ans = i;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

def condition(num):
    count=0
    s=N-1
    t=0
    while N-1>=t and s>=0:
        if num>A[s]+A[t]:
            t+=1
        else:
            count+=N-t
            s-=1
    return count>=M

subans=0
start=1
end=2*A[N-1]
while end-start>1:
    test=(end+start)//2
    if condition(test):
        start=test
    else:
        end=test
if condition(end):
    subans=end
else:
    subans=start

data=[0]*N
count=0
s=N-1
t=0
while N-1>=t and s>=0:
    if subans>A[s]+A[t]:
        t+=1
    else:
        count+=N-t
        data[s]=2*(N-t)
        s-=1

ans=sum(data[i]*A[i] for i in range(0,N))
if count>M:
    ans-=(count-M)*subans
print(ans)


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

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();

using namespace std;
const int N=201, mod= 1e9+7;
vector<int> col(N,-1);
vector<int> g[N];
int n;

bool dfs(int u,int c){
	col[u]=c;
	bool res=1;
	for(auto v:g[u]){
		if( col[v]==-1 ){
			res&=dfs(v,c^1);
		}else if( col[v]!=(c^1) ) return 0;
	}
	return res;
}

int bfs(int u){
	vector<bool> vis(n+1); vector<int> h(n+1);
	queue<int> q; 
    q.push(u); 
    h[u]=1;
    vis[u] = true; 
  
    while (!q.empty()) { 
        int u = q.front(); 
        q.pop();
        for (auto v:g[u]) { 
            if (!vis[v]) { 
                q.push(v); 
                vis[v] = true;
                h[v]=h[u]+1;
            } 
        } 
    } 
    return *max_element(h.begin(),h.end());
}

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int root=-1;
	cin>>n;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
		char ch;
		cin>>ch;
		if(ch=='1'){
			g[i].pb(j);
			g[j].pb(i);
			root=i;
		}
	}
	if(root==-1)cout<<"0";
	else {
		int res=0;
		if(dfs(root,0)){
			for(int i=1;i<=n;i++){
				res=max( res,bfs(i) );
			}
			cout<<res;
		}else cout<<"-1";
	}
	
	
    yogeshk972();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(r) r.begin(),r.end()
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        vvll a(3, vll(n));
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < n; j++) {
                in >> a[i][j];
            }
            sort(all(a[i]));
        }
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            ll ud = lower_bound(all(a[0]), a[1][i]) - a[0].begin();
            ll dd = a[2].end() - upper_bound(all(a[2]), a[1][i]);
            ans += ud * dd;
        }
        out << ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 3456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		long wa = 0;
		for(int i = 1; i <= n; i++)
		{
			var c = (n - i);
			
			for(int j = 1; j * j <= c; j++)
			{
				double t = (double)c / j;
				if(t == (int)t)
				{
					if(t*t==c)
						wa+=1;
					else
						wa+=2;
				}
			}
		}
		Console.WriteLine(wa);
		
	}

	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 27608
using System;
using System.IO;

class Solve
{
    static void Main(string[] args) {
        var A = int.Parse(Console.ReadLine());
        var B = int.Parse(Console.ReadLine());
        var C = int.Parse(Console.ReadLine());
        var X = int.Parse(Console.ReadLine());
        var answer = 0;
        for (int i = 0; i <= A && i * 500 <= X; i++) {
            var v1 = X - 500 * i;
            for (int j = 0; j <= B && j * 100 <= v1; j++) {
                var v2 = v1 - 100 * j;
                for (int k = 0; k <= C && k * 50 <= v2; k++) {
                    var v3 = v2 - 50 * k;
                    if (v3 != 0) continue;
                    answer++;
                    break;
                }
            }
        }
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

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

typedef vector<int> vi;
typedef pair<int, int> pii;
#define endl "\n"
#define sd(val) scanf("%d", &val)
#define ss(val) scanf("%s", &val)
#define sl(val) scanf("%lld", &val)
#define debug(val) printf("check%d\n", val)
#define all(v) v.begin(), v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val, 0, sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ                            \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

#define testcase(t) \
    while (t--)     \
        solve();

void solve()
{
}

int32_t main()
{
    FIO;
    //OJ;

    string s;
    cin >> s;
    int res = 0;
    for (int i = 0; i < s.length(); i++)
    {
        switch (s[i])
        {
        case '1':
            res += 1;
            break;
        case '2':
            res += 2;
            break;
        case '3':
            res += 3;
            break;
        case '4':
            res += 4;
            break;
        case '5':
            res += 5;
            break;
        case '6':
            res += 6;
            break;
        case '7':
            res += 7;
            break;
        case '8':
            res += 8;
            break;
        case '9':
            res += 9;
            break;
        default:
            break;
        }
    }
    if (res % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3744
import sys
input=sys.stdin.readline
from math import atan2,pi

def InnerProduct(V0,V1):
    x0,y0=V0
    x1,y1=V1
    return x0*x1+y0*y1
def CrossProduct(V0,V1):
    x0,y0=V0
    x1,y1=V1
    return x0*y1-x1*y0
def clockwise(P0,P1,P2):
    V0,V1=(P1[0]-P0[0],P1[1]-P0[1]),(P2[0]-P0[0],P2[1]-P0[1])
    return CrossProduct(V0,V1)<0

def MonotoneChain(V):
    upper,lower=[],[]
    P=sorted(V)
    for p in P:
        while len(lower)>1 and (not clockwise(lower[-2],lower[-1],p)):
            lower.pop()
        lower.append(p)
    for p in P[::-1]:
        while len(upper)>1 and (not clockwise(upper[-2],upper[-1],p)):
            upper.pop()
        upper.append(p)
    return lower[:-1]+upper[:-1]

n=int(input())
P=[tuple(map(int,input().split())) for _ in range(n)]
d={p: i for i,p in enumerate(P)}
ans=[0]*n
CH=MonotoneChain(P)
CH+=[CH[0],CH[1]]
for (x0,y0),(x1,y1),(x2,y2) in zip(CH,CH[1:],CH[2:]):
    V0,V1=(x0-x1,y0-y1),(x2-x1,y2-y1)
    ans[d[(x1,y1)]]=(pi-atan2(CrossProduct(V0,V1),InnerProduct(V0,V1)))/(2*pi)
for a in ans:
    print(a)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	ll n, k;
	cin >> n >> k;
	ll num = n % k;
	ll minv = min(abs(num - k), num);
	cout << minv << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int x,y,z;
    cin>>x>>y>>z;
    cout<<((x-z)/(y+z))<<endl;

    return 0;
}


Measured memory_bytes: 256
def solve(string):
    n, *x = map(int, string.split())
    mid = n // 2
    l, r = sorted(x)[mid - 1:mid + 1]
    return "\n".join([str(r) if _x < r else str(l) for _x in x])


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 125268
import java.util.*;
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();

        if(a==b){
          System.out.println(c);
        }else if(a==c){
          System.out.println(b);
        }else{
          System.out.println(a);
        }
  }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main(){
  int ans[20000]={};
  ans[1]=2;
  for(int i=2;i<=10000;i++){
    ans[i]=ans[i-1]+i;
  }
  int n;
  while(cin>>n)
    cout<<ans[n]<<endl;
  return 0;
}

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

#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl

using namespace std;
typedef long long ll;

const int maxn = 0;

int main(){
    ll a, b;
    cin >> a >> b;
    if (a > b) swap (a, b);
    ll d = a + b;
    if (d % 2) cout << "IMPOSSIBLE\n";
    else cout << (d / 2) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int K,A,B; cin>>K>>A>>B;

    if(K<A+1){
        cout<<1+K<<endl;
        return 0;
    }

    int ans;
    if(B<=A+2){
        ans=1+K;
    }
    else{
        ans=B; K-=A+1;
        ans+=(B-A)*(K/2);
        ans+=K%2;
    }
    cout<<ans<<endl;
 
}


Measured memory_bytes: 256
x, n = map(int, input().split())
p = set(map(int, input().split()))


ans = 0
i = 0
while True:
    if (x - i) not in p:
        ans = x - i
        break
    elif (x + i) not in p:
        ans = x + i
        break
    i += 1

print(ans)


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

int N;
int main(){
  cin >> N;
  vector<i64> ans(N + 1,1e9);
  ans[0] = 0;
  for(int i = 6;i <= N;i *= 6){
    rep(j,i,N){
      ans[j] = min(ans[j],ans[j - i] + 1);
    }
  }
  for(int i = 9;i <= N;i *= 9){
    rep(j,i,N){
      ans[j] = min(ans[j],ans[j - i] + 1);
    }
  }

  i64 res = N;
  rep(i,0,N){
    res = min(res , i + ans[N - i]);
  }
  cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    cout << c<<" "<<a<<" "<<b<<endl; 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
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> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
//////////////////

void solve(){
  ini(N , M);
  vi a(N) , cnt(N , 1);
  a[0] = 1;
  rep(i , M){
    ini(x , y); x--; y--;
    if(a[x] == 1){
      a[y] = 1;
      if(cnt[x] == 1) a[x] = 0;
    }
    cnt[x]--; cnt[y]++;
  }  
  out(accumulate(all(a) , 0LL));
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template< int mod >
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(long long n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    long long t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
  static int get_mod() { return mod; }
};
const int MOD = 1000000007;
using mint = ModInt< MOD >;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> c(n);
  rep(i, n) cin >> c[i];
  sort(c.rbegin(), c.rend());
  mint ans = 0;
  mint num1 = mint(2).pow(n-1);
  mint num2 = mint(2).pow(n-2);
  rep(i, n)
    ans += (num1+num2*i)*c[i];
  ans *= mint(2).pow(n);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b;
	cin>>a>>b;
	cout<<(a*3+b)/2<<endl;
	
}











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

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

int main() {
    long long N, W;
    cin >> N >> W;
    vector<long long> w(N), v(N);
    for(int i=0; i<N; i++){
        cin >> w.at(i) >> v.at(i);
    }

    vector<vector<long long>> dp(N+10, vector<long long> (W+10, 0));
    long long sum_w;
    for(int i=0; i<N; i++){
        for(long long sum_w = 0; sum_w <= W; sum_w++){
            if (sum_w-w.at(i)>=0){
                chmax(dp.at(i+1).at(sum_w), dp.at(i).at(sum_w-w.at(i)) + v.at(i));
            }
            chmax(dp.at(i+1).at(sum_w), dp.at(i).at(sum_w));
        }
    }

    cout << dp.at(N).at(W) << endl;

    return 0;
}

Measured memory_bytes: 87296
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var le = num.ToString().Length;
        var result = 0;
        for (var i = 0; i < 3; i++)
            dfs(num, "", i, ref result);
        WriteLine(result);
    }
    private static void dfs(int num,string n,int index,ref int result)
    {
        string na = "357";
        n += na.Substring(index,1);
        var nu = ToInt64(n);
        if (nu <= num)
        {
            if(n.Contains("3")&&n.Contains("5")&&n.Contains("7"))
            result++;
            for (var i = 0; i < 3; i++)
                dfs(num, n, i, ref result);
        }
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 17360
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    cin>>s;
    cout<<(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]?"Bad":"Good")<<endl;
}

Measured memory_bytes: 256
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	int a[n];
	forn(i,n)
	{
		cin>>a[i];
		if(a[i]%2==0)
		{
			if(a[i]%3!=0&&a[i]%5!=0)
			{
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]", B: "List[int]", C: "List[int]"):

    cst = sum(B)
    for i in range(1, N):
        if(A[i-1]+1 == A[i]):
            cst += C[A[i-1]-1]

    print(cst)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N - 1)]  # type: "List[int]"
    solve(N, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
int main(){
	int n,i,a[100][2],b=0,f=0;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		if(n%i==0){
			a[b][0]=i;
			a[b][1]=n/i;
			b++;
			}
		}
	for(i=0;i<b;i++){
		if(a[i][0]<=9&&a[i][0]>=1&&a[i][1]<=9&&a[i][1]>=1){
			f=1;
			break;
		}}
	if(f==1||n==1)printf("Yes\n");
	if(f==0&&n!=1) printf("No\n");
	
	
	
	
	
	 
	
	
	
	
	
	
	
	
	
	
	
	
	
} 


Measured memory_bytes: 128
use proconio::{fastout, input, marker::Chars};

#[fastout]
fn main() {
    input! {
        s: Chars,
    }
    for i in 1..s.len() {
        if s[i] == s[i - 1] {
            println!("{} {}", i, i + 1);
            return;
        }
        if i > 1 && s[i] == s[i - 2] {
            println!("{} {}", i - 1, i + 1);
            return;
        }
    }

    println!("-1 -1");
}


Measured memory_bytes: 2504
#include <stdio.h>
#include <string.h>

int main() {
	int a;
	char b[a];
	
	scanf("%d", &a);
	scanf("%s", b);
	
	int c = 0;
	
	if(a < 2) {
		printf("No\n");
		return 0;
	}
	
	if(a%2 != 0) {
		printf("No\n");
		return 0;
	}
	
	for(int i = 0; i < a/2; i++) {
		
		if(b[i] == b[i + (a / 2)]) {
			continue;
		}
		
		else if (b[i] != b[i + (a/2)]) {
			c++;
		}
		i++;
	}
	
	if(c != 0) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}

	return 0;
}


Measured memory_bytes: 1660
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<int>[] E = new List<int>[N];
		for(int i=0;i<N;i++){
			E[i] = new List<int>();
		}
		for(int i=0;i<N-1;i++){
			E[A[i]].Add(i);
			E[B[i]].Add(i);
		}
		
		int K = 0;
		for(int i=0;i<N;i++){
			K = Math.Max(K, E[i].Count);
		}
		
		Func<int,int,int> Nxt = (v, e) =>{
			if(A[e] == v) return B[e];
			return A[e];
		};
		
		int[] parent = new int[N];
		int[] parentE = new int[N];
		for(int i=0;i<N;i++){
			parent[i] = -1;
			parentE[i] = -1;
		}
		
		int[] color = new int[N-1];
		var q = new Queue<int>();
		q.Enqueue(0);
		while(q.Count > 0){
			var now = q.Dequeue();
			int pec = 0;
			if(parentE[now] != -1){
				pec = color[parentE[now]];
			}
			int ec = pec;
			foreach(var e in E[now]){
				if(e == parentE[now]) continue;
				ec++;
				if(ec >= K) ec -= K;
				color[e] = ec;
			}
			
			foreach(var e in E[now]){
				int nxt = Nxt(now, e);
				if(nxt == parent[now]) continue;
				parent[nxt] = now;
				parentE[nxt] = e;
				q.Enqueue(nxt);
			}
		}
		
		
		for(int i=0;i<N-1;i++) color[i]++;
		Console.WriteLine(K);
		Console.WriteLine(String.Join("\n",color));
		
		
		
	}
	int N;
	int[] A,B;
	public Sol(){
		N = ri();
		A = new int[N-1];
		B = new int[N-1];
		for(int i=0;i<N-1;i++){
			var d = ria();
			A[i] = d[0] - 1; B[i] = d[1] - 1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 31104
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] sum = new long[n];
        sum[0] = sc.nextLong();
        for (int i = 1; i < n; i++) {
            sum[i] = sc.nextLong() + sum[i-1];
        }
        long ans = Long.MAX_VALUE;
        for (int i = 0; i < n - 1; i++) {
            ans = Math.min(ans, Math.abs(sum[n-1] - sum[i] *2));
        }


        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 85220
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n,k;
        cin>>n>>k;
        if(k>=n)
        {
            cout<<min(n,k-n);
        }
        else
        {
            ll x=(n%k);
            cout<<min(x,k-x);
        }
    }
    return 0;
}

Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
X=int(input())

ans=0
for a in range(0,A+1):
  for b in range(0,B+1):
    if a*500+b*100>X:
      break
    if (X-a*500-b*100)//50<=C:
      ans+=1
print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count1 = 0;
        int count2 = 0;
        for(int i = 0; i < n; i++){
            String word1 = sc.next();
            String word2 = sc.next();
            if(word1.compareTo(word2) > 0){
                count1 += 3;
            }else if(word1.compareTo(word2) < 0){
                count2 += 3;
            }else{
                count1 += 1;
                count2 += 1;
            }
        }
        System.out.println(count1 + " " + count2);
    }
}


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

int main(void)
{
    int n, count = 0;
    vector<int> a;
    
    cin >> n;
    for (int i = 0; i < n; i++) { int tmp; cin >> tmp; a.push_back(tmp); }
    
    for (int i = 0; i < n; i++) {
        int minj = i;
        for (int j = i+1; j < n; j++)
            if (a.at(minj) > a.at(j)) minj = j;
        if (i != minj) {
            swap(a.at(i), a.at(minj));
            count++;
        }
    }
    for (int i = 0; i < n-1; i++) cout << a.at(i) << " ";
    cout << a.at(n-1) << endl;
    cout << count << endl;
    
    return 0;

}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=1e6;
const long inf=1e9;
int main(){
	int N; cin>>N;
	int cnt[1000001] = {};
	int A[N];
	rep(i,0,N){ cin>>A[i]; cnt[A[i]]++; }
	int ans = N;
	rep(i,0,N){
        if(cnt[A[i]] > 1){ ans--; continue; }
        else if(A[i] != 1 && cnt[1]){ ans--; continue; }
        rep(j,2,A[i]){
            if(j * j > A[i]) break;
            if(A[i] % j == 0){
                if(cnt[j] || cnt[A[i]/j]){ ans--; break; }
            }
        }
	}cout<<ans<<endl;
}

Measured memory_bytes: 8324
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = long long;

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

void solve(){
    int a, b;
    cin >> a >> b;
    if(a*b%2 == 0){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }   
}

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


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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
char a[305][305];
int u[305][305];
int cur = 0;


int main () {
   SpeedForce;
	cin >> n >> m >> k;
	For (i, 1, n)
		For (j, 1, m)
			cin >> a[i][j];
	For (i, 1, n) {
		For (j, 1, m) {
			if (a[i][j] == '#') {
				u[i][j] = ++cur;
				int l1 = j;
				int r1 = j;
				while (r1 < m && a[i][r1+1] != '#') r1++;
				while (l1 > 1 && a[i][l1-1] != '#') l1--;
				for (int k = l1; k <= r1; k ++)
					u[i][k] = cur;
			}
		}
	}

	queue < pair < int, int > > q;
	For (i, 1, n)
		For (j, 1, m) if (u[i][j])
			q.push({i, j});
	while (q.size()) {
		auto it = q.front();
		q.pop();

		for (int dir = 0; dir < 4; dir ++) {
			int nx = dx[dir] + it.F;
			int ny = dy[dir] + it.S;
			if (nx < 1 || ny < 1 || nx > n || ny > m) continue;
			if (!u[nx][ny]) {
				u[nx][ny] = u[it.F][it.S];
				q.push({nx, ny});
			}
		}
	}

	For (i, 1, n) {

		For (j, 1, m) {
			cout << u[i][j] << ' ';
		}

		cout << '\n';
	}

   return Accepted;
}

// B...a

Measured memory_bytes: 1920