akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

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

const ll oo = 1e9 + 10;
const ll mod = 998244353,maxn = 110;
const double PI = acos(-1); 


int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;

    vector<int> v(n);
    for (auto &x: v) cin >> x;
    sort(all(v));

    for (int i=0; i<n; i++){
        for (int j=i+1; j<n; j++){
            for (int k=j+1;k<n;k++){
                if (v[k] < v[i] + v[j] and v[k] != v[i] and v[i] != v[j] and v[j] != v[k]) ans++;
            }
        }
    }

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

Measured memory_bytes: 3656
# ABC141d
import sys
import heapq
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = list(map(int, input().split()))

ha = []

for i in a:
    heapq.heappush(ha, -i)


# print(ha)

for _ in range(m):
    heapq.heappush(ha, math.ceil(heapq.heappop(ha)/2))

# print(ha)
print(-sum(ha))

Measured memory_bytes: 14380
<?php
list($n, $k, $s) = ints();
for ($i = 0; $i < $n; ++$i)
    $a[] = $i < $k ? $s : $s % 10 ** 9 + 1;
echo implode(' ', $a);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 21804
#include <stdio.h>
int main(void){
    int x, y, t;
    
    while(1){
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0) break;

    if (x < y ){
       printf("%d %d\n",x,y);
 
    } else{
 
        printf("%d %d\n",y,x);
    }
    }
   return 0;
}



Measured memory_bytes: 2136
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n, q;
		n = scanner.nextInt();
		q = scanner.nextInt();
		int[] s0 = new int[n];
		for (int i = 0; i < n; i++)
			s0[i] = scanner.nextInt();
		int[] s = Arrays.copyOf(s0, n);
		Arrays.sort(s);
		List<Integer> sym = new ArrayList<Integer>();
		while (q-- > 0) {
			char qtype = scanner.next().charAt(0);
			int x = scanner.nextInt();
			if (qtype == 'A') {
				sym.add(s0[x - 1]);
			} else if (qtype == 'R') {
				sym.remove(sym.indexOf(s0[x - 1]));
			} else {
				Collections.sort(sym);
				int left = 0;
				int right = INF;
				while (left != right) {
					int center = (left + right) / 2;
					int pre = 0;
					int BAN = 0;
					for (int i = 0; i < sym.size(); i++) {
						int c = sym.get(i) - center;
						int p = Arrays.binarySearch(s, c);
						if (p < 0)
							p = p * -1 - 1;
						else {
							for (int j = p - 1; j >= 0; j--) {
								if (s[j] != c) {
									break;
								}
								p--;
							}
						}
						BAN += Math.max(p - pre, 0);
						pre = Arrays.binarySearch(s, sym.get(i)) + 1;
						for (int j = pre; j < n; j++) {
							if (s[j] != sym.get(i)) {
								break;
							}
							pre++;
						}
					}
					BAN += Math.max(n - pre, 0);
					if (BAN <= x)
						right = center;
					else
						left = center + 1;
				}
				if (left != INF)
					System.out.println(left);
				else
					System.out.println("NA");
			}
		}

	}

	int INF = 1000000001;
}

Measured memory_bytes: 302176
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, a[100001];
int main() {
  cin >> n; read_n(a, n);
  set<lli> s;
  for (lli i=0; i<n; ++i) {
    lli x = a[i];
    if (s.count(x)>0) s.erase(x);
    else s.insert(x);
  }
  cout << s.size() << '\n';
  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int A,B;
	scanf("%d %d",&A,&B);

	if(A <= 9 && B <= 9){

		printf("%d\n",A*B);

	}else{

		printf("-1\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
#define N 100005
int a[N],x[N],r[N];
int n,m;
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	cin>>n>>m;
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++)
	{
		int t=a[i];
		while(t%2==0)
		{
			t/=2,x[i]++;
		}
		a[i]/=2;
	}
	for(int i=1;i<n;i++)
	{
		if(x[i]!=x[i+1])
		{
			cout<<"0\n";
			return 0;
		}
	}
	int lcm=1;
	for(int i=1;i<=n;i++)
	{
		lcm=lcm/__gcd(lcm,a[i])*a[i];
		if(lcm>m)
		{
			cout<<"0\n";
			return 0;
		}
	}
	int num=m/lcm;
	cout<<(num+1)/2<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
typedef long long int ll;
const long long INF = 1LL << 60;
using namespace std;

int n;
ll w,weight[110],value[110];

ll dp[110][100010]={0};

int main(){
	cin >>n>>w;
	cinf(n,weight,value);
	for(int i=0;i<n;i++){
		for(int sum_w=0;sum_w<=w;sum_w++){
			if(sum_w- weight[i]>=0){
				dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w- weight[i]]+value[i]);
			}
			dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w]);
		}
	}
	cout << dp[n][w] << endl;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

const int N = 100050,M = 200050;
struct T{
	int v,a;
	bool operator < (const T w) const{ return v<w.v; }
}tt[N];
int v[N];
int n,m,a[N],l[M],r[M],ans[M],cnta;
int To[N<<1],Ne[N<<1],He[N],_k,Id[N<<1];
inline void add(int x,int y,int z){
	++_k; To[_k] = y,Ne[_k] = He[x],He[x] = _k,Id[_k] = z; 
}
int fa[N];
inline int Find(int x){
	return x == fa[x] ? x : fa[x] = Find(fa[x]); 
}
inline void Merge(int x,int y){
//	cout<<"EE "<<x<<' '<<y<<endl;
	x=Find(x),y=Find(y),fa[x]=y;
}

int b[N];
int val[N],vis[N],fap[N];
inline void dfs(int x){
	vis[x] = 1;
	val[x] = b[x];
	for (int p=He[x],y; p ; p =Ne[p]) if (((y=To[p])^fa[x])&&!vis[y]){
		fa[y] = x,fap[y] = Id[p],dfs(y),val[x] ^= val[y];
	}
	ans[fap[x]] ^= val[x];
	if (ans[0]){
		puts("-1");
		exit(0);
	}
}
int main(){
	int i;
	read(n),read(m);
	for (i = 1; i <= n; ++i) read(tt[i].v),read(tt[i].a); sort(tt+1,tt+n+1);
	for (i = 1; i <= n; ++i) a[i] = tt[i].a,v[i] = tt[i].v,fa[i] = i; fa[n+1] = n+1;
	for (i = 1; i <= m; ++i){
		read(l[i]),read(r[i]);
		l[i] = lower_bound(v+1,v+n+1,l[i]) - v;
		r[i] = upper_bound(v+1,v+n+1,r[i]) - v - 1;
		if (l[i]>r[i]) continue;
		if (Find(l[i])!=Find(r[i]+1)) Merge(l[i],r[i]+1),add(l[i],r[i]+1,i),add(r[i]+1,l[i],i);
	}
	for (i = 1; i <= n; ++i) if (a[i]) b[i]^=1,b[i+1]^=1;
	for (i = 1; i <= n+1; ++i) if (!vis[i]) fa[i] = fap[i] = 0,dfs(i);
	cnta = 0;
	for (i = 1; i <= m; ++i) if (ans[i]) ++cnta;
	cout<<cnta<<endl;
	for (i = 1; i <= m; ++i) if (ans[i]) cout<<i<<' '; cout<<endl;
    return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<cstdio>
#include<cmath>
#define MN 1002
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
double D[MN+5];
int n,x[MN+5],y[MN+5],r[MN+5],a,b,c,d,head[MN+5],cnt=0,vis[MN+5];
struct edge{int to,next;double w;}e[MN*MN*2+5];
inline double dis(int x,int y,int X,int Y){return sqrt(1LL*(X-x)*(X-x)+1LL*(Y-y)*(Y-y));}
inline void ins(int f,int t,double w)
{
    e[++cnt]=(edge){t,head[f],w};head[f]=cnt;
    e[++cnt]=(edge){f,head[t],w};head[t]=cnt;
}
int main()
{
    a=read();b=read(),c=read(),d=read();n=read();
    for(int i=1;i<=n;++i) x[i]=read(),y[i]=read(),r[i]=read();
    for(int i=1;i<n;++i) for(int j=i+1;j<=n;++j)
        ins(i,j,max(0.,dis(x[i],y[i],x[j],y[j])-r[i]-r[j]));
    for(int i=1;i<=n;++i)
        ins(n+1,i,max(0.,dis(a,b,x[i],y[i])-r[i])),
        ins(n+2,i,max(0.,dis(c,d,x[i],y[i])-r[i]));
    for(int i=1;i<=n+2;++i) D[i]=5e18;D[n+1]=0;
    for(int i=1;i<=n+2;++i)
    {
        double mn=6e18;int from=0;
        for(int j=1;j<=n+2;++j) if(!vis[j]&&D[j]<mn) mn=D[j],from=j;
        vis[from]=1;
        for(int i=head[from];i;i=e[i].next)
            D[e[i].to]=min(D[e[i].to],D[from]+e[i].w);
    }
    printf("%.10lf",min(D[n+2],dis(a,b,c,d)));
    return 0;
}



Measured memory_bytes: 16640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = 100;
		int w = 100;
		char[][] c = new char[h][w];

		// Initialize
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i < h/2) {
					c[i][j] = '#';
				} else {
					c[i][j] = '.';
				}
			}
		}

		for (int i = 0; i < a - 1; i++) {
			int y = (i * 2 / w) * 2;
			int x = (i * 2) % w;
			c[y][x] = '.';
		}
		for (int i = 0; i < b - 1; i++) {
			int y = (h - 1) - (i * 2 / w) * 2;
			int x = (i * 2) % w;
			c[y][x] = '#';
		}

		System.out.println(h + " " + w);
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				System.out.print(c[i][j]);
			}
			System.out.print("\n");
		}
	}
}


Measured memory_bytes: 27860
#include<iostream>
using namespace std;
int abs(int a) {
	if (a < 0) return -a;
	return a;
}
int main() {
	int ans,sum=0,min=10000000,n, l, data[200];
	cin >> n >> l;
	for (int i = 0; i < n; ++i) {
		data[i] = l + i;
		sum += data[i];
	}
	for (int i = 0; i < n; ++i) {
		int x = abs(sum - (sum - data[i]));
		if (x < min) {
			min = x;
			ans = sum - data[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	slice := make([]int, 3)
	for i := 0; i < 3; i++ {
		slice[i] = nextInt()
	}

	min := 10000
	sum := 0
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			if i == j {
				continue
			}

			sum = slice[i] + slice[j]
			// fmt.Printf("%d + % d = %d\n", slice[i], slice[j], sum)
			if min > sum {
				min = sum
			}
		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 640
#include<stdio.h>
main()
{
	int n, i;
	char a[5];
	scanf("%s", a);
	for (i=0, n=0; i<strlen(a); i++)
	{
		if (a[i]=='+')
		{
			n++;
		}
		else if (a[i]=='-')
		{
			n--;
		}
	}
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);

		int N = s.nextInt();
		int A = s.nextInt();
		int B = s.nextInt();

		int sum = 0;
		int resultSum = 0;
		for (int i = 1; i <= N; i++) {
			int result1 = i / 10000;
			int result2 = i % 10000 / 1000;
			int result3 = i % 1000 / 100;
			int result4 = i % 100 / 10;
			int result5 = i % 10;
			resultSum = result1 + result2 + result3 + result4 + result5;

			if (A <= resultSum && resultSum <= B) {
				sum += i;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 21460
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)

string s;
ll N;

int main() {
    cin >> N;
    cin >> s;
    ll r = 0;
    ll b = 0;
    rep(i,s.size()){
        if (s[i] == 'R') r++;
        else b++;
    }
    if (r>b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <algorithm>
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
using namespace std;
int main() {
	int N, M, A[105];
	cin >> N >> M;
	rep(i, N) cin >> A[i];
	int sum = 0;
	rep(i, N) sum += A[i];
	int count = 0;
	rep(i, N) {
		if (4 * M * A[i] >= sum) count++;
	}
	if (count >= M) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

#define db(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

using namespace std;

const int N = 2e5 + 7;

int n, firstOdd, firstEven, secondOdd, secondEven;
int a[N], cntO[N], cntE[N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i += 2){
        cntO[a[i]]++;
    }
    for (int i = 2; i <= n; i += 2){
        cntE[a[i]]++;
    }
    for (int i = 1; i <= 200000; i++){
        if (cntO[i] > cntO[firstOdd])
            firstOdd = i;
        if (cntE[i] >= cntE[firstEven])
            firstEven = i;
    }
    for (int i = 1; i <= 200000; i++){
        if (i != firstOdd && cntO[i] > cntO[secondOdd])
            secondOdd = i;
        if (i != firstEven && cntE[i] >= cntE[secondEven])
            secondEven = i;
    }
    int res = 0;
    if (firstOdd != firstEven) res = cntO[firstOdd] + cntE[firstEven];
    res = max(res, cntO[firstOdd] + cntE[secondEven]);
    res = max(res, cntO[secondOdd] + cntE[firstEven]);
    cout << n - res;
}


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


int main (){

    int N,ans=0;
    cin >> N;
    string s[N];
    map<string,int>m;
    for(int i = 0; i < N; i++) {
        cin >> s[i];
        m[s[i]]++;
    }
    int M;
    cin >> M;
    string t[M];
    for(int i = 0; i < M; i++) {
        cin >> t[i];
        m[t[i]]--;
    }
    for(int i = 0; i < N; i++) {
        if(m[s[i]] > ans) {
            ans = m[s[i]];
        }
    }
    for(int i = 0; i < M; i++) {
        if(m[t[i]] > ans) {
            ans = m[t[i]];
        }
    }

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


Measured memory_bytes: 256
// C++ implementation of the approach 
#include <bits/stdc++.h> 
using namespace std; 

// Graph class represents a undirected graph 
// using adjacency list representation 
class Graph { 
	// No. of vertices 
	long long int V; 

	// Pointer to an array containing adjacency lists 
	list<long long int>* adj; 

	// A function used by DFS 
	void DFSUtil(long long int v, bool visited[]); 

public: 
	// Constructor 
	Graph(long long int V); 

	void addEdge(long long int v, long long int w); 
	long long int NumberOfconnectedComponents(); 
}; 

// Function to return the number of 
// connected components in an undirected graph 
long long int Graph::NumberOfconnectedComponents() 
{ 

	// Mark all the vertices as not visited 
	bool* visited = new bool[V]; 

	// To store the number of connected components 
	long long int count = 0; 
	for (long long int v = 0; v < V; v++) 
		visited[v] = false; 

	for (long long int v = 0; v < V; v++) { 
		if (visited[v] == false) { 
			DFSUtil(v, visited); 
			count += 1; 
		} 
	} 

	return count; 
} 

void Graph::DFSUtil(long long int v, bool visited[]) 
{ 

	// Mark the current node as visited 
	visited[v] = true; 

	// Recur for all the vertices 
	// adjacent to this vertex 
	list<long long int>::iterator i; 

	for (i = adj[v].begin(); i != adj[v].end(); ++i) 
		if (!visited[*i]) 
			DFSUtil(*i, visited); 
} 

Graph::Graph(long long int V) 
{ 
	this->V = V; 
	adj = new list<long long int>[V]; 
} 

// Add an undirected edge 
void Graph::addEdge(long long int v, long long int w) 
{ 
	adj[v].push_back(w); 
	adj[w].push_back(v); 
} 

// Driver code 
int main() 
{ 
    long long int n,m,a,b;
    cin>>n>>m;
    Graph g(n);
    for(long long int i=0;i<m;i++)
    {cin>>a>>b;
    g.addEdge(a-1,b-1);
    } 

	cout << g.NumberOfconnectedComponents()-1; 

	return 0; 
} 


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

const int Mod=1e9+7,N=2010;

int n,m,k,f[2][N],sum[2][N];

void Init() {
	scanf("%d%d%d",&n,&m,&k);
}

void Solve() {
	int now=0,ans=0;
	f[0][0]=1; k--;
	for (int j=0;j<=n;++j) sum[0][j]=1;
	for (int i=1;i<=n+m;++i) {
		now^=1;
		for (int j=0;j<=n;++j) f[now][j]=0;

		for (int j=0;j<=n && j<=k*i;++j) {
			f[now][j]=(sum[now^1][j]+((j-1>=k)?(Mod-sum[now^1][j-k-1]):0))%Mod;
			if (j && (j%k)==(n%k) && k*i-j<=m-1 && ((k-j%k)%k)==((m-1)%k)) 
				ans=(ans+(f[now][j]-f[now^1][j]+Mod)%Mod)%Mod;
		}
		sum[now][0]=f[now][0];
		for (int j=1;j<=n;++j) {
			sum[now][j]=(sum[now][j-1]+f[now][j])%Mod;
		}
	}	
	printf("%d\n",ans);
}

int main() {
	Init();
	Solve();
	return 0;
}

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

int main() {
  //ios_base::sync_with_stdio(0);
  //cin.tie(0);
  ll n,m;
  cin>>n>>m;
 vector< pair<ll ,ll> >p;
 for(int i=1;i<=n;i++)
 {
   ll u,v;
   cin>>u>>v;
   p.push_back(make_pair(u,v));

 }
 sort(p.begin(),p.end());
 ll c=0,cost=0;
 for(int i=0;i<p.size()&&m>0;i++)
 {
       if  (p[i].second<m)
       {
         cost+=(p[i].first*p[i].second);
         m-=p[i].second;
         c+=p[i].second;
       }
       else if(m>0)
       {
         cost+=(p[i].first*m);
         c+=m;
         break;
       }  
 }
 cout<<cost<<endl;
  
}

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

long long N;

void solve(long long current, int bits, int &counter)
{
	if (current > N) return;
	if (bits == 0b111) ++counter;

	solve(current*10 + 3, bits | 0b001, counter);
	solve(current*10 + 5, bits | 0b010, counter);
	solve(current*10 + 7, bits | 0b100, counter);
}

int main(int argc, char **argv)
{
	cin >> N;
	int ans = 0;
	solve(0, 0, ans);
	std::cout << ans << std::endl;
}


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

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    long long x, y, z;
    std::cin >> x >> y >> z;

    std::cout << z << " " << x << " " << y << std::endl;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    string S;
    cin >> S;
    cout << (S == "ABC" ? "ARC" : "ABC") << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();
		int X = fs.nextInt();
		int Y = fs.nextInt();
		int Z = fs.nextInt();

		System.out.println(Z + " " + X + " " + Y);
	}

}


Measured memory_bytes: 20948
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "unordered_set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<int,int>

typedef long long ll;
using namespace std;

int n;

double x[1002], y[1002], r[1002], d[1002][1002],g[1002];
priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>>q;

int main() {
	cin >> x[0] >> y[0] >> x[1] >> y[1] >> n;
	r[0] = r[1] = 0;

	rep(n) {
		cin >> x[i + 2] >> y[i + 2] >> r[i + 2];
	}
	rep(n + 2) {
		REP(n+2, j) {
			d[i][j] = max(sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])) - r[i] - r[j], (double)0);
		}
	}
	rep(n + 2)
		g[i] = -1;
	g[0] = 0;
	for (int i = 1; i < n + 2; ++i) {
		q.push(mkp(d[0][i], i));
	}
	while (!q.empty()) {
		double qfst = q.top().first;
		int qsnd = q.top().second;
		q.pop();
		if (g[qsnd] == -1) {
			g[qsnd] = qfst;
			rep(n + 2) {
				if (g[i] == -1) {
					q.push(mkp(qfst + d[qsnd][i], i));
				}
			}
		}
	}
	printf("%.10f", g[1]);
	return 0;
}

Measured memory_bytes: 18412
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s,t("keyence");
    cin>>s;
    int cnt=0,n=s.size();
    rep(i,7){
        if(s[i]==t[i]) cnt++;
        else break;
    }
    rep(i,7){
        if(s[n-1-i]==t[6-i]) cnt++;
        else break;
    }
    if(cnt>=7) cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 3564
#include<stdio.h>

int main()
{
  int n, i;
  double x, sum = 0;
  char u[3];

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%lf%s", &x, u);
    if(u[0]=='J'){
      sum+=x;
    }
    else if(u[0]=='B'){
      sum+=x*380000.0;
    }
  }

  printf("%f\n", sum);

  return 0;
}

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

void solve() {
	int ans = 1e9;
	string s, t; cin >> s >> t;
	int nt = t.size(), ns = s.size();
	for (int i = 0; i <= ns - nt; i++) {
		int curans = 0;
		for (int j = 0; j < nt; j++)curans += (s[i + j] != t[j]);
		ans = min(curans, ans);
	}
	cout << ans;

}

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
	// int t; cin >> t;
	// while (t--)
	solve();

}

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

ll sub[200009];

int main(){
	// freopen("Input.txt","r",stdin); freopen("Output.txt","w",stdout);
	int n,tmp;cin>>n;
	for(int i=2;i<=n;i++) cin>>tmp,sub[tmp]++;
	for(int i=1;i<=n;i++) cout<<sub[i]<<"\n";  
}

Measured memory_bytes: 5148
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    ll x,y; cin >>x>>y;

    ll count = 0;
    ll a = x;
    while (a <= y) {
        count++;
        a = a*((ll)2);
    }
    
    cout << count << endl;
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int a,b,k,c;
  cin>>a>>b>>k;
  for(int i=100; i>=1; i--) {
    if(a%i==0&&b%i==0) {
      c++;
    }
    if(c==k) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdio.h>
#define X first
#define Y second

#define _ << " " <<
#define debug(x) #x << " = " << x

#define ll long long
#define ull unsigned long long
#define all(v) v.begin(), v.end()

using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

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

    int a, b;
    std::cin >> a >> b;

    const int base = 100'000;
    std::map<int, int> score = {
        {1, base * 3},
        {2, base * 2},
        {3, base * 1},
    };

    int total = score[a] + score[b];
    if (a == 1 && b == 1)
        total += 4 * base;

    std::cout << total << std::endl;
    return 0;
}

Measured memory_bytes: 256
A, B, C, K = map(int, input().split())

ans = 0

if K - A >= 0:
    ans += A
    K -= A
else:
    ans += K
    print(ans)
    exit()

K -= B

if K > 0:
    if K-C >= 0:
        ans -= C
    else:
        ans -= K

print(ans)


Measured memory_bytes: 61600
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;

  
     signed main(){
     long double a,b,h,m;
     cin>>a>>b>>h>>m;
     m+=h*60;
    
     cout<< std::fixed << std::setprecision(15) <<sqrt(a*a+b*b-2*a*b*cos(2*M_PI*(m/720-m/60)))<<endl;

      }

        

Measured memory_bytes: 4156
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = input()
    if int(N[-1]) in [2, 4, 5, 7, 9]:
        print("hon")
    elif int(N[-1]) in [0, 1, 6, 8]:
        print("pon")
    else:
        print("bon")


if __name__ == '__main__':
    main()


Measured memory_bytes: 68704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
pll stuff[105];
ll dp[105][100005];
ll solve(int current, int n, int w)
{
	if (w <= 0)
		return 0;
	if (current == n)
		if (w >= stuff[current].first)
			return stuff[current].second;
		else
			return 0;
	if (dp[current][w])
		return dp[current][w];
	return dp[current][w] = max(solve(current + 1, n, w), (w - stuff[current].first >= 0)? stuff[current].second + solve(current + 1, n, w - stuff[current].first): 0);
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, w;
	cin >> n >> w;
	for (int i = 0; i < n; ++i)
		cin >> stuff[i].first >> stuff[i].second;
	cout << solve(0, n - 1, w) << '\n';
	return 0;
}

Measured memory_bytes: 76032
#if 0
2019.07.08

震惊，这题我竟然一遍过。
要求所有边被覆盖，对于这个条件，考虑用容斥处理，
对于每个边集 E ，钦定 E 不被覆盖后其他边随意的方案数为 f(E) ，
则 E 对答案的贡献为 f(E) * -1^|E| 。

钦定一些边不被覆盖相当于把树切成森林，每颗新的树独立。
考虑 DP ，设 f[u][i] 表示 u 的子树中，
去掉 u 在内的 i 个点的新树（这些点相互配对）的方案。
u -> v 转移时即 f[u][i + j] += f[u][i] * f[v][j] 。
特别地，对于 f[u][0] ，枚举 u 所在的新树大小 i ，f[u][0] -= f[u][i] * g[i] ，
其中 g[i] 表示大小为 i 的新树中随意配对的方案数，
为什么是 -= ？，因为要考虑容斥系数。
#endif
#include <cstdio>
#include <vector>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long lolong;
inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 5005, mod = 1000000007;
lolong f[maxn][maxn], fu[maxn], g[maxn];
int size[maxn];
std::vector<int> G[maxn];

void dp(int u, int fa) {
	size[u] = 1;
	f[u][1] = 1;
	for(int v : G[u])
		if(v != fa) {
			dp(v, u);
			for(int i = 0; i <= size[u]; i ++) {
				fu[i] = f[u][i];
				f[u][i] = 0;
			}
			for(int i = 0; i <= size[u]; i ++)
				for(int j = 0; j <= size[v]; j ++)
					(f[u][i + j] += fu[i] * f[v][j]) %= mod;
			size[u] += size[v];
		}
	if(f[u][0]) puts("FUCK");
	for(int i = 1; i <= size[u]; i ++)
		(f[u][0] -= f[u][i] * g[i]) %= mod;
}

int main() {
	int n = input();
	for(int i = 1; i < n; i ++) {
		int u = input(), v = input();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	g[0] = 1;
	for(int i = 2; i <= n; i ++)
		g[i] = g[i - 2] * (i - 1) % mod;
	dp(1, 0);
	printf("%lld\n", (mod - f[1][0]) % mod);
}

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

#define ll long long

int main() {
    int N, L;
    cin >> N >> L;
    int A[N];
    for(int i = 0;i < N;i++) {
        A[i] = L + i;
    }
    auto cmp = [](int a, int b) {return abs(a) < abs(b);};
    sort(A, A + N, cmp);
    int sum = 0;
    for(int i = 1;i < N;i++) {
        sum += A[i];
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;


// Bismilahir Rahmanir Rahim


typedef unsigned int ui;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef short int si;
typedef unsigned short int usi;
typedef pair <int, int> pii;


#define CASE false
#define TEST false
#define BUFFER true
#define TIME false
#define DEBUG true
#define SET_GEN false
#define _ << " " <<
#define __ << "\n"
#define ff first
#define ss second
#define RANGE(a, b) (rand() % (b-a+1) + a)


const double pi = acos(-1.);
const double eps = 1e-7;
const int high = 2e9;
const int inf = 2147483647;
const int _inf = -2147483648;
const lli INF = 1e18;
const int mod = 1e9+7;


void delay(int sec); // DEBUG


void solution(void)
{	
	int n, k;
	cin >> n >> k;
	
	vector <int> height(n), dp(n, inf);
	dp[0] = 0;
	
	for(int i = 0; i < n; ++i) 
		cin >> height[i];
		
	for(int i = 0; i < n; ++i) {
		for(int j = i+1; j <= i+k; ++j) {
			if (j < n) 
				dp[j] = min(dp[j], dp[i] + abs(height[i]-height[j]));
		}
	}
	
	
	cout << dp[n-1];
	

    return ;
}

int main(int argc, char *arv[])
{
    #if BUFFER
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #endif

    #if SET_GEN
    srand((unsigned int) time(0));
    #endif

    int t = 1;

    #if CASE
    int cnt = 1;
    #endif

    #if TEST
    cin >> t;
    #endif

    #if TIME
    clock_t start_time, end_time;
    double time_elapsed;
    #endif


    while(t--) {

        #if TIME
        start_time = clock();
        #endif

        #if CASE
        cout << "Case " << cnt++ << ": ";
        #endif

        solution();

        #if TIME
        end_time = clock();

        time_elapsed = (double) (end_time - start_time) / CLOCKS_PER_SEC;

        cout << "\nRuntime: " << fixed << setprecision(7) << time_elapsed << "\n";
        #endif
    }


    return 0;
}

void delay(int sec)
{
    int mili_sec = 1000 * sec;

    clock_t start_time = clock();

    while (clock() < start_time + mili_sec);

    return ;
}


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

int sum[10000][1280];
int main() {
	int N, M, r;
	while (scanf("%d%d", &N, &M), N) {
		scanf("%d", &r);
		memset(sum, 0, sizeof(sum));
		rep(i, r) {
			int t, n, m, s; scanf("%d%d%d%d", &t, &n, &m, &s);
			if (s)sum[m - 1][t]++;
			else sum[m - 1][t]--;
		}
		rep(i, M) {
			for (int j = 540; j <= 1260; j++)
				sum[i][j] += sum[i][j - 1];
		}
		int q; scanf("%d", &q);
		rep(i, q) {
			int ts, te, m; scanf("%d%d%d", &ts, &te, &m);
			int cnt = 0;
			for (int j = ts; j < te; j++) {
				if (sum[m - 1][j])cnt++;
			}
			printf("%d\n", cnt);
		}
	}
}

Measured memory_bytes: 53200
from operator import itemgetter
from heapq import heappush,heappop
N = int(input())
table=[]
for i in range(N):
    a,b = map(int,input().split())
    table.append([a,b,i])
A = sorted(table,key=itemgetter(0))
B = sorted(table,key=itemgetter(1))

graph=[]
for k in range(N):#距離、点
    graph.append([min(abs(A[k][0]-A[k-1][0]),abs( A[k][1]-A[k-1][1])),A[k][2],A[k-1][2]])
for k in range(N):
    graph.append([min(abs(B[k][0]-B[k-1][0]),abs( B[k][1]-B[k-1][1])),B[k][2],B[k-1][2]])

class Unionfindtree:
    def __init__(self,number):
        self.par = [i for i in range(number)]
        self.rank = [0]*(number)

    def find(self,x):#親を探す xの親を示す
        if self.par[x] ==x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self,x,y):#x,yを繋げる
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return 
        if self.rank[px]<self.rank[py]:
            self.par[px]=py
        else:
            self.par[py]=px
        if self.rank[px]==self.rank[py]:
            self.rank[px] +=1
    
    def connect(self,x,y):#親が同じかみる
        return self.find(x)==self.find(y)
#クラスカル法
kei = Unionfindtree(N)
graph.sort()
dist =0
for d,i,j in graph:
    if not kei.connect(i,j):
        kei.union(i,j)
        dist +=d
print(dist)

Measured memory_bytes: 56852
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <list>
#include <stdio.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m,n;
/////////////////////////////////////////////////////

ll N,K;
ll MAX;
ll ref;
int main(){
    cin>>N>>K;
    
    MAX=N/K;
    ref=MAX*MAX*MAX;

    if(K%2==0){
        MAX=(N+K/2)/K;
        ref+=MAX*MAX*MAX;
    }
    cout<< ref <<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Jan  5 17:31:25 2019
//
package main

import "fmt"

func pow2(n int) int {
	if n == 0 {
		return 1
	}
	return 2 * pow2(n-1)
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	fmt.Println((1900*M + 100*(N-M)) * pow2(M))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int mod = 1e9 + 7;
signed main() {
    int n;
    cin >> n;
    int ans9 = 1, ans10 = 1, ans8 = 1;
    rep(i, 0, n) {
        ans8 = ans8 * 8 % mod;
        ans9 = ans9 * 9 % mod;
        ans10 = ans10 * 10 % mod;
    }
    int ans = (ans10 - 2 * ans9 + ans8 + 3 * mod) % mod;
    cout << ans << "\n";
}


Measured memory_bytes: 3536
#include <stdio.h>

int main(){
  int a[3];
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  int i,j,temp;
  for(i=0;i<3;i++){
    for(j=i+1;j<3;j++){
      if(a[i]>a[j]){
        temp=a[i];
        a[i]=a[j];
        a[j]=temp;
      }
    }
  }
  printf("%d %d %d\n",a[0],a[1],a[2]);
}



Measured memory_bytes: 2668
#include <stdio.h>
int main(int argc, char *argv[])
{
	int n,a[4],x,y,i,j;
	while(scanf("%d",&n) != EOF)
	{ 
		a[0] = n % 10;
		a[1] = (n/10) % 10;
		a[2] = (n/100) % 10;
		a[3] = n / 1000;
		y = 0;
		for(i = 0; i < 2; i++)
		{
			x = 1;
			for(j = i + 1; j < 3+i;j ++)
			{
				if(a[i] == a[j])
				{
					x ++;
					if(x >= 3){
					   y = 1;
					   break;
					}
				}
			}
		} 
		if(y)printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 0; i < n - 2; i++) {
            if (p[i] < p[i + 1] && p[i + 1] < p[i + 2] || p[i + 2] < p[i + 1] && p[i + 1] < p[i]) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int main() {
  int num;
  cin>>num;
  for(int i=0;i<num;i++){
    map<string,int> strmap;
    string str;
    cin>>str;
    for(int j=1;j<str.length();j++){
      string fir=str.substr(0,j);
      string sec=str.substr(j,str.length()-j);
      string revfir=fir;
      string revsec=sec;
      reverse(revfir.begin(),revfir.end());
      reverse(revsec.begin(),revsec.end());
      //1:????????????
      strmap[fir+sec]++;
      //2:2+1
      strmap[sec+fir]++;
      //3:1reverse+2
      strmap[revfir+sec]++;
      //4:1+2reverse
      strmap[fir+revsec]++;
      //5:2rev+1
      strmap[revsec+fir]++;
      //6:2+1rev
      strmap[sec+revfir]++;
      //7:1rev+2rev
      strmap[revfir+revsec]++;
      //8:2rev+1rev
      strmap[revsec+revfir]++;
    }
    cout << strmap.size() << endl;
    
      
      
      

    
  }
  
    return 0;
}

Measured memory_bytes: 3172
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long W = sc.nextLong();
		long H = sc.nextLong();
		long x = sc.nextLong();
		long y = sc.nextLong();
		
		System.out.println((double)W*H/2 + " " + (x*2==W && y*2==H ? 1 : 0));
		sc.close();
	}
}

Measured memory_bytes: 21972
#include<stdio.h>
int main(void){
  int a,b,sum=0,c;
  scanf("%d %d\n",&a,&b);
  for(c=0;c<2;c++){
    if(a>=b){
      sum=sum+a;
      a--;
    }
    else{
      sum=sum+b;
      b--;
    }
  }
    printf("%d",sum);
  return 0;
}

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

using namespace std;

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

    vector<int> d(N);
    for (int i = 0; i < N; i++) cin >> d[i];

    int sum = 0;
    for (int i = 0; i < N; i++)
        for (int j = i + 1; j < N; j++)
            sum += d[i] * d[j];

    cout << sum << endl;
}


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N, K, Q;
int A[100010];
int B[100010];

int main() {
	cin >> N >> K >> Q;
	REP(i, Q) cin >> A[i];
	REP(i, N) B[i] = K;
	REP(i, Q) {
		B[A[i] - 1]++;
	}
	REP(i, N) {
		if (B[i] > Q) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
}

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

using namespace std;

using int64 = long long;

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

constexpr int DEBUG = 0;

int Solve() {
  int n;
  cin >> n;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) cin >> xs[i];

  auto is_valid = [&](int k) -> bool {
    if (k == 1) {
      for (int i = 0; i < n - 1; i++) {
        if (xs[i] >= xs[i + 1]) return false;
      }
      return true;
    }

    map<int, int> current;
    for (int i = 1; i < n; i++) {
      if (xs[i] <= xs[i - 1]) {
        while (!current.empty() && current.rbegin()->first > xs[i]) {
          current.erase(current.rbegin()->first);
        }
        current[xs[i]]++;
        int x = xs[i];
        for (int x = xs[i]; x >= 1; x--) {
          if (current[x] < k) break;
          current[x] = 0;
          current[x - 1]++;
        }
        if (current[0] > 0) return false;
      }
    }
    return true;
  };
  if (is_valid(1)) return 1;

  int l = 1;
  int r = n;
  while (r - l >= 2) {
    int m = (l + r) / 2;
    if (is_valid(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  return r;
}

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

  cout << Solve() << endl;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
const int maxn=1005;
int a[maxn];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k,ans=0;
	cin>>n>>k;
	rep(i,0,n) cin>>a[i];
	sort(a,a+n);
	rep(i,0,k) ans+=a[i];
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)

using namespace std;

int gcd(int a, int b){
   
    if(a < b){
        return gcd(b,a);
    }else{
        if(a % b == 0){
            return b;
        }else{
            return gcd(b, a%b);
        }
    }
}

int main(){

    int n;
    cin >> n;

    vector<int> a;

    rep(i,n){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    vector<int> lgcd;
    vector<int> rgcd;

    lgcd.push_back(a[0]);
    rgcd.push_back(a[n - 1]);

    rep(i,n - 1){
        lgcd.push_back(gcd(lgcd[i],a[i + 1]));
        rgcd.push_back(gcd(rgcd[i],a[n - 2 - i]));
    }

    //fordebug
    /*

    rep(i,n){
        cout << lgcd[i] << " ";
    }
    cout << endl;

    rep(i,n){
        cout << rgcd[n - 1 - i] << " ";
    }
    cout << endl;
    */

    int ans = max(lgcd[n - 2], rgcd[n - 2]);

    rep(i, n - 2){
        ans = max(ans, gcd(lgcd[i], rgcd[n - 3 - i]));
    }

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

Measured memory_bytes: 1912
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N,M;
vector<P1> V;
priority_queue<P1,vector<P1> > que;
queue<P1> idq;

signed main(){
    cin>>N>>M;
    for(int i=0;i<N;++i){
        int a,b;
        cin>>a>>b;
        V.PB(P1(a,b));
    }
    sort(V.begin(),V.end());
    if(N==1){
        idq.push(P1(0,0));
    }
    else{
        int left=0,right=0;
        for(int i=1;i<N;++i){
            if(V[i].fi==V[i-1].fi)continue;
            right=i-1;
            idq.push(P1(left,right));
            left=right+1;
        }
        right=N-1;
        idq.push(P1(left,right));
    }
    int day=M-1;
    int ans=0;
    while(day>=0){
        if(!idq.empty()){
            P1 seg=idq.front();
            if(day+V[seg.fi].fi<=M){
                for(int i=seg.fi;i<=seg.se;++i){
                    que.push(P1(V[i].se,V[i].fi));
                }
                idq.pop();
            }
        }
        if(!que.empty()){
            P1 v=que.top();
            que.pop();
            ans+=v.fi;
        }
        day--;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4976