akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

class UnionFind {
public:
    vector<long long> parent;
    long long n;
    UnionFind(long long x) :parent(x, -1), n(x){}
    bool unite(long long x, long long y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x, y);
        parent[x] += parent[y]; parent[y] = x;
        return true; }
    bool same(long long x, long long y){ return find(x) == find(y); }
    long long find(long long x){ return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    long long size(long long x){ return -parent[find(x)]; }
};

int main(){
    Init();
    UnionFind uf(13);
    uf.unite(1, 3);    
    uf.unite(1, 5);    
    uf.unite(1, 7);    
    uf.unite(1, 8);    
    uf.unite(1, 10);    
    uf.unite(1, 12);    
    uf.unite(4, 6);    
    uf.unite(4, 9);    
    uf.unite(4, 11);
    ll x, y; cin >> x >> y;
    (uf.same(x, y)) ? Yes() : No();

}

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

int main() {
	int n, p[20], sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> p[i];
	sort(p, p + n);
	sum += p[n - 1] / 2;
	for (int i = 0; i < n - 1; i++) sum += p[i];
	cout << sum << endl;
	return 0;
}

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

#define IMAX 2147483647
#define WHITE 1
#define BLACK -1
#define GRAY 0

typedef struct{
  int d;
  int p;
  int color;
  int M[100];
} Point;

int root(Point *, int);

int main(){
  Point *A;
  int i,j,n;
  
  scanf("%d",&n);

  A=(Point *)malloc(sizeof(Point *) * n);
  
  //for(i=0;i<n;i++) A[i].M=(int *)malloc(sizeof(int) * n);
  
  for(i=0;i<n;i++) for(j=0;j<n;j++){
      scanf("%d",&A[i].M[j]);
      if(A[i].M[j] == -1) A[i].M[j]=IMAX;
    }

  //printf("\n");for(i=0;i<n;i++){for(j=0;j<n;j++)printf(" %d",A[i].M[j]);printf("\n");}

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

  return 0;
}

int root(Point *A,int n){
  int min,u,i,sum=0;
  
  for(u=0;u<n;u++){
    A[u].color=WHITE;
    A[u].d=IMAX;
    A[u].p=-1;
  }
  A[0].d=0;

  while(1){
    u=-1;
    min=IMAX;
    
    for(i=0;i<n;i++) if(A[i].color != BLACK && A[i].d < min){
	//printf("min=%d,A[%d].d=%d\n",min,i,A[i].d);
	min=A[i].d;
	u=i;
      }

    //printf("u=%d\n",u);

    if(u == -1) break;

    A[u].color = BLACK;

    for(i=0;i<n;i++) if(A[i].color != BLACK && A[u].M[i] != IMAX)if(A[u].M[i] < A[i].d){
	A[i].d=A[u].M[i];
	A[i].p=u;
	A[i].color=GRAY;
	//printf("i=%d,d=%d,p=%d,color=%d\n",i,A[i].d,A[i].p,A[i].color);
      }
  
  }
  for(i=0;i<n;i++) if(A[i].p != -1){
      sum+=A[i].M[ A[i].p ];
      //printf("A[%d].M[%d]=%d\n",i,A[i].p,A[i].M[ A[i].p ]);
    }

  return sum;
}



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

const int64_t INF = 1e15;

int main() {
    int64_t N; cin >> N;
    vector<int64_t> X(N), Y(N), P(N);
    for(int i = 0; i < N; ++i) cin >> X[i] >> Y[i] >> P[i];
    vector<vector<int64_t>> costx(1 << N, vector<int64_t>(N));
    vector<vector<int64_t>> costy(1 << N, vector<int64_t>(N));
    for(int S = 0; S < (1 << N); ++S) {
        for(int i = 0; i < N; ++i) {
            costx[S][i] = abs(X[i]) * P[i];
            for(int j = 0; j < N; ++j) {
                if(S & (1 << j)) costx[S][i] = min(costx[S][i], abs(X[i] - X[j]) * P[i]);
            }
        }
    }
    for(int S = 0; S < (1 << N); ++S) {
        for(int i = 0; i < N; ++i) {
            costy[S][i] = abs(Y[i]) * P[i];
            for(int j = 0; j < N; ++j) {
                if(S & (1 << j)) costy[S][i] = min(costy[S][i], abs(Y[i] - Y[j]) * P[i]);
            }
        }
    }
    vector<int64_t> ans(N + 1, INF);
    auto f = [&](auto &&f, int pos, int64_t XS, int64_t YS) -> void {
        if(pos == N) {
            vector<int64_t> cost(N);
            for(int i = 0; i < N; ++i) {
                cost[i] = min(costx[XS][i], costy[YS][i]);
            }
            int n = __builtin_popcount(XS) + __builtin_popcount(YS);
            ans[n] = min<int64_t>(ans[n], accumulate(cost.begin(), cost.end(), 0LL));
            return;
        }
        int npos = pos + 1;
        f(f, npos, XS, YS);
        f(f, npos, XS | (1 << pos), YS);
        f(f, npos, XS, YS | (1 << pos));
    };
    f(f, 0, 0, 0);
    for(int i = 0; i <= N; ++i) cout << ans[i] << '\n';
    return 0;
}


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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	
	vector<int> vec(n);
	for (int i = 0; i < n; i++) {
		cin >> vec[i];
	}
	sort(vec.begin(), vec.end(), greater<int>());
	
	int diff = vec[0] - vec[k - 1];
	for (int i = 0; i <= n - k; i++)
		diff = min(diff, vec[i] - vec[i + k - 1]);
	
	cout << diff << endl;
	
	return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  int n; cin>>n;
  vector<int> a(n+5, 0);
  for (int i=1; i<=n; i++) {
    cin>>a[i];
  }
  ll sum=0;
  for (int i=0; i<=n+1; i++) {
    sum+=abs(a[i]-a[i-1]);
  }
  for (int i=1; i<=n; i++) {
    cout << (sum + abs(a[i+1]-a[i-1]) - (abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))) << endl;
  }
}

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


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

using namespace std;

int main()
{
	string qn,str,p,answer;
	int q,a,b,y;
	cin >> str >> q;
	for (int i = 0 ; i < q ; i++ ){
		cin >> qn;
		if (qn == "replace"){
			cin >> a >> b >> p;
			for (int j = 0 ; j < b - a + 1 ; j++ ){
				str[a + j] = p[j]; 
			}
		} 

		if (qn == "reverse"){
			cin >> a >> b;
				for (int x = a ; x < b ; x++ ){
					y = b;
					answer[x] = str[x];
					
				    str[x] = str[y];
				    str[y] = answer[x];
					b--;
                   
				}
		}
		
		if (qn == "print"){
			cin >> a >> b;
			cout << str.substr(a,b - a + 1) << endl;
		}
	}

 return 0;
}

Measured memory_bytes: 3228
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
int main(){
	int ans = 0;
	for(int i = 0; i < 10; i++){
		int a;
		scanf("%d",&a);
		ans += a;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
	string o, e;
	cin >> o >> e;
	for (int i = 0; i < e.size(); i++)
		cout << o[i] << e[i];
	if (o.size() > e.size())
		cout << o.back();
	cout << endl;
}

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

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

int main() {
    ll N;
    cin >> N;
    ll P[200000] = {};
    rep(i,N){
        cin >> P[i];
    }
    ll minn = INF;
    ll ans = 0;
    rep(i,N){
        if(P[i] <= minn) ans++;
        minn = min(P[i],minn);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ab = []
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    ab.append((a,b))
ab = sorted(ab)
for c, d in ab:
    if m >= d:
        ans += c*d
        m -= d
    else:
        ans += c*m
        break
print(ans)

Measured memory_bytes: 17740
#include<stdio.h>

int main(void)
{
	int i,j,temp,A[100],n,count=0;
	
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	{
		scanf("%d",&A[i]);
	}
	for(i=0;i<=n-2;i++)
	{
		for(j=0;j<=n-2-i;j++)
		{
			if(A[j]>A[j+1])
			{
				temp=A[j+1];
				A[j+1]=A[j];
				A[j]=temp;
				count++;
			}
		}
	}
	printf("%d",A[0]);
	for(i=1;i<=n-1;i++)
	{
		printf(" %d",A[i]);
	}
	printf("\n");
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 1800
fun main(args: Array<String>){
    val X = readLine()!!.toInt()
    var max: Int = 1
    for (b in 1 until 33){
        var num: Int = b
        for (p in 2 until 10){
            num *= b
            if (num <= X && num > max){
                max = num
            }
        }
    }
    println(max)
}

Measured memory_bytes: 31928
N = int(input())
H = list(map(int,input().split()))

answer = 0
now = 0

for i in range(N-1):
    if H[i] >= H[i+1]:
        now += 1
    elif now > answer:
        answer = now
        now = 0
    else:
        now = 0

if now > answer:
    answer = now

print(answer)


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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  int ans = X;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    int temp = (D + A - 1) / A;
    ans += temp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
k = inp()
now = 1
for _ in range(n):
    now = min(now+k, now*2)
print(now)

Measured memory_bytes: 95784
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#define	MOD  1000000007;
#define PI = 3.14159265358979323846;
using namespace std;

int main()
{
	int N;
	cin >> N;

	int A[100000];
	map<int, int> mp;
	map<int, int>::iterator it;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		mp[A[i]]++;
	}

	int count = 0;
	for (it = mp.begin(); it != mp.end(); it++)
	{
		if (it->second % 2 != 0)
		{
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    pair<int,int> U = make_pair(0,1),D = make_pair(0,-1),L = make_pair(-1,0),R = make_pair(1,0);
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;

    int  dx = tx - sx,dy = ty - sy;

    for(int i = 0; i < dx;i++){
        cout << "R";
    }
    for(int i = 0; i < dy;i++){
        cout << "U";
    }

    for(int i = 0; i < dx;i++){
        cout << "L";
    }
    for(int i = 0; i < dy;i++){
        cout << "D";
    }
    cout << "D";
    for(int i = 0; i < dx+1;i++){
        cout << "R";
    }
    for(int i = 0; i < dy+1;i++){
        cout << "U";
    }
    cout << "L";

    cout << "U";
    for(int i = 0; i < dx+1;i++){
        cout << "L";
    }
    for(int i = 0; i < dy+1;i++){
        cout << "D";
    }
    cout << "R";
    return 0;
}

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

void DFS(ll x, int n, int& ans)
{
	if (n < x) return;

	string tmp = to_string(x);
	map<char, int> mp;
	for (int i = 0; i < tmp.size(); i++) {
		if (mp.count(tmp[i])) mp[tmp[i]]++;
		else mp[tmp[i]] = 1;
	}
	if (mp.size() == 3) ans++;

	DFS(x * 10 + 3, n, ans);
	DFS(x * 10 + 5, n, ans);
	DFS(x * 10 + 7, n, ans);
}

int main()
{
	int n;
	cin >> n;
	vector<int> a;
	int ans = 0;
	DFS(0, n, ans);
	cout << ans << endl;
}


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

namespace ConsoleApp15
{
    class Class167
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            long p = 1;
            for(int i = 1; i <= N; i++)
            {
                p *= i;
                p %= 1000000007;
            }
            Console.WriteLine(p);
        }
    }
}


Measured memory_bytes: 11092
from itertools import product
from math import ceil
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = 10**9
for bit in product([0, 1], repeat=d):
    score = 0
    probs = 0
    for i, b in enumerate(bit):
        p, c = pc[i]
        if b==1:
            probs+=p
            score+=100*(i+1)*p
            score+=c
    if score >= g:
        ans = min(ans, probs)
    else:
        # greedyに足す
        for i, b in list(enumerate(bit))[::-1]:
            p, c = pc[i]
            if b==1:
                continue
            if score+100*(i+1)*p >= g:
                a = ceil((g-score)/(100*(i+1)))
                probs += a
                score += (100*(i+1))*a
                if a == p: score += c
                break
            else:
                probs += p
                score += (100*(i+1))*p+c
                if score >= g: break
        if score >= g:
            ans = min(ans, probs)
print(ans)

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

  if (S.size() <= K) cout << S << endl;
  else {
    REP(i, K) cout << S[i];
    cout << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
n = int(input())

p_list = [int(x) for x in input().split()]
q_list = sorted(p_list)

count = 0
ans = "YES"
for p, q in zip(p_list, q_list):
    if p != q:
        count += 1
        if count > 2:
            ans = "NO"
            break
print(ans)

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define loop(i, n) for(int i = 0;i < n;i++)

int main(void){

    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(8) << sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)) << endl;

    return 0;
}



Measured memory_bytes: 3272
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::*;

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed reading char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed parsing")
}

fn main() {
  let n: usize = read::<usize>();

  let mut p: Vec<usize> = vec![];

  for _ in 0..n {
    p.push(read::<usize>());
  }

  let mut count: usize = 1;
  let mut minn: usize = p[0];
  for i in 1..n {
    if p[i] <= minn {
      count = count + 1;
      minn = p[i];
    }
  }
  println!("{}", count);
}


Measured memory_bytes: 6396
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, t;
	vector <pair<int, int>> v;

	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		cin >> t;
		v.push_back(make_pair(t, i));
	}

	sort(v.begin(), v.end());

	for (auto it : v)
	{
		cout << it.second << ' ';
	}
	cout << '\n';

	return 0;
}


Measured memory_bytes: 1780
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int i,n,L;
    cin>>n>>L;
    vi v(n,0);
    rep(i,n)v[i]=L+i;
    int minp=0;
    int minatai=INF;
    rep(i,n){
        if(abs(v[i])<minatai){
            minp=i;
            minatai=abs(v[i]);
        }
    }
    int sum=0;
    rep(i,n){
        if(i!=minp)sum+=v[i];
    }
    cout<<sum<<endl;
//////////////////////////////////////////////////////
return 0;}

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

int main()
{
   char s[200000];
   cin>>s;
   int sum = 0, i=0;
   while(s[i])
   {
       sum = sum + (int)s[i] - 48;
     i++;
     if(sum%9==0)
       sum=0;
   }
   if(sum%9==0)
   cout<<"Yes\n";
   else
   cout<<"No\n";
   return 0;
}

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

const int N = 6005;
std::string s, f[N];
int n, apos[N], bpos[N], id[N];
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> s;
	int a = 0, b = 0;
	for (int i = 0; i < n + n; ++i)
		if (s[i] == 'a') apos[a] = i, id[i] = a++;
		else bpos[b] = i, id[i] = b++;
	f[n - 1] = apos[n - 1] < bpos[n - 1] ? "ab" : "ba";
	for (int i = n - 2; ~i; --i) {
		f[i] = f[i + 1];
		if (apos[i] < bpos[i]) {
			f[i] = std::max(f[i], "ab" + f[i + std::count(s.begin() + apos[i], s.begin() + bpos[i], 'a')]);
		} else {
			std::string t; int q = 0;
			for (int j = bpos[i]; j < n + n; ++j) if (id[j] >= i) {
				q += s[j] == 'b' ? 1 : -1, t += s[j];
				if (!q) break;
			}
			f[i] = std::max(f[i], t + f[i + t.size() / 2]);
		}
	}
	std::cout << f[0] << '\n';
	return 0;
}

Measured memory_bytes: 14720
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N;

int main() {
  cin >> N;
  int last = N % 10;
  if (last == 2 || last == 4 || last == 5 || last == 7 || last == 9) {
    cout << "hon" << endl;
    return 0;
  } else if (last == 3) {
    cout << "bon" << endl;
    return 0;
  } else {
    cout << "pon" << endl;
  }
}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int Maxn = 100000;
char s[Maxn];
int l;
bool f;
int main()
{
    f = false;
    scanf("%s",s);
    l = strlen(s);
    for (int i = 0; i < l; i++)
        if(s[i] == 'A' && s[i+1] == 'C')
        {
            f = true;
            break;
        }
    if(f)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  char txt;
 
  while(1){
    scanf("%c",&txt);
 
    if(txt>96 && txt<123)txt-=32;
    else  if(txt>64 && txt<91)txt+=32;
 
    printf("%c",txt);
   if(txt=='\n')break;
  }
  return 0;
}


Measured memory_bytes: 2044
import itertools
n=int(input())
p=input().split()
q=input().split()

def bikkuri(n):
    a=1
    for i in range(1,n+1):
        a*=i
    return a

ans=0
for i in range(n):
    pcnt=0
    qcnt=0
    for j in range(i+1,n):
        if p[i]>p[j]:
            pcnt+=1
        if q[i]>q[j]:
            qcnt+=1
    ans+=(pcnt-qcnt)*bikkuri(n-i-1)
print(abs(ans))


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var W = input[1];
            var Wmax = Enumerable.Repeat(long.MaxValue, (int)Math.Pow(10, 5) + 1).ToArray();
            Wmax[0] = 0;
            for (int i = 0; i < N; i++)
            {
                input = ReadArrayInt();
                var w = input[0];
                var v = input[1];
                for (int j = (int)Math.Pow(10, 5) + 1; j >= v; j--)
                {
                    if (Wmax[j - v] != long.MaxValue && Wmax[j - v] + w < Wmax[j])
                    {
                        Wmax[j] = Wmax[j - v] + w;
                    }
                }
            }

            for (int i = (int)Math.Pow(10, 5); i >= 0; i--)
            {
                if (Wmax[i] <= W)
                {
                    Console.WriteLine(i);
                    break;
                }
            }

            Console.WriteLine();
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << ((a <= c && c <= b) ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 3560
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005


ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


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


int main(){
    int n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll ans=0;
    bool flag=true;
    while(flag){
        flag=false;
        rep(i,0,n-1){
            ll plus=a[i]/n;
            if(plus>0){
                flag=true;
                ans+=plus;
                rep(j,0,n-1){
                    if(j==i){
                        a[j]-=plus*n;
                    }else{
                        a[j]+=plus;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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



Measured memory_bytes: 2732
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main() 
{
	int N;

	cin >> N;

	if (N<=999) 
	{
		cout << "ABC" << endl;
	}
	else
	{
		cout << "ABD" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	int n;
	cin>>n;

	int res = 0;
	for(int i = 0; i < n; i++){
		ll t;
		cin>>t;
		while(t%2==0){
			t/=2;
			res++;
		}
	} 
	cout<<res;
}

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

using namespace std;

typedef pair<int, int> P;
typedef pair<int, pair<int, int> > P3;

struct edge{
  int to,cost;
};

int minCost[101][11];
vector<edge> G[101];
static const int INF = INT_MAX;

int c,n,m,d;

int dijkstra(int s){
  priority_queue<P3, vector<P3>, greater<P3> >que;
  que.push(make_pair(0,make_pair(s,c)));

  for(int i=0;i<101;i++)
    for(int j=0;j<11;j++)
      minCost[i][j]=INF;

  while(!que.empty()){
    P3 p = que.top();
    que.pop();
    
    for(int i=0;i<G[p.second.first].size();i++){
      edge e = G[p.second.first][i];
      if(p.first+e.cost < minCost[e.to][p.second.second]){
	minCost[e.to][p.second.second] = p.first+e.cost;
	que.push(make_pair(p.first+e.cost,make_pair(e.to,p.second.second)));
      }
    }
    
    if(p.second.second==0)continue;
    
    for(int j=0;j<G[p.second.first].size();j++){
      edge e = G[p.second.first][j];
      if(p.first+e.cost/2 < minCost[e.to][p.second.second-1]){
	minCost[e.to][p.second.second-1] = p.first+e.cost/2;
	que.push(make_pair(p.first+e.cost/2,make_pair(e.to,p.second.second-1)));
      }
    }
  }
  int ans=INT_MAX;
  for(int i=0;i<11;i++)
    ans=min(minCost[d][i],ans);

  return ans;
}

int main(void){
  int a,b,f,s;

  while(cin >> c >> n >> m >> s >> d,c|n|m|s|d){

    for(int i=0;i<=n;i++)G[i].clear();

    for(int i=0;i<m;i++){
      cin >> a >> b >> f;
      edge e;
      e.to=b,e.cost=f;
      G[a].push_back(e);
      e.to=a;
      G[b].push_back(e);
    }

    cout << dijkstra(s) << endl;
  }

  return 0;
}

Measured memory_bytes: 1264
const input = require('fs').readFileSync('/dev/stdin', 'utf8');const lines = input.trim().split('\n');let array;let index = 0;let n;let m;let answers = [];while (line = lines.shift()) {if(index === 0){const test = line.split(' ').map(Number);n = test[0];m = test[1];index ++;} else {    array = line.split(' ').map(Number);let answer = 0;for(let i = 0; i<n ;i++){        for(let j = 0;j<n;j++){if(i === j){continue;}const test = array [i] + array [j];if(test > answer && test <= m){answer = test;}}}index = 0;answers.push(answer);}}answers.forEach(data => console.log(data ? data : 'NONE'))


Measured memory_bytes: 18556
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;


/*
 * Union-Find tree
 * header requirement: vector
 */
class UnionFind {
private:
  std::vector<int> disj;
  std::vector<int> rank;
public:
  UnionFind(int n) : disj(n), rank(n) {
    for (int i = 0; i < n; ++i) {
      disj[i] = i;
      rank[i] = 0;
    }
  }
  int root(int x) {
    if (disj[x] == x) {
      return x;
    }
    return disj[x] = root(disj[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) {
      return;
    }
    if (rank[x] < rank[y]) {
      disj[x] = y;
    } else {
      disj[y] = x;
      if (rank[x] == rank[y]) {
	++rank[x];
      }
    }
  }
  bool is_same_set(int x, int y) {
    return root(x) == root(y);
  }
};

const int N = 112222;
int a[N], b[N], w[N];

typedef pair<ll, PI> PLPI;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  VI c(n);
  REP(i, 0, n) {
    cin >> c[i];
  }
  vector<PLPI> pool;
  REP(i, 0, m) {
    cin >> a[i] >> b[i] >> w[i];
    a[i]--, b[i]--;
    pool.push_back(PLPI(w[i], PI(a[i], b[i])));
  }
  sort(pool.begin(), pool.end());
  UnionFind uf(k + n);
  int conn = k;
  ll tot = 0;
  REP(i, 0, pool.size()) {
    if (conn <= 1) break;
    ll ww = pool[i].first;
    int x = pool[i].second.first;
    int y = pool[i].second.second;
    x = c[x] == 0 ? k + x : c[x] - 1;
    y = c[y] == 0 ? k + y : c[y] - 1;
    assert (x >= 0);
    assert (y >= 0);
    if (not uf.is_same_set(x, y)) {
      tot += ww;
      uf.unite(x, y);
      conn--;
    }
  }
  cout << (conn > 1 ? -1 : tot) << "\n";
}


Measured memory_bytes: 4976
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

vector<int> ls;

int main(void) {
    int N;
    cin >> N;

    ls.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> ls[i];
    }
    sort(ls.begin(), ls.end());

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                int a = ls[i];
                int b = ls[j];
                int c = ls[k];
                if (a != b && b != c && a + b > c) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
    
int main(){
    int n, a;
    int mem[100002] = {0};
    scanf("%d", &n);

    for(int i=0; i<n; i++) {
        scanf("%d", &a);
        mem[a-1]++;
        mem[a]++;
        mem[a+1]++;
    }
    
    int mx = 0;
    for(int i=0; i<100002; i++)
    {
        mx = max(mem[i], mx);
    }
    printf("%d\n", mx);
    return 0;
}

Measured memory_bytes: 640
abc = list(map(int, input().split()))
k = int(input())

# print(abc)
# print(k)

# print(max(abc))
# print(abc.index(max(abc)))
max_index = abc.index(max(abc))

for _ in range(k):
    abc[max_index] = abc[max_index] * 2

# print(abc)
print(sum(abc))


Measured memory_bytes: 9104
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e5 + 3;
 
int main(){
    fast;
    ll n, m, k;
    cin >> n >> m >> k;
    ll a[n+1], b[m+1], prefix_sum[n+1], prefix_sum1[m+1];
    prefix_sum[0] = 0;
    prefix_sum1[0] = 0;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        prefix_sum[i] = prefix_sum[i-1] + a[i];
    }
    for(int i = 1; i <= m; ++i){
        cin >> b[i];
        prefix_sum1[i] = prefix_sum1[i-1] + b[i];
    }
    ll mx = 0;
    for(int i = 0; i <= n; ++i){
        ll diff = k - prefix_sum[i], ans = 0;
        if(diff < 0)
            break;
        ll low = 1, high = m;
        while(low <= high){
            ll mid = (low + high)/2;
            if(prefix_sum1[mid] <= diff){
                ans = mid;
                low = mid + 1; 
            }
            else
                high = mid - 1;
        }
        mx = max(mx, i+ans);  
        // cout << i << ' ' << ans << ' ';
    }
    cout << mx;
    return 0;
}

Measured memory_bytes: 9900
import sys
import bisect
def input(): return sys.stdin.readline().rstrip()
 
 
def main():
    n = int(input())
    A=[0]*n
    for i in range(1,n+1):
        A[-i]=int(input())
    inf=10**10    
    dp=[0]
    for AA in A:
        if dp[-1]<=AA:
            dp.append(AA)
        else:
            bis=bisect.bisect_right(dp, AA)
            dp[bis]=AA #n以下の個数を数える
    print(len(dp)-1)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 13636
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let q: usize = scan(tokens);
    let mut g: Vec<Vec<usize>> = vec![Vec::new(); n + 1];
    for _ in 0..n - 1 {
        let a: usize = scan(tokens);
        let b: usize = scan(tokens);
        g[a].push(b);
        g[b].push(a);
    }
    let mut p: Vec<usize> = vec![0; n + 1];
    fn dfs(i: usize, j: usize, p: &mut Vec<usize>, g: &Vec<Vec<usize>>) {
        p[j] = i;
        for &k in &g[j] {
            if k != i {
                dfs(j, k, p, g);
            }
        }
    }
    dfs(0, 1, &mut p, &g);
    let mut x: Vec<usize> = vec![0; n + 1];
    for _ in 0..q {
        let a: usize = scan(tokens);
        let b: usize = scan(tokens);
        x[a] += b;
    }
    fn dfs2(i: usize, cumsum: usize, x: &mut Vec<usize>, g: &Vec<Vec<usize>>, p: &Vec<usize>) {
        x[i] += cumsum;
        for &j in &g[i] {
            if j != p[i] {
                dfs2(j, x[i], x, g, p);
            }
        }
    }
    dfs2(1, 0, &mut x, &g, &p);
    for i in 1..n + 1 {
        print!("{}", x[i]);
        if i < n {
            print!(" ");
        } else {
            println!("");
        }
    }
}


Measured memory_bytes: 41208
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

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

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

int main(){
    char c;
    cin>>c;
    if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        cout<<"vowel"<<endl;
    else
        cout<<"consonant"<<endl;
}

Measured memory_bytes: 256
import string

h, w = map(int, input().split())
Alpha = [x for x in string.ascii_lowercase]
Alpha_count = {x:0 for x in Alpha}

for _ in range(h):
    A = str(input())
    for a in A:
        Alpha_count[a] += 1

odd_count = 0
two_count = 0
four_count = 0

for a in Alpha:
    if Alpha_count[a]%2 == 1:
        odd_count += 1
    if Alpha_count[a] == 2:
        two_count += 1
    else:
        four_count += int(Alpha_count[a] // 4)
        if Alpha_count[a] >= 6 and Alpha_count[a]% 4 == 2:
            two_count += 1

if odd_count >= 2:
    ans = 'No'
elif h%2 == 0 and w%2 == 0:
    if four_count == int(h/2)*int(w/2):
        ans = 'Yes'
    else:
        ans = 'No'
elif h%2 == 0 and w%2 != 0:
    need_four_count = int(h/2)*int((w-1)/2)
    need_two_count = int(h/2)
    if four_count < need_four_count:
        ans = 'No'
    elif four_count == need_four_count:
        if two_count == need_two_count:
            ans = 'Yes'
        else:
            ans = 'No'
    elif four_count > need_four_count:
        if need_two_count == 2*(four_count - need_four_count) + two_count:
            ans = 'Yes'
        else:
            ans = 'No'
elif h%2 != 0 and w%2 == 0:
    need_four_count = int(w/2)*int((h-1)/2)
    need_two_count = int(w/2)
    if four_count < need_four_count:
        ans = 'No'
    elif four_count == need_four_count:
        if two_count == need_two_count:
            ans = 'Yes'
        else:
            ans = 'No'
    elif four_count > need_four_count:
        if need_two_count == 2*(four_count - need_four_count) + two_count:
            ans = 'Yes'
        else:
            ans = 'No'
else:
    if odd_count != 1:
        ans = 'No'
    else:
        need_four_count = int((h-1)/2)*int((w-1)/2)
        need_two_count = int((h-1)/2)+int((w-1)/2)
        if four_count < need_four_count:
            ans = 'No'
        elif four_count == need_four_count:
            if two_count == need_two_count:
                ans = 'Yes'
            else:
                ans = 'No'
        elif four_count > need_four_count:
            if need_two_count == 2*(four_count - need_four_count) + two_count:
                ans = 'Yes'
            else:
                ans = 'No'

print(ans) 

Measured memory_bytes: 3832
while (n=gets.to_i) != 0 do
	es = {}
	n.times do
		e, p, q = gets.split.map(&:to_i)
		es[e] ||= 0
		es[e] += p * q
	end
	some = false
	es.each_pair do |e,sell|
		if sell >= 1000000
				p e
				some = true
		end
	end
	unless some
			puts "NA"
	end
end

Measured memory_bytes: 8876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i = 0; i < n; i++)
const int INF = 1e9;
const int N = 1001;
const int MOD = 1e9 + 7;

bool prime[N];
int cnt[N];

int main(){

  int p = 0;
  fill(prime + 2,prime + N,1);
  for(int i = 2; i < N; i++){
    if(prime[i]){
      for(int j = 2*i; j < N; j+=i) prime[j] = 0;
    }
  }

  fill(cnt,cnt+N,1);
  int n; cin >> n;
  while(n >= 2){
    for(int j = n; j >= 2; j--){
      int t = n;
      if(prime[j]){
        while(t%j == 0){
          //cout << t << " " << j << endl;
          t /= j;
          cnt[j]++;
        }
      }
    }
    n--;
  }
  //REP(i,N) cout << cnt[i] << " ";

  ll ans = 1;
  REP(i,N){
    ans *= cnt[i];
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  vector<int> diff(3);
  diff[0] = abs(A[0]-A[1]);
  diff[1] = abs(A[1]-A[2]);
  diff[2] = abs(A[2]-A[0]);
  sort(diff.begin(), diff.end());
  cout << diff[0] + diff[1] << endl;
}

Measured memory_bytes: 256
EPS = 1e-4

#外積
def OuterProduct(one, two):
	tmp = one.conjugate() * two
	return tmp.imag

#凹多角形の面積(多角形はCCWリスト)
def Area(dots):
	res = 0
	for i in range(len(dots)-1):
		res += OuterProduct(dots[i], dots[i+1])
	res += OuterProduct(dots[-1], dots[0])
	return res/2

n = int(input())
dots = []
for _ in range(n):
	x, y = map(int, input().split())
	dots.append(complex(x, y))

print(Area(dots))


Measured memory_bytes: 5628
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
using namespace std;
const int N=105;
#define rg register int
int a[N],n,ans[N],tot;
inline void move(int pos)
{
    for(rg i=pos;i<n;i++)
        a[i]=a[i+1];
    n--;
}
int main()
{
    scanf("%d",&n);
    for(rg i=1;i<=n;i++)
        scanf("%d",a+i);
    int p=n;
    while(tot<p)
    {
        bool f=0;
        for(rg i=n;i;i--)
            if(a[i]==i)
            {
                f=1,ans[++tot]=i;
                move(i);
                break;
            }
        if(!f)return puts("-1"),0;
    }
    for(rg i=tot;i;i--)
        printf("%d\n",ans[i]);
}

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

int main(void){
    char s[101];
    scanf("%s", s);
    int i,result=0;
    for(i=0;i<strlen(s);i++){
        if(i%2==1){
        /*偶奇は入れ替わる*/
        /*偶数番目の文字*/
            if(s[i]=='R'){
                result = -1;
            }
        }else{
        /*奇数番目の文字*/
            if(s[i]=='L'){
                result = -1;
            }
        }
    }switch (result) {
        case 0:printf("Yes\n" );   break;
        case -1:printf("No\n" );   break;
    }
    return 0;
}


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

using namespace std;

int main(){
  int n, k;
  int sum = 0;
  int L[100] = {0};
  scanf("%d%d", &n, &k);
  for(int i = 0;i < n;++i) scanf("%d", &L[i]);
  sort(L, L + n);
  for(int i = 0;i < n - k;++i) L[i] = 0;
  for(int i = 0;i < n;++i) sum += L[i];
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
c = [""] * h
for i in range(h):
    c[i] = input()

ans = 0
for i in range(2 ** h):
    hst = set()
    for ii in range(h):
        if (i >> ii) & 1:
            hst.add(ii)
    for j in range(2 ** w):
        wst = set()
        for jj in range(w):
            if (j >> jj) & 1:
                wst.add(jj)
        cnt = 0
        for x in range(h):
            for y in range(w):
                if x in hst or y in wst:
                    continue
                if c[x][y] == "#":
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)


Measured memory_bytes: 74132
s=list(input())
x=[]
for i in range(len(s)):
    if s[i]=='A':
        x.append(0)
    elif s[i]=='B':
        x.append(1)
    elif i>0 and s[i]=='C' and s[i-1]=='B':
        x[-1]=3
    else:
        x.append(2)
ans=0
tmp0=0
for i in range(len(x)):
    if x[i]==0:
        tmp0+=1
    if x[i]==3:
        ans+=tmp0
    if x[i]!=0 and x[i]!=3:
        tmp0=0
print(ans)

Measured memory_bytes: 61680
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c; cin>>a>>b>>c;
  a=a.at(0)+'A'-'a';
  b=b.at(0)+'A'-'a';
  c=c.at(0)+'A'-'a';
  cout<<a<<b<<c<<endl;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll L, R;
std::vector<pair<ll, ll>> V, V1;

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld %lld", &L, &R);
		V.push_back(make_pair(L + R, L - R));
		V1.push_back(make_pair(L - R + 1, L + R - 1));
	}
	sort(V.begin(), V.end());
	ll cnt = 1;
	ll lastVal = V[0].first;
	for(int i = 1; i < N; i++) {
		if(V[i].second < lastVal) {
			continue;
		}
		else {
			lastVal = max(lastVal, V[i].first);
			cnt++;
		}
		// cout << lastVal << " " << i << "\n";
	}
	// cnt = max(cnt1, cnt);
	printf("%lld\n", cnt);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 3564
#include<stdio.h>
int main()
{
int S, h, m;
0<=S<=86400;
scanf("%d",&S);
h=S / 3600;
S= S % 3600;
m=S / 60;
S=S % 60;
printf("%d:%d:%d\n",h, m, S);
return 0;
}


Measured memory_bytes: 2100
n = int(input().strip())

count_by_kw = {}
for i in range(n):
    s=''.join(sorted(input().strip()))
    if s in count_by_kw.keys():
        count_by_kw[s]+=1
    else:
        count_by_kw[s]=1

c=list(count_by_kw.values())
ans=0
for val in c:
    ans+=val*(val-1)//2

print(ans)

Measured memory_bytes: 17852
def kaijyo(n):
    ans = 1
    for i in range(n):
        ans *= i + 1
    return ans

N,M = map(int,input().rstrip().split(" "))
hen = []
ans = 0
for i in range(M):
    a,b = map(int,input().rstrip().split(" "))
    hen.append([a,b])
for i in range(kaijyo(N-1)):
    lis = [i+2 for i in range(N-1)]
    lis2 = [1]
    k = i
    for i2 in range(N-1):
        lis2.append(lis[k % (N - 1 - i2)])
        k = k // (N - 1 - i2)
        for i3 in range(len(lis)):
            if lis[i3] == lis2[-1]:
                lis.pop(i3)
                break
    for i2 in range(N-1):
        if not ([lis2[i2],lis2[i2+1]] in hen or [lis2[i2+1],lis2[i2]] in hen):
            break
        if i2 == N - 2:
            ans += 1
print(ans)

Measured memory_bytes: 9260
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<int> A(N, 0);
	int res = 0;
	int c;
	for (int i = 0; i < N; i++) {
		cin >> c;
		c--;
		A[c]++;
	}
	vector<int> B;
	for (int i = 0; i < N; i++) {
		if (A[i] != 0) {
			B.push_back(A[i]);
		}
	}
	sort(B.begin(), B.end());
	reverse(B.begin(), B.end());
	res = N;
	for (int i = 0; i < min((int)B.size(),K); i++) {
		res -= B[i];
	}
	cout << res << endl;
}

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

int main() {
  vector<int> vec={0,0,0,0};
  int p;
  for(int i=0;i<6;i++){
    cin>>p;
    vec.at(p-1)++;
  }
  sort(vec.begin(),vec.end());
  
  if(vec.at(0)==1&&vec.at(1)==1&&vec.at(2)==2&&vec.at(3)==2){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

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

vector<vector<int>> matrix;
vector<vector<int>> memo;
int vacation(int N, int r, int c){
	if( r == N){
		return 0;
	}
	if(memo[r][c] != -1)
		return memo[r][c];
	if(c == 0){
		memo[r][c]= matrix[r][c] + std::max(
			vacation(N, r+1, 1),
			vacation(N, r+1, 2)
			);
		return memo[r][c];
	}
	if(c == 1){
		memo[r][c] = matrix[r][c] + std::max(
			vacation(N, r+1, 0),
			vacation(N, r+1, 2)
			);
		return memo[r][c];
	}
	if(c == 2){
		memo[r][c] = matrix[r][c] + std::max(
			vacation(N, r+1, 1),
			vacation(N, r+1, 0)
			);
		return memo[r][c];
	}
}
int main(){
	int N;
	int a,b,c;
	cin>>N;
	matrix.resize(N);
	memo.resize(N);
	for(int i=0; i<N; i++){
		cin>>a>>b>>c;
		matrix[i] = {a,b,c};
		memo[i] = {-1,-1,-1};
	}
	// for(auto a : matrix){
	// 	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<"\n";
	// }
	int ans = std::max(vacation(N, 0, 0), std::max(vacation(N, 0, 1), vacation(N, 0, 2)));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 18944