akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<typename T>
class fixed_point : T {
	public:
		explicit constexpr fixed_point (
				T&& t
			) noexcept
			: T(forward<T>(t))
			{
			}
		template<typename... Args>
		constexpr decltype(auto)
		operator()(
				Args&&... args
			) const
			{
				return T::operator()(*this, forward<Args>(args)...);
			}
};
template<typename T>
static inline constexpr decltype(auto)
	make_fixed_point (T&& t) noexcept {
		return fixed_point<T>{forward<T>(t)};
	}
void err() {
	cout << "No" << endl;
	exit(0);
}
int main() {
	cin.tie(0); cin.sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> grh(n);
	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		grh[--s].push_back(--t);
		grh[t].push_back(s);
	}
	vector<int> deg(n);
	for (int i = 0; i < n; i++) {
		deg[i] = (int) grh[i].size();
	}
	for (int i = 0; i < n; i++) {
		if (deg[i] % 2 == 1) err();
	}
	for (int i = 0; i < n; i++) {
		if (deg[i] >= 6) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		if (deg[i] >= 4) {
			vector<int> ckd(n, false);
			ckd[i] = true;
			auto dfs = make_fixed_point ([&](auto dfs, int crr, int prt) -> void {
				ckd[crr] = true;
				for (auto const& nxt : grh[crr]) if (nxt != i && nxt != prt) {
					if (ckd[nxt]) {
						cout << "Yes" << endl;
						exit(0);
					}
					dfs(nxt, crr);
				}
			});
			for (auto const& r : grh[i]) {
				if (!ckd[r]) {
					dfs(r, r);
				}
			}
		}
	}
	err();
	return 0;
}

Measured memory_bytes: 8704
<?php

$input = explode(' ', trim(fgets(STDIN)));
$n = (int)$input[0];
$a = (int)$input[1];
$b = (int)$input[2];

$x_array = explode(' ', trim(fgets(STDIN)));;
$sum = 0;

$from = (int)$x_array[0];
for ($i=1; $i < $n; $i++) { 
	$to = (int)$x_array[$i];
	$dist = $to - $from;
	$sum += min($b, $dist*$a);
	$from = $to;
}
echo $sum;

Measured memory_bytes: 12792
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define VI vector<int>
#define VD vector<double>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVC vector<VC>
#define VVS vector<VS>
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define mp make_pair
#define fi first
#define se second
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define range(vec,x,y) vec.begin()+x,vec.begin()+y
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
#define eraseif(vec,condition_x) vec.erase(remove_if(all(vec),[](auto x){return condition_x;}),vec.end())
#define countif(vec,condition_x) count_if(all(vec),[](auto x){return condition_x;})
#define replaceif(vec,condition_x,n) replace_if(all(vec),[](auto x){return condition_x;},n)
#define optvalue(vec,condition_x,relation_x_opt) *min_element(all(vec),[](int x,int opt){return condition_x ? (opt==0)||!(relation_x_opt):false;})
#define erase_unique(vec) vec.erase(unique(all(vec)),vec.end())
#define calcvec(vec,calc_x) for_each(all(vec),[](int&x){x= calc_x;})
#define calc2vec(vec1,op,vec2) {rep(1){int s=min(si(vec1),si(vec2));fou(i,0,s)vec1[i]=vec1[i] op vec2[i];}}
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__);
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(Head head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(Head head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
template<class C>void outvec(vector<C> vec){int vecsize=si(vec);fou(i,0,vecsize-1)cout<<vec[i]<<" ";out(vec[vecsize-1]);}
template<class C> C gcd(C a,C b){if(a&&b)return gcd(min(a,b),max(a,b)%min(a,b));else return a;}
template<class C> C lcm(C a,C b){return a/gcd(a,b)*b;}




// #define int int64_t
// #define double long double


// 無名関数template
// map,makepair

signed main(){
  IOS;

  in(int,h,w)
  VVI a(h,VI(w));
  fou(i,0,h)fou(j,0,w) cin>>a[i][j];

  VVI ans;
  VI flag(h);
  fou(i,0,h){
    fou(j,0,w){
      if(flag[i]==1){
        VI ans0(4,(i)+1);
        ans0[1]=(j-1)+1;ans0[3]=(j)+1;
        ans.emb(ans0);
      }
      if(a[i][j]%2==1) flag[i]=1-flag[i];
    }
  }
  int flag2=0;
  fou(i,0,h){
    if(flag2==1){
      VI ans0(4,(w-1)+1);
      ans0[0]=(i-1)+1;ans0[2]=(i)+1;
      ans.emb(ans0);
    }
    if(flag[i]==1) flag2=1-flag2;
  }

  int ansnum=si(ans);
  out(ansnum);
  fou(i,0,ansnum){
    outvec(ans[i]);
  }

}

Measured memory_bytes: 11440
n = int(input())
s = input()
l = ['SS','WS','SW','WW']

for i in range(n):
  for j in range(len(l)):
    l[j] += 'SW'[::-1 if s[i]=='o' else 1][l[j][i]==l[j][i+1]]
for i in range(len(l)):
  if l[i][1]==l[i][n+1] and l[i][0]==l[i][n]:
    print(l[i][1:n+1])
    exit()
print(-1)

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
void solve(string s, string t){
    int l1=s.size(),l2=t.size();
    vector <vector<int>> dp(l1+10 ,vector <int>(l2+10 ));
    for(int i=0;i<l1;i++){
        for(int j=0;j<l2;j++){
            if(s[i]==t[j]) {
                dp[i+1][j+1] = max(dp[i][j] + 1, dp[i+1][j+1]);
            }else{
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
    cout<<dp[l1][l2]<<endl;
}
int main(void){
    int n; cin>>n;
    for(int i=0;i<n;i++){
        string s,t; cin>>s>>t;
        solve(s,t);
    }
}



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


int n, m;
int a[28], b[28];
bool reached[8];

int main(void)
{
	cin >> n >> m;

	int path[8][8] = {};
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		path[a-1][b-1] = 1;
		path[b-1][a-1] = 1;
	}

	vector<int> v(n-1);
	for (int i = 1; i < n; i++) {
		v[i-1] = i;
	}

	int count = 0;

	do {
		int cur_i = 0;
		int i;
		for (i = 0; i < v.size(); i++) {
			if (path[cur_i][v[i]] == 0)
				break;
			cur_i = v[i];
		}
		if (i == v.size())
			count++;
	} while (next_permutation(v.begin(), v.end()));

	cout << count << endl;

	return 0;
}


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

string s;
vector <char> v;

bool even(){
    if(v.size()%2) return 0;
    for(int i = v.size()/2 ; i < v.size() ; i++)
        if(v[i] != v[i-v.size()/2]) return 0;
    return 1;
}
int main() {
    cin >> s;
    for(int i = 0 ; i < s.size() ; i++)
        v.push_back(s[i]);
    v.pop_back();
    while(!even()) v.pop_back();
    cout << v.size() << endl;
    return 0;
}

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

int main() {

long long  a,b,c,k;

cin >> a >> b >> c >> k;

long long n;

if (k > a+b) n = a - (k-a-b);
else if ( k<a ) n = k;
else  n = a;


cout << n << endl;

}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<pii> balls(n);
    REP(i,n){
        int32 x,y;
        cin >> x >> y;
        balls[i] = mp(x,y);
    }
    map<pii,int32> cnt;
    REP(i,n)REP(j,n){
        if(i == j)continue;
        int32 p,q;
        p = balls[i].first - balls[j].first;
        q = balls[i].second - balls[j].second;
        cnt[mp(p,q)]++;
    }
    int32 ans = n;
    for(auto it : cnt){
        ans = min(ans, n - it.second);
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 384
S = input()
len_s = len(S)
cnt = 0
flag = True
even_list = ["L","U","D"]
odd_list = ["R","U","D"]
for i in S:
  cnt += 1
  if cnt%2 == 0 and i in even_list:
    pass
  elif cnt%2 == 1 and i in odd_list:
    pass
  else:
    flag = False

if flag == True:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
using System;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var num = int.Parse(Console.ReadLine());
            foreach(var count in Enumerable.Range(1, num))
            {
                var str = new String(Console.ReadLine().OrderBy(n => n).ToArray());
                var min = int.Parse(str);
                var max = int.Parse(new String(str.Reverse().ToArray()));
                Console.WriteLine(max - min);
            }
        }
    }
}

Measured memory_bytes: 6384
dx=[0,1,0,-1]
dy=[-1,0,1,0]
dic={'^':0,'>':1,'v':2,'<':3}
while True:
    H,W=map(int,raw_input().split())
    if (H,W)==(0,0):
        break
    board=[""]*H
    for i in xrange(H):
        board[i]=raw_input()
    visited=[[False]*W for i in xrange(H)]
    x,y=0,0
    while not(board[y][x]=="." or visited[y][x]):
        visited[y][x]=True
        x,y=x+dx[dic[board[y][x]]],y+dy[dic[board[y][x]]]
    print "{} {}".format(x,y) if board[y][x]=="." else "LOOP"

Measured memory_bytes: 4388
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll a,b;
int main(){FAST;
cin>>a>>b;
ll ans = -1;
if(a<=9 and b<=9)ans=a*b;
cout<<ans;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007


void solve()
{
  int R;
  cin>>R;
  cout<<3*R*R<<endl;
  return;  
}

int32_t main(int32_t argc, const char *argv[])
{
  // std::ios::sync_with_stdio(false);
  // std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

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

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

    int b = a / 100;
    int c = a % 100;

    if (1 <= b && b <= 12 && 1 <= c && c <= 12) {
        cout << "AMBIGUOUS" << endl;
    } else if (1 <= b && b <= 12) {
        cout << "MMYY" << endl;
    } else if (1 <= c && c <= 12) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// You can win if you want
#include <bits/stdc++.h>
using namespace std;
# define ll long long
# define endl "\n"
# define pi 3.14159265359
# define str string
# define vll vector<ll>
# define pb push_back
# define mll map<ll,ll>
# define vp vector< pair<ll,ll> >
# define mp make_pair
# define ff first
# define ss second
# define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x;
    cin>>x;
    str s;
    cin>>s;
    ll a=0,b=0;
    f(i,s.length()){
        if(s[i]=='R'){
            a++;
        }
        else{
            b++;
        }
    }
    ll b1=b;
    str s2="";
    while(a>0){
        s2+='R';
        a--;
    }
    while(b>0){
        s2+='W';
        b--;
    }
    ll k=0;
    f(i,s.length()){
        if(s2[i]!=s[i]){
            k++;
        }
    }
    cout<<min(k/2,b1);
    return 0;
}

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

ll inf=1e18;

int main() {
  ll n;
  cin >> n;
  vector<map<ll,ll>> box(n);
  for(ll i=0;i<n;i++) {
    box[i][i]=0;
  }
  for(ll i=0;i<n-1;i++) {
    ll a,b,c;
    cin >> a >> b >> c;
    a--;
    b--;
    box[a][b]=c;
    box[b][a]=c;
  }
  ll qn,k;
  cin >> qn >> k;
  k--;
  vector<pll> qe(qn);
  for(ll i=0;i<qn;i++) {
    ll x,y;
    cin >> x >> y;
    x--;
    y--;
    qe[i]=pll(x,y);
  }
  vector<ll>d(n,inf);
  d[k]=0;
  priority_queue<pll, vector<pll>, greater<pll>> q;
  q.push(pll(0,k));
  while(q.size()) {
    auto p=q.top();
    q.pop();
    if(d[p.second]<p.first) {
      continue;
    }
    for(auto tp:box[p.second]) {
      if(d[tp.first]>d[p.second]+tp.second) {
        d[tp.first]=d[p.second]+tp.second;
        q.push(pll(d[tp.first],tp.first));
      }
    }
  }
  for(auto p:qe) {
    cout << d[p.first]+d[p.second] << endl;
  }
}

Measured memory_bytes: 28788
#include<bits/stdc++.h>
#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 MOD 1000000007
// 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;
ll n, dp[100005][15];
string s;
ll expo[100005];
const ll mom = 13;
ll compute( ll i, ll m)
{
	if( i == n )
	{
		if(m == 5) return 1;
		return 0;
	}
	if(dp[i][m] != -1) return dp[i][m];
	ll ans = 0;
	if( s[i] != '?')
	{
		ll cur = ll(s[i] - '0');
		cur *= expo[n - i - 1];
		cur %= mom;
		cur += m;
		cur %= mom;
		ans = compute(i+1, cur);
		ans %= MOD;
	}
	else 
	{
		int j;
		FOR0(j, 10)
		{
			ll cur = expo[ n - i - 1];
			cur *= j;
			cur %= mom;
			cur += m;
			cur %= mom;
			ans += compute(i+1, cur);
			ans %= MOD;
		}
	}
	return dp[i][m] = ans;
}
int main()
{
    she_told_me_dont_worry
    cin>>s;
    n = s.size();
    memset(dp, -1, sizeof dp);
    expo[0] = 1;
   	int i;
    FOR(i, 1, 100005)
    {
    	expo[i] = expo[i-1];
    	expo[i] *= 10;
    	expo[i] %= mom;
    }
    ll ans = compute(0, 0);
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}


Measured memory_bytes: 19280
import collections

s=list(input())
a=[0]

s.reverse()

mod=2019

mod10=1

for i in range(len(s)):
  x=int(s[i])
  y=a[-1]
  ans=(x*mod10+y)%mod
  a.append(ans)
  mod10=(mod10*10)%mod
  
ans1=0

c = collections.Counter(a)
d=list(c.values())

for r in d:
  if r>=2:
    ans1+=(r*(r-1))//2
    
print(ans1)

Measured memory_bytes: 17916
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

LL s[100005];
bool bad[100005];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>a;
		bad[a]=true;
	}
	s[0]=1;
	for(i=1;i<=n;i++){
		if(bad[i])continue;
		if(i==1)s[i]=s[0];
		else s[i]=s[i-1]+s[i-2];
		s[i]%=MAX;
	}
	cout<<s[n]<<endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<17;



int main(){
    int N;
    cin >> N;
    LL X;
    cin >> X;
    vector<LL> x;
    for(int i=0;i<N;i++){
        LL t;
        cin >> t;
        x.pb(abs(t-X));
    }
    LL t=x[0];
    for(int i=1;i<N;i++){
        t=__gcd(t,x[i]);
    }
    cout << t << endl;
    return 0;
}


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

int main(){
    int n,i,maxval=0,val=0;
    cin >> n;
    int s[n];
    for(i=0;i<n;i++){
        cin >> s[i];
        val = val + s[i];
        maxval=max(s[i],maxval);
    } 
    cout << val - maxval/2;
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;

struct Unionfind{
  vector<int> rank,p;
  Unionfind(){}
  Unionfind(int size){
		rank.resize(size,0);
		p.resize(size,0);
		for(int i=0;i<size;i++){
	    makeSet(i);
		}
	}
  void makeSet(int x){
		p[x]=x;
		rank[x]=0;
	}
  bool same(int x,int y){
		return (findSet(x)==findSet(y));
  }

  void unite(int x,int y){
		link(findSet(x),findSet(y));
  }

  void link(int x,int y){
		if(rank[x]>rank[y]){
	    p[y]=x;
		}
		else{
	    p[x]=y;
	    if(rank[x]==rank[y]){
				rank[y]++;
	    }
		}
  }

  int findSet(int x){
		if(x!=p[x]){
	    p[x]=findSet(p[x]);
		}
		return p[x];
  }
};

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,q;
  cin>>n>>q;
  Unionfind uf(n);
  rep(i,q){
    int t,u,v;
    cin>>t>>u>>v;
    if(t==0){
      uf.unite(u,v);
    }
    else{
      if(uf.same(u,v)){
        cout<<1<<'\n';
      }
      else{
        cout<<0<<'\n';
      }
    }
  }
  return(0);
}

Measured memory_bytes: 4708
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int N;
    cin >> N;
    ll MOD = pow(10, 9) + 7;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
        A[i]++;
    }

    vector<ll> dp(N, 0);
    ll ans = 1;
    dp[0] = 3;

    for (int i = 0; i < N; i++) {
        if (dp[A[i] - 1] == 0) {
            cout << 0 << endl;
            return 0;
        }

        ans *= dp[A[i] - 1];
        ans %= MOD;
        dp[A[i] - 1]--;
        dp[A[i]]++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4796
#include <bits/stdc++.h>
using namespace std;
int main ()
{
  int n;
  cin>>n;
  std::vector<int> v(n);
  for (int i = 0; i < n; ++i)
  
    cin>>v[i];
    int max = v[0];
    int min = v[0];
    for (int i = 1; i < n; ++i)
    {
      if (min>v[i]) min = v[i];
      if (max<v[i]) max = v[i];
    }
  cout<<max-min<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      
      string w=Console.ReadLine();
      string[] arr=new string[w.Length];
      bool flg=false;
      for(int i=0;i<w.Length;i++){
        arr[i]=w.Substring(i,1);
      }
      string[] dis=arr.Distinct().ToArray();
      foreach(var e in dis){
        if((arr.Count(value=>value==e))%2!=0){
          flg=true;
          break;
        }
           }
     if(!flg){
       Console.WriteLine("Yes");
     }else{
       Console.WriteLine("No");
     }
    }
    
  }

}



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

typedef long long ll;
typedef unsigned long long ull;

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

  string s;
  cin >> s;

  vector<ll> incl;
  char c = s[0];
  bool in = false;
  for (ll i = 1; i < n; ++i) {
    if (c == s[i]) {
      if (in) {
        incl.push_back(2);
        in = false;
      }
      continue;
    }
    in = true;
  }
  if (in) incl.push_back(1);
  
  ll ans = 0;
  char prev = s[0];
  for (ll i = 1; i < n; ++i) {
    if (prev == s[i]) ans++;
    prev = s[i];
  }

  for (ll i = 0; i < min(k, ll(incl.size())); ++i) {
    ans += incl[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1020
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) {
	if os.Getenv("ONLINE_JUDGE") == "false" {
		fmt.Fprintln(os.Stderr, a...)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, q := scanInt(), scanInt()
	bit := newBinaryIndexedTree(n)

	for i := 0; i < n; i++ {
		a := scanInt()
		bit.add(i, a)
	}

	for i := 0; i < q; i++ {
		if scanInt() == 0 {
			p, x := scanInt(), scanInt()
			bit.add(p, x)
		} else {
			l, r := scanInt()-1, scanInt()-1
			fmt.Fprintln(wr, bit.sum(r)-bit.sum(l))
		}
	}
}

type binaryIndexedTree []int

func newBinaryIndexedTree(n int) *binaryIndexedTree {
	bit := make(binaryIndexedTree, n+1)
	return &bit
}
func (t binaryIndexedTree) sum(i int) (s int) {
	for i++; i > 0; i -= i & -i {
		s += t[i]
	}
	return
}
func (t binaryIndexedTree) add(i, x int) {
	for i++; i < len(t) && i > 0; i += i & -i {
		t[i] += x
	}
}
func (t binaryIndexedTree) lowerBound(x int) int {
	idx, k := 0, 1
	for k < len(t) {
		k <<= 1
	}
	for k >>= 1; k > 0; k >>= 1 {
		if idx+k < len(t) && t[idx+k] < x {
			x -= t[idx+k]
			idx += k
		}
	}
	return idx
}


Measured memory_bytes: 12960
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next(); String t = sc.next(); int lenS = s.length(); int lenT = t.length();
		boolean value = false;
		if (lenS == lenT) {
			value = false;
		} else if (lenS + 1 == lenT && s.substring(0, lenS).equals(t.substring(0, lenS))) {
			value = true;
		}

		System.out.println(value ? "Yes" : "No");
	}
}


Measured memory_bytes: 35216
#include <iostream>
#include <cstdio>
using namespace std;
int key;

int dfs(int n, int sum, int before) {
    int ret = 0;
    if(n == 0 && sum == key) return(1);
    if(n > 0) {
        for(int r = before; r <= 9; r++) {
            ret += dfs(n - 1, sum + r, r + 1);
        }
    }
    return(ret);

}

int main(void) {
    int n;
    while(cin >> n >> key, n + key != 0) {
        cout << dfs(n, 0, 0) << endl;
    }
    return(0);
}

Measured memory_bytes: 1160
n, a, b = [ int(v) for v in input().split() ]
s = input()
total, abroad = 0, 0
for i in s:
    ans = "No"
    if i == "a":
        if total < a + b:
            total += 1
            ans = "Yes"
    elif i == "b":
        if total < a + b and abroad < b:
            total += 1
            abroad += 1
            ans = "Yes"
    print(ans)


Measured memory_bytes: 54872
#include<iostream>
#include <string>
using namespace std;
int main()
{
   long long int r,x,d,ans;
    cin>>r>>d>>x;
    for(int i=0;i<10;i++){
        ans=(r*x)-d;
        cout<<ans<<endl;
        x=ans;
        
        }
return 0;
}

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

int main(){
    int n; cin >> n;
    vector<int> a(n); for(auto i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    pair<int, int> ans = { a.back(), a.front() };
    for (auto i = 0; i < n; i++) {
//        cout << ans.first << " " << ans.second << " " << a[i] << endl;
        if(abs(ans.first - a[i] * 2) < abs(ans.first - ans.second * 2))
            ans.second = a[i];
    }

    cout << ans.first << " " << ans.second << endl;
    return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
#define INFTY 1000000000
#define N 500000

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int count=0;

int main(){
  int n,i,A[N];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}

void merge(int A[],int left,int mid,int right){
  int i,j,k,n1,n2;
  int L[N/2+2],R[N/2+2];
  
  n1 = mid - left;
  n2 = right - mid;
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]){
      A[k] = L[i];
      i=i+1;
    }
    else {
      A[k] = R[j];
      j=j+1;
    }
  }
}
void  mergeSort(int A[],int left,int right){
  int mid;
  if(left+1<right){
    mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

/*
#include <stdio.h>
#define INFTY 1000000000
#define N 500000
 
void merge(int *,int,int,int);
void mergeSort(int *,int,int);
 
int count=0;
 
int main(){
  int n,i,A[N];
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
 
  return 0;
}
 
void merge(int A[],int left,int mid,int right){
  int i,j,k,n1,n2;
  int L[N/2+2],R[N/2+2];
   
  n1 = mid - left;
  n2 = right - mid;
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]){
      A[k] = L[i];
      i=i+1;
    }
    else {
      A[k] = R[j];
      j=j+1;
    }
  }
}
void  mergeSort(int A[],int left,int right){
  int mid;
  if(left+1<right){
    mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}
*/



Measured memory_bytes: 5684
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    static BigInteger dp[][] = new BigInteger[901][901];

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int P = scan.nextInt();

        int even = 0;
        int odd = 0;
        for (int i : IntStream.range(0, N).toArray()) {
            if(scan.nextInt() % 2 ==0 ){
                even++;
            }
            else {
                odd++;
            }
        }
        long evenPartern =(long) Math.pow(2, even);
        long oddPatern = 0;
        for (int i :IntStream.range(0, odd+1).toArray()){
            if(P == 0 && i % 2 == 1) {
                continue;
            }
            if(P == 1 && i % 2 == 0) {
                continue;
            }
            oddPatern += comb(odd, i).intValue();
        }
        System.out.println(evenPartern*oddPatern);
    }

    private static BigInteger comb(int n, int k) {
        if (n < 2 * k) {
            k = n - k;
        }
        if (dp[n][k] != null) {
            return dp[n][k];
        }
        BigInteger m = BigInteger.ONE;
        for (int i : IntStream.range(1, k + 1).toArray()) {
            m = m.multiply(BigInteger.valueOf((n - i + 1)));
        }
        for (int i : IntStream.range(1, k + 1).toArray()) {
            m = m.divide(BigInteger.valueOf(i));
        }
        dp[n][k] = m;
        return m;
    }

}


Measured memory_bytes: 31056
function Main(s) {
  var ans = [-1, -1];
  if(s[0] === s[1]){
    console.log("1 2");
    return;
  }
  for(var i = 2; i < s.length; i++){
    if(s[i-2] === s[i]){
      ans = [i-1, i+1];
      break;
    }
    if(s[i-1] === s[i]){
      ans = [i, i+1];
      break;
    }
  }
  console.log(ans.join(" "));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

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

    const int mod = 1e9 + 9;
    const ll inf = 1e18;
    long double n , m , a  , b , mx = -1e9 , mx1 ;
    long long cnt;
    string s;
    int main()
    {
        cin >> n >> m;
         cnt = n * m;
         cout << cnt << endl;
    }


Measured memory_bytes: 3748
while True:
    n = int(input())
    if n == 0:
        break
    count = [0] * n
    for i in range(n):
        count[i] = len(input())
    for i in range(n-4):
        ind = i
        fin = True
        for tmp in [5, 7, 5, 7, 7]:
            while tmp > 0 and ind < n:
                tmp -= count[ind]
                ind += 1
            if tmp != 0:
                fin = False
                break
        if fin:
            print(i+1)
            break



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;
LL n,ans;
LL getans(LL x){
    if(x==1)return 1;
    return getans(x/2)*2+1;
}
int main(){
    cin>>n;
    cout<<getans(n);
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    rep(i,0,k+1){
        if(c>b){
            if(b>a){
                cout<<"Yes"<<endl;
                return 0;
            }
            
        }
        if(a>=b)b*=2;
        else if(b>=c)c*=2;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3624
package main
 
import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}
 
func scanString() string {
	sc.Scan()
	return sc.Text()
}
 
func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100001), 100001*100)
}

func main() {
  var N, A, ANS int
  N = scanInt()
  MIN := 20000001
  for i := 0; i < N; i++ {
	  A = scanInt()
	  MIN = calcmin(MIN, A)
	  if MIN == A {
		  ANS++
	  }
  }
  fmt.Println(ANS)
}

func calcmin(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    {
        bool check = (A[0] == 0);
        for (int i = 1; i < N - 1; i++) {
            if (A[i] > i) check = false;
        }
        if (!check) {
            cout << -1 << endl;
            return 0;
        }
    }
    int ans = 0;
    for (int i = N - 1; i >= 1;) {
        ans += A[i];
        int count = 0;
        for (int j = i - 1; j >= 0; j--) {
            if (A[j] != A[i] - ++count) {
                if (A[j] < A[i] - count) {
                    cout << -1 << endl;
                    return 0;
                }
                i = j;
                break;
            }
            if (j == 0) i = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val p = readLine()!!.replace(" ", "").toInt()
    val q = readLine()!!.replace(" ", "").toInt()

    var fact = 1
    repeat(n) {
        fact *= (it+1)
    }
    var pPos = 0
    var qPos = 0

    fun chk(i:Int) : Boolean{
        val s = i.toString().toCharArray()
        if (s.size != n) return false
        val f = BooleanArray(n + 1){ false }
        s.forEach {
            val c = it.toString().toInt()
            when {
                c == 0 -> return false
                c > n -> return false
                f[c] -> return false
                else -> f[c] = true
            }
        }
        return true
    }
    var cnt = 0
    var i = Math.min(p,q)
    while(i <= Math.max(p,q)) {
        if (chk(i)) cnt++
        if (i == p) pPos = cnt
        if (i == q) qPos = cnt
        i+=9
    }
    println(Math.abs(pPos - qPos))
}


Measured memory_bytes: 114308
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int n,m;
int a[250];
ll ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>m;
	for(int i=0;i<n;i++)a[i]=0;
	for(int i=0;i<m;i++)a[i+n]=1;
	for(int i=0;i<n+m;i++){
		for(int j=i+1;j<n+m;j++) {
			if((a[i]+a[j])%2==0)ans++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) 
{
  int N;
  int i, j;
  int ans = 0;
  char S[110];
  
  scanf("%d %s", &N, S);
  for(i = 0; i < N; i++) {
    int alf1[30] = {0};
    int cnt = 0;
    for(j = 0; j < i; j++) alf1[S[j] - 'a']++;
    for(j = i; j < N; j++) {
      if(alf1[S[j] - 'a'] > 0) {
        cnt++;
        alf1[S[j] - 'a'] = 0;
      }
    }
    if(ans < cnt) ans = cnt;
  }
  printf("%d\n", ans);
  
  return 0;
}
      

Measured memory_bytes: 128
#include <stdio.h>

void Do(int N, int T){
  int i, min, c, t;
  min = 1e9;
  for(i = 0;i < N;i++){
    scanf("%d %d", &c, &t);
    if(T < t) continue;
    if(min > c) min = c;
  }
  if(min == 1e9) printf("TLE\n");
  else printf("%d\n", min);
}

int main(void){
  int N, T;
  scanf("%d %d", &N, &T);
  Do(N, T);
  return 0;
}


Measured memory_bytes: 128
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S; cin >> S;
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#define N 4005
using namespace std;

int n, a[N], d[N][N];

int abs(int p) {return p > 0 ? p : -p;}

int f(int q, int r) {
	if (q == n || r == n) return abs(a[q] - a[r]);
	if (d[q][r]) return d[q][r];
	if (q > r) return d[q][r] = max(f(q + 1, r), f(q, q + 1));
	else return d[q][r] = min(f(r + 1, r), f(q, r + 1));
}

int main()
{
	int i;
	cin >> n >> a[0] >> a[1];
	n++;
	for (i = 2; i <= n; i++) scanf("%d", &a[i]);
    cout << f(2, 1) << endl;
    return 0;
}

Measured memory_bytes: 32640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,a,ans=0,n;
	scanf("%d%d",&h,&a);
    while(a){
        scanf("%d",&n);
        ans+=n;
        a--;
    }
    if(ans>=h){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



int main() {
    ll n;
    cin >> n;
    
    ll m = 1;
    while(m * (m + 1) / 2 < n){
        m++;
    }
    
    vector<ll> ans;
    for(ll i = m; n > 0; i--){
        if(i <= n){
            n -= i;
            ans.push_back(i);
        }
    }
    
    reverse(ans.begin(), ans.end());
    
    REP(i, ans.size()){
        cout << ans[i] << '\n';
    }
}


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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
//No change above here

const ll maxi = (2 * 1e6 + 3);
ll mod = (1e9 + 7);

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }

//declare needed things here

int main()
{
	IOS;
	int N, M;
	cin >> N >> M;
	if (N % 2)
	{
		for (int i = 1; i <= M; ++i)
			cout << i << " " << (N - i) << endl;
	}
	else
	{
		int x = (M + 1) / 2;
		for (int i = 1; i <= x; ++i)
			cout << i << " " << (N - i + 1) << endl;
		for (int i = x+1; i <= M; ++i)
			cout << i << " " << (N - i) << endl;

	}
	return 0;
}

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

long long n;
long long tab[100010];
long long DP[100010];
int k;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for (long long i = 1 ; i <= n ; i++)
		cin >> tab[i];
	for (int i = 1 ; i <= n ; i++)
		DP[i] = (int)1e9 + 7;
	DP[1] = 0;
	for (int i = 2 ; i <= n ; i++)
	{
		for (int j = 1 ; j <= min(i - 1,k) ; j++)
		{
			// cout << j << endl;
			DP[i] = min(DP[i],DP[i - j] + abs(tab[i - j] - tab[i]));
		}
	}
	cout << DP[n] << endl;
}

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

int main(){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  int antennas[5] = {a, b, c, d, e};
  
  for(int i=0; i<4; i++){
    for(int j=i+1; j<5; j++){
      int dis = antennas[i]-antennas[j];
      dis = (dis < 0 ? -dis : dis);
      if(dis > k){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  
  cout << "Yay!" << endl;
  
  return 0;
}

Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/
#define int ll
signed main() {
	EmiliaMyWife

	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<int>> dp(h+1, vector<int>(w+1));
	dp[0][1] = 1;
	for(int i = 1; i <= h; i++) {
		for(int j = 0; j < (1<<(w-1)); j++) {
			bool ok = true;
			for(int k = 1; k < w-1; k++) {
				ok &= !(((j>>k)&1)&&((j>>(k-1))&1));
			}
			if(ok) {
				vector<bool> has(w+1);
				for(int k = 0; k < w-1; k++) {
					if((j>>k)&1) {
						dp[i][k+1] = (dp[i][k+1] + dp[i-1][k+2]) % MOD;
						dp[i][k+2] = (dp[i][k+2] + dp[i-1][k+1]) % MOD;
						has[k+1] = has[k+2] = 1;
					}
				}
				for(int k = 1; k <= w; k++)
					if(!has[k])
						dp[i][k] = (dp[i][k] + dp[i-1][k]) % MOD;
			}
		}
	}
	cout << dp[h][k];

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int aa[n];
    for(int i=0;i<n;i++)
    {
        cin>>aa[i];
    }
    int sum=0;
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            sum+=aa[i]*aa[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace ALDS1_11_B {
    class Problem {
        Dictionary<int, Node> _nodes;
        private int _vol, _time;

        public void Run() {
            _nodes = new Dictionary<int, Node>();
            SetNodes();

            StringBuilder sb = new StringBuilder();
            for (int i = 1; i <= _vol; i++) {
                if (_nodes[i].First == 0) {
                    DFS(i);
                }
                sb.Append(i + " ");
                sb.AppendLine(_nodes[i].ToString());
            }
            Console.Write(sb);
        }

        private void SetNodes() {
            _vol = int.Parse(Console.ReadLine());
            for (int i = 0; i < _vol; i++) {
                string[] input = Console.ReadLine().Split(' ');
                int u = int.Parse(input[0]);
                int k = int.Parse(input[1]);
                _nodes[u] = new Node();
                for (int j = 0; j < k; j++) {
                    _nodes[u].Children.Add(int.Parse(input[2 + j]));
                }
            }
        }

        private void DFS(int id) {
            _nodes[id].First = ++_time;
            foreach (int next in _nodes[id].Children) {
                if (_nodes[next].First == 0) {
                    DFS(next);
                }
            }
            _nodes[id].last = ++_time;
        }
    }

    class Node {
        public List<int> Children { get; set; }
        public int First { get; set; }
        public int last { get; set; }

        public Node() {
            Children = new List<int>();
        }

        public override string ToString() {
            return First + " " + last;
        }
    }

    class Program {
        static void Main(string[] args) {
            Problem p = new Problem();
            p.Run();
        }
    }
}

Measured memory_bytes: 9804
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

struct Point {
	long double px, py;
};

struct Circle {
	long double px, py, r;
};

long double PI = 3.14159265358979;
long long N, K;
Point G[1 << 18]; long double C[1 << 18];
Circle H[1 << 18];

double dst(Point V1, Point V2) {
	return sqrt((V1.px - V2.px) * (V1.px - V2.px) + (V1.py - V2.py) * (V1.py - V2.py));
}

double dst(Circle V1, Circle V2) {
	return sqrt((V1.px - V2.px) * (V1.px - V2.px) + (V1.py - V2.py) * (V1.py - V2.py));
}

int solve(double T) {
	for (int i = 1; i <= N; i++) {
		H[i].px = G[i].px;
		H[i].py = G[i].py;
		H[i].r = T / C[i];
	}

	vector<Point> Major;
	for (int i = 1; i <= N; i++) {
		Major.push_back(Point{ H[i].px, H[i].py });
	}
	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			if (dst(H[i], H[j]) > H[i].r + H[j].r) continue;
			
			double DST = dst(H[i], H[j]);
			double DX = (H[j].px - H[i].px) / DST;
			double KAKUDO = acos(DX);
			if (H[j].py < H[i].py) KAKUDO = PI * 2.0 - KAKUDO;

			double cl = 0.0, cr = PI, cm;
			for (int k = 0; k < 50; k++) {
				cm = (cl + cr) / 2.0;
				double vx = H[i].px + H[i].r * cos(KAKUDO + cm);
				double vy = H[i].py + H[i].r * sin(KAKUDO + cm);
				double ds = dst(Circle{ vx, vy, 0.0 }, H[j]);
				if (ds < H[j].r) { cl = cm; }
				else { cr = cm; }
			}

			double tx = H[i].px + H[i].r * cos(KAKUDO + cm);
			double ty = H[i].py + H[i].r * sin(KAKUDO + cm);
			double ux = H[i].px + H[i].r * cos(KAKUDO - cm);
			double uy = H[i].py + H[i].r * sin(KAKUDO - cm);
			Major.push_back(Point{ tx, ty });
			Major.push_back(Point{ ux, uy });
		}
	}

	int maxn = 0;
	for (int i = 0; i < Major.size(); i++) {
		int cnt = 0;
		for (int j = 1; j <= N; j++) {
			double I = dst(G[j], Major[i]);
			if (I <= H[j].r + 1e-7) cnt++;
		}
		maxn = max(maxn, cnt);
	}
	return maxn;
}

int main() {
	cin >> N >> K;
	for (int i = 1; i <= N; i++) cin >> G[i].px >> G[i].py >> C[i];

	long double L = 0, R = 1e6, M;
	for (int i = 0; i < 50; i++) {
		M = (L + R) / 2.0;
		int I = solve(M);
		if (I >= K) { R = M; }
		else { L = M; }
	}
	printf("%.12Lf\n", M);
	return 0;
}

Measured memory_bytes: 4648