akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back

int main() {
  vi p(1010);
  int n,k,ans=0; cin>>n>>k;
  rep(i,n) cin>>p[i];
  sort(p.begin(),p.begin()+n);
  rep(i,k) ans+=p[i];
  cout<<ans<<endl;
}


Measured memory_bytes: 3500
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		String[] S = new String[N];
		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}

		Arrays.sort(S);

		System.out.println(String.join("", S));
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 8276
x,y,a,b,c = list(map(int, input().split(' ')))
p = sorted(list(map(int, input().split(' '))))[-x:]
q = sorted(list(map(int, input().split(' '))))[-y:]
r = sorted(list(map(int, input().split(' '))))[-x-y:]

z = sorted(p+q+r)[-x-y:]

print (sum(z))

Measured memory_bytes: 22504
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll a,b,c;
  cin >> a >> b >> c;
  if(a%2==0||b%2==0||c%2==0)printf("0");
  else printf("%lld",min({a,b,c})*((a+b+c)-max({a,b,c})-min({a,b,c})));
}

Measured memory_bytes: 256
from collections import deque


n, m = map(int, input().split())
edg = [[] for i in range(n+1)]
ans = [-1]*(n+1)


for _ in range(m):
	u, v = map(int, input().split())
	edg[u].append(v)
	edg[v].append(u)



def bfs():
	q = deque()
	q.append(1)
	ans[1] = 1

	while q:
		top = q.popleft()
		for child in edg[top]:
			if ans[child] == -1:
				ans[child] = top
				q.append(child)


bfs()

if -1 in ans[1:]:
	print("No")
else:
	print("Yes")
	print("\n".join(map(str, ans[2:])))


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

using namespace std;
using ll = long long int;

vector<pair<int, int>> dirs = {
    {-1, -1}, {-1, -0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, -0}, {1, 1},
};

void dfs(vector<vector<int>> &field, vector<vector<bool>> &visit, int x, int y,
         function<bool(int, int)> check) {
  visit[y][x] = true;

  for (const auto &dir : dirs) {
    int nx = x + dir.first;
    int ny = y + dir.second;
    if (check(nx, ny))
      dfs(field, visit, nx, ny, check);
  }
}

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

  while (true) {
    int w, h;
    cin >> w >> h;
    if (w == 0 && h == 0)
      return 0;
    vector<vector<int>> field(h, vector<int>(w));
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        cin >> field[y][x];
      }
    }
    vector<vector<bool>> visit(h, vector<bool>(w, false));
    auto check = [&](int x, int y) {
      return (0 <= x && x < w) && (0 <= y && y < h) && field[y][x] == 1 &&
             !visit[y][x];
    };
    int ans = 0;
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if (visit[y][x] || field[y][x] == 0)
          continue;
        ans++;
        dfs(field, visit, x, y, check);
      }
    }
    cout << ans << endl;
  }

  return 0;
}



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

#define for_(i,a,b) for(int i=a;i<b;i++)
#define minit(a,b) memset(a,b,sizeof(a));

int w, d;
int h[15], h_[15];
bool over[15];

void solve() {
	minit(over, 0);
	
	for_(i,0,w) {
		for_(j,0,d) {
			if (over[j]) continue;
			if (h[i] == h_[j]) {
				over[j] = true;
				break;
			}
		}
	}
	
	int ans = 0;
	for_(i,0,w) ans += h[i];
	for_(i,0,d) if (!over[i]) ans += h_[i];
	cout << ans << endl;
}

int main() {
	while (cin >> w >> d, w) {
		for_(i,0,w) cin >> h[i];
		for_(i,0,d) cin >> h_[i];
		solve();
	}
	
	return 0;
}

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

int main(){
  long long A,V,B,W,T;
  cin >> A >> V >> B >> W >> T;
  string check = "NO";
  if (A < B){
    if (A + T * V >= B + T * W){
      check = "YES";
    }
  }
  if (A > B){
    if (A - T * V <= B - T * W){
      check = "YES";
    }
  }
  cout << check;
}

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

main(){
  int N;
  cin >> N;
  int A[N];
  int B[N];
  int C[N];
  for(int ii=0;ii<N;ii++){
    cin >> A[ii];
  }
  for(int ii=0;ii<N;ii++){
    cin >> B[ii];
  }
  for(int ii=0;ii<N-1;ii++){
    cin >> C[ii];
  }
  int ans=0;
  for(int ii=0;ii<N;ii++){
    ans+=B[A[ii]-1];
    //     cout << ans << endl;
    if(A[ii+1]==A[ii]+1){
      ans+=C[A[ii]-1];
    }
    //cout << A[ii] << endl;
    //cout << ans << endl;
  }
  cout << ans << endl;
}


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

typedef long long ll;

const ll MAX_N = 2e5 + 10;
ll n, ans;
ll cnt[MAX_N];
string s, march = "MARCH";

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> s;
		cnt[s[0] - 'A']++;
	}

	for (ll mask = 0; mask < 32; mask++)
		if (__builtin_popcount(mask) == 3) {
			ll res = 1;
			for (int i = 0; i < 5; i++)
				if ((mask >> i) & 1)
					res *= cnt[march[i] - 'A'];

			ans += res;
		}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 384
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
ll n,h,w;
void input(){
    cin>>n>>h>>w;
}
void src(){
    int ans=0;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        if(a>=h and b>=w)ans++;
    }
    cout<<ans;
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    while ( true )
    {
        int a, b;
        char op;
        std::cin >> a >> op >> b;

        if ( op == '?' ) { break; }

        int ans = 0;
        if ( op == '+' ) { ans = a + b; }
        if ( op == '-' ) { ans = a - b; }
        if ( op == '*' ) { ans = a * b; }
        if ( op == '/' ) { ans = a / b; }

        std::cout
            << ans
            << std::endl;
    }

    return 0;
}

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

UL G[200000];
string AL = "abcdefghijklmnopqrstuvwxyz";

struct RSQ {
	UL N;
	vector<UL> V;
	void init(UL n) {
		N = 1; while (N < n) N <<= 1;
		V.resize(N * 2 - 1);
		rep(i, n) V[i + N - 1] = 1;
		for (UL i = N - 2; i != ~0u; i--)
			V[i] = V[(i << 1) + 1] + V[(i << 1) + 2];
	}
	void upd(UL p, UL v) {
		UL i = p + N - 1;
		V[i] += v;
		while (i) {
			i = (i - 1) >> 1;
			V[i] += v;
		}
	}
	UL query(UL l, UL r, UL a = ~0u, UL b = ~0u, UL i = ~0u) {
		if (i == ~0u) { a = i = 0; b = N; }
		if (r <= a || b <= l) { return 0; }
		if (l <= a && b <= r) { return V[i]; }
		auto q1 = query(l, r, a, (a + b) >> 1, (i << 1) + 1);
		auto q2 = query(l, r, (a + b) >> 1, b, (i << 1) + 2);
		return q1 + q2;
	}
	UL search(UL v, UL a = ~0u, UL b = ~0u, UL i = ~0u) {
		if (i == ~0u) { a = i = 0; b = N; }
		if (v == 0) { return 0; }
		if (v >= V[i]) { return b - a; }
		if (b - a == 1) { return 0; }
		auto q1 = search(v, a, (a + b) >> 1, (i << 1) + 1);
		if (q1 != (b - a) >> 1) return q1;
		auto q2 = search(v - V[(i << 1) + 1], (a + b) >> 1, b, (i << 1) + 2);
		return q1 + q2;
	}
};

struct RMQ {
	UL N;
	vector<pair<UL, UL>> V;
	void init(UL n) {
		N = 1; while (N < n) N <<= 1;
		V.resize(N * 2 - 1);
		rep(i, n) V[i + N - 1] = { G[i], i };
		for (UL i = N - 2; i != ~0u; i--)
			V[i] = min(V[(i << 1) + 1], V[(i << 1) + 2]);
	}
	void upd(UL p, UL v = ~0u) {
		UL i = p + N - 1;
		V[i].first = v;
		while (i) {
			i = (i - 1) >> 1;
			V[i] = min(V[(i << 1) + 1], V[(i << 1) + 2]);
		}
	}
	pair<UL, UL> query(UL l, UL r, UL a = ~0u, UL b = ~0u, UL i = ~0u) {
		if (i == ~0u) { a = i = 0; b = N; }
		if (r <= a || b <= l) { return { ~0u, ~0u }; }
		if (l <= a && b <= r) { return V[i]; }
		auto q1 = query(l, r, a, (a + b) >> 1, (i << 1) + 1);
		auto q2 = query(l, r, (a + b) >> 1, b, (i << 1) + 2);
		return min(q1, q2);
	}
};

RMQ Q;
RSQ I;
RSQ J;
string ans;

int main() {
	string S;
	UL K; cin >> S >> K;
	UL N;
	N = S.size();
	{
		vector<pair<UL, UL>> D(N);
		rep(i, N) D[i] = { AL.find(S[i]), i };
		sort(D.begin(), D.end());
		rep(i, N) G[D[i].second] = i;
	}

	Q.init(N);
	I.init(N);
	J.init(N);

	rep(i, N) {
		auto p = Q.query(0, min(N, J.search(min(K + 1, N)))).second;
		//printf("J=%u, ", min(N, J.search(min(K + 1, N))));
		ans.push_back(S[p]);
		UL k = J.query(0, p);
		I.upd(k, 1);
		J.upd(p, (UL)-1);
		Q.upd(p);
		K -= k;
		//printf("p=%u, k=%u, K=%u, ans=%s\n", p, k, K, ans.c_str());
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 12600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
i<jでjが左に落ちるならiも必ず落ちる
落ちる場所で２分探索する。

逆からたどったらWA
*/

ll n,q,ans=0;
string s;
char t[200010],d[200010];

bool f(ll p,ll a){
	bool ok=false;
	rep(i,q){
		if(t[i]==s[p]){
			if(d[i]=='R'){
				p++;
			}else{
				p--;
			}
		}
		if((a==0 && p==0)||(a==1 && p==n+1)){
			ok=true;
			break;
		}
	}
	return ok;
}

int main(void){
	cin>>n>>q>>s;
	s=" "+s;
	rep(i,q)cin>>t[i]>>d[i];
	if(f(1,0)){
		if(f(n,0)){
			ans=n;
		}else{
			ll ok=1,ng=n;
			while(ng-ok>1){
				ll mid = (ng+ok)/2;
				if(f(mid,0)){
					ok=mid;
				}else{
					ng=mid;
				}
			}
			ans+=ok;
		}
	}
	if(f(n,1)){
		if(f(1,1)){
			ans=n;
		}else{
			ll ok=n,ng=1;
			while(ok-ng>1){
				ll mid = (ng+ok)/2;
				if(f(mid,1)){
					ok=mid;
				}else{
					ng=mid;
				}
			}
			ans+=n+1-ok;
		}
	}
	cout<<n-min(n,ans)<<endl;
	return 0;
}
/*
3 4
ABC
B R
C R
B L
A L
*/

Measured memory_bytes: 984
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
#include <iomanip>
using namespace std;
typedef long long ll;
typedef struct
{
    double x, y;
} Point;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

void solve(int n, Point s, Point t)
{
    if(n == 0) return;
    Point left, right, mid;
    double theta = M_PI / 3.0;

    left.x = (2.0 * s.x + t.x) / 3.0;
    left.y = (2.0 * s.y + t.y) / 3.0;
    right.x = (s.x + 2.0 * t.x) / 3.0;
    right.y = (s.y + 2.0 * t.y) / 3.0;
    mid.x = (right.x - left.x) * cos(theta) - (right.y - left.y) * sin(theta) + left.x;
    mid.y = (right.x - left.x) * sin(theta) + (right.y - left.y) * cos(theta) + left.y;

    solve(n - 1, s, left);
    cout << left.x << " " << left.y << endl;
    solve(n - 1, left, mid);
    cout << mid.x << " " << mid.y << endl;
    solve(n - 1, mid, right);
    cout << right.x << " " << right.y << endl;
    solve(n - 1, right, t);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(8);
    int n;
    cin >> n;
    Point left = {0.0, 0.0}, right = {100.0, 0.0};
    cout << left.x << " " << left.y << endl; 
    solve(n, left, right);
    cout << right.x << " " << right.y << endl;
    return 0;
}



Measured memory_bytes: 3276
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    cnt = 0
    for i, item in enumerate(As):
        if (i+1) % 2 == 1 and item % 2 == 1: 
            cnt += 1

    print(cnt)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9112
import itertools 
n,c = map(int,raw_input().split())
d = [map(int,raw_input().split()) for i in range(c)]
arr = [map(int,raw_input().split()) for i in range(n)]
coltable = [[0 for j in range(c)] for i in range(3)]

for i in range(n):
	for j in range(n):
		coltable[((i+1) + (j+1))%3][arr[i][j]-1] += 1

perm = list(itertools.permutations(range(c),3))

ans = float("inf")




for i in perm:
	point = 0

	for j in range(3):
		for k in range(c):
			point += d[k][i[j]] * coltable[j][k]


	ans = min(ans,point)

print ans


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

const int DATA_NIL = 0;

template <class T>
class SegmentTree {
private:
    const int n;
    vector<T> dat;
    void prop_to(int i) { dat[i] = max(dat[i<<1], dat[i<<1|1]); }

public:
    SegmentTree(int _n) : n(_n), dat(2*n, DATA_NIL) {}

    void fill(int l, int r, T x)
    {
        l += n, r += n;
        for (; l<r; l >>= 1, r >>= 1) {
            if (l & 1) dat[l++] += x;
            if (r & 1) dat[r-1] += x;
        }
    }

    T get(int i)
    {
        T res = dat[i += n];
        while (i >>= 1) { res += dat[i]; }
        return res;
    }

    void dump()
    {
        cerr << "-----------" << endl;
        int h = __lg(2*n);
        for (int i=1; i<=h; i++) {
            for (int j=0; j<1<<(i-1); j++) cerr << dat[(1<<(i-1)) + j].second << " ";
            cerr << endl;
        }
        cerr << "-----------" << endl;
    }
};

int main()
{
    ios::sync_with_stdio(false);

    int N, Q;
    cin >> N >> Q;
    SegmentTree<int> seg_tree(N);

    rep(q, Q) {
        int T; cin >> T;
        if (T == 0) {
            int A, B, X; 
            cin >> A >> B >> X;
            A--, B--;
            seg_tree.fill(A, B+1, X);
        } else {
            int I; cin >> I;
            I--;
            cout << seg_tree.get(I) << endl;
        }
        // seg_tree.dump();
    }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
vector<int>h,m;
int dp(int i){
	if(i<0) return 0;
	if(m[i]!=-1) return m[i];
	if(i>=2)
	m[i]=min(dp(i-1)+abs(h[i]-h[i-1]),dp(i-2)+abs(h[i]-h[i-2]));
	return m[i];
}
int main(){
	int n,i;
	scanf("%d",&n);
	h.resize(n);
	m.resize(n);
	for(i=0;i<n;i++) scanf("%d",&h[i]);
	fill(m.begin(),m.end(),-1);
	m[0]=0;
	m[1]=abs(h[1]-h[0]);
	
	cout<<dp(n-1)<<endl;
}

Measured memory_bytes: 3328
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M 1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
ll res[10005]={0};
int main()
{
   ll L,R,d;
   cin>>L>>R>>d;
   ll a=R/d;
   ll b=(L-1)/d;
   a-=b;
   cout<<a;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    double a, b, x;
    cin >> a >> b >> x;

    double S = x / a;
    double ans;

    if (S >= a * b / 2) {
        ans = atan(2 * (a * b - S) / (a * a)) / M_PI * 180.0;
    } else {
        ans = atan((b * b) / (2.0 * S)) / M_PI * 180.0;
    }

    // double theta = (atan((a * a) / (2 * (a * b - S)))) / M_PI * 180.0;
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define sz 100005
ll inf = 1e16;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
} 
ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  char a;
  cin>>a;
  if(a>='A' && a<='Z')
    cout<<"A";
  else
    cout<<"a";
  
  return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;
for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}

Measured memory_bytes: 2492
switch_num, light_num = list(map(int, input().split()))
switch_list = []
for i in range(light_num):
    switch_list.append(list(map(int, input().split()))[1:])
each_mod = list(map(int, input().split()))
bit_cnt = 0
for each_bit in range(1<<switch_num):
    for i in range(light_num):
        cnt = 0
        for each_switch in switch_list[i]:
            if (1 << (each_switch-1)) & each_bit:
                cnt += 1
        if not cnt & 1 == each_mod[i]:
            break
    else:
        bit_cnt += 1
print(bit_cnt)

Measured memory_bytes: 3064
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int t[101];
int pri[26];
int res = 0;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}
void solv() {

	int n;
	cin >> n;
	uini(n);
	pair<ll, int> xr[100010];
	pair<ll, int> yr[100010];
	for (size_t i = 1; i <= n; i++)
	{
		ll x, y;
		cin >> x >> y;
		xr[i] = pair<ll, int>(x, i);
		yr[i] = pair<ll, int>(y, i);
	}

	sort(xr, xr + n + 1);
	sort(yr, yr + n + 1);
	map<ll, vector<pair<int, int>>> mx;
	for (int i = 2; i <= n; i++)
	{
		ll rem = abs( xr[i].first - xr[i - 1].first);
		mx[rem].push_back(pii(xr[i].second, xr[i - 1].second));

		ll remy = abs(yr[i].first - yr[i - 1].first);
		mx[remy].push_back(pii(yr[i].second, yr[i - 1].second));
	}
	ll res = 0;
	for (map<ll, vector<pii>>::iterator i = mx.begin(); i != mx.end(); i++)
	{
		ll val = i->first;
		vector<pii> v = i->second;
		for (int j = 0; j < v.size(); j++)
		{
			if (unit(v[j].first, v[j].second)) {
				res += val;
			}
		}
	}
	cout << res << endl;
}


int main() {
	solv();

	return 0;
}


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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	string s; cin >> s;
	ll n = ll(s.size());
	ll dp[2][2019];
	ll ans = 0;
	rep(i, 0, n){
		rep(j, 0, 2019) dp[1][j] = 0;
		rep(j, 0, 2019) dp[1][(j*10+s[i]-'0')%2019] += dp[0][j];
		dp[1][s[i]-'0']++;
		ans += dp[1][0];
		swap(dp[0], dp[1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  int h, w ;
  cin >> h >> w ;
  vector<vector<string>> str(h,vector<string>(w)) ;
  
  REP(i,h){
    REP(j,w){
      cin >> str.at(i).at(j) ;
    }
  }
  
  REP(i,h){
    REP(j,w){
      if(str.at(i).at(j)=="snuke"){
        cout << (char)('A'+j)<<i+1 <<endl ;
      }
    }
  }


  return 0 ;
}



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

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

typedef long long ll;

using namespace std;

int main(){
  int x,y;
  cin >> x >> y;
  cout << x + (y/2) << endl;

  return 0;
}


Measured memory_bytes: 256
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i,j,n,m,t,k,a[262144],b[262144],h,r=0,l,mf=-inf;
    double d;
    char s[262144];
    scanf("%d%d",&n,&h);
    //l=strlen(s);
    for(i=0;i<n;i++){scanf("%d%d",&a[i],&b[i]);mf=max(mf,a[i]);}
    qsort(b,n,sizeof(int),sortfnckj);
    for(i=0;i<n;i++){
        if(h==0||mf>b[i]){break;}
        r++;h-=b[i];h=max(0,h);
    }
    r+=ceil(h,mf);
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 1404
while True:
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    for y in range(h):
        for x in range(w):
            if y==0 or y==h-1 or x==0 or x==w-1:
                print("#",end='')
            else:
                print(".",end='')
        print()
    print()

Measured memory_bytes: 8996
import math
n=int(input())
p=[]

for i in range(n):
  x,y=map(int,input().split())
  p.append([x,y])
  
ans=0
for i in range(n):
  for j in range(n):
    ans+=math.factorial(n-1)*math.sqrt((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)
    
print(ans/math.factorial(n))

Measured memory_bytes: 9156
#include <stdio.h>

int main(void) {
	int n,m;
	int i,j;
	int A[100][100]={},b[100]={},c[100]={};

	scanf("%d %d",&n,&m);

	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&A[i][j]);
		}
	}

	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
	}

	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			c[i]+=A[i][j]*b[j];
		}
		printf("%d\n",c[i]);
	}

	return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int n,m,sum,s[1111111];
bool cmp(int cl,int cr) {return cl>cr;}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&s[i]);
	sort(s+1,s+1+n,cmp);
	for(int i=1;i<=m;i++) sum+=s[i];
	printf("%d\n",sum); 
	return 0;
}



Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int D = int.Parse(input[1]);

        int m = D * 2 + 1;

        int sho = N / m;
        int amari = N % m;
        if(amari == 0)
        {
            Console.WriteLine(sho);
        }
        else
        {
            Console.WriteLine(sho + 1);
        }
        //Console.ReadKey();
    }
}

Measured memory_bytes: 11092
n, k= input().split()
l = list(map(int,input().split()))
checkNum=[i for i in range(11)]

def find(x):
    while x!=checkNum[x]:
        checkNum[x]=checkNum[checkNum[x]]
        x=checkNum[x]
    return x

for i in l:
    checkNum[find(i)]=checkNum[find(i+1)]

fin=""
for i in range(len(n)):
    first=int(n[i])
    k=find(first)
    if k==first:
        fin+=str(k)
    else:
        if k!=10:
            fin=str(k)+str(find(0))*(len(n)-i-1)
        else:
            fin=str(find(1))+str(find(0))*len(n)
        break

print(fin)


Measured memory_bytes: 9088
#include<stdio.h>
#include<math.h>

int main( void ) 
{
	double x1,y1;
	double x2,y2;
	double distance;

    scanf( "%lf%lf%lf%lf", &x1, &y1, &x2, &y2 );
    x1=(x1-x2);
    x1 = (x1 < 0)? -1*(x1): x1;
    y1=(y1-y2);   
    y1 = (y1 < 0)? -1*(y1): y1;
    distance = sqrt( pow( x1, 2 )+pow( y1, 2 ) );
	printf( "%.8lf\n", distance );

	return 0;
}

Measured memory_bytes: 656
using System;
using System.Collections.Generic;
using System.Globalization;

enum occupant
{
build, floor, room, number
}

class Program
 {



    static void Main(string[] args)
    {
        string nyuryoku;
        int[] alphabet = new int[26];
        int moji;
        string text = "";
        int ch;
        while (true)
        {
            ch = Console.Read();
            if(ch == -1)
                break;
            if (ch >= 'a' & ch<= 'z')
                moji = ch- 'a';
            else if (ch >= 'A' & ch <= 'Z')
                moji = ch - 'A';
            else
                continue;
            alphabet[moji]++;
        }
        for (int i = 0; i < 26; i++)
            Console.WriteLine("{0} : {1}", (char)('a' + i), alphabet[i]);
    }


 


 }



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

int main() {
    int n;
    cin >> n;
    int v[n], c[n];
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];

    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        int value = 0;
        rep(j, n) {
            if (i & (1 << j)) {
                value += v[j] - c[j];
            }
        }
        ans = max(ans, value);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
  a.append(input())

frag='Yes'
for i in range(n):
  if a.count(a[i])!=1:
    frag='No'
    break
for i in range(n-1):
  if a[i][-1]!=a[i+1][0]:
    frag='No'
    break
    
print(frag)

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

X = list(map(int,input().split()))

ans = 0
for i in range(len(X) - 2):
  if (X[i] > X[i+1] > X[i+2]) or (X[i] < X[i+1] < X[i+2]):
  	ans += 1

print(ans)

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

int main(void) {
    char s[100];
    char ans[8];
    int strNum;
    
    scanf("%s", s);
    strNum = strlen(s);
    
    sprintf(ans, "%c%d%c", s[0], strNum-2, s[strNum - 1]);
    printf("%s\n", ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<ld> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000009;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };

int main() {
	int k,a,b;
	scanf("%d%d%d",&k,&a,&b);
	puts(b/k==(a-1)/k?"NG":"OK");
}

Measured memory_bytes: 3716
from itertools import permutations
import math

n = int(input())

x = []
y = []
v = []

for i in range(n):
    v.append(i)
    x1, y1 = map(int, input().split())
    x.append(x1)
    y.append(y1)

ans = 0
cnt = 0

for i in list(permutations(v)):
    for f in range(1, n):
        ans += math.sqrt((x[i[f - 1]] - x[i[f]])*(x[i[f - 1]] - x[i[f]]) + (y[i[f - 1]] - y[i[f]])*(y[i[f - 1]] - y[i[f]]))
    cnt += 1

ans /= cnt
print(ans)


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

using namespace std;

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

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

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

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

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

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    vector<int> v(4), u = {1, 9, 7, 4};
    rep(i, 4) cin >> v[i];
    sort(v.begin(), v.end());
    sort(u.begin(), u.end());
    bool b = v == u;
    string ans = b ? "YES" : "NO";
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <cstdio>
int main() {
	int b1,b2,b3;
	scanf("%d %d %d",&b1,&b2,&b3);
	if(b1) {
		if(b2) printf("Open\n"); else printf("Close\n");
	}else {
		if(b2) printf("Close\n");
		else if(b3) printf("Open\n");
		else printf("Close\n");
	}
}

Measured memory_bytes: 1012
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
mod = 10**9+7

last = {}
dp = [0]*(N+1)
dp[0] = 1
for i in range(1, N+1):
    dp[i] = dp[i-1]
    c = int(input())
    if c in last and last[c]+1<i:
        dp[i] += dp[last[c]]
        dp[i] %= mod
    last[c] = i

print(dp[N])

Measured memory_bytes: 95728
#include <iostream>
#include <cstdint>
#include <cmath>

int main()
{
	std::uint32_t n;
	std::cin >> n;
	for (std::uint32_t i = 0; i < n; ++i) {
		double x1, y1, x2, y2, x3, y3;
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		double const a = x1 - x2, b = y1 - y2;
		double const c = x1 - x3, d = y1 - y3;
		double const e = a * (x1 + x2) / 2 + b * (y1 + y2) / 2;
		double const f = c * (x1 + x3) / 2 + d * (y1 + y3) / 2;
		double const denominator = a * d - b * c;
		double const px = (e * d - b * f) / denominator;
		double const py = (a * f - e * c) / denominator;
		std::cout.setf(std::ios::fixed | std::ios::showpoint);
		std::cout.precision(3);
		std::cout << px << ' ' << py << ' '
			      << std::hypot(px - x1, py - y1) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1300
#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 elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int N, M, A, ans;
    cin >> N >> M;
    queue<int> que[N];
    rep(i, N){
        rep(j, M) {
            cin >> A;
            que[i].push(A);
        }
    }
    priority_queue<pair<int, int> > pque[M];
    int cnt[M+1];
    bool used[M+1];
    fill_n(cnt, M+1, 0);
    fill_n(used, M+1, false);
    rep(i, N) cnt[que[i].front()]++;
    rep2(i, 1, M+1) pque[0].push(P(cnt[i], i));
    ans = pque[0].top().first;
    rep(i, M-1){
        P p = pque[i].top();
        int j = p.second;
        cnt[j] = 0;
        used[j] = true;
        rep(k, N){
            if(que[k].front() == j){
                while(used[que[k].front()]) que[k].pop();
                cnt[que[k].front()]++;
            }
        }
        rep2(k, 1, M+1) pque[i+1].push(P(cnt[k], k));
        ans = min(ans, pque[i+1].top().first);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1920
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.stream.IntStream;

import static java.util.stream.Collectors.toList;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            final List<Integer> numList = Arrays.stream(args.get(1).split(" ")).map(Integer::valueOf).collect(toList());
            final List<Integer> matchedIndexList = IntStream.range(0, numList.size())
                    .filter(x -> numList.get(x).equals(x + 1))
                    .boxed()
                    .collect(toList());

            Integer curr = -1;
            Integer cnt = 0;
            Integer ans = 0;
            for (final Integer index : matchedIndexList) {
                if (curr == -1 || curr + 1 == index) {
                    cnt++;
                    curr = index;
                    continue;
                }

                ans += Double.valueOf(Math.ceil(cnt.doubleValue() / 2)).intValue();
                cnt = 1;
                curr = index;
            }
            ans += Double.valueOf(Math.ceil(cnt.doubleValue() / 2)).intValue();

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

}


Measured memory_bytes: 46052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>

using namespace std;

int main() {
	int a = 0;
	int i = 1;
	while (cin >> a, a != 0) {
			cout << "Case " << i << ": " << a << endl;
			i++;
		}
}
	


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

struct card{
  int b;
  long int c;
};

int asc(const void *a, const void *b) {
  if(*(long*)a - *(long*)b > 0) {
    return 1;
  } else {
    return -1;
  }
}

int desc(const void *a, const void *b) {
  if (((struct card*)b)->c - ((struct card*)a)->c > 0) {
    return 1;
  } else {
    return -1;
  }
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  long int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%ld", a+i);
  }
  qsort(a, n, sizeof(long int), asc);
  struct card p[m];
  for (int i = 0; i < m; i++) {
    scanf("%d %ld", &(p[i].b), &(p[i].c));
  }
  qsort(p, m, sizeof(struct card), desc);
  int j = 0, k = 0, l = 0;
  while ((k < m) && (j < n)) {
    if (a[j] < p[k].c) {
      a[j] = p[k].c;
      l++;
      if (p[k].b <= l) {
        k++;
        l=0;
      }
    }
    j++;
  }
  long int ans=0;
  for (int i = 0; i < n; i++) {
    ans += a[i];
  }
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 4084
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0: break
    for j in range(h):
        for i in range(w):
            if (i + j)%2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

 
int main() {
  int n;
  cin >> n;
  vector<ll> a(n+1,0);
  for(int i=1;i<=n;i++) cin >> a.at(i);
  rep(i,n) a.at(i+1) += a.at(i);
  map<ll,ll> mp;
  rep(i,n+1) mp[a.at(i)] ++;
  ll ans = 0;
  for(auto p:mp){
    ans += p.second*(p.second-1)/2;
  }
  cout << ans << endl;
    
  return 0;
}



Measured memory_bytes: 14336
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
#define fi first
#define se second
using namespace std;

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



int main() {

	int n,a;
	int odd = 0, four = 0;

	cin >> n;
	rep(i, 0, n) {
		cin>>a;
		if (a % 2 == 1)odd++;
		else if (a % 4 == 0)four++;
	}
	if (odd + four != n) {
		if (odd <= four)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		if (odd <= four + 1)cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)

Q, Ikr, FullBit = [], Hash.new{|h,k| h[k] = 100001 }, (1<<N)-1
master_key = 0
M.times{
	a, c = gets.to_i, gets.split.map(&:to_i)
	tkrbit = c.inject(0){|bit, tkr|
		bit | (1<<(tkr-1))
	}
	next if Ikr[tkrbit] < a
	master_key |= tkrbit
	Ikr[tkrbit] = a
	Q << ((a<<N)|tkrbit)
}
if master_key != FullBit
	p -1
	exit
end

Q.sort!
while lowest = Q.shift
	low_cost, low_tkrbit = lowest>>N, lowest&FullBit
	next if Ikr[low_tkrbit] < low_cost
	break if low_tkrbit == FullBit

	q, r = [], []
	while kg = Q.shift
		cost, tkrbit = kg>>N, kg&FullBit
		next if Ikr[tkrbit] < cost
		cost, tkrbit = low_cost+cost, low_tkrbit|tkrbit
		next if tkrbit == low_tkrbit
		q << kg
		next if Ikr[tkrbit] <= cost
		Ikr[tkrbit] = cost
		r << ((cost<<N)|tkrbit)
	end

	until q.empty?
		unless r.empty?
			Q << (q[0] < r[0] ? q : r).shift
		else
			Q.concat(q)
			q.clear
		end
	end
	Q.concat r
end
p Ikr[FullBit]


Measured memory_bytes: 2684
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, A, B, C;
    cin >> N;
    ll dp[N][3];
    REP(ll,i,0,N){
        REP(ll,j,0,3) dp[i][j] = 0;
    }
    cin >> A >> B >> C;
    dp[0][0] = A;
    dp[0][1] = B;
    dp[0][2] = C;
    REP(ll,i,1,N){
        cin >> A >> B >> C;
        ll ba, ca;
        ba = B + dp[i-1][0];
        ca = C + dp[i-1][0];
        ll ab, cb;
        ab = A + dp[i-1][1];
        cb = C + dp[i-1][1];
        ll ac, bc;
        ac = A + dp[i-1][2];
        bc = B + dp[i-1][2];
        dp[i][0] = max(ab,ac);
        dp[i][1] = max(ba,bc);
        dp[i][2] = max(ca,cb);
    }
    cout << max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2])) << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define INF 2000000000
#define MOD 1000000007

using namespace std;

int main() {
	long long n, x;
	cin >> n >> x;
	long long ans = 0;
	ans += x;
	ans += n - x;
	long long a = x, b = n - x;
	if (a < b)
		swap(a, b);
	while (true) {
		if (a < b)
			swap(a, b);
		if (a % b == 0) {
			ans += (a * 2 - b);
			cout << ans << endl;
			return 0;
		}	
		else {
			ans += (a / b * b * 2);
			a %= b;
		}
	}
	return 0;
}

Measured memory_bytes: 256