akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define rer(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<pi, int> ppi;
typedef vector<ll> vi;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest) { 
	cout << arg << " "; Debug(rest...); }
template<class T>ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<< ", ";out<<v.back();}out << "]";return out;}
template<class S, class T>ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";return out;}
const int MAX_N = 200100;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N; ll K;
int nex[MAX_N][26];
ll dp[MAX_N];
int pv[MAX_N];
int E[26];
string str;

void solve() {
	cin >> str; N = (int)str.size();
	rep(i, 0, 26) str += char('a' + i);
	fill(E, E + 26, -1);
	rer(i, N + 27, 0) { //1-origin
		rep(j, 0, 26) nex[i][j] = E[j];
		if(i) E[str[i - 1] - 'a'] = i;
	}
	fill(dp, dp + N + 1, inf);
	fill(pv, pv + N + 1, 1);
	rer(i, N + 1, 0) {
		rep(j, 0, 26) {
			assert(nex[i][j] != -1);
			pi p = pi(dp[nex[i][j]] + 1, str[nex[i][j] - 1] - 'a');
			if(pi(dp[i], str[pv[i] - 1] - 'a') > p) {
				dp[i] = dp[nex[i][j]] + 1;
				pv[i] = nex[i][j];
			}
		}
	}
	int at = 0;
	while(at < N + 1) {
		at = pv[at];
		cout << str[at - 1];
	}
	cout << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(5);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 23188
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define W 100007
#define N 1004

int n;
vector<P> p;
ll w[N], s[N], v[N];
ll dp[W];

int main() {
  cin >> n;
  rep(i, n) {
    cin >> w[i] >> s[i] >> v[i];
    p.push_back(P(w[i]+s[i], i));
  }
  sort(ALL(p));

  repe(&e, p) {
    int i = e.second;
    repr(j, s[i]+1) {
      dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
    }
  }

  ll ans = 0;
  rep(i, W) {
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
#ABC54 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n,ma,mb = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
sa = 0
sb = 0
for a,b,c in x:
    sa += a
    sb += b
dp = [[float('inf')]*(sb+1) for _ in range(sa+1)]
dp[0][0] = 0
for a,b,c in x:
    y = [[True]*(sb+1) for _ in range(sa+1)]
    for i in range(sa+1-a):
        for j in range(sb+1-b):
            if y[i][j]:
                if dp[i+a][j+b] > dp[i][j] + c:
                    dp[i+a][j+b] = dp[i][j] + c
                    y[i+a][j+b] = False
ans = float('inf')
for i in range(1,sa+1):
    for j in range(1,sb+1):
        if i*mb == j*ma:
            ans = min(ans,dp[i][j])
if ans == float('inf'):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 53340
/*
#include <cstdio>
#include <cfloat>
#include <stack>
#include <cstdlib>
using namespace std;
 
#define MAX_N 15
 
int n;
int idx[MAX_N], dst[MAX_N], num[MAX_N];
double dp[MAX_N][1 << MAX_N];
int prv[MAX_N][1 << MAX_N];
double spd[1 << MAX_N];
 
 
int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        scanf("%d%d%d", &idx[i], &dst[i], &num[i]);
    }
 
    int M = 1 << n;
    for(int S = 0; S < M; ++S){
        int c = 0;
        for(int i = 0; i < n; ++i){
            prv[i][S] = -1;
            dp[i][S] = DBL_MAX;
 
            if(S >> i & 1){
                c += num[i];
            }
        }
        spd[S] = (7 + 2 * c) / 200.0;
    }
 
    for(int i = 0; i < n; ++i){
        dp[i][1 << i] = 0.0;
    }
 
    for(int S = 1; S < M; ++S){
        for(int i = 0; i < n; ++i){
            if(!(S >> i & 1)){ continue; }
            for(int j = 0; j < n; ++j){
                if(S >> j & 1){ continue; }
 
                double tm = dp[i][S] + abs(dst[i] - dst[j]) * spd[S];
                int T = S | 1 << j;
                if(dp[j][T] > tm){
                    dp[j][T] = tm;
                    prv[j][T] = i;
                }
            }
        }
    }
 
    int x = 0;
    for(int i = 1; i < n; ++i){
        if(dp[x][M - 1] > dp[i][M - 1]){
            x = i;
        }
    }
 
    stack<int> st;
    int U = M - 1;
    while(x != -1){
        st.push(idx[x]);
        int y = prv[x][U];
        U ^= 1 << x;
        x = y;
    }
 
    printf("%d", st.top());
    st.pop();
    while(!st.empty()){
        printf(" %d", st.top());
        st.pop();
    }
    puts("");
}
*/


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

int i,j,n,nxt,divs,max,num[20],dist[20],wei[20],next[36000][20];
double time[36000][20],speed[36000];

double search(int code,int now){

	if(code>=max-1)return 0;
	if(time[code][now]!=0.0){return time[code][now];}

	int div=2,sel,i;
	double ttt=999999999,tim,movt;

	for(i=0;i<n;i++,div*=2){
		if(code%div<div/2){
			if(code==0)movt=0;
			else movt=abs(dist[now]-dist[i])/speed[code];
			tim=movt+search(code+div/2,i);
			if(ttt>tim){ttt=tim;sel=i;}
		}
	}

	next[code][now]=sel;
	time[code][now]=ttt;

	return ttt;
}

int main(){
	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d %d %d",&num[i],&dist[i],&wei[i]);
		wei[i]*=20;
	}

	max=(int)pow(2.0,n);
	for(i=max;i>=0;i--){
		for(j=0,divs=2;j<n;j++,divs*=2){
			if(i%divs>=divs/2)speed[i]+=wei[j];
		}
		speed[i]=2000.0/(speed[i]+70);
	}

	search(0,0);

	for(i=0,j=0;i<max-1;){
		nxt=next[i][j];
		printf("%s%d",i>0?" ":"",num[nxt]);
		i+=(int)pow(2.0,nxt);
		j=nxt;
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 9080
def main2():
    K = int(input())

    rem = set()
    n = ans = 0

    while True:
        n = n * 10 + 7
        ans += 1

        if n % K == 0:
            print(ans)
            break
        else:
            n = n % K
            
            if n in rem:
                print(-1)
                break
            else:
                rem.add(n)
                
if __name__ == "__main__":
    main2()

Measured memory_bytes: 78072
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <complex>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

typedef complex<double> C;

namespace std
{
    bool operator < (const C a, const C b) {
        return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
    }
}
//??£??????
C normalize(C c)
{
    return c / abs(c);
}

//?§????(rad)
double getarg(C a,C b){
    return arg(b*conj(a));
}

//??????
double cross(const C a, const C b)
{
    return imag(conj(a)*b);
}
//??????
double dot(const C a, const C b)
{
    return real(conj(a)*b);
}

int ccw(C a, C b, C c)
{
    b -= a; c -= a;
    if(cross(b, c) > 0)   return +1;       // counter clockwise
    if(cross(b, c) < 0)   return -1;       // clockwise
    if(dot(b, c) < 0)     return +2;       // c--a--b on line
    if(norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;   //b--a--c on line
}


vector<C> convex_hull(vector<C> ps)
{
    int n = (int)ps.size(), k = 0;
    sort(ps.begin(), ps.end());
    vector<C> ch(2*n);
    for (int i = 0; i < n; ch[k++] = ps[i++]){
        while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) k--;
    }
    for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]){
        while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) k--;
    }
    ch.resize(k-1);
    return ch;
}

int contains(const vector<C>& ps, const C p)
{
    bool flag = false;
    rep(i,ps.size()) {
        C a = ps[i] - p, b = ps[(i+1)%ps.size()] - p;
        if (imag(a) > imag(b)) swap(a, b);
        if (imag(a) <= 0 && 0 < imag(b)){
            if (cross(a, b) < 0) flag = !flag;
        }
        if (cross(a, b) == 0 && dot(a, b) <= 0) return 1;
  }
  return flag ? 2 : 0;
}

int main(){
	int n;
	cin >> n;
	vector<double>x(n),y(n);
	rep(i,n){
		cin >> x[i] >> y[i];
	}
	bool flag = 0;
	for(int i=0;i<n;i++){
		vector<C> ps;
		vector<C> conv;	
		for(int j=0;j<i;j++){
			complex<double> z(x[j],y[j]);
			ps.push_back(z);
		}
		complex<double> z(x[i],y[i]);
		if(ps.size()>2){
			conv = convex_hull(ps);
			if(contains(conv,z)==2){
				flag = 1;
				break;
			}
		}
		vector<C> ps2;
		for(int j=i+1;j<n;j++){
			complex<double> z(x[j],y[j]);
			ps2.push_back(z);
		}
		if(ps2.size()>2){
			conv = convex_hull(ps2);
			if(contains(conv,z)==2){
				flag = 1;
				break;
			}
		}
	}
	if(flag){
		cout << "Impossible" << endl;
	}else{
		cout << "Possible" << endl;
	}
	return 0;
}

Measured memory_bytes: 3328
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n,m=map(int,input().split())
ab = [list(map(lambda x: int(x)-1,input().split())) for _ in range(m)]
ab.reverse()

u =UnionFind(n)

ans=[0]*(m+1)
ans[m] = n*(n-1)//2
for i in range(m):
    a, b = ab[i][0], ab[i][1]
    if u.same(a,b):
        ans[m-i-1] = ans[m-i]
    else:
        ans[m-i-1] = ans[m-i] - u.size(a)*u.size(b)
        u.union(a,b)

for i in range(m):
    print(ans[i+1])

Measured memory_bytes: 33408
m,k=map(int,input().split())
if k>2**m-1 or m==k==1:
    print(-1)
elif k:
    a=[]
    for i in range(2**m):
        if i!=k:
            a.append(i)
    a.append(k)
    for i in range(2**m-1,-1,-1):
        if i!=k:
            a.append(i)
    a.append(k)
    print(*a)
else:
    a=[]
    for i in range(2**m):
        a.extend([i,i])
    print(*a)

Measured memory_bytes: 19316
import math
A, B = map(int, input().split())
lst = []
for i in range(1, 1010):
    if int(i*0.08) == A and int(i*0.1) == B:
        lst.append(i)

if len(lst) > 0:
    print(lst[0])
else:
    print(-1)

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

using namespace std;

int main(){
  long long N;
  cin >> N;
  
  
  long long ans = 0;
  for(long long p = 2; p * p <= N; p++){
    int e = 0;
    while(N % p == 0){
      ++e;
      N /= p;
    }
    
    long long sum = 1;
    for(int i = 2; sum <= e; i++){
      ++ans;
      sum += i;
    }
  }
  
  if(N > 1) ++ans;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3636
d = [0]*5
for i in range(5):
    d[i] = int(input())
k = int(input())
ng = 0
for i in range(4,-1,-1):
    for j in range(i-1,-1,-1):
        if( d[i] - d[j] > k ):
            ng = 1
if( ng == 1 ):
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3064
import math
s=input()
S_list = [s[i: i+1] for i in range(0, len(s))]
sumup=0
if len(S_list)%2==0:
  for i in range(math.floor(len(S_list)/2)):
    if S_list[i]!=S_list[len(S_list)-i-1]:
      sumup+=1
  print(sumup)
else:
  for i in range(math.floor((len(S_list)-1)/2)):
    if S_list[i]!=S_list[len(S_list)-i-1]:
      sumup+=1
  print(sumup)

Measured memory_bytes: 3064
#include<iostream>
#include<set>
#include<vector>

using namespace std;

int main()
{
	int N; cin >> N;
	vector<int> ans(N);

	for (int i = 1; i < N; ++i)
	{
		int A; cin >> A;
		ans[A - 1]++;
	}

	for (int an : ans)
	{
		cout << an << endl;
	}
}

Measured memory_bytes: 4052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <queue>

#define ll long long

using namespace std;

inline int read() {
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

const int N=1005;

int a[N];

int main() {
	int n=read(),k=read();
	for (int i=1;i<=n;i++) {
		a[i]=read();
	}
	sort(a+1,a+n+1);
	int ans=0;
	for (int i=1;i<=k;i++) {
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3624
#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, M;
  cin >> N >> M;
  vector<int> A(M);
  long sum = 0;
  rep(i, M)
  {
    cin >> A[i];
    sum += A[i];
  }
  if(sum > N){
    cout << -1 << endl;
    return 0;
  }
  else{
    cout << N-sum << endl;
    return 0;
  }
}

Measured memory_bytes: 3632
X = int(input())

for A in range(0,10**3):
 for B in range(0,10**3):
  A1,A2,B1,B2 = A,-A,B,-B
  if(A1**5-B1**5 == X):
    ans = [A1,B1]
    break
  elif(A1**5-B2**5 == X):
    ans = [A1,B2]
    break
  elif(A2**5-B1**5 == X):
    ans = [A2,B1]
    break  
  elif(A2**5-B2**5 == X):
    ans = [A2,B2]
    break    
            
print(ans[0],ans[1])   

Measured memory_bytes: 83788
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n-1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e18;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MOD = 1e9+7;
int main(void) {
    int n; cin >> n; vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll ans = 0;
    rep(i, 30) {
        ll cnt = 0, t = 1LL << i;
        vector<int> tmpa(n), tmpb(n);
        rep(j, n) {
            tmpa[j] = a[j] % (2 * t);
            tmpb[j] = b[j] % (2 * t);
        }sort(ALL(tmpb));
        rep(j, n) {
            cnt += lower_bound(ALL(tmpb), 2 * t - tmpa[j]) - lower_bound(ALL(tmpb), t - tmpa[j]);
            cnt += lower_bound(ALL(tmpb), 4 * t - tmpa[j]) - lower_bound(ALL(tmpb), t * 3 - tmpa[j]);
        }if (cnt % 2) ans += t;
    }cout << ans << endl;
}

Measured memory_bytes: 6360
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
L=[0]*(n+1)
L[0]=1
Chk=True
for i in range(n+1):
  if i==0:
    if A[i]>0:
      Chk=False
      break
  elif i<n:
    if L[i-1]*2<=A[i]:
      Chk=False
      break
    else:
      L[i]=L[i-1]*2-A[i]
  else:
    L[i]=L[i-1]*2

if L[-1]<A[-1]:
  Chk=False
else:
  L[-1]=0
  ans=A[-1]
  for i in range(n)[::-1]:
    if A[i+1]+L[i+1]<L[i]:
      L[i]=A[i+1]+L[i+1]
    ans+=L[i]+A[i]


if n==0 and A==[1]:
  print(1)
else:
  if Chk:
    print(ans)
  else:
    print(-1)

Measured memory_bytes: 668448
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
struct Point{
   ll x,y;
   Point (ll x=0, ll y=0):x(x),y(y){}
};
 
typedef Point Vector;
 
Vector operator +(Vector A,Vector B) { return Vector(A.x+B.x,A.y+B.y); }
Vector operator -(Vector A,Vector B) { return Vector(A.x-B.x,A.y-B.y); }
Vector operator *(Vector A,double p) { return Vector(A.x*p,A.y*p); }
 
ll Dot(Vector A,Vector B) { return A.x*B.x+A.y*B.y; }
ll Cross(Vector A,Vector B) { return A.x*B.y-A.y*B.x; }
ll Length(Vector A) { return Dot(A,A); }
 
const int maxn = 2e5+10;
Point p[maxn],sol[maxn];
ll n,m;
 
bool cmp(Point a, Point b){
   ll ans = Cross(a-p[0],b-p[0]);
   return ans>0 || ans==0 && Length(a-p[0])<Length(b-p[0]);
}
 
ll ConvexHull(Point *p,Point *ch){
    sort(p+1,p+n,cmp);
    ll m = 0;
    for (ll i=0; i<n; i++) {
        while (m>1 && Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0) m--;
        ch[m++] = p[i];
    }
 
    ll k = m;
    for (ll i=n-2; i>=0; i--){
        while (m>k && Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0) m--;
        ch[m++] = p[i];
    }
 
    if (n>1) m--;
    return m;
}
ll f(Point A,Point B){
	return abs(A.x-B.x)+abs(A.y-B.y);
}
ll Rotate_calipers(Point* ch, int n){
    ll q=1;
    ll ans = 0;
    ch[n] = ch[0];
    for (ll i=0; i<n; i++) {
        while ( Cross(ch[q+1]-ch[i],ch[q+1]-ch[i+1])>Cross(ch[q]-ch[i],ch[q]-ch[i+1]) ) q = (q+1)%n;
        ans = max( ans,max( f(ch[i],ch[q]),f(ch[i+1],ch[q+1]) ) );
        //ans = max( ans,max( Length(ch[i]-ch[q]),Length(ch[i+1]-ch[q+1]) ) );
    }
    return ans;
}
 
int main(){
    while (scanf("%lld",&n)==1){
        ll x,y;
        for (ll i=0; i<n; i++) {
            scanf("%lld%lld",&x,&y);
            p[i] = Point(x,y);
        }
 
        if (n==2) {
            printf("%lld\n",f(p[0],p[1]));
            continue;
        }
 
        for (ll i=1; i<n; i++) {
            if (p[i].x<p[0].x || p[i].x==p[0].x && p[i].y<p[0].y) swap(p[i],p[0]);
        }
        m = ConvexHull(p,sol);
        printf("%lld\n",Rotate_calipers(sol,m));
 
    }
    return 0;
}


Measured memory_bytes: 7984
W, H, N = map(int, input().split())
values  = (map(int, input().split()) for _ in range(N))
canvas = [[0 for _ in range(W)] for _ in range(H)]

for x, y, a in values:
    x_range = (0, W)
    y_range = (0, H)
    if a == 1:
        x_range = (0, x)
    elif a == 2:
        x_range = (x, W)
    elif a == 3:
        y_range = (0, y)
    elif a == 4:
        y_range = (y, H)

    for i in range(*y_range):
        for j in range(*x_range):
            canvas[i][j] = 1

sum_filled = sum([sum(row) for row in canvas])
print(W * H - sum_filled)


Measured memory_bytes: 3064
#include <stdio.h>

int main() {
  int x, y;
  while (1) {
    scanf("%d%d", &x, &y);
    if (x == 0 && y == 0) {
      break;
    } else if (x > y) {
      printf("%d %d\n", y, x);
    } else {
      printf("%d %d\n", x, y);
    }
  }
  return 0;
}


Measured memory_bytes: 2052
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 100000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

int ctoi(char c) {
	if (c == 'R') {
		return 0;
	}
	else if (c == 'G') {
		return 1;
	}
	else {
		return 2;
	}
}
int main() {
	int N; cin >> N;
	string S; cin >> S;
	ll ans = 0;

	if (N < 3) {
		ans = 0;
	}
	else {
		vvi Color(N, vi(3, 0));
		Color[N - 1][ctoi(S[N - 1])]++;
		for (int i = N - 2; i >= 0; i--) {
			for (int j = 0; j < 3; j++) {
				Color[i][j] = Color[i + 1][j];
			}
			Color[i][ctoi(S[i])]++;
		}
		
		for (int i = 0; i < N - 2; i++) {
			for (int j = i + 1; j < N - 1; j++) {
				if (S[i] != S[j]) {
					int index_of_color = 3 - ctoi(S[i]) - ctoi(S[j]);
					int diff = j - i;
					ans += Color[j + 1][index_of_color];
					if (j + diff < N and ctoi(S[j + diff]) == index_of_color) {
						ans--;
					}

				}
				
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3764
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	vector<int>pre(n),suf(n);
	pre[0]=v[0];
	suf[n-1]=v[n-1];
	for(int i=1;i<n;i++){
		pre[i]=pre[i-1]+v[i];
	}
	for(int i=n-2;i>=0;i--){
		suf[i]=suf[i+1]+v[i];
	}
	int ans=INT_MAX;
	for(int i=1;i<n-1;i++){
		ans=min(ans,abs(pre[i]-suf[i+1]));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 200001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,a,b,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,
q,q1,q2,q3,q4,r,s,t,u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;

//double rat;
L A[Mx+5],B[Mx+5];


int main()
{
    scanf("%lld%lld%lld",&a,&b,&c);
    swap(a,b);
    swap(a,c);
    printf("%lld %lld %lld\n", a,b,c);
    return 0;
}
/// empty() lld lld push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3788
//
// Created by Hideaki Imamura on 2019-07-09.
//

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

const ll INF = 10000000000;

int main() {
    ll n, k, x, m, cost;
    vector<ll> xs;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        xs.push_back(x);
    }

    ll res = INF;

    for (int l = 0; l + k - 1 < n;  ++l) {
        int r = l + k - 1;
        cost = abs(xs[l]) + abs(xs[r] - xs[l]);
        if (cost < res) {
            res = cost;
        }
        cost = abs(xs[r]) + abs(xs[r] - xs[l]);
        if (cost < res) {
            res = cost;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1400
k, a, b = list(map(int, input().split()))

if b - a <= 2:
    print(k + 1)
    exit(0)

if k <= a:
    print(k + 1)
    exit(0)

n = 0
ans = 0
if (k - a + 1) % 2 == 0:
    n = (k - a + 1) // 2
else:
    n = (k - a + 1) // 2

ans = (k - n * 2) + 1

# print(n, b - a)
ans += (b - a) * n
print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
#define N 1000
#define MAX_W 1'000'000'000ll
#define INF (N * MAX_W)
struct edge { int u, v, w; };
ll d[N+1];
bool neg_cycle[N+1];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector<edge> edges;
    for(int i = 0; i < m; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        edges.push_back({u, v, w});
    }
    for(int i = 1; i <= n; i++) {
        d[i] = -INF;
    }
    d[1] = 0;
    for(int i = 0; i < n - 1; i++) {
        for(edge& e : edges) {
            if(d[e.u] != -INF) {
                d[e.v] = max(d[e.v], d[e.u] + e.w);
            }
        }
    }
    memset(neg_cycle, false, sizeof neg_cycle);
    for(int i = 0; i < n; i++) {
        for(edge& e : edges) {
            if(d[e.u] != -INF) {
                if(d[e.v] < d[e.u] + e.w) {
                    d[e.v] = max(d[e.v], d[e.u] + e.w);
                    neg_cycle[e.v] = true;
                }
            }
        }
    }
    if(neg_cycle[n]) {
        cout << "inf" << endl;
    } else {
        cout << d[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 384
using System;

public class OfficialHouse
{
    //4?£?????????¬???????????\?±?????????±?????\????????????
    static void Main(string[] args)
    {
        /*---??£?¨???¨---*/
        int i;
        int buildIndex;
        int floorIndex;
        int roomIndex;
        int count;
        //???????????¬?????§3???????????????????????¢????????¨?±???¨??????
        int[,,] officialHouse = new int[4,3,10];
        int[] houseData = new int[4];
        string[] buffer;
        /*---??£?¨???¨---*/

        /*??\??????[b, f, r, v](b?£? f??? r???????????¨?±? v???(-???????????¨??????))???????????????*/
        count = int.Parse(Console.ReadLine());
        for (i = 0; i < count; i++){
            buffer = Console.ReadLine().Split(' ');
            //houseData = buffer.Select(s => int.Parse(s)).ToArray();
            houseData[0] = int.Parse(buffer[0]);
            houseData[1] = int.Parse(buffer[1]);
            houseData[2] = int.Parse(buffer[2]);
            houseData[3] = int.Parse(buffer[3]);
            officialHouse[houseData[0] - 1, houseData[1] - 1, houseData[2] - 1] +=houseData[3];
        }

        /*?????±?????¨???*/
        for (buildIndex = 0; buildIndex < 4; buildIndex++){
            for (floorIndex = 0; floorIndex < 3; floorIndex++) {
                for (roomIndex = 0; roomIndex < 10; roomIndex++) {
                    Console.Write(" {0}", officialHouse[buildIndex, floorIndex, roomIndex]);
                }
                Console.Write("\n");
            }
            //?£????????????????????????????????????\????????????
            if(buildIndex != 3)
                Console.WriteLine("####################");
        }
    }
}

Measured memory_bytes: 9180
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
using ll = long long;

vector<vector<int>>vac;
ll dp[100010][3];


int main() {
	int n,a,b,c;
	cin >> n;
	vac.resize(n);
	rep(i, n) {
		cin >> a >> b >> c;
		vac[i].push_back(a);vac[i].push_back(b);vac[i].push_back(c);
	}
	for (int i = 0; i < n; i++) {
		dp[i + 1][0] = max(dp[i][1], dp[i][2]) + vac[i][0];
		dp[i + 1][1] = max(dp[i][0], dp[i][2]) + vac[i][1];
		dp[i + 1][2] = max(dp[i][0], dp[i][1]) + vac[i][2];
	}
	cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << endl;
	return 0;
}

Measured memory_bytes: 8064
def max_bomb_set(l):
    l.sort(key=lambda x: x[0], reverse=True)
    res = []
    for cnt, tag in l:
        if cnt == l[0][0]:
            res.append(tag)
        else:
            break
    return res, l[0][0]


def main():
    h, w, m = map(int, input().split())
    height = [[0, i] for i in range(h)]
    width = [[0, i] for i in range(w)]
    target = set()
    for _ in range(m):
        x, y = map(lambda x: int(x) - 1, input().split())
        target.add((x, y))
        height[x][0] += 1
        width[y][0] += 1
    max_height, max_h_val = max_bomb_set(height)
    max_width, max_w_val = max_bomb_set(width)
    ans = max_h_val + max_w_val
    for hh in max_height:
        for ww in max_width:
            if (hh, ww) not in target:
                return ans
    return ans - 1


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


Measured memory_bytes: 131068
public class Main {
  public static void main(String[] args){
    String str = new java.util.Scanner(System.in).next();
    if (("ABCDEFGHIJKLMNOPQRSTUVWXYZ").indexOf(str) >= 0) {
      System.out.println("A");
    } else {
      System.out.println("a");
    }
  }
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define repo(i,o,n) for(int i=o;i<(int)(n);i++)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

#define MAX 1000000007

int n,ans,memo[26];
string s;
vector<int> v;

main() {
    cin >> n >> s;
    sort(all(s));
    int cnt=1;
    char ctmp=s[0];
    rep1(i,n-1) {
        if (ctmp == s[i]) cnt++;
        else {
            v.pb(cnt)
            ctmp = s[i];
            cnt = 1;
        }
    }
    v.pb(cnt);
    rep1(i,v.size()) {
        int itmp;
        rep(j,i) {
            if (!j) {
                itmp = memo[0];
                memo[0] += v[i-1];
                memo[0] %= MAX;
            } else {
                int itmptmp = memo[j];
                memo[j] += itmp*v[i-1];
                memo[j] %= MAX;
                itmp = itmptmp;
            }
        }
    }
    rep(i,26) {
        ans += memo[i];
        ans %= MAX;
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
#include<stdio.h>

int space[10][10]={0};/*space[y][x]と対応*/

void small(int a,int b){
	space[a][b]++;
	if(a-1>=0) space[a-1][b]++; if(a+1<=9) space[a+1][b]++;
	if(b-1>=0) space[a][b-1]++; if(b+1<=9) space[a][b+1]++;
}

void mid(int a,int b){
	small(a,b);
	if(a-1>=0) do{
				if(b-1>=0) space[a-1][b-1]++; if(b+1<=9) space[a-1][b+1]++;
	}while(0);
	if(a+1<=9) {
				if(b-1>=0) space[a+1][b-1]++; if(b+1<=9) space[a+1][b+1]++;
	}while(0);
}

void large(int a,int b){
	mid(a,b);
	if(a-2>=0) space[a-2][b]++; if(a+2<=9) space[a+2][b]++;
	if(b-2>=0) space[a][b-2]++; if(b+2<=9) space[a][b+2]++;	
}

int main(void){
	int x,y,size;
	int i,j,count,max;

	while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
	if(size==1) small(y,x);
	if(size==2) mid(y,x);
	if(size==3) large(y,x);
	};
	max=space[0][0]; count=0;
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			if(space[i][j]==0) count++;
			if(max<space[i][j]) max=space[i][j];
		};};
		printf("%d\n%d\n",count,max);
		return (0);
}

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


int main()
{
  int n, k;
  cin >> n >> k;
  vector<ll> a(n + 1);
  rep(i, n)
  {
    int A;
    cin >> A;
    a[i+1] = a[i] + A - 1;
  }
  map<ll, int> mp;
  ll ans = 0;
  rep(i, n + 1)
  {
    if (i >= k)
      mp[a[i-k]%k]--;
    ans += mp[a[i]%k];
    mp[a[i]%k]++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    long long a,b,c,k,sum=0;
    cin >> a >> b >> c >>k;
    if(k>=a)
        sum+=a;
    else
        sum+=k;
    k-=a;
    if(k<=0)
        cout << sum;
    else{
        k-=b;
        if(k<=0)
            cout <<sum;
        else{
            sum-=k;
            cout << sum;
        }
    }


}


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main () {
    int n,m;
    char a[109][109];
    int b[102];
    int c[120];
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    scanf("%d %d",&n,&m);
     for(int i=0;i<n;i++){
            getchar();
        for(int j=0;j<m;j++){
            scanf("%c",&a[i][j]);
        }

    }
    //printf("\n\n");
   for(int i=0;i<n;i++){
        int k=0;
        for(int j=0;j<m;j++){
                if(a[i][j]=='.'){
                 k++;
                }
            }
        if(k==m){
            b[i]=1;
        }
    }
    for(int j=0;j<m;j++){
        int k=0;
        for(int i=0;i<n;i++){
            if(a[i][j]=='.'){
                k++;
            }
            }if(k==n){
                c[j]=1;
        }
    }

    for(int i=0;i<n;i++){
            int flag=0;
        for(int j=0;j<m;j++){
            if(b[i]!=1&&c[j]!=1){
                printf("%c",a[i][j]);
            }
            if(b[i]==1){
                flag=1;
            }

            if(flag==0&&j==m-1)
             printf("\n");
        }
    }


    return 0;
}


Measured memory_bytes: 128
#include <iostream>

#define BOARD_SIZE 10

void init(int a[BOARD_SIZE])
{
	for (int i=0; i<BOARD_SIZE; i++) a[i] = 0;
}

void init(int a[][BOARD_SIZE])
{
	for (int i=0; i<BOARD_SIZE; i++) {
		for (int j=0; j<BOARD_SIZE; j++) a[i][j] = 0;
	}
}

void copy(int a[][BOARD_SIZE], int b[][BOARD_SIZE])
{
	for (int i=0; i<BOARD_SIZE; i++) {
		for (int j=0; j<BOARD_SIZE; j++) a[i][j] = b[i][j];
	}
}

bool next(int a[BOARD_SIZE])
{
	for (int i=0; i<BOARD_SIZE; i++) {
		if (a[i] == 0) { a[i] = 1; return true; }
		a[i] = 0;
	}
	return false;
}

void point(int a[], int board[][BOARD_SIZE], int i, int j)
{
	board[i][j] = 1 - board[i][j];
	if (i>0) board[i-1][j] = 1 - board[i-1][j];
	if (i<BOARD_SIZE-1) board[i+1][j] = 1 - board[i+1][j];
	if (j>0) board[i][j-1] = 1 - board[i][j-1];
	if (j<BOARD_SIZE-1) board[i][j+1] = 1 - board[i][j+1];
}

bool isCorrect(int board[][BOARD_SIZE])
{
	for (int i=0; i<BOARD_SIZE; i++) {
		for (int j=0; j<BOARD_SIZE; j++) {
			if (board[i][j] == 1) return false;
		}
	}
	return true;
}

void show(int a[][BOARD_SIZE])
{
	for (int i=0; i<BOARD_SIZE; i++) {
		std::cout << a[i][0];
		for (int j=1; j<BOARD_SIZE; j++) {
			std::cout << " " << a[i][j];
		}
		std::cout << std::endl;
	}
}

bool check(int a[], int board[][BOARD_SIZE], int ans[][BOARD_SIZE])
{
	for (int j=0; j<BOARD_SIZE; j++) {
		if (a[j] == 1) { point(a, board, 0, j); ans[0][j] = 1; }
	}
	
	for (int i=1; i<BOARD_SIZE; i++) {
		for (int j=0; j<BOARD_SIZE; j++) {
			if (board[i-1][j] == 1) { point(a, board, i, j); ans[i][j] = 1; }
		}
	}
	return isCorrect(board);
}

int main()
{
	int board[BOARD_SIZE][BOARD_SIZE];
	int board_cpy[BOARD_SIZE][BOARD_SIZE];
	int a[BOARD_SIZE];
	int ans[BOARD_SIZE][BOARD_SIZE];
	int n; std::cin >> n;
	for (int k=0; k<n; k++) {
		for (int i=0; i<BOARD_SIZE; i++) {
			for (int j=0; j<BOARD_SIZE; j++) std::cin >> board[i][j];
		}
		init(a);
		do {
			init(ans);
			copy(board_cpy, board);
			if (check(a, board_cpy, ans)) { show(ans); break; }
		} while (next(a));
	}
	
	return 0;
}




Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int d;
	cin>>d;
	switch(d){
		case 25:
		cout<<"Christmas";
		break;
		case 24:
		cout<<"Christmas Eve";
		break;
		case 23:
		cout<<"Christmas Eve Eve";
		break;
		case 22:
		cout<<"Christmas Eve Eve Eve";
	}
}

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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            var n = long.Parse(Console.ReadLine());

            var hash = new HashSet<string>();

            for (int i = 0; i < n; i++) {
                // 文字列の入力
                var ss = Console.ReadLine();

                if (hash.Contains(ss)) {
                    continue;
                }

                hash.Add(ss);
            }

            Console.WriteLine(hash.Count());

            Console.Out.Flush();
        }
    }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;

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

  cin>>n;
  vector<P> ps(n);
  vector<ll> ord(n);
  rep(i,n){
    cin>>ps[i].fi>>ps[i].se;
    ord[i]=i;
  }

  double sum=0,cnt=0;
  do{
    rep(i,n-1){
      sum+=sqrt(pow(ps[ord[i+1]].fi-ps[ord[i]].fi,2)+pow(ps[ord[i+1]].se-ps[ord[i]].se,2));
    }
    cnt++;
  }while(next_permutation(all(ord)));
  printf("%.10f\n", sum/cnt);

  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ACoffee {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;
        if (s[2] == s[3] && s[4] == s[5]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ACoffee solver;
    solver.solve(in, out);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int l = 1000,r = 0;
    rep(i,n) {
        int a;
        cin >> a;
        l = min(l,a);
        r = max(r,a);
    }
    cout << r-l << endl;
}

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

#define ll long long
#define ld long long
#define M 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
    fast;
	ll n;
    cin >> n;
    ll k = n;
    if (n%2 == 0)
        k++;
    vector<pair<ll, ll>> ans;
    for (ll i = 1; i < n; i++) {
        for (ll j = i+1; j <= n; j++) {
            if (i + j != k)
                ans.push_back({i, j});
        }
    }
    cout << ans.size() << endl;
    for (auto i: ans)
        cout << i.first << " " << i.second << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
using str = string;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << std::setprecision(10);

    double ans=0;
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double ax,ay,bx,by,as,bs;
    as = h*30+m*0.5;
    bs = m*6;

    //double pi =  3.141592653589793;
    as = as*M_PI/180;
    bs = bs*M_PI/180;
    double sa = abs(as-bs);
    /*
    ax=a;
    ay=0;
    bx=a;
    by=tan(sa)*a;
    double nagasa=sqrt(pow(bx,2)+pow(by,2));
    bx = bx*(b/nagasa);
    by = by*(b/nagasa);
    */
    
    ax = cos(as)*a;
    ay = sin(as)*a;
    bx = cos(bs)*b;
    by = sin(bs)*b;
    /*
    cout << ax << " " << ay << endl;
    cout << bx << " " << by << endl;
    */
    ans = sqrt( pow(ax-bx,2)+pow(ay-by,2));
    cout << fixed << setprecision(10) << ans << endl; 
    return 0;
}

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

int main() {
	int x, y;
	while (1) {
		cin >> x >> y;
		if (x == 0 && y == 0)
			break;
		if (x < y) {
			cout << x <<" "<< y << endl;
		}
		else {
			cout << y<<" "<< x << endl;
		}
	}
}


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

int main(){
  string w; cin >> w;
  int n = w.size();
  bool flag = true;
  rep(i,n){
      int cnt = 0;
      rep(j,n){
          if(w[i] == w[j]){
              cnt++;
          }
      }
      if(cnt%2 != 0){
          flag = false;
          break;
      }
  }

  if(flag){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main()
{
	FastIO;
	int n,k;
	cin>>n>>k;
	k--;
	string s;
	cin>>s;
	if(isupper(s[k]))s[k]=tolower(s[k]);
	else s[k]=toupper(s[k]);
	cout<<s;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        boolean[][] matrix = new boolean[w][h];// false:白, true:黒

        for (int i = 0; i < n; i++) {
            int borderX = sc.nextInt();
            int borderY = sc.nextInt();
            int a = sc.nextInt();

            switch (a) {
                case 1:// x<xi を黒くする
                    for (int x = 0; x < borderX; x++) {
                        for (int y = 0; y < h; y++) {
                            matrix[x][y] = true;
                        }
                    }
                    break;
                case 2:// x>xi を黒くする
                    for (int x = borderX; x < w; x++) {
                        for (int y = 0; y < h; y++) {
                            matrix[x][y] = true;
                        }
                    }
                    break;
                case 3:// y<yi を黒くする
                    for (int x = 0; x < w; x++) {
                        for (int y = 0; y < borderY; y++) {
                            matrix[x][y] = true;
                        }
                    }
                    break;
                case 4:// y>yi を黒くする
                    for (int x = 0; x < w; x++) {
                        for (int y = borderY; y < h; y++) {
                            matrix[x][y] = true;
                        }
                    }
                    break;
            }
        }


        int count = 0;
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < h; j++) {
                if (matrix[i][j] == false) count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 23584
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
using ll = long long;

int main(void)
{
    string s;
    cin >> s;
    list<char> v;
    int cnt = 0;
    REP(i, s.size())
    {
        v.push_back(s[i]);
    }
    int q;
    cin >> q;
    REP(i, q)
    {
        int qr;
        cin >> qr;
        if (qr == 1)
        {
            cnt++;
            //reverse(v.begin(), v.end());
        }
        else
        {
            int fnc;
            cin >> fnc;
            char chr;
            cin >> chr;

            if ((fnc == 1 && cnt % 2 == 0) or (fnc == 2 && cnt % 2 == 1))
            {
                //s = chr + s;
                //s.insert(s.begin(), chr);
                v.push_front(chr);
            }
            else
            {
                v.push_back(chr);
            }
        }
    }
    if (cnt % 2 == 1)
    {
        reverse(v.begin(), v.end());
    }
    for (auto i : v)
    {
        cout << i;
    }
    cout << endl;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int d,t,s;
  cin>>d>>t>>s;
  if(d%s==0){
    if(d/s<=t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  else{
    if(d/s<t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3620