akhauriyash/Code-Regression huggingface dataset:
n = int(input())
s = [input()for _ in range(n)]

for i in range(n):
    s[i] = ''.join(sorted(s[i]))

s.sort()

ans = 0
count = 0

for i in range(1, n):
    if count == 0:
        if s[i] == s[i-1]:
            count = 2
    else:
        if s[i] == s[i-1]:
            count += 1
        else:
            ans += count * (count - 1) // 2
            count = 0

ans += count * (count - 1) // 2

print(ans)


Measured memory_bytes: 10584
h, w = gets.split.map(&:to_i)
cm = Array.new(h + 2){Array.new(w + 2, 0)}
que = []
b = 0
1.upto(h) do |i|
  s = gets.chomp
  1.upto(w) do |j|
    if s[j - 1] == '.'
      cm[i][j] = -1
    else
      b += 1
    end
  end
end
que << [1, 1, 0]
while que.size > 0
  y, x, r = que.shift
  c = r + 1
  if cm[y + 1][x] == -1
    cm[y + 1][x] = c
    que << [y + 1, x, c]
  end
  if cm[y - 1][x] == -1
    cm[y - 1][x] = c
    que << [y - 1, x, c]
  end
  if cm[y][x - 1] == -1
    cm[y][x - 1] = c
    que << [y, x - 1, c]
  end
  if cm[y][x + 1] == -1
    cm[y][x + 1] = c
    que << [y, x + 1, c]
  end
end
puts cm[h][w] == -1 ? -1 : h * w - b - cm[h][w] - 1

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

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

	bool ans = true;
	if ((a == b && b == c) || (a != b && b != c && a != c))
		ans = false;

	cout << ((ans) ? "Yes" : "No") << endl;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

signed main(){
    double R;
    cin >> R;
    cout << fixed << setprecision(10) << M_PI * 2 * R << endl;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
const ll mod=1e9+7;

ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}

double dp[3100][3100];

int main()
{
	ll n,i;
	cin>>n;
	double p[n];
	for(i=0;i<n;i++)
		cin>>p[i];
	dp[0][0]=1;
	ll j;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=i;j++)
		{
			if(j)
				dp[i][j]+=dp[i-1][j-1]*(p[i-1]);
			dp[i][j]+=dp[i-1][j]*(1-p[i-1]);
		}
	}
	double ans=0.0;
	// for(i=0;i<=n;i++)
	// {
	// 	for(j=0;j<=n;j++)
	// 		cout<<dp[i][j]<<" ";
	// 	cout<<"\n";
	// }
	for(i=0;i<=n;i++)
	{
		if(i>n-i)
			ans+=dp[n][i];
	}
	printf("%.15lf",ans);
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s;
	cin >> s;
	string t="";
	rep(i,5){
		t+="hi";
		if(s==t){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		long f = 1;
		for(int i = 1; i <= n; i++) {
			f = f * i;
		}
		System.out.println(f);
	}
}

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, a, b) for (i = a; i < b; i++)
#define repr(i, a, b) for (i = a; i >= b; i--)
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define all(a) (a).begin(), (a).end()

void solve()
{
    ull a;
    long double b;
    cin >> a;
    cin >> b;
    ull prod = a * b;
    // sting s= prod.to
    cout << (ull)prod;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // int t = 0;
    solve();

    return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

int main(){_;
  int n;cin>>n;
  int count=0;
  for(int i=1;i<=n;i++){
    if(i==100000)continue;
    if(i>=1000&&i<10000)continue;
    if(i>=10&&i<100)continue;
    count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;

int main(void){
    int N;
    cin >> N;
    vector<ll> a(N);
    ll t=0;
    for(int i=0; i<N;i++){
        cin >> a[i];
        t += a[i];
    }
    ll x = a[0];
    ll y = t - x;
    ll ans = abs(x-y);
    for(int i=1;i<N-1;i++){
        x += a[i];
        y -= a[i];
        ans = min(ans, abs(x-y));
    }
    cout << ans <<endl;
    return 0;
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  int sum = a + b + c;
  int N = 10000000;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      a = 1;
    }
  }
  if (sum >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
int a[100000];
int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx-sx;
    int y = ty-sy;
    for(int i = 0;i < y;i++)
    {
        cout<<"U";
    }
    for(int i = 0;i < x;i++)
    {
        cout<<"R";
    }
    for(int i = 0;i < y;i++)
    {
        cout<<"D";
    }
    for(int i = 0;i < x;i++)
    {
        cout<<"L";
    }
    cout<<"L";
    for(int i = 0;i <= y;i++)
    {
        cout<<"U";
    }
    cout<<"R";
    for(int i = 0;i < x;i++)
    {
        cout<<"R";
    }
    cout<<"D";
    cout<<"R";
    for(int i = 0;i <= y;i++)
    {
        cout<<"D";
    }
    cout<<"L";
    for(int i = 0;i < x;i++)
    {
        cout<<"L";
    }
    cout<<"U";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

int main()
{
    std::string days[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    
    std::string today;
    std::cin >> today;
    
    int idx = -1;
    for(int i = 0; i < 7; ++i)
        if (today == days[i])
        {
            idx = i;
            break;
        }
    std::cout << (7 - idx) << std::endl;
}

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

long long N;
vector<long long> d;

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		d.push_back(tmp);
	}
	sort(d.begin(), d.end());
	cout << d[N/2] - d[N/2-1] << endl;
}

Measured memory_bytes: 1400
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		try (PrintWriter out = new PrintWriter(System.out);) {

			long a = scan.nextLong();
			long b = scan.nextLong();

			long ret;
			if (a > 2 * b) {
				ret = a - 2 * b;
			} else {
				ret = 0;
			}

			out.println(ret);
			out.flush();
		}
	}

	public static boolean isPrime(long num) {
		if (num == 1L)
			return true;
		else if (num == 2L)
			return true;
		else if (num % 2L == 0)
			return false; // 偶数はあらかじめ除く

		double sqrtNum = Math.sqrt(num);
		for (long i = 3; i <= sqrtNum; i += 2) {
			if (num % i == 0) {
				// 素数ではない
				return false;
			}
		}

		// 素数である
		return true;
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21332
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		List<Integer>[] edge = new ArrayList[N*3];
		for(int i = 0; i < N*3; i++)
			edge[i] = new ArrayList<>();
		for(int i = 0; i < M; i++) {
			int u = sc.nextInt()-1;
			int v = sc.nextInt()-1;
			edge[u].add(v+N);
			edge[u+N].add(v+2*N);
			edge[u+2*N].add(v);
		}
		int S = sc.nextInt()-1;
		int T = sc.nextInt()-1;
		long[] d = new long[N*3];
		int INF = Integer.MAX_VALUE;
		Arrays.fill(d, INF);
		d[S] = 0;
		Queue<Integer> q = new ArrayDeque<>();
		for(int i : edge[S]) {
		    q.offer(i);
		    d[i] = 1;
		}
		while(q.size() > 0) {
		    int x = q.poll();
		    for(int i : edge[x]) {
		        if(d[i] > d[x] + 1) {
		            d[i] = d[x] + 1;
		            q.offer(i);
		        }
		    }
		}
		System.out.println(d[T] != INF ? d[T]/3 : -1);
	}

}


Measured memory_bytes: 119600
#include<bits/stdc++.h>
using namespace std;
#define int long long  
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	    
signed main(){
// __builtin_ctz(N);      Nを２で何回割り切れるかを返す
//(n+1)*n/2;              １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,d,e,q=0;
    int c[1000]={};
    cin>>a>>b;
    for(int i=0;i<a;i++){
	cin>>d;
	for(int j=0;j<d;j++){
	    cin>>e;
	    c[e]++;
	}
    }
    for(int i=0;i<50;i++){
	if(c[i]==a) q++;
    }
    cout<<q<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 5000005
using namespace std;
int pre[maxn];


int main()
{
	string str;
	cin>>str;
	int len = str.length();
	int ans = 0;
	for(int i=0;i<len;i++){
		if(str[i] == '2')ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int cnt=0,ans=0;
string s;
signed main(){
	cin>>s;
	rep(i,s.size()){
		if(s[i]=='A'){
			cnt++;
		}
		else if(s[i]=='B'&&s[i+1]=='C'){
			ans+=cnt;
			i++;
		}
		else cnt=0;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String b=sc.nextLine(), ans="";
		if(b.equals("A")) ans="T";
		if(b.equals("C")) ans="G";
		if(b.equals("G")) ans="C";
		if(b.equals("T")) ans="A";
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

X, K, D = MI()
a = abs(X) % D
b = D - a
c = abs(X) // D
ans = 0
if K <= c:
    ans = abs(X) - K * D
elif K > c and (K - c) % 2 == 0:
    ans = a
else:
    ans = b
print(ans)

Measured memory_bytes: 74520
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 105005
#define PI 	3.14159265358979323846

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(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << x*y/2 << endl;
}

/*
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int cake[1050][3];//0,1,2
    REP(i,n)REP(j,3)cin >> cake[i][j];
    //nデータを8パターンで全探索
    static ll sum[8][3];
    REP(i,n){
        //+++:1
        
        //++-:2
        //+--:3
        //---:4
        //--+:5
        //-++:6
        //-+-:7
        //+-+:8
    }
   return 0;
}*/

Measured memory_bytes: 256
let words str =
  let len = String.length str in
  let buf = Buffer.create 10 in
  let rec loop acc = function
      i when i = len -> acc, (Buffer.contents buf |> int_of_string)
    | i ->
      loop
        (match str.[i] with
         | ' ' ->
           let v = Buffer.contents buf |> int_of_string in
           Buffer.clear buf; v
         | c ->
           Buffer.add_char buf c; acc)
        (i+1)
  in loop 0 0

let bsearch predicate maxv =
  let rec loop minp maxp =
    let middle =
      match maxp+minp with
        v when v mod 2 = 0 -> v/2
      | v -> v/2 + 1 in
    if middle = maxp then (if predicate minp then minp else maxp) else
      match predicate middle with
        true -> loop minp middle
      | false -> loop middle maxp
  in
  loop 1 maxv

let check num_of_truck goods capacity =
  let len = Array.length goods in
  let rec loop acc = function
      _, i when i >= len -> true
    | 0, _  -> false
    | rem_truck, i -> match goods.(i)+acc with
        x when x > capacity -> loop 0 (rem_truck-1,i)
      | x -> loop x (rem_truck,i+1)
  in
  loop 0 (num_of_truck,0)

let () =
  let n,num_of_truck = read_line () |> words in
  let goods = Array.init n (fun _ -> read_int ()) in
  let sum = Array.fold_left (fun acc v -> acc+v) 0 goods in
  bsearch (check num_of_truck goods) sum |> Printf.printf "%d\n"

Measured memory_bytes: 5256
def abs(i):
    if i <0:
        i = -i
    return i
N = int(input())
As = [int(Ai) for Ai in input().split()]
count = 0
for i in As:
    if i <= 0:
        count += 1
As_prime = [abs(Ai) for Ai in As]
if count % 2 == 0:
    print(sum(As_prime))
else:
    print(sum(As_prime)-2*min(As_prime))

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

int dp[50001];
int N,M;
vector<int>C;
int main(){
    cin>>N>>M;
    C.resize(M);
    for(int i=0;i<M;i++)cin>>C[i];

    for(int i=1;i<=N;i++){
        int mi=1001001001;
        for(int j=0;j<M;j++){
            if(i-C[j]<0)continue;
            mi=min(mi,dp[i-C[j]]+1);
        }
        dp[i]=mi;
    }
    cout<<dp[N]<<endl;
    return 0;
}

Measured memory_bytes: 1388
#include <stdio.h>

int main(void)
{
	int b1;
	int b2;
	int b3;
	
	scanf("%d %d %d", &b1, &b2, &b3);
	
	if ((b1 == 1) && (b2 == 1) || (b3 == 1)){
		printf("Open\n");
	}
	else {
		printf("Close\n");
	}
	return (0);
}

Measured memory_bytes: 584
#include <iostream>

using namespace std;

int main(void) {
    int64_t X, Y;
    cin >> X >> Y;
    Y /= X;
    for(int i=0; i<62; i++) {
        if(1LL<<i > Y) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
char s[1000009], t[10009];
int main() {
	scanf("%s%s", s, t);
	unsigned long long hs = 0, ht = 0, pw = 1;
	int sl = strlen(s), tl = strlen(t);
	for (int i = 0; i < tl; i++) {
		hs = (hs << 8) + hs + s[i];
		ht = (ht << 8) + ht + t[i];
		pw = (pw << 8) + pw;
	}
	for (int i = tl; i <= sl; i++) {
		if (hs == ht) printf("%d\n", i - tl);
		hs = (hs << 8) + hs + s[i] - s[i - tl] * pw;
	}
	return 0;
}

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

int main(){
    int N;
    cin >>N;
    int A[N];
    for(int i =0; i < N; i++){
        cin >> A[i];
    }
    int m = *min_element(A, A + N);
    int M = *max_element(A, A + N);		
    // int temp = 0;
    // for(int i =0; i < N - 1; i++){
    //     for(int j = i + 1; j < N; j++){
    //         if(abs(A[i]-A[j]) >temp) temp =abs(A[i]-A[j]);
    //     }
    // }
    cout << M - m << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc154e()
}

fun abc154e() {
    val s = readLine()!!
    val K = readLine()!!.toInt()
    val n = s.length

    val dp = Array(105) { Array(4) { LongArray(2) } }
    dp[0][0][0] = 1

    for (i in 0 until n) {
        for (j in 0..K) {
            for (k in 0..1) {
                val nd = s[i] - '0'
                for (d in 0..9) {
                    val ni = i + 1
                    var nj = j
                    var nk = k
                    if (d != 0) nj++
                    if (nj > K) continue
                    if (k == 0) {
                        if (d > nd) continue
                        if (d < nd) nk = 1
                    }
                    dp[ni][nj][nk] += dp[i][j][k]
                }
            }
        }
    }

    val answer = dp[n][K].sum()

    return println(answer)
}


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

const long long INF = -1 * 1e18;

struct edge{  
  int to;
  int cost;
  edge(int &to, int &cost){  
    this-> to = to;
    this-> cost = cost;
  }
};

int V, E;

//if G has negative cycle d[start] = INF
vector<long long> BellmanFord(int start, vector<vector<edge>> G){  
  vector<long long> d(V, INF);
  d[start] = 0;
  long long N = 0;
  for(int i = 0; i <= 2 * V; i++){  
    bool update = false;
    if(i == V){  
      N = d[V-1];
    } 
    if(i == 2 * V){
      if(N == d[V-1]) cout << d[V-1] <<endl;
      else cout << "inf" <<endl;
      return d;
    }
    for(int j = 0; j < V; j++){  
      for(auto e: G[j]){  
        if(d[j] == INF) continue;
        else if(d[e.to] < d[j] + e.cost){  
          d[e.to] = d[j] + e.cost; 
          update = true;
        } 
      } 
    }
    if(!update){ 
      cout << d[V-1] <<endl; 
      return d;
    }
  }
  return d;
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  cin >> V >> E;
  vector<vector<edge>> G(V);
  for(int i = 0; i < E; i++){  
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back(edge(b, c));
  }
  BellmanFord(0, G);;
}


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

#define NAME "test"
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define ms(arr,val) memset(arr,val,sizeof(arr))
#define len length()

const int maxn = 50;
vector<int> pos[26];
int main(){
    //ifstream cin(NAME".inp");
    string s,t;
    cin>>s>>t;

    for(int i=0;i<s.len;i++) pos[s[i]-'a'].push_back(i);

    for(int i=0;i<t.len;i++) if (pos[ t[i]-'a' ].size()==0 ) {
        cout<<-1;
        return  0;
    }

    int pre = -1;
    int cycle = 0;
    int id;
    for(int i=0;i<t.len;i++){
        id = lower_bound( pos [t[i]-'a' ].begin(),pos [t[i]-'a' ].end() ,pre+1) - pos [t[i]-'a' ].begin();
        if (id == pos [t[i]-'a' ].size()){
            // do recycle
            pre = pos [t[i]-'a' ][0];
            cycle++;
        }else{
            pre = pos[t[i]-'a'][id];
        }
    }
    cout<<s.len*cycle + pre+1<<endl;
}


Measured memory_bytes: 4188
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        int[] input = ReadInts();
        int A = input[0];
        int B = input[1];
        if (A <= 5) return "0";
        else if (A <= 12) return (B / 2).ToString();
        else return B.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11092
#coding:utf-8

N = int(input())

C = str(input())

Lis = [0,0] #["R","W"]

for i in C:
    if i == "R":
        Lis[0] += 1
    else:
        Lis[1] += 1

D = "R" * Lis[0] + "W" * Lis[1]

Lis = [0,0]

for s,t in zip(C,D):
    if (s != t) and (s == "R"):
        Lis[0] += 1
    elif (s != t) and (s == "W"):
        Lis[1] += 1

print("{}".format(max(Lis)))

Measured memory_bytes: 9528
N = int(input())
K = int(input())
I = list(map(int,input().split()))
dis = 0

for i in I:
    a = i           #0からiまでの距離
    b = abs(K-i)    #Kからiまでの距離
    if a >= b:
        dis += 2 * b
    else:
        dis += 2 * a


print(dis)

Measured memory_bytes: 3060
def main():
    Sdict = {}
    Tdict = {}
    S = list(input())
    T = list(input())
    for i in S:
        if i in Sdict.keys():
            Sdict[i] += 1
        else:
            Sdict[i] = 1
    for i in T:
        if i in Tdict.keys():
            Tdict[i] += 1
        else:
            Tdict[i] = 1
    if sorted(list(Sdict.values())) == sorted(list(Tdict.values())):
        print("Yes")
    else:
        print("No")

main()

Measured memory_bytes: 6704
import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        long A = sc.nextLong();
        long B = sc.nextLong();
        long N = sc.nextLong();
        long i =Math.min(B-1,N);
        System.out.println((A*i/B)-A*(i/B));
    }
}

Measured memory_bytes: 35680
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    cin >> n;
    vec(a,62);
    REP(i,n){
        int tmp;
        cin >> tmp;
        REP(j,62){
            int x = tmp%2;
            if(x==1){
                a[j]++;
            }
            tmp /= 2;
        }
    }
    int ans = 0;
    int t = 1;
    REP(i,62){
        int s = a[i]*(n-a[i])%max_int;
        ans += t*s;
        ans %= max_int;
        t *= 2;
        t %= max_int;
    }
    print(ans);

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


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

int N, A[1 << 18], B[1 << 18];
multiset<int> S;

int main() {
	cin >> N;
	for (int i = 0; i < (1 << N); i++) { cin >> A[i]; S.insert(A[i]); }
	sort(A, A + (1 << N));

	B[0] = A[(1 << N) - 1];
	for (int i = 0; i <= N - 1; i++) {
		for (int j = 0; j < (1 << i); j++) {
			auto itr = S.lower_bound(B[j]);
			if (itr == S.begin()) {
				cout << "No" << endl;
				return 0;
			}
			itr--;
			B[j + (1 << i)] = (*itr);
			S.erase(itr);
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 14592
// AOJ 0056: Goldbach's Conjecture
// 2017.11.3 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MAX  50000
#define SQRT 223

char prime[MAX+5] = {1,1,0,0,1}, *pmax = prime+MAX;
char buf[100], *p;

int main()
{
	int n, i, ans;
	char *p1, *p2;

//	memset(prime, 1, MAX), prime[1] = 0;
	for (p1 = prime + 3, i = 3; i <= SQRT; p1 += 2, i += 2) if (!*p1) {
		for (p2 = p1 + i; p2 <= pmax; p2 += i) *p2 = 1;
	}

	while (fgets(p=buf, 10, stdin) && *buf != '0') {
		n = 0; while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
		if (n & 1) putchar('1'-prime[n-2]), putchar('\n');
		else if (n == 4) puts("1");
		else {
			i = n >> 1;
			p1 = p2 = prime + i;
			if (!(i & 1)) i--, p1--, p2++;
			for (ans = 0; i > 0; i -= 2, p1 -= 2, p2 += 2) {
				if (!*p1 && !*p2) ans++;
			}
			printf("%d\n", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int64_t h;
  cin >> h;
  int64_t ct=1LL;
  int64_t i=1LL;
  if(h==1) cout << 1 << endl;
  else{
    while(h/2>0){
      ct += pow(2, i);
      //cout << ct << endl;
      i++;
      h /= 2;
    }
  
  cout << ct << endl;
  }
} 

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
//#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define reps(i, j, k) for(auto i = j; i < k; ++i)
#define rep(i, j) reps(i, 0, j)
#define decs(i, j, k) for(auto i = j; i >= k; --i)
#define dec(i, j) decs(i, j, 0)
#define iter(i, j) for(auto i = j.begin(); i != j.end(); ++i)
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define vpi vector<pi>
#define vb vector<bool>
#define F first
#define S second
#define mp make_pair
#define um unordered_map
#define all(x) (x).begin(), (x).end()  
#define fast_io ios::sync_with_stdio(0); cin.tie(0);
#define file_io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define IMAX std::numeric_limits<int>::max()
#define IMIN std::numeric_limits<int>::min()
using namespace std;

int main()
{
    //fast_io
    //file_io
	int A, B; cin >> A >> B;
	int p = 2000;
	for(int b = 1000; b > 0; b /= 2)
		while(p - b >= 0 && floor((p - b) * 0.08) >= A && floor((p - b) * 0.1) >= B)
			p -= b;
	if(floor(p * 0.08) == A && floor(p * 0.1) == B)
		cout << p;
	else cout << -1;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn consume_num(target: u64,num: u64) -> u64 {
    if target <= num {return 1};
    if target % num != 0 {
        target / num + 1
    } else {
        target / num
    }
}

fn main() {
    input!(
        n: u64,
        a: u64,
        b: u64,
        c: u64,
        d: u64,
        e: u64,
    );

    let mut min = a;
    let n_a = consume_num(n, a); 
    if min > b {min = b};
    let a_b = n_a + consume_num(n - (n_a - 1) * min, b); 
    if min > c {min = c};
    let b_c = a_b + consume_num(n - (a_b - 2) * min, c);
    if min > d {min = d}; 
    let c_d = b_c + consume_num(n - (b_c - 3) * min, d);
    if min > e {min = e}; 
    let d_e = c_d + consume_num(n - (c_d - 4) * min, e); 
    println!("{:?}",d_e);

}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    string s; cin>>s;
    int n=s.size();

    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=1; i+j<=n; j++){
            string t = s.substr(i, j);
            //cout << t << endl;

            bool valid = true;
            for(int k=0; k<t.size(); k++){
                if(t[k] != 'A' && t[k] != 'T' && t[k] != 'C' && t[k] != 'G'){
                    valid = false;
                }
            }

            if(valid){
                //cout << t.size() << endl;
                chmax(ans, (int)t.size());
            }
        }
    }

    cout << ans << endl;
}

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

using namespace std;
struct op
{
    string name;
    int p;
    int w;
}s[10010];
bool cmp(op a,op b)
{
    if(a.name==b.name)
        return a.p>b.p;
    return a.name<b.name;
}
int main()
{
	int n;
	while(cin>>n)
    {
        for(int i=0;i<n;i++)
        {
            cin>>s[i].name>>s[i].p;
            s[i].w=i+1;
        }
        sort(s,s+n,cmp);
        for(int i=0;i<n;i++)
        {

            cout<<s[i].w<<endl;
        }

    }
	return 0;
}

/*
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
*/


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int k, a, b;
    cin >> k >> a >> b;

    for (int i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            OP("OK");
            return 0;
        }
    }
    OP("NG");
    return 0;
}

Measured memory_bytes: 3612
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
CB = []
for i in range(M):
    B, C = list(map(int, input().split()))
    CB.append([C, B])
 
A.sort()
A.reverse()
CB.sort()
CB.reverse()
 
ans = 0
a_index = 0
cb_index = 0
f = 0
 
while True:
    if f == 1 or A[a_index] >= CB[cb_index][0]:
        ans += A[a_index]
        a_index += 1
        N -= 1
        if N == 0:
            break
    else:
        if N <= CB[cb_index][1]:
            ans += CB[cb_index][0] * N
            break
        else:
            ans += CB[cb_index][0] * CB[cb_index][1]
            N -= CB[cb_index][1]
            cb_index += 1
            if len(CB) == cb_index:
              f = 1
 
print(ans)

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

int main() {
  double N, K;
  cin >> N >> K;
  
  vector<double> p(N);
  for(int i=0; i<N ;i++){
    cin >> p.at(i);
  }
  
  double pnowa = 0;
    for(int j=0; j<K ; j++){
      pnowa = pnowa + p.at(j);
    }
  
  double saidai = pnowa;
  
  for(int i=0; i<N-K ; i++){
    pnowa = pnowa - p.at(i) + p.at(i+K);
        
    if(pnowa>saidai){
      saidai = pnowa;
    }
  }
  double kitaichi = (saidai+K)/2;
  
  
  printf("%.10f\n", kitaichi);
 
  
}



Measured memory_bytes: 4912
#include <complex>
#include <vector>
#include <cmath>
#include <utility>
#include <cassert>
#include <cmath>
#include <iostream>

#include <algorithm>
const double EPS=1e-10;

#define equals(a, b) (fabs((a)-(b))<EPS)
#define X real()
#define Y imag()

using namespace std;

typedef complex<double> Point;
typedef complex<double> Vector;

struct Segment {
    Point p1, p2;
};
typedef Segment Line;

struct Circle {
    Point c;
    double r;
    Circle(Point c=Point(), double r=0.0) :
        c(c),r(r){}
};

typedef vector<Point> Polygon;

double dot(Vector a, Vector b) {
    return a.X*b.X + a.Y*b.Y;
}

double cross(Vector a,Vector b) {
    return a.X*b.Y - a.Y*b.X;
}

Point project(Segment s, Point p) {
    Vector base = s.p2-s.p1;
    double r=dot(p-s.p1,base) / norm(base);
    return s.p1+base*r;
}

Point reflect(Segment s, Point p) {
    return p+(project(s,p)-p)*2.0;
}

enum CCW {
    COUNTER_CLOCKWISE=1,
    CLOCKWISE=-1,
    ONLINE_BACK=2,
    ONLINE_FRONT=-2,
    ON_SEGMENT=0,
};

int ccw(Point p0, Point p1, Point p2) {
    Vector a=p1-p0;
    Vector b=p2-p0;
    if(cross(a,b)>EPS) return CCW::COUNTER_CLOCKWISE;
    if(cross(a,b)<-EPS) return CCW::CLOCKWISE;
    if(dot(a,b)<-EPS) return CCW::ONLINE_BACK;
    if(norm(a)<norm(b)) return CCW::ONLINE_FRONT;

    return CCW::ON_SEGMENT;
}

double getDistance(Point a,Point b) {
    return abs(a-b);
}

double getDistanceLP(Line l, Point p) {
    return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

bool intersect(Point p1,Point p2,Point p3,Point p4) {
    return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&
            ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2) {
    return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}
bool intersect(Circle c,Line l) {
    return getDistanceLP(l,c.r)<=c.r;
}

Point getCrossPoint(Segment s1,Segment s2) {
    Vector base=s2.p2-s2.p1;
    double d1=abs(cross(base,s1.p1-s2.p1));
    double d2=abs(cross(base,s1.p2-s2.p1));
    double t=d1/(d1+d2);
    return s1.p1+(s1.p2-s1.p1)*t;
}
pair<Point, Point> getCrossPoints(Circle c, Line l) {
    // assert(intersect(c,l));
    Vector pr=project(l,c.c);
    Vector e=(l.p2-l.p1)/abs(l.p2-l.p1);
    double base=sqrt(c.r*c.r-norm(pr-c.c));

    return make_pair(pr+e*base,pr-e*base);

}

pair<Point,Point> getCrossPoints(Circle c1, Circle c2) {
    double d=abs(c1.c-c2.c);
    double a=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
    double t=arg(c2.c-c1.c);

    return make_pair(c1.c+polar(c1.r,t+a),c1.c+polar(c1.r,t-a));
}

int main() {
    Circle c1,c2;
    double x,y,r;
    cin>>x>>y>>r;
    c1=Circle(Point{x,y},r);
    cin>>x>>y>>r;
    c2=Circle(Point{x,y},r);
    vector<Point> ans;
    auto t=getCrossPoints(c1,c2);
    Point p1,p2;
    p1=t.first;
    p2=t.second;

    if(p1.X>p2.X||(p1.X==p2.X&&p1.Y>p2.Y)) swap(p1,p2);
    printf("%.10f %.10f %.10f %.10f\n",p1.X,p1.Y,p2.X,p2.Y);
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define int long long
#define inf 200000000
const int maxnodes=1005;
#define ll long long
#define N 301
#define EPS 0.01
#define ld long double



int32_t main()
{
    IOS;

    int n;
    cin >> n;
    multiset<double> s;
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        s.insert(a);
    }
    while(s.size() >= 2)
    {
        double a = *s.begin();
        s.erase(s.begin());
        double b = *s.begin();
        s.erase(s.begin());
        s.insert((a+b)/2);
    }
    cout << fixed << setprecision(6);
    cout << *s.begin();
}

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

int main(void){
    int b,n,q,i,tmp=0;
    string a;
    queue<string> qu_name;
    queue<int> qu_time;
    cin >> n >> q;
    for(i=0;i<n;i++){
        cin >> a >> b;
        qu_name.push(a);
        qu_time.push(b);
    }
    while(!qu_time.empty()){
        b=qu_time.front();
        a=qu_name.front();

        if(b<=q){
            tmp+=qu_time.front();
            cout << a << " " << tmp << endl;
            qu_time.pop();
            qu_name.pop();

        }
        else{
            tmp+=q;
            qu_time.pop();
            qu_name.pop();
            qu_name.push(a);
            qu_time.push(b-q);
        }
    }
    return 0;
}

Measured memory_bytes: 5804
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Comparator;

/**
 * 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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            int A[][] = new int[N][2];

            for (int i = 0; i < N; i++) {
                A[i][0] = in.nextInt();
                A[i][1] = in.nextInt();
            }
            Arrays.sort(A, Comparator.comparing((int[] a) -> a[0]));

            long sum = 0;
            int k = 0;
            for (int i = 0; i < M; i++) {
                A[k][1]--;
                sum += A[k][0];
                if (A[k][1] == 0) {
                    k++;
                }
            }

            out.println(sum);
        }

    }
}



Measured memory_bytes: 94752
#include<stdio.h>

int main(void){
  int i,n;
  int sum;
  int ue,
      mae,migi,usiro,hidari,
      sita,
      swp;
  char ope[10];

  for(;;){
    scanf("%d",&n);
    if(n==0)
      break;

    ue=1;
    mae=2;
    migi=3;
    usiro=5;
    hidari=4;
    sita=6;

    sum=1;

    for(i=0;i<n;i++){
      scanf("%s",ope);

      if(ope[0]=='N'){
        swp=ue;
        ue=mae;
        mae=sita;
        sita=usiro;
        usiro=swp;
      }else if(ope[0]=='E'){
        swp=ue;
        ue=hidari;
        hidari=sita;
        sita=migi;
        migi=swp;
      }else if(ope[0]=='W'){
        swp=ue;
        ue=migi;
        migi=sita;
        sita=hidari;
        hidari=swp;
      }else if(ope[0]=='S'){
        swp=ue;
        ue=usiro;
        usiro=sita;
        sita=mae;
        mae=swp;
      }else if(ope[0]=='R'){
        swp=mae;
        mae=migi;
        migi=usiro;
        usiro=hidari;
        hidari=swp;
      }else if(ope[0]=='L'){
        swp=mae;
        mae=hidari;
        hidari=usiro;
        usiro=migi;
        migi=swp;
      }
      sum+=ue;
    }

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

  return 0;
}

Measured memory_bytes: 0
n=int(input())
l=list(map(int,input().split()))
cnt=0
length=len(l)
for i in range(1,length-1):
  if (l[i]>l[i-1] and l[i]<l[i+1]):
    cnt+=1
  elif(l[i]<l[i-1] and l[i]>l[i+1]):
    cnt+=1
print (cnt)
  

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int r[n]={0};
	
	for(int i=0; i<n; i++)
	{
		cin >> r[i];
	}
	
	int minv = r[0];
	int maxv = r[1] - r[0];
	
	for(int j=1; j<n; j++)
	{
		maxv = max(maxv, r[j] - minv);
		minv = min(minv, r[j]) ;
	}
	
	cout << maxv << endl;
	
	return 0;
} 


Measured memory_bytes: 3876
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int N,A,B;
  cin >> N;
  if(N==1){
      cout << "Hello World" << endl;
  }if(N==2){
      cin >> A >> B;
      cout << A+B << endl;
  }

}

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

int main(int argc, const char * argv[]) {
    int temp;
    int x[3];
    string str;
   
    for(int i=0; i< sizeof(x)/sizeof(x[0]); i++){
        cin >> x[i];
    }
    
    for(int i=0; i< (sizeof x)-1; i++){
        for(int j=0; j< 2;j++){
            if(x[j]> x[j+1]){
                temp = x[j];
                x[j]=x[j+1];
                x[j+1]=temp;
            }
        }
    }

        cout << x[0] << " " << x[1] << " " << x[2]  << endl;
return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;

int main() {
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k%2) {
        cout<<b-a<<endl;
    } else {
        cout<<a-b<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3544
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    xs <- getIntList
    print $ minimum [sum (map (\x -> (x - p) ^ 2) xs) | p <- [1..100]]

Measured memory_bytes: 508