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

using namespace std;

const int md = 998244353;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

const int N = 330;

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

  int n, m;
  cin >> n >> m;
  vector< vector<int> > a(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }

  auto lowbit = [](vector<int> a) {
    for (int i = 0; i < (int) a.size(); i++) {
      if (a[i] == 1) {
        return i;
      }
    }
    return -1;
  };

  auto Xor = [&](int i, int j) {
    for (int k = 0; k < m; k++) {
      a[i][k] ^= a[j][k];
    }
  };

  vector<int> base;
  for (int i = 0; i < n; i++) {
    for (auto j : base) {
      if (a[i][ lowbit(a[j]) ] == 1) {
        Xor(i, j);
      }
    }
    if (lowbit(a[i]) != -1) {
      base.push_back(i);
    }
  }

  int r = base.size();
  // cerr << r << '\n';
  int res = 1;
  res = mul(res, power(2, r - 1));
  res = mul(res, power(2, r) - 1);
  res = mul(res, power(2, (n - r) + (m - r)));
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 640
letters = input()
times = int(input())

for t in range(times):
    s = input().split()
    l = s[0]
    a = int(s[1])
    b = int(s[2]) + 1

    if l == 'print':
        print(letters[a:b])
    
    elif l == 'replace':
        rl = s[3]
        first_part = letters[:a]
        last_part = letters[b:]
        letters = first_part + rl + last_part
        
    elif l == 'reverse':
        temp_letter = ''.join(reversed(letters[a:b]))
        letters = letters.replace(letters[a:b], temp_letter)


Measured memory_bytes: 5612
/*input

*/
/*
Contest: 
Problem: 
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#define F first
#define S second
#define mp make_pair
#define append push_back
#define vi vector<ll>
#define pii pair<ll,ll>
#define qi queue<ll>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define print(a) cout<<a<<endl
#define sorted(a) sort(arr.begin(), arr.end())
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define read(a) scanf("%d", &a)
#define int long long int
 
const int MOD = 1e9 + 7;

signed main(){
    
    int n;
    cin>> n;

    vector<int> a(n), b(n);

    for(int i = 0; i < n; i++)
    	cin>> a[i];
    for(int i = 0; i < n; i++)
    	cin>> b[i];

    priority_queue<int> more;

    int less = 0, ans = 0;

    for(int i = 0; i < n; i++){
    	if(a[i] > b[i])
    		more.push(a[i] - b[i]);
    	else if(a[i] < b[i]){
    		less += b[i] - a[i];
    		ans++;
    	}
    }
    while(less > 0 and !more.empty()){
    	less -= more.top();
    	more.pop();
    	ans++;
    }
    if(less <= 0)
    	print(ans);
    else
    	print(-1);

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

int main () {
  int  N ;
  cin >> N ;
  int ans ;
  for(int i = 0 ; i < 100000 ; i++ ){
    int pre = i * ( i + 1 ) / 2;
    if(pre >= N) {
      ans = i ;
      break ;
    }
  }
  cout << ans << endl ;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, sum int
	fmt.Scan(&n)
	d := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&d[i])
	}
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			sum += d[i] * d[j]
		}
	}
	fmt.Print(sum)
}


Measured memory_bytes: 1776
#include <iostream>
using namespace std;
int H,W;
char C[101][101];
int main(){
  cin >> H >> W;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin >> C[i][j];
    }
  }
  for(int i=1;i<=2*H;i++){
    for(int j=1;j<=W;j++){
      cout << C[(i+1)/2][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

A,B=input().split()
AA=int(A)
BB=int(B[0])*100 + int(B[2])*10 + int(B[3])

print((AA*BB)//100)


Measured memory_bytes: 9260
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  string S; cin >> S;
  string T; cin >> T;
  string tmp;
  rep(i, T.length() - 1) tmp += T[i];
  if (S == tmp) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3632
import math


n = int(input())
t = [list(map(int,input().split())) for i in range(n)]
ans = 0

for i in range(n):
  x, y = t[i]
  for j in range(i, n):
    x1, y1 = t[j]
    ans += math.sqrt((x-x1)**2 + (y-y1)**2)*(n-1)*2
print(ans/((n-1)*n))

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

int main(){
    ll n; cin >> n;
    vector<int> a(1000000,0);
    ll now=2;
    ll n0=n;
    while(now*now<=n0){
        while(n%now==0){
            a[now-1]++;
            n/=now;
        }
        now++;
    }

    // cout << a[0] << endl;
    // cout << a[1] << endl;
    // cout << a[2] << endl;
    // cout << a[3] << endl;
    // cout << a[4] << endl;

    ll ans=0;
    if(n!=1) ans++;
    rep(i,1000000){
        int e=1;
        while(a[i]>=e){
            a[i]-=e;
            e++;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 7192
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 
using pi = pair<int,int>;

signed main(){
	cout << fixed << setprecision(9);
	int n; cin>>n;
	vl v(n);
	vector<pi> ad(n);
	rep(i,0,n)v[i]=i;
	rep(i,0,n){
		int a,b; cin>>a>>b;
		ad[i]=make_pair(a,b);
	}
	double sum=0;
	int cnt=0;
	do{
		double k=0;
		rep(i,1,n){
			int a,b,c,d;
			tie(a,b)=ad[v[i-1]];
			tie(c,d)=ad[v[i]];
			int x=(a-c);
			int y=(b-d);
			x*=x; y*=y;
			k+=sqrt(x+y);
		}
		sum+=k;
		cnt++;
	}while(next_permutation(all(v)));
	
	cout<<sum/cnt<<endl;
	return 0;
}

Measured memory_bytes: 3844
import java.io.*;

class Card{

	public String mark;
	public int number;
	public int order;
	Card(String mark, int number, int order){
		this.mark = mark;
		this.number = number;
		this.order = order;
	}

	@Override
	public String toString(){
		return mark + " " + number;
	}
}

public class Main{
	
	public static void main(String[] args) throws IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		Card[] cards = new Card[n];
		for(int i = 0; i < n; i++){
			String[] in = br.readLine().split(" ");
			cards[i] = new Card(in[0], Integer.parseInt(in[1]), i);
		}

		quickSort(cards, 0, n-1);
		System.out.printf("%s\n", isStable(cards, n)? "Stable" : "Not stable");
		for(Card card : cards){
			System.out.printf("%s\n", card);
		}
	}

	private static boolean isStable(Card[] c, int n){
		for(int i = 1; i < n; i++){
			if(c[i-1].number == c[i].number && c[i-1].order > c[i].order){
				return false;
			}
		}
		return true;
	}

	private static void quickSort(Card[] c, int p, int r){
		if(p < r){
			int q = partition(c, p, r);
			quickSort(c, p, q-1);
			quickSort(c, q+1, r);
		}
	}

	private static int partition(Card[] c, int p, int r){
		int x = c[r].number;
		int i = p-1;
		Card card;
		for(int j = p; j < r; j++){
			if(c[j].number <= x){
				i++;
				card = c[i];
				c[i] = c[j];
				c[j] = card;
			}
		}
		card = c[r];
		c[r] = c[i+1];
		c[i+1] = card;
		return i+1;
	}
}

Measured memory_bytes: 125004
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String s = saori.nextHayami();
		if(s.equals("SUN")){
			System.out.println(7);
		} else if(s.equals("MON")){
			System.out.println(6);
		}else if(s.equals("TUE")){
			System.out.println(5);
		}else if(s.equals("WED")){
			System.out.println(4);
		}else if(s.equals("THU")){
			System.out.println(3);
		}else if(s.equals("FRI")){
			System.out.println(2);
		}else if(s.equals("SAT")){
			System.out.println(1);
		}
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,num[100]={0};
    cin>>n;
    rep(i,10)rep(j,10) num[i*j]++;
    if(num[n]) cout<<"Yes";
    else cout<<"No";
}

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

int n, mx = -2e9, ss, a[105][15], b[15], c[105][15];
void f(int p) {
	int i, j, s = 0, cnt;
	if (p == 10) {
		ss++;
		if (ss == 1) return;
		for (i = 0; i < n; i++) {
			cnt = 0;
			for (j = 0; j < 10; j++) {
				if (b[j] == 1 && a[i][j] == 1) cnt++;
			}

			s += c[i][cnt];
		}
		mx = max(mx, s);
		return;
	}
	b[p] = 0;
	f(p + 1);
	b[p] = 1;
	f(p + 1);
}
int main()
{
	int i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		for (j = 0; j < 10; j++) {
			scanf ("%d", &a[i][j]);
		}
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j <= 10; j++) {
			scanf ("%d", &c[i][j]);
		}
	}
	f(0);
	cout << mx;
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

ll digit_sum(ll x){
  ll ret = 0;
  string s = to_string(x);
  for(char c: s){
    ret += c - '0';
  }
  return ret;
}

int main(){
  cout << setprecision(10);
  ll N; cin >> N;

  ll ans = 10000000000;
  for(ll i = 1; i <= N; i++){
    ll A = i;
    ll B = N - i;
    if(B == 0) continue;

    ans = min(ans, digit_sum(A) + digit_sum(B));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
long long n,d,g,k,a[1000005],h[1000005],sum,j,ans,i;
pair<long long,long long>x[200005],p[200005];
int main(){
	
	cin>>n>>d>>g;
	for(k=1;k<=n;k++){
		cin>>a[k]>>h[k];
		p[k].first=a[k];
		p[k].second=h[k];
	}
	sort(p+1,p+n+1);
	for(k=1;k<=n;k++){
		a[k]=p[k].first;
		h[k]=p[k].second;
		while(x[j].first<a[k] && j<=i) {
		sum-=x[j].second;	j++; 
		}
		
		h[k]-=sum; 
		if(h[k]>0){
			i++;
			x[i].first=a[k]+2*d;
			x[i].second=h[k]/g;
			if(h[k]%g>0) x[i].second++;
			
			ans+=x[i].second;
		           x[i].second*=g;
			sum+=x[i].second; 
			
		}
	
		
		
	}
	cout<<ans;
}

Measured memory_bytes: 12544
void main() {
	auto N = ri;
	ceil(N.to!float / 2).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

a = []
b = []
c = []
d = []

for i in range(N):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

for j in range(M):
    x, y = map(int, input().split())
    c.append(x)
    d.append(y)

for i in range(N):
    ans = 0
    minDist = 10**8 * 2
    for j in range(M):
        dist = abs(c[j]-a[i]) + abs(d[j]-b[i]) 
        if dist < minDist:
            minDist = dist
            ans = j
        
    print(ans+1)


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
 	}
 #endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	int N;
	cin >> N;
	vector<string> S(N);
	vector<pair<int, int>> v1, v2;
	int fs = 0, p = 0;
	forn(i, N)
	{
		cin >> S[i];
		int m = 0, f = 0;
		for(char c : S[i])
		{
			if (c == '(')
				++f;
			else
				--f;
			m = min(m, f);
		}
		fs += f; 
		if (m == 0)
			p += f;
		else if (f < 0)
			v1.push_back(make_pair(m-f,f));
		else if(f >= 0)
			v2.push_back(make_pair(m, f));
	}
	if (fs != 0)
	{
		cout << "No\n";
		return 0;
	}
	bool ok = true;
	sort(all(v2));
	reverse(all(v2));
	forn(i, v2.size())
	{
		if (p + v2[i].first < 0)
			ok = false;
		p += v2[i].second;
	}
	sort(all(v1));
	forn(i, v1.size())
	{
		if (p + v1[i].first + v1[i].second < 0)
			ok = false;
		p += v1[i].second;
	}
	if(ok)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#include <iostream>
#include <vector>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
typedef long long int ll;

#define min(x,y)(x<y?x:y)
 
using namespace std;

int main() {
	FAST;

    int N,C;
    int D[31][31],c;
    scanf("%d %d",&N,&C);

    int i,j,k,l;
    int mod[3][31]={};
	
    for(i=1;i<=C;i++)
        for(j=1;j<=C;j++)
            scanf("%d",&D[i][j]);
    for(i=1;i<=N;i++){
        for(j=1;j<=N;j++){
            scanf("%d",&c);
            mod[(i+j)%3][c]++;
        }
    }
    int ans = 1e9;
    for(i=1;i<=C;i++){
        for(j=1;j<=C;j++){
            for(k=1;k<=C;k++){
                if(i == j || j == k || k == i){
                    continue;
                }
                int S = 0;
                for(l=1;l<=C;l++){
                    S += mod[0][l]*D[l][i];
                    S += mod[1][l]*D[l][j];
                    S += mod[2][l]*D[l][k];
                }
                if(ans > S){
                    ans = S;
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define f(a) for (ll i = 0; i < a; i++)
#define fio                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

ll findno(ll a[],ll b[],ll c[],ll n,ll arr[],vector<ll>x[])
{
    ll mx=0;
    if(arr[n-1]!=(-1)){return arr[n-1];}
    ll i;
    for(auto it = x[n-1].begin(); it != x[n-1].end(); ++it)
    {   i=*it;
        if(arr[a[i]-1]==(-1))
        {mx=max(mx,findno(a,b,c,a[i],arr,x));}
        else{mx=max(mx,arr[a[i]-1]);}

    }
    arr[n-1]=mx+1;
    return mx+1;

}


int main()
{
    fio;
    ll n,m;
    ll i,j;
    cin>>n>>m;
    ll a[m],b[m];
    ll c[n];
    ll arr[n];
    vector<ll>x[n];
    f(n){c[i]=0;arr[i]=-1;}
    f(m){cin>>a[i]>>b[i];c[b[i]-1]++;x[b[i]-1].push_back(i);}
    f(n){if(c[i]==0){arr[i]=0;}}
    ll ans=0;
    f(n){if(arr[i]==(-1)){arr[i]=findno(a,b,c,i+1,arr,x);}}
	f(n){ans=max(ans,arr[i]);}
	cout<<ans;
	return 0;
}


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

int32_t main()
{
    int n,k,s=0;
    set<int> l;
    cin >> n >> k;
    //set<int> :: iterator it=l.begin();
    for(int i=0;i<k;i++)
    {
        int m;cin >> m;
        s+=m;
    }
    if(s>=n)
    {
        cout << "Yes" << endl;
    }
    else
    {cout << "No" << endl;}
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 0x3f3f3f3f
int main()
{
    string s1;
    string s2;
    cin>>s1;
    cin>>s2;
    string s3;
    int len1=s1.length();
    int len2=s2.length();
    bool flag=0;
    for(int i=0;i<s2.length();i++){
        s3="";
        for(int j=i;j<len2;j++){
            s3+=s1[j];
        }
        for(int j=0;j<i;j++){
            s3+=s1[j];
        }
        if(s2==s3){
            flag=1;break;
        }
    }
    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

int Partition(int A[], int p, int r)
{
    int x = A[r];
    int i = p - 1;
    int temp;
    for (int j = p; j < r; j++)
    {
        if (x >= A[j])
        {
            i++;
            temp = A[i];
            A[i] = A[j];
            A[j] = temp;
        }
    }
    temp = A[i + 1];
    A[i+1] = A[r];
    A[r] = temp;
    return i + 1;
}

int main()
{
    int A[MAX];
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> A[i];

   int q=Partition(A,0,n-1);

    for (int i = 0; i < n; i++)
    {
        if (i)
            cout << " ";
        if (i==q)
        {
            cout<<"["<<A[i]<<"]";
            continue;
        }
        cout << A[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3392
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      
      int[] array = new int[n+1];
      
      int count = 0;
      for(int k = 1; k <= n; k++){
         array[k] = Integer.parseInt(st.nextToken());
         if(array[k] != k){
            count++;
         }
      }
      
      if(count <= 2){
         out.println("YES");
      } else {
         out.println("NO");
      }

      
      
      
      
      out.close();
   }
   
      
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define enter putchar('\n')
#define space putchar(' ')
#define fi first
#define se second
#define mp make_pair
#define MAXN 200005
//#define ivorysi
#define pii pair<int,int>
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}

template<class T>
void out(T x) {
    if(x < 0) {putchar('-');x = -x;}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,K;
int A[305],B[305];
int cnt[605][605],dp[605][605],g[605];
bool vis[605][605];
bool in(int a,int l,int r) {
    return a >= l && a <= r;
}
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void Solve() {
    read(N);read(K);
    for(int i = 1 ; i <= K ; ++i) {
	read(A[i]);read(B[i]);
    }
    g[0] = 1;
    for(int i = 1 ; i <= 2 * N ; ++i) {
	if(i & 1) g[i] = 0;
	else g[i] = mul(g[i - 2],i - 1);
    }
    for(int i = 1 ; i <= 2 * N ; ++i) {
	for(int j = i + 1 ; j <= 2 * N ; ++j) {
	    for(int h = 1 ; h <= K ; ++h) {
		if(in(A[h],i,j) && in(B[h],i,j)) {
		    ++cnt[i][j];
		}
		else if((!in(A[h],i,j) && in(B[h],i,j)) || (in(A[h],i,j) && !in(B[h],i,j))) {
		    vis[i][j] = 1;
		    break;
		}
	    }
	}
    }
    for(int d = 2 ; d <= 2 * N ; d += 2) {
	for(int i = 1 ; i <= 2 * N ; ++i) {
	    int j = i + d - 1;
	    if(j > 2 * N) break;
	    if(vis[i][j]) continue;
	    int x = j - i + 1 - 2 * cnt[i][j];
	    dp[i][j] = g[x];
	    for(int h = i + 1 ; h < j ; h += 2) {
		if(!dp[i][h]) continue;
		x = j - h - 2 * cnt[h + 1][j]; 
		dp[i][j] = inc(dp[i][j],MOD - mul(dp[i][h],g[x]));
	    }
	}
    }
    int ans = 0;
    for(int i = 1 ; i <= 2 * N ; ++i) {
	for(int j = i + 1 ; j <= 2 * N ; j += 2) {
	    int y = 2 * N - (j - i + 1 - 2 * cnt[i][j]) - 2 * K; 
	    ans = inc(ans,mul(dp[i][j],g[y]));
	}
    }
    out(ans);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 3456
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int data[][][] = new int [4][3][10];

        for(int i = 0; i < 4; i++) {
            for(int j = 0; j < 3; j++) {
                for(int k = 0; k < 10; k++) {
                    data[i][j][k] = 0;
                }
            }
        }

        for(int i = 0; i < n; i++) {
            int b = scan.nextInt();
            int f = scan.nextInt();
            int r = scan.nextInt();
            int v = scan.nextInt();

            data[b - 1][f - 1][r - 1] += v;
        }

        for(int i = 0; i < 4; i++) {
            for(int j = 0; j < 3; j++) {
                for(int k = 0; k < 10; k++) {
                    System.out.print(" " + data[i][j][k]);
                }
                System.out.print("\n");
            }
            if(i != 3) {
                System.out.print("####################\n");
            }
        }
    }
}


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


/*
sからtへの写像を考えた時、あるx,yでx=yかつf(x)!=f(y)だとよくない
*/

void solve(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    string ans = "Yes";
    unordered_map<char,char> hash;
    rep(i,n){
        hash[s[i]] = t[i];
    }
    rep(i,n){
        if(hash[s[i]]!=t[i]) ans = "No";
    }

    unordered_map<char,char> hash2;
    rep(i,n){
        hash2[t[i]] = s[i];
    }
    rep(i,n){
        if(hash2[t[i]]!=s[i]) ans = "No";
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 916
import java.util.*;

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

Measured memory_bytes: 52352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    int check=0;
for(int i=n;i>=1;i--){
    if(i==1){
        cout<<1<<endl;
        return 0;
    }
for(int j=sqrt(n);j>=2;j--){
check=i;
    while(check%j==0){
        if(check/j==1){
            cout<<i<<endl;
            return 0;
        }
       check/=j;
    }
}
}

}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		RQ rq = new RQ(n, false);

		int q = scan.nextInt();
		for (int i = 0; i < q; i++)
			switch (scan.nextInt()) {
			case (0):
				rq.update(scan.nextInt(), scan.nextInt());
				break;
			case (1):
				System.out.println(rq.find(scan.nextInt(), scan.nextInt()));
				break;
			}

		scan.close();
		System.exit(0);
	}
}

class RQ {
	boolean debug;
	int[] minTable;
	int ixn;

	public RQ(int n, boolean d) {
		debug = d;

		ixn = (int) (Math.log(n) / Math.log(2)) + 1;
		ixn = (int) Math.pow(2, ixn);
		minTable = new int[n + ixn];
		int ini = (int) (Math.pow(2, 31) - 1);
		for (int i = 1; i < minTable.length; i++)
			minTable[i] = ini;
	}

	public int find(int x1, int x2) {
		return idxfind(x1 + ixn, x2 + ixn);
	}

	private int idxfind(int x1, int x2) {
		int ret = Math.min(minTable[x1], minTable[x2]);
		int x1up = (x1 + 1) / 2;
		int x2up = (x2 - 1) / 2;
		if (x1up > x2up)
			return ret;
		else
			return Math.min(ret, idxfind(x1up, x2up));
	}

	public void update(int x, int y) {
		minTable[ixn + x] = y;

		int i = (ixn + x) / 2;
		while (i > 0) {
			int min = minTable[i * 2];
			if (i * 2 + 1 < minTable.length)
				min = Math.min(minTable[i * 2], minTable[i * 2 + 1]);
			if (minTable[i] == min)
				break;
			minTable[i] = min;
			i /= 2;
		}

		if (debug) {
			int j = 1;
			for (int k = 1; k < minTable.length; k++) {
				if (k == j) {
					System.out.println();
					j *= 2;
				}
				System.out.print(" " + k + ":" + minTable[k]);
			}
			System.out.println();
		}
	}
}

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

string f(string x) {
    string ans;
    ans.assign(x.size(), 'a');
    for (int i = 0; i < x.size(); ++i) {
        if (i != x.size() - 1) ans[i + 1] = x[i];
        else ans[0] = x[i];
    }
    return ans;
};

int main() {
    string s;
    string t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); ++i) {
        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
        s = f(s);
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll a; cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3636
public class Hello{
    public static void Main(){
        int Inning = int.Parse(System.Console.ReadLine());
        int CurrentInning = 0;

        
        while(CurrentInning < Inning){
            int OutCount = 0, Point = 0;
            bool[] Base = new bool[3];
            while(OutCount < 3){
                switch(System.Console.ReadLine()){
                    case "HIT":
                        if(Base[2]) Point++;
                        Base[2] = Base[1];
                        Base[1] = Base[0];
                        Base[0] = true;
                        break;
                    case "OUT":
                        OutCount++;
                        break;
                    case "HOMERUN":
                        Point++;
                        for(int i = 0; i < 3; i++){
                            if(Base[i]) Point++;
                            Base[i] = false;
                        }
                        break;
                }
            }
            CurrentInning++;
            System.Console.WriteLine(Point);
        }
    }
}

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define inf 1e17
#define MAX_SIZE 1000005 
#define PI 3.14159265358979323846264338327950L

void pr(int arr[], int size) 
{ for (ll i=0; i < size; i++) {printf("%d ", arr[i]); }cout << endl;}

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
   ll t=1;
    // cin>>t;
    while(t--){
        long double a , b , h , m;
        cin >> a >> b >> h >> m;
        long double x = abs(6*((h+(m/60))*5 - m));
        long double ang = cosl( x* PI / 180.0 );
        long double ans = sqrt(a*a + b*b - 2*a*b*ang);
        cout << fixed << setprecision(20) << ans << endl;
        
        
        
    }
  return 0;
}


Measured memory_bytes: 4168
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int L, R, D, count, ans = 0 ;
  cin >> L >> R >> D ;
  for(int i=L;i<(R+1);i++){
    if((i % D) == 0) ans++ ;
  }
  
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 3564
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(){
	int r;
	scanf("%d",&r);
	double o = M_PI;
	double raio = r*r*M_PI;
	printf("%.lf\n",raio/o);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll

int k,n;
vector<P> a;

signed main(){

  cin>>n>>k;

  rep(i,n){
    int t,d;
    cin>>t>>d;
    a.PB(P(d,t));
  }

  sort(all(a));
  reverse(all(a));

  int sum=0;
  int ans=0;

  map<int,int> mp;
  priority_queue<P,vector<P>,greater<P> > q;
  int m=0;

  rep(i,k){
    sum+=a[i].F;
    if(mp[a[i].S])
      q.push(a[i]);
    else
      m++;
    mp[a[i].S]++;
  }

  ans = sum+m*m;
  

  rep(i,n){
    if(q.empty()) break;
    if(mp[a[i].S]) continue;
    P p = q.top();
    q.pop();
    sum-=p.F;
    sum+=a[i].F;
    mp[a[i].S]++;
    m++;
    ans = max(ans,sum+m*m);
  }


  cout<<ans<<endl;
}

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

int main() {
    int K, S; cin >> K >> S;
    int count = 0;
    for (int x = 0; x <= K; ++x) {
        for (int y = 0; y <= K; ++y) {
            int z = S - x - y;
            if (z >= 0 && z <= K) {
                ++count;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pl pair < long long , long long >
#define ll long long

using namespace std;

const long long MOD = 2e19 ;
const long long BIG = 1e7 + 9 ;
ll ans , res ;
string s ;
int main()
{
    int n ;
    cin >> n >> s ;
    ll r , g , b ;
    r = g = b = 0 ;
    for ( auto i : s )
    {
        if ( i == 'R' )
            r++;
        if ( i == 'G' )
            g++;
        if ( i == 'B' )
            b++;
    }
    ans = r*g*b ;
    for ( int i = 0 ; i < n ; i++ )
    {
        for ( int j = i + 1 ; j < n ; j++ )
        {
            int k = j + ( j - i ) ;
            if ( k <= n - 1 )
            {
                if ( s[i] != s[j] && s[j]!= s[k] && s[i] != s[k] )
                    res++;
            }
        }
    }
    cout << ans - res ;
    return 0 ;


}


Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

vector<int> find_cycle(const vec<int, 2>& g) {
  int N = g.size();
  vector<int> used(N, 0), len(N, -1), path, in_path(N, 0);
  auto dfs = [&](auto& f, int v) -> int {
    used[v] = 1;
    len[v] = path.size();
    path.push_back(v);
    in_path[v] = 1;
    for (int u : g[v]) {
      if (in_path[u]) return u;
      if (used[u]) continue;
      int r = f(f, u);
      if (r >= 0) return r;
    }
    path.pop_back();
    in_path[v] = 0;
    return -1;
  };
  for (int v = 0; v < N; v++) {
    if (used[v]) continue;
    int r = dfs(dfs, v);
    if (r >= 0) {
      return vector<int>(path.begin() + len[r], path.end());
    }
  }
  return vector<int>();
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, M;
  while (cin >> N >> M) {
    vec<int, 2> g(N);
    for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      g[a].push_back(b);
    }
    auto c1 = find_cycle(g);
    vector<int> id(N, -1);
    for (int i = 0; i < c1.size(); i++) id[c1[i]] = i;
    vec<int, 2> g2(N);
    for (int v : c1) {
      int to = -1, mx = -1;
      for (int u : g[v]) {
        if (id[u] < 0) continue;
        int dist = (id[u] - id[v] + c1.size()) % c1.size();
        if (dist > mx) {
          mx = dist;
          to = u;
        }
      }
      g2[v].push_back(to);
    }
    auto ans = find_cycle(g2);
    if (ans.empty()) {
      cout << -1 << endl;
    } else {
      cout << ans.size() << endl;
      for (int v : ans) cout << v + 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 384
def Lun(ume,gen,start):
    global keta
    if(ume==keta):
        global ans
        temp=0
        for i in range(ume):
            temp+=gen[i]*(10**(keta-i-1))
        ans.append(temp)
        #print(gen)
        return
    ima=gen[ume-1]
    send=gen[:]
    if(start):
        if(ima>0):
            send[ume]=ima-1
            Lun(ume+1,send,start)
        send[ume]=ima
        Lun(ume+1,send,start)
        if(ima<9):
            send[ume]=ima+1
            Lun(ume+1,send,start)
    else:
        Lun(ume+1,send,False)
        for i in range(1,10):
            send[ume]=i
            Lun(ume+1,send,True)




ans=[]
keta=10
hajime=[0]*keta
Lun(1,hajime,False)
for i in range(1,4):
    hajime[0]=i
    Lun(1,hajime,True)

print(ans[int(input())])

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

#define int ll

int power(int x, int y, int p) {
    int res = 1;
    x       = x % p;
    while (y) {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

signed main() {
    int n, pop = 0, defm = 0, defp = 0;
    string x;
    cin >> n >> x;
    for (auto i : x) pop += i == '1';
    for (int cm = 1, cp = 1, i = n - 1; i >= 0; --i) {
        if (x[i] == '1') {
            (defp += cp) %= (pop + 1);
            if (pop > 1) (defm += cm) %= (pop - 1);
        }
        if (pop > 1) (cm *= 2) %= (pop - 1);
        (cp *= 2) %= (pop + 1);
    };
    for (int pos = 0; pos < n; ++pos) {
        int k = 1, p, d;

        p = pop + (x[pos] == '0' ? 1 : -1);
        if (p == 0) {
            cout << 0 << endl;
            continue;
        }
        d = (x[pos] == '0' ? (defp + power(2, n - 1 - pos, p)) % p
                           : (defm - power(2, n - 1 - pos, p) + p) % p);
        if (d < 0) {
            d = -d;
            d = p - d % p;
        }
        d %= p;
        while (d > 0) {
            int dt = d;
            p      = 0;
            while (dt > 0) {
                p += dt % 2;
                dt /= 2;
            }
            d %= p;
            ++k;
        }
        cout << k << endl;
    }
}


Measured memory_bytes: 3712
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>
#include<atcoder/all>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll n, m;
	cin >> n >> m;
	atcoder::dsu d(n);
	rep(i, 0, m) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		d.merge(a, b);
	}

	cout << d.groups().size() - 1 << endl;
	return 0;
}


Measured memory_bytes: 8940
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

const double PI = 2 * acos(0);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<double, double> pdd;
typedef pair<double, pdd> pddd;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int l[3000000];

void solve() {
    int n;
    scanf("%d", &n);
    for(int i = 0; i < 3*n; i++) {
        scanf("%d", &l[i]);
    }
    sort(l, l+3*n);
    ll ret = 0;
    for(int i = 0; i < n; i++) {
        ret += l[3*n-2*i-2];
    }
    printf("%lld\n", ret);
}

int main() {
	solve();
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#include<set>
#include<map>
#define re register
#define ll long long
using namespace std;
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9'|| ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return sum*f;
}
const double eps=1e-10,Pi=acos(-1.0);
struct node{
	double x,y;
	node operator+(node b){return (node){x+b.x,y+b.y};}
	node operator-(node b){return (node){x-b.x,y-b.y};}
	node operator*(double b){return (node){x*b,y*b};}
	double len(){return sqrt(x*x+y*y);}
};
int fh(double a){return fabs(a)<eps?0:a>eps?1:-1;}
double cross(node a,node b){return a.x*b.y-a.y*b.x;}
double dot(node a,node b){return a.x*b.x+a.y*b.y;}
node projection(node p1,node p2,node p){node v=p2-p1;return p1+v*(dot(v,p-p1)/dot(v,v));}
node reflection(node p1,node p2,node p){node P=projection(p1,p2,p);P=P*2-p;return P;}
void Counter_Clockwise(node p1,node p2,node p){
	if(cross(p2-p1,p-p1)>eps){puts("COUNTER_CLOCKWISE");return;}
	if(cross(p2-p1,p-p1)<-eps){puts("CLOCKWISE");return;}
	if(dot(p2-p1,p-p1)<-eps){puts("ONLINE_BACK");return;}
	if(dot(p2-p1,p2-p1)>=dot(p-p1,p2-p1)){puts("ON_SEGMENT");return;}
	puts("ONLINE_FRONT");
}
bool insegment(node A,node B,node p){
	if(fh(cross(B-A,p-A)))return false;
	return ((fh(p.x-A.x)>=0 && fh(B.x-p.x)>=0) || (fh(p.x-A.x)<=0 && fh(B.x-p.x)<=0)) && ((fh(p.y-A.y)>=0 && fh(B.y-p.y)>=0) || (fh(p.y-A.y)<=0 && fh(B.y-p.y)<=0));
}
int parallel(node A1,node A2,node B1,node B2){
	if(!fh(cross(B2-B1,A2-A1)))return 2;
	if(!fh(dot(B2-B1,A2-A1)))return 1;
	return 0;
}
bool intersection(node A1,node A2,node B1,node B2){
	if(!fh(cross(B2-B1,A2-A1))){
		if(insegment(A1,A2,B1) || insegment(A1,A2,B2) || insegment(B1,B2,A1) || insegment(B1,B2,A2))return true;
		return false;
	}
	return fh(cross(A1-B1,B2-B1)*cross(A2-B1,B2-B1))<=0 && (fh(cross(B1-A1,A2-A1)*cross(B2-A1,A2-A1))<=0);
}
node getintersection(node A1,node A2,node B1,node B2){
	node v=A2-A1;
	return A1+v*(cross(B2-B1,B1-A1)/cross(B2-B1,A2-A1));
}
int main(){
	node p1,p2,p3,p4;
	int Q=gi();
	while(Q--){
		p1.x=gi();p1.y=gi();p2.x=gi();p2.y=gi();
		p3.x=gi();p3.y=gi();p4.x=gi();p4.y=gi();
		node P=getintersection(p1,p2,p3,p4);
		printf("%.8lf %.8lf\n",P.x,P.y);
	}
	return 0;
}


Measured memory_bytes: 3232
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner kbd = new Scanner(System.in);
        int n = kbd.nextInt();
        int k = kbd.nextInt();
        double pt = 1.0 * 1 / n;
        double sum = 0;
        for (int i = 1; i < n + 1; i++) {
            int counter = i;
            double temp = pt;
            while (counter < k) {
                temp = temp * 0.5;
                counter = counter * 2;
            }
            sum = sum + temp;
        }
        System.out.println(sum);
        // int point = 0;
        // point = point + dice(n);
        // while (point >= 1 && k - 1 >= point) {
        // int temp = coin();
        // if (temp == 0) {
        // point = point * 2;
        // } else {
        // point = 0;
        // }
        // }
        // if (point != 0) {

        // }
    }

    // static int dice(int n) {
    // Random ran = new Random();
    // return ran.nextInt(n) + 1;
    // }

    // static int coin() {
    // Random ran = new Random();
    // return ran.nextInt(2);
    // }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e6 + 5;

long long a[maxN];

int main() {
    for(int i = 1; i < maxN; i++) {
        a[i] = i;
    }

    for(int i = 1; i < maxN; i++) {
        if(a[i] % 3 == 0 || a[i] % 5 == 0) {
            a[i] = 0;
        }
    }

    int n;  cin >> n;

    long long sum = 0;

    for(int i = 1; i <= n; i++) {
        sum += a[i];
    }

    cout << sum << '\n';

    return 0;
}


Measured memory_bytes: 11440
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a,b;
char s;
int32_t main(){
CODE_START;
cin >> a;
cin >> s;
cin >> b;
if(s=='+'){
    cout << a+b;
}else {
cout << a-b;
}
return 0;}


Measured memory_bytes: 256