akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
priority_queue< ll > pq;
int main()
{
    she_told_me_dont_worry
    ll n, m, i;
    cin>>n>>m;
    vector < pll > ab;
    FOR0(i, n)
    {
        pll temp;
        cin>>temp.ff>>temp.ss;
        ab.pb(temp);
    }
    sort(ab.begin(), ab.end());
    ll cur = 1;
    ll ans = 0;
    int j = 0;
    FOR(i, 1, m+1)
    {
        while(j < n && ab[j].ff <= i)
        {
            pq.push(ab[j].ss);
            j++;
        }
        if(pq.size())
        {
            ans += pq.top();
            pq.pop();
        }
    }
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define loop(i, a, b) for(int i = a; i < b; i++)


const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

int slen, tlen;
ll dp[3001][3001] = {};
vector<char> v;
map<int, char> subsequence;

ll sub(string s, string t, int si, int ti)
{	
	loop(i, 1, slen + 1)
	loop(j, 1, tlen + 1)
	{
		if(s[i - 1] == t[j - 1])
		{
			dp[i][j] = max(1 + dp[i - 1][j - 1], dp[i][j]);
			// subsequence.insert(pair<int, char> (i, s[i - 1]));
			// cout << "i = " << i << " j = " << j << " s[i] = " << s[i] << " t[j] = " << t[j] << "\n";
			
		}
		else
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
	}
	return dp[slen][tlen];
}

int main()
{
	// char s[3000], t[3000];
	fastIO;
	string s,t;
	cin >> s;
	cin >> t;

	slen = s.length(), tlen = t.length();
	// memset(dp,0,sizeof(dp));
	ll ans = sub(s, t, 0, 0), x = slen, y = tlen;

	while(ans)
	{
		if(s[x - 1] == t[y - 1])
		{
			ans--;
			subsequence.insert(pair<int, char> (x, s[x - 1]));
			x--;
			y--;
		}
		else
		{
			if(dp[x - 1][y] > dp[x][y - 1])
				x--;
			else 
				y--;
		}



	}
	// for(int i = 0; i < v.size(); i++)
	// 	cout << v[i];
	map<int, char>::iterator itr;
	for(itr = subsequence.begin(); itr != subsequence.end(); ++itr)
	{
		cout << itr -> second;
	}

	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    ll N;
    cin >> N;
    ll ans = -1;
    for (ll i = 0; i <= 50000; i++) {
        ll tmp = i * 1.08;
        if (tmp == N) {
            ans = i;
            break;
        }
    }

    if (ans != -1) cout << ans << endl;
    else cout << ":(" << endl;
}

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

int main() {
    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }

    for (int i=k; i<n; i++) {
        if (a.at(i-k) >= a.at(i)) cout << "No" << endl;
        else cout << "Yes" << endl;
    }


}

Measured memory_bytes: 4836
num = STDIN.gets.chomp().to_i
points = [0, 0]

for i in 0..num - 1 do
    line = STDIN.gets.chomp()
    cards = line.split(" ")
    result = cards[0] <=> cards[1]
    case result
    when -1 then
        points[1] += 3
    when 0 then
        points[0] += 1
        points[1] += 1
    when 1 then
        points[0] += 3
    end
end

puts points.join(" ")

Measured memory_bytes: 6096
from sys import stdin
import fractions

# N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
# print(N)
# print(A)
ans = 0

for i in A:
    ans += i

if ans >= 22:
    print('bust')
else:
    print('win')


Measured memory_bytes: 5048
line_count = STDIN.gets.chomp.to_i
points = Array.new(STDIN.gets.chomp.to_i) { STDIN.gets.split(',').map { |i| i.chomp.to_i } }
puts (1..line_count).map { |i|
  position = i
  points.each do |point|
    case position
    when point[0]
      position = point[1]
    when point[1]
      position = point[0]
    end
  end
  [position, i]
}.sort_by { |x| x[0] }.map { |e| e[1] }

Measured memory_bytes: 8564
import java.util.*;
public class Main{
	public static void main(String[] args){
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		
		for(int i=0; i<n; i++){
			a[i] = sc.nextLong();
		}
		for(int i=0; i<n; i++){
			if(a[i] % 2 == 1){
				ans = 1;
				break;
			}
		}
		
		if(ans % 2 == 1){
			System.out.println("first");
		}else{
			System.out.println("second");
		}
	}
	
	static void quick_sort(long[] d, int left, int right) {
		if(left>=right){
				return;
		}
		long p = d[(left+right)/2];
		int l = left, r = right;
		long tmp;
		while(l<=r){
			while(d[l] > p){ l++; }
			while(d[r] < p){ r--; }
			if (l<=r) {
				tmp = d[l]; d[l] = d[r]; d[r] = tmp;
				l++;
				r--;
			}
		}
		quick_sort(d, left, r);
		quick_sort(d, l, right);
	}
}

Measured memory_bytes: 63468
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,l,r,a[200010],ans=1;
string s;
signed main(){
	cin>>n>>s;
	init_fact(200000);
	rep(i,2*n){
		if(i==0||i==2*n-1){
			if(s[i]=='W'){
				puts("0");
				return 0;
			}
		}
		if(i==0)a[i]=1;
		else{
			if(s[i]==s[i-1])a[i]=1-a[i-1];
			else a[i]=a[i-1];
		}
	}
	rep(i,2*n){
		if(a[i]==0){
			ans*=l-r;
			ans%=MOD;
		}
		if(a[i]==1)l++;
		else r++;
	}
	ans*=kaijo[n];
	ans%=MOD;
	if(l==r)cout<<ans<<endl;
	else puts("0");
	return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  V<string> a(h); for (int i = 0; i < h; i++) cin >> a[i];
  V<> ei(h), ej(w);
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) if (a[i][j] == '#') ei[i] = ej[j] = 1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) if (ei[i] and ej[j]) cout << a[i][j];
    if (ei[i]) cout << '\n';
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	string s;
	int n, i, j, k, ans = 0;
	cin >> n >> s;
	for (i = 0; i + 2 < n; i++) {
		if (s.substr(i, 3) == "ABC") ans++;
	}
	cout << ans << "\n";

	return 0;
}


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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define ff first
#define tcase int _; cin>> _; for( ; _; --_)
#define ss second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
    cin >> n;
    cout<< (n >= 30 ? "Yes\n": "No\n");
}

int32_t main(){
	fastio;
	solve();
	return 0;
}



Measured memory_bytes: 3608
A,B,M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = [list(map(int, input().split())) for _ in range(M)]

#solve
cheapest = min(a) + min(b)
for i in m:
  price = a[i[0]-1] + b[i[1]-1] - i[2]
  if price < cheapest: cheapest = price
print(cheapest)

Measured memory_bytes: 38492
n=int(input())
dp=[False]*n
for i in range(n):
    d1,d2=map(int, input().split())
    if d1==d2:
        dp[i]=True
for j in range(n-2):
    if dp[j] and dp[j+1] and dp[j+2]:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 9180
main(f){float w;char*p[]={"light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy"};for(;~scanf("%f",&w);){f=w>48?w>51?w>54?w>57?w>60?w>64?w>69?w>75?w>81?w>91?10:9:8:7:6:5:4:3:2:1:0;puts(p[f]);}return 0;}

Measured memory_bytes: 0
S = input()
s = list(S)

zero = s.count("0")
one = s.count("1")
if(len(S) == 1):
  if(zero == 1 or one == 1):
    print(0)
elif(zero > one):
  print(one*2)
elif(zero < one):
  print(zero*2)
else:
  print(zero*2)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	ll n;
	cin >> n;
	map<ll, ll> mp;
	ll p = n;
	repl(i, 2, (ll)sqrt(n) + 1) {
		while (p % i == 0) {
			p /= i;
			mp[i]++;
		}
	}
	if (p != 1) mp[p]++;
	vector<ll> a(1000000);
	rep(i, 1000000) a[i] = i * (i + 1) / 2;
	ll ans = 0;
	for (auto m : mp) ans += upper_bound(all(a), m.second) - a.begin() - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11104
n=int(input())
lst=list(map(int,input().split()))
A = list(filter(lambda x : x % 2==0, lst))
c=0
for i in A:
    if(i%3==0 or i%5==0):
        c+=1
if(c==len(A)):
    print("APPROVED")
else:
    print("DENIED")

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

using namespace std;

const long long INF = 1e18;

int n,k,i,j,a[100005];
long long l[100005],r[100005],sum[100005];

int main(){
	scanf("%d%d", &n, &k);
	for(i = 1; i <= n; i++)
	scanf("%d", &a[i]);
	
	for(i = 1; i <= n; i++)
	l[i] = l[i - 1] + max(0, a[i]);
	for(i = n; i >= 1; i--)
	r[i] = r[i + 1] + max(0, a[i]);
	for(i = 1; i <= n; i++)
	sum[i] = sum[i - 1] + a[i];
	
	long long res = - INF;
	
	for(i = 1; i <= n - k + 1; i++)
	res = max(res, max(0LL, sum[i + k - 1] - sum[i - 1]) + l[i - 1] + r[i + k]);
	
	printf("%lld\n", res);
}


Measured memory_bytes: 2944
from sys import stdin
a = stdin.readlines()

n = int(a[0].split()[0])
m = int(a[0].split()[1])
x = int(a[0].split()[2])

l = []
for i in range(n):
    tmp = []
    for j in range(m+1):
        tmp.append(int(a[i+1].split()[j]))
    l.append(tmp)

ans = []
for i in range(2**n):
    bag = []
    for j in range(n):
        if ((i >> j) & 1):
            bag.append(l[j])
    s = [0]*(m+1)
    for j in range(len(bag)):
        s = list(map(lambda x,y: x+y, s, bag[j]))
    for j in range(1,m+1):
        if not s[j] >= x:
            break
    else:
        ans.append(s[0])
if ans == []:
    print(-1)
else:
    print(min(ans))

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define PI 3.141592653589793

#define MOD 1000000007L
#define INF 100000000000

signed main() {
	int n, t;
	cin >> n >> t;
	int a[n];
	for (size_t i = 0; i < n; i++) {
		cin >> a[i];
	}

	ll sum = t;
	for (size_t i = 0; i < n - 1; i++) {
		sum += min(a[i + 1] - a[i], t);
	}
	cout << sum << endl;
}


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


void solve(long long N, long long A, long long B, std::vector<long long> X){
  long long res = 0;
  for (int i = 1; i < N; i++) {
    res += min(A*(X[i]-X[i-1]), B);
  }
  cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, A, B, std::move(X));
    return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	vector<int> a;
	set<int> p;
	int pos[200005];
	long long ans = 0;

	cin >> n;
	for(int i=0; i<n; i++){
		int t;
		cin >> t;
		pos[t] = i;
		a.push_back(t);
	}

	p.insert(-1);
	p.insert(n);
	for(int i=1; i<=n; i++){
		//printf("%d %d %d\n", lpos[i], rpos[i], i* ((abs(lpos[i] + 1 - pos[i]) + 1) * (abs(rpos[i] - 1 - pos[i]) + 1)));
		auto l = --p.lower_bound(pos[i]);
		auto r = p.upper_bound(pos[i]);
		//cout << (*l) << ' ' << (*r) << endl;
		ans += (long long)i* (long long)(abs((*l) - pos[i])) * (long long)(abs((*r) - pos[i]) );
		//cout << ((abs((*l) - pos[i])) * (abs((*r) - pos[i]) )) << endl;
		p.insert(pos[i]);
	}

	cout << ans<< endl;

	

	return 0;
}


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

int main()
{
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  
  int ans = 0;
  for(int d = 0; d <= A; ++d)
  {
    for(int e = 0; e <= B; ++e)
    {
      for(int f = 0; f <= C; ++f)
      {
        if(500*d + 100*e + 50*f == X) ++ans;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    Point(double theta){
        y = sin(theta);
        x = cos(theta);
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    Point operator/(double a) const{
        return Point(y / a, x / a);
    }
    double length() const{
        return sqrt(y * y + x * x);
    }
    double dist(const Point& p) const{
        return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
    }
    double dot(const Point& p) const{
        return y * p.y + x * p.x; // |a|*|b|*cosθ
    }
    double cross(const Point& p) const{
        return x * p.y - y * p.x; // |a|*|b|*sinθ
    }
    double angle() const{
        return atan2(y, x);
    }
};

double getArea(const Point& a, const Point& b, const Point& c)
{
    return abs((b - a).cross(c - a) / 2.0);
}

int solve(const vector<Point>& p, int m, double area)
{
    int n = p.size();
    const Point& a = p[0];
    const Point& b = p[m];

    int left = 0;
    int right = (n - m) / 2;
    while(left < right){
        int mid = (left + right + 1) / 2;
        const Point& c = p[m+mid];
        if(getArea(a, b, c) < area)
            left = mid;
        else
            right = mid - 1;
    }

    return min(left * 2, n - 1 - m);
}

int main()
{
    int n;
    long long k;
    cin >> n >> k;

    vector<Point> p(n);
    for(int i=0; i<n; ++i)
        p[i] = Point(2 * M_PI / n * i);

    double left = 0.0;
    double right = M_PI;
    for(int t=0; t<50; ++t){
        double mid = (left + right) / 2.0;
        long long cnt = 0;
        for(int i=1; i<n-1; ++i)
            cnt += solve(p, i, mid) * (long long)n;
        cnt /= 3;

        if(cnt < k)
            left = mid;
        else
            right = mid;
    }
    printf("%.10f\n", left);

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    bool check_n = false, check_s = false, check_w = false, check_e = false;
    rep(i,s.size()) {
        if (s[i] == 'N') check_n = true;
        if (s[i] == 'S') check_s = true;
        if (s[i] == 'W') check_w = true;
        if (s[i] == 'E') check_e = true;
    }
    if (!(check_n^check_s) && !(check_e^check_w)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int a,b,h,m;
int main() 
{
	cin>>a>>b>>h>>m;
	double deg1=(double)h*30.0f+(double)m/2.0f;
	double deg2=(double)m*6.0f;
	double d=abs(deg1-deg2);
	d=min(d,360-d);
	printf("%0.12f\n",sqrt((double)a*(double)a+(double)b*(double)b-2.0f*(double)a*(double)b*cos(d/180.0f*3.1415926535897932)));
	return 0;
}

Measured memory_bytes: 4136
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int foods[5];
  int remainder[5];
  int sum = 0;
  for(int i=0; i<5; ++i){
    cin >> foods[i];
    sum = sum + (foods[i]/10)*10;
    remainder[i] = foods[i]%10;
  }
  sort(remainder, remainder+5);
  for(int i=3; i>=0; --i){
    if((remainder[i]==0)&&(remainder[i+1]!=0)){
      sum = sum + remainder[i+1];
      break;
    }
    else if((i==0)&&(remainder[i]!=0)){
      sum = sum + 10+ remainder[i];
    }
    else if((remainder[i]==0)&&(remainder[i+1]==0)){
      break;
    }
    else{
      sum = sum + 10;
    }
  }
  cout << sum;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()


int n, k;
int a[200000];


bool f(int x) {
	long long cnt = 0;

	rep(i, n) {
		cnt += (a[i] + x - 1) / x - 1;
	}
	return cnt <= k;
}


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

	cin >> n >> k;
	rep(i, n)cin >> a[i];


	int lb = 0, ub = 1000000000;
	while (ub-lb>1) {
		int mid = (lb + ub) / 2;
		if (f(mid))ub = mid;
		else lb = mid;
	}
	cout << ub << endl;


	return 0;
}


Measured memory_bytes: 4388
N=int(input())
d={}
for i in range(1,10):
  for j in range(1,10):
    d[i*10+j]=0
for i in range(1,min(10,N+1)):
  d[i*10+i]=1
p,h,t,c=10,10,1,1
for i in range(11,N+1):
  if t==10:
    t=1
  else:
    d[h+t]+=1
    t+=1
  if p==c:
    h+=10
    c=0
  if h==100:
    h=10
    p*=10
  c+=1
ans=0
for i in range(1,9):
  for j in range(i+1,10):
    ans+=(d[i*10+j]*d[j*10+i])*2
for i in range(1,10):
  ans+=d[i*10+i]**2
print(ans)

Measured memory_bytes: 9228
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll n;
ll prime[10010];
bool is_prime[1001000];

//n??\???????´???°????????????
void sieve(int n){
	int p = 0;
	for (int i = 0; i <= n; i++)is_prime[i] = 1;
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i <= n; i++){
		if (is_prime[i]){
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i)is_prime[j] = 0;
		}
	}
}

int main(){
	sieve(105000);
	while (cin >> n&&n){
		ll sum = 0;
		for (int i = 0; i < n; i++){
			sum += prime[i];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1340
//I am so vegetable
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	int r;cin>>r;
	cout<<2*pi*r;
	return 0;
}

Measured memory_bytes: 3756
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define oo 2000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int GCD(int a, int b) {return (b == 0) ? a : GCD(b, a%b);}

int n, k, a[maxN];

int main () {
    scanf("%d%d", &n, &k);
    fto(i, 1, n) scanf("%d", &a[i]);

    int d = 0;
    fto(i, 1, n) d = GCD(d, a[i]);

    puts((k <= *max_element(a+1, a+n+1) && k%d == 0) ? "POSSIBLE" : "IMPOSSIBLE");

    return 0;
}


Measured memory_bytes: 640
#include <cmath>
#include <vector>
#include <complex>
#include <iostream>
using namespace std;

const double EPS = 1e-9;

double cross(const complex<double>& p1, const complex<double>& p2)
{
  return p1.real() * p2.imag() - p1.imag() * p2.real();
}

bool intersected(const complex<double>& a1, const complex<double>& a2,
		 const complex<double>& b1, const complex<double>& b2)
{
  return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
         ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

complex<double> intersection_p(const complex<double>& a1, const complex<double>& a2,
			       const complex<double>& b1, const complex<double>& b2)
{
  complex<double> b = b2-b1;
  double d1 = abs(cross(b, a1-b1));
  double d2 = abs(cross(b, a2-b1));
  double t = d1 / (d1 + d2);
  return a1 + (a2-a1) * t;
}

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    vector<pair<complex<double>, complex<double> > > p(n);
    for (int i = 0; i < n; ++i)
      cin >> p[i].first.real() >> p[i].first.imag()
	  >> p[i].second.real() >> p[i].second.imag();

    int ans = 1;
    for (int i = 0; i < n; ++i) {
      vector<complex<double> > ip;
      for (int j = 0; j < i; ++j) {
	if (p[i].first == p[j].first || p[i].first == p[j].second ||
	    p[i].second == p[j].first || p[i].second == p[j].second ||
	    !intersected(p[i].first, p[i].second, p[j].first, p[j].second))
	  continue;
	
	bool dup = false;
	complex<double> cip = intersection_p(p[i].first, p[i].second, p[j].first, p[j].second);
	for (unsigned int i = 0; i < ip.size() && !dup; ++i) {
	  if (abs(cip.real()-ip[i].real()) < EPS && abs(cip.imag()-ip[i].imag()) < EPS)
	    dup = true;
	}
	
	if (!dup) {
	  ++ans;
	  ip.push_back(cip);
	}
      }
      ++ans;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 968
f=lambda:list(map(int,input().split()))
n,l,q=f()[0],f(),f()[0]
from collections import *
C=Counter(l)
s=sum(k*C[k] for k in C)
for _ in range(q):
  b,c=f()
  v=C[b]
  C[b]-=v
  C[c]+=v
  s+=(c-b)*v
  print(s)

Measured memory_bytes: 24040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    string S; cin >> S;

    if (S[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }

    int cntc = 0;
    for (int i = 2;i < S.length() - 1; i++) {
        if (S[i] == 'C') cntc++;
    }
    if (cntc != 1) {
        cout << "WA" << endl;
        return 0;
    }

    bool ans = true;
    rep(i,S.length()) {
        if (!(S[i] == 'A' or S[i] == 'C' or isupper(S[i]) == 0)) {
            cout << "WA" << endl;
            return 0;
        }
    }
    cout << "AC" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import copy

def main():
  n = int(sys.stdin.readline())
  S = list(map(int, sys.stdin.readline().split()))
  q = int(sys.stdin.readline())
  T = list(map(int, sys.stdin.readline().split()))

  C = 0
  
  for i in range(q):
    tmp = T[i]
    L = 0
    R = n - 1
    M = n // 2

    while M >= L:
      if tmp == S[M]:
        C += 1
        break
      elif tmp > S[M]:
        L = M + 1
      else:
        R = M - 1

      M = (R + L) // 2

  print(C)

if __name__ == '__main__':
  main()


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

int main() {
	int num;
	std::string str;
	std::cin >> num >> str;

	int pre = 0;
	int end = 0;
	for (int i = 0; i < num; i++) {	
		if (str[i] == ')')end++;
		if (str[i] == '(') {
			pre++;
			while(end >= pre) {
				str.insert(0, "(");
				pre++;
				num++;
				i++;
			}
		}
	}
	while (end > pre) {
	str.insert(0, "(");
	pre++;
	}
	while (pre > end) {
		str += ")";
		end++;
	}
	std::cout << str.c_str();
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;
string s;
int e[300005];
int w[300005];

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

	if (s[0] == 'W') {
		w[0] = 1;
	}
	else {
		e[0] = 1;
	}

	for (int i = 1;i < n;i++) {
		if (s[i] == 'W') {
			w[i] = w[i - 1] + 1;
			e[i] = e[i - 1];
		}
		else {
			e[i] = e[i - 1] + 1;
			w[i] = w[i - 1];
		}
	}

	int ans = n;
	for (int i = 0;i < n;i++) {
		int t = w[i] + e[n-1] - e[i];
		if (s[i] == 'W') t--;
		ans = min(ans, t);
	}

	cout << ans << endl;

	return 0;
}


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

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

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

#define INF 1e16
#define mod 1000000007

ll n,m;
vector<int> g[100010],rg[100010];
int res[100010];
int col[100010];
int ord[100010];
vector<int> vs;

void dfs(int v){
  col[v]=1;
  for(int nv : g[v]){
    if(col[nv]==0)dfs(nv);
  }
  col[v]=2;
  vs.push_back(v);
}

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

  cin>>n>>m;
  rep(i,n+m-1){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    rg[b].push_back(a);
  }

  rep(i,n){
    if(col[i]==0){
      dfs(i);
    }
  }
  reverse(all(vs));
  rep(i,n)ord[vs[i]]=i;

  memset(res,-1,sizeof(res));
  rep(i,n){
    for(int nv : rg[i]){
      if(res[i]==-1){
        res[i]=nv;
      }else{
        if(ord[res[i]]<ord[nv])res[i]=nv;
      }
    }
  }

  rep(i,n){
    if(res[i]==-1)cout<<0<<endl;
    else cout<<res[i]+1<<endl;
  }

  return 0;
}


Measured memory_bytes: 16636
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>M;
	int P,R,S;
	cin>>S>>P>>R;
	int point[256]={};
	point['p']=P;
	point['r']=R;
	point['s']=S;
	string s;
	cin>>s;
	vector<vector<int>>dp(N,vector<int>(2));
	for(int i=0;i<M;i++){
		dp[i][1]=point[s[i]];
	}
	for(int i=M;i<N;i++){
		if(s[i]==s[i-M]){
			dp[i][0]=max(dp[i-M][1],dp[i-M][0]);
			dp[i][1]=dp[i-M][0]+point[s[i]];
		}
		else{
			dp[i][0]=max(dp[i-M][1],dp[i-M][0]);
			dp[i][1]=dp[i][0]+point[s[i]];
		}
	}
	long long int ans=0;
	for(int i=0;i<M;i++){
		ans+=max(dp[N-1-i][0],dp[N-1-i][1]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5840
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
typedef vector<int>		vi;
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=1000000007;

int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    lli n,k;
	cin>>n>>k;
	lli a[n];
	for(lli i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	lli ani=0;
	for(lli i=0;i<n-k;i++)ani+=a[i];
    cout<<ani;
    
}

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


ll solve(ll arr[], ll n, ll k)
{
	ll dp[n + 1][k + 1];

	for (ll i = 0; i <= k; i++)
		dp[1][i] = (i <= arr[1]) ? 1 : 0;

	for (ll i = 2; i <= n; i++)
	{
		for (ll j = 0; j <= k; j++)
		{
			if (j == 0)
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = (mod + dp[i][j - 1] + dp[i - 1][j] - ((j - arr[i] - 1) >= 0 ? dp[i - 1][j - arr[i] - 1] : 0)) % mod;
		}
	}

	return dp[n][k];
}

int main()
{

	ll n, k;

	cin >> n >> k;

	ll arr[n + 1];

	for (ll i = 1; i <= n; i++)
		cin >> arr[i];

	cout << solve(arr, n, k);
}


Measured memory_bytes: 81688
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    ll n;
    cin>>n;
    vector<ll> ans;
    ll x=1;
    ll diff=0;
    while(n>0)
    {
        ans.push_back(x);
        n-=x;
        //cout<<n<<"\n";//
        if(n<0)
        {
            diff=abs(n);
        }
        x++;
    }
    for(auto i:ans)
    {
        if(i!=diff)
        cout<<i<<"\n";
    }
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

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

#define o(output) cout << output << endl
#define priolity_queue pq
#define push p
#define top t

using namespace std;

string s;
int a,b,c,d;
char A,B;

int main(){
  cin >> a >> b;
  o((a-1)*(b-1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> data(n);
  for(int i=0;i<n;i++)cin>>data[i];
  int ans=1000001000;
  sort(data.begin(),data.end());
  for(int i=0;i<n-k+1;i++){
    if(data[i+k-1]-data[i]<ans)ans=data[i+k-1]-data[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl //小数をn桁で出力

int main() {
    IN(int, n);
    IN(int, m);
    vector<int> a(n);
    int sum = 0;
    int c = 0;
    REP(i, n){
        cin >> a[i];
        sum += a[i];
    }
    REP(i, n){
        if (a[i]*4*m >= sum) {
            c++;
        }
    }
    Yes(c>=m);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
int main(void){
    // Your code here!
    int k, t;
    cin >> k >> t;
    priority_queue<P> pq;
    for(int i=0; i<t; i++){
        int c; cin >> c;
        pq.push(P(c, i));
    }
    int ans = 0;
    int prev = -1;
    
    while(!pq.empty()){
        int x = pq.top().first;
        int i = pq.top().second;
        pq.pop();
        
        // cout << x << " " << i << endl;
        if(i == prev){
            if (pq.size() > 0){
                int x2 = pq.top().first;
                int i2 = pq.top().second;    
                pq.pop();
                
                pq.push(P(x, i));
                prev = i2;
                if (x2 - 1 > 0) pq.push(P(x2 - 1, i2));
            }else{
                ans += x;
                break;
            }
        }else{
            if (x - 1 > 0) pq.push(P(x-1, i));
            prev = i;
        }
    }
    cout << ans << endl;
}


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

// macros
#define overload_rep(va_0, va_1, va_2, va_3, name, ...) name
#define rep_0_(i, n) for(int i = 0; i < (n); ++i)
#define rep_1_(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep_2_(i, x, y, z) for(int i = (x); i >= (y); --i)
#define rep(...) overload_rep(__VA_ARGS__, rep_2_, rep_1_, rep_0_)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations

// solve
int main(){

    int N, Xor = 0;
    cin >> N;

    while(N--){
        int A, K;
        cin >> A >> K;
        while(true){
            int grp = A / K;
            if(grp == 0)break;
            int dec = grp + 1;
            int dif = A - grp * K;
            if(dif % dec == 0){
                Xor ^= grp;
                break;
            }
            A -= (dif + dec - 1) / dec * dec;
        }
    }

    cout << (Xor ? "Takahashi\n" : "Aoki\n");
    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
    int main(){
        int n;

        scanf("%d",&n);
        char str[n];

        scanf("%s",str);
        int counter =0;
        int max = 0;
        for(int j =0 ; j<n ;j++){

            if(str[j]=='I'){
                counter++;
                    if(counter > max){
                max = counter;
            }}else {
                counter--;
            }
        }


        printf("%d",max);

    return 0;
}

Measured memory_bytes: 1732
from collections import defaultdict

def main():
  n = int(input())
  mod = 10**9 + 7
  primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
  fact = defaultdict(int)
  for i in range(2, n + 1):
    tmp = i
    for j in primes:
      if tmp % j == 0:
        cnt = 0
        while tmp % j == 0:
          cnt += 1
          tmp //= j
        fact[j] += cnt
    if tmp != 1:
      fact[tmp] += 1
    if not fact:
      fact[i] = 1
  ans = 1
  for f in fact.values():
    ans = ans * (f + 1) % mod
  print(ans)
 
if __name__ == "__main__":
  main()

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

int main(){
  const int MAX = 100;
  int n,m, temp,sum;
  int matrix[MAX][MAX]={};
  int vector[MAX] ={};
  cin >> n>> m;
  for(int n_i=0; n_i<n ; n_i++){
    for(int m_i=0; m_i<m; m_i++){
      cin >> temp;
      matrix[n_i][m_i] = temp;
    }
  }
  for(int m_i=0; m_i<m; m_i++){
    cin >> temp;
    vector[m_i] = temp;
  }
  for(int n_i=0; n_i<n; n_i++){
    sum = 0;
    for(int m_i=0; m_i<m; m_i++){
      sum += matrix[n_i][m_i]* vector[m_i];
    }
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,A,B;
    cin >> N >> A >> B;
    if((B - A) & 1)cout << "Borys" << endl;
    else cout << "Alice" << endl;
}

Measured memory_bytes: 256
void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1], t = tmp[2];
    writeln(t / a * b);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int n, k; cin>>n>>k;
    set<int> st;
    for(int i=0; i<k; i++){
        int d; cin>>d;
        for(int j=0; j<d; j++){
            int x; cin>>x;
            st.emplace(x);
        }
    }

    cout << n - st.size() << endl;

    return 0;
}

Measured memory_bytes: 3680