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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */

/*struct*/
struct aaa {
	aaa() {
		cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 9o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
//#define int long long

signed main()
{
 int a,b,c; cin >> a >> b >> c;
  
  if((a + b > c && a + c > b && b + c > a)
      && (a > 0 && b > 0 && c > 0)){
    if(a == b && b == c){
      cout << "Yes";
      return 0;
    }
  }
  
   cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#include <random>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

random_device gen;
mt19937 rnd(gen());

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

string s;
int cnt[nmax];

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
	getline(cin, s);
	int n = (int)s.length();
	ll answer = 0;
	for (int i = 0; i < n; i++) {
		cnt[s[i]]++;
	}
	for (int i = 0; i < n; i++) {
		cnt[s[i]]--;
		answer += (n - i - cnt[s[i]] - 1);
	}
	cout << answer + 1 << endl;
	return 0;
}



Measured memory_bytes: 640
#include<stdio.h>


int main( void ) 
{
	int S[14]={0},H[14]={0},C[14]={0},D[14]={0};
	int n;
	int i,num;
	char pattern[2]={'\0'};
	
	scanf( "%d", &n );
	for( i=0; i<n; i++ ) {
		scanf( "%s%d", pattern, &num );
		pattern[1]='\0';
		if( 'S' == pattern[0] ) {
			S[num]=1;
		} else if( 'H' == pattern[0] ) {	
			H[num]=1;
		} else if( 'C' == pattern[0] ) {	
			C[num]=1;
		} else if( 'D' == pattern[0] ) {	
			D[num]=1;
		} else {
			;
		}
	}
	n=52-n;
	for( i=1; i<14; i++ ) {
		if( 0 == S[i] ) {
			printf( "S %d\n", i );
		}
	}
	for( i=1; i<14; i++ ) {
		if( 0 == H[i] ) {
			printf( "H %d\n", i );
		}
	}
	for( i=1; i<14; i++ ) {
		if( 0 == C[i] ) {
			printf( "C %d\n", i );
		}
	}
	for( i=1; i<14; i++ ) {
		if( 0 == D[i] ) {
			printf( "D %d\n", i );
		}
	}			
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long
#define pr pair<ll,ll>
using namespace std;
int num[100005];
int main(){
	int n,sum=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> num[i];
		sum = -sum + num[i];
	}
	for (int i = 0; i < n; i++) {
		cout << sum<<' ';
		sum = 2 * (num[i] - sum / 2);
	}
	return 0;
}

Measured memory_bytes: 3968
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <cstdint>
#include <iostream>
#include <algorithm>

constexpr int32_t kMaxLength = 100000;

void CallLongestIncreasingSubsequence(std::istream &input_stream);

class LongestIncreasingSubsequence {
 public:
  LongestIncreasingSubsequence() noexcept;
  ~LongestIncreasingSubsequence() noexcept;
  void AppendValue(const int32_t value);
  int32_t FindLengthOfLis() noexcept;

 private:
  LongestIncreasingSubsequence(const LongestIncreasingSubsequence &obj) = delete;
  LongestIncreasingSubsequence &operator=(const LongestIncreasingSubsequence &obj) = delete;
  LongestIncreasingSubsequence(LongestIncreasingSubsequence &&obj) = delete;
  LongestIncreasingSubsequence &operator=(LongestIncreasingSubsequence &&obj) = delete;

 private:
  int32_t length_;
  int32_t length_of_lis_;
  int32_t values_[kMaxLength];
  int32_t look_up_value_at_right_end_of_[kMaxLength + 1];
};

void CallLongestIncreasingSubsequence(std::istream &input_stream) {
  input_stream.tie(0);
  std::ios::sync_with_stdio(false);
  LongestIncreasingSubsequence *longest_increasing_subsequence = new LongestIncreasingSubsequence();
  try {
    int32_t length;
    input_stream >> length;
    for (int32_t i = 0; i < length; ++i) {
      int32_t value;
      input_stream >> value;
      longest_increasing_subsequence->AppendValue(value);
    }
    std::cout << longest_increasing_subsequence->FindLengthOfLis() << std::endl;
  } catch (...) {
    std::cerr << "ERROR: CallLongestIncreasingSubsequence()" << std::endl;
    delete longest_increasing_subsequence;
    throw;
  }
  delete longest_increasing_subsequence;
}

// ****************************************************
LongestIncreasingSubsequence::LongestIncreasingSubsequence() noexcept : length_(0), length_of_lis_(1) {}

LongestIncreasingSubsequence::~LongestIncreasingSubsequence() noexcept {}

void LongestIncreasingSubsequence::AppendValue(const int32_t value) {
  if (length_ >= kMaxLength) {
    std::cerr << "ERROR: AppendValue(): length_ exceeded a limit = " << kMaxLength << std::endl;
  }
  const int32_t index_stored = length_;
  values_[index_stored] = value;
  ++length_;
}

int32_t LongestIncreasingSubsequence::FindLengthOfLis() noexcept {
  int32_t c_lis_length = 1;
  try {
    look_up_value_at_right_end_of_[c_lis_length] = values_[0];
    for (int32_t current_right_end = 0; current_right_end < length_; ++current_right_end) {
      int32_t current_value = values_[current_right_end];
      if (look_up_value_at_right_end_of_[c_lis_length] < current_value) {
        look_up_value_at_right_end_of_[c_lis_length + 1] = current_value;
        c_lis_length++;
      } else {
        int32_t *start = look_up_value_at_right_end_of_ + 1;
        int32_t *end = look_up_value_at_right_end_of_ + 1 + c_lis_length;
        *std::lower_bound(start, end, current_value) = current_value;
      }
    }
  } catch (...) {
    std::cerr << "ERROR: FindLengthOfLis()" << std::endl;
    throw;
  }
  return c_lis_length;
}

int main() {
  try {
    CallLongestIncreasingSubsequence(std::cin);
  } catch (...) {
    std::cerr << "ERROR: main()" << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3480
#include<stdio.h>


#define MAX_K 100


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

	int ans = 0 ;
	int i = 1 ;
	while( i < K )
	{
		int j = i + 1 ;
		while( j <= K )
		{
			ans += (i + j) % 2 ;
			++j ;
		}

		++i ;
	}

	printf( "%d\n" ,ans ) ;

	return 0 ;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define loop(i,a,b) for(ll i=a;i<b;i++)
const int inf=1e5+7;
ll visited[inf];
ll dp[inf];
 vector<ll> graph[inf];

void visit(ll i)
{
	visited[i]=1;
	for(auto x:graph[i])
	{
		if(!visited[x])
		 visit(x);
		 dp[i]=max(dp[i],dp[x]+1);
	}
}

int main()
{	
    ll n,m;
    cin>>n>>m;
    ll x,y;
    loop(i,0,m)
    {
    	cin>>x>>y;
    	graph[x].push_back(y);
	}
	loop(i,1,n+1)
	{
		if(!visited[i])
		{
			visit(i);
		}
	}
	ll ans=0;
	loop(i,1,n+1)
	ans=max(ans,dp[i]);
	cout<<ans;
    return 0;
}


Measured memory_bytes: 9344
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
S = input().rstrip()

ans = 0
for i in range(1000):
    t = str(i).zfill(3)
    t1 = S.find(t[0])
    if t1 == -1:
        continue
    t2 = S.find(t[1], t1+1)
    if t2 == -1:
        continue
    t3 = S.find(t[2], t2+1)
    if t3 == -1:
        continue
    ans += 1

print(ans)


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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; }

int MAX = 1000010;

int main()
{   
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    vi cnt(MAX);
    for(auto x : a) {
        if(cnt[x] >= 2) continue;
        for(int i = x; i <= MAX; i += x) {
            cnt[i]++;
        }
    }

    //cout << cnt[5] << endl;

    int ans = 0;
    for(auto x : a) {
        if(cnt[x] >= 2) continue;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7948
n, k = map(int, input().split())
mod = 10 ** 9 + 7
ans = 0
coma = 1
comb = 1
for i in range(min(k+1, n)):
    ans += coma * comb
    ans %= mod
    coma *= (n-i) * pow(i+1, mod-2, mod)
    coma %= mod
    comb *= (n-i-1) * pow(i+1, mod-2, mod)
    comb %= mod

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

void trace(int A[], int N){
 int i;
 for(i=0; i<N; i++){
  if (i>0) printf(" ");
  printf("%d",A[i]);
 }
 printf("\n");
}

void insertionSort(int A[], int N){
int j,i,v;
for(i=1;i<N;i++){
 v=A[i];
 j=i-1;
 while(j>=0 && A[j]>v){
 A[j+1]=A[j];
 j--;
 }
A[j+1]=v;
trace(A,N);
}
}

int main(){
int N,i,j;
int A[100];

scanf("%d",&N);
for(i=0;i<N;i++){
scanf("%d",&A[i]);
}

trace(A,N);
insertionSort(A,N);

return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <cmath>
#include <algorithm>
/*
for (int i = 0; i < 7; i++) {

	}
*/
using namespace std;

int main()
{
	//A=65
	int n,val;
	char s[10010];

	cin >> n >> s;
	char dir[26][2]={"A","B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S","T","U","V", "W", "X", "Y","Z" };

	for (int i = 0; s[i] != 0; i++) {
		for (int j = 0; j < 26; j++) {
			if (s[i] == dir[j][0]) {
				val = j;
				break;
			}
		}
		s[i] = dir[(val+n)%26][0];
	}

	cout << s;

}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include <string>
#include<algorithm>
#include <map>
#pragma warning(disable:4786)  // VisualC++6.0の警告対策



using namespace std;

#define ll long long
#define SINT(n) scanf("%d",&n);
#define SLL(n) scanf("%lld",&n);

#define PINT(n) printf("%d",(int)(n));
#define PLL(n) printf("%lld",(long long)(n));
#define PINTN(n) printf("%d\n",(int)(n));
#define PLLN(n) printf("%lld\n",(long long)(n));
#define PSP() printf(" ");
#define PN() printf("\n");

#define dlp(i) while(i-->0)
#define ulp(i) for(int _hoge_counter_hoge_=i,i=0;i<_hoge_counter_hoge_;i++)
#define lp(i,to) for(i=0;i<to;i++)
#define lpp(i,from,to) for(i=from;i<to;i++)


map<ll, map<ll, short> > memo[50][50][4];

char Map[60][60];

int main(){

	int N,M;
	int i,j,k;
	int a;
	int now;
	int masu[1050];
	int me[1050];

	while(1){
		SINT(N);
		SINT(M);
		if(N==0&&M==0) break;
		lp(i,N)SINT(masu[i]);
		lp(i,M)SINT(me[i]);

		now=0;
		lp(i,M){
			a=me[i];
			now+=a;
			if(now>=N-1)break;
			now+=masu[now];
			if(now>=N-1)break;
		}
		PINTN(i+1);
	}


	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	if (N % 2 == 0) {
		cout << N / 2 - 1 << endl;
	} else {
		cout << N / 2 << endl;
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
import string
A=string.ascii_lowercase
S=input()
if S==A[::-1]:
    print(-1)
elif len(S)==26:
    i=-1
    while S[i-1]>S[i]:
        i-=1
    for j in range(-1,i-1,-1):
        if S[j]>S[i-1]:
            c=S[j]
            break
    print(S[:i-1]+c)
else:
    c=sorted(set(A)-set(S))[0]
    print(S+c)

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(ll i=0;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define vec_input(A) for(auto &a : A) cin >> a;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;


void run_case(){
	ll n; cin >> n;
	vector<ll> a(n);
	ll ans = 0;

	for(auto &x : a) cin >> x;

	for(ll i = 0 ; i < n ; i++){
		for(ll j = i + 1 ; j < n ; j++)
			for(ll k = j + 1; k < n ; k++){
				if(a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i])
					if(a[i] != a[j] && a[j] != a[k] && a[i] !=a[k])
					ans++;
				
				
			}
	}
	cout << ans;
}


int main() {

	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	#ifndef ONLINE_JUDGE
    freopen("input", "r", stdin);
    freopen("output", "w", stdout);
    freopen("error", "w", stderr);
	#endif

	
	

	int t = 1;
	// cin >> t;
	while(t--) 
	{
		run_case();



	}

	return 0;
}


Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int ca(int c){
  int x = 0;
  for(int i=1; i<=c; i++){
    if(c<i) break;
    c-=i;
    x++;
  }
  return x;
}

int main(void){

  long long N;
  int c, ans = 0;

  cin >> N;

  for(long long z=2; z*z<=N; z++){
    c = 0;
    while(true){
      if(N%z==0){
        N = N / z;
        c++;
      }
      else{
        ans += ca(c);
        break;
      }
    }
  }
  if(N!=1) ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

int const mod = 1e9 + 7;
int const maxn = 2e5 + 5;

vector<ll>g[maxn];
bool used[maxn];

void dfs(ll u) {
	used[u] = 1;
	for (ll v : g[u]) {
		if (used[v]) continue;
		dfs(v);
	}
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	ll m; cin >> m;
	for (ll i = 0; i < m; i++) {
		ll x, y, z; cin >> x >> y >> z;
		g[x].push_back(y), g[y].push_back(x);
	}
	ll ans = 0;
	rep(i, n) {
		ll u = i + 1;
		if (!used[u]) {
			ans++;
			dfs(u);
		}
	}
	cout << ans << endl;
	return 0;
}
/*

*/

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

int main() {
  int r,D;
  cin >> r >> D;
  vector<int> x(11);
  cin >> x.at(0);
  for(int i=0;i<10;i++){
    x.at(i+1) = r*x.at(i)-D;
    cout << x.at(i+1) << endl;
  }
}

Measured memory_bytes: 256
using System;

namespace myApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input_n = System.Console.ReadLine();
            var n = 0;

            if(!int.TryParse(input_n, out n))
                return;

            if(n < 2 && n > 10)
                return;

            var total_pi    = 0;
            var max_pi      = 0;

            while(n > 0)
            {
                n--;

                var input_pi    = System.Console.ReadLine();
                var pi          = 0;

                if(!int.TryParse(input_pi, out pi))
                    continue;

                if(pi < 100 && pi > 10000)
                    continue;

                if(pi % 2 != 0)
                    continue;

                if(max_pi == 0)
                    max_pi = pi;
                else if(max_pi < pi)
                {
                    total_pi += max_pi;
                    max_pi = pi;
                }
                else if(max_pi >= pi)
                    total_pi += pi;
            }

            total_pi += max_pi / 2;

            System.Console.WriteLine(total_pi);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
 
using namespace std;
 
const int N = int(3e5) + 7;
const int mod = int(1e9) + 7;
typedef pair<int, int> pii;
 
int n, m, res, l[N], r[N], t[N], remain;
vector<int> dis[N];
 
void Update(int x, int val) {for(; x < N; x += (x & -x)) t[x] += val;}
int Get(int x) {int res = 0; for(; x > 0; x -= (x & -x)) res += t[x]; return res;}
 
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> m;
    for(int i = 0; i < n; ++i) {
        cin >> l[i] >> r[i];
        dis[r[i] - l[i] + 1].pb(i);
    }
    remain = n;
    for(int i = 1; i <= m; ++i) {
       for(int j: dis[i - 1]) Update(l[j], 1), Update(r[j] + 1, -1);
       remain -= int(dis[i - 1].size()); res = remain;
       if(i != 1) for(int j = i; j <= m; j += i) res += Get(j);
       cout << res << '\n';
    }
}

Measured memory_bytes: 14592
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a,const void *b)
{
	return *(int *)a - *(int *)b;
}

int main(void)
{
	int n,k,*h,i,j,min;
	scanf("%d %d",&n,&k);
	h = (int *)malloc(sizeof(int) * n);
	for (i=0;i<n;i++) scanf("%d",&h[i]);
	
	qsort(h,n,sizeof(int),compare);

	min = 1E9+1;
	for (i=0,j=k-1;j<n;i++,j++) {
		if (min > h[j]-h[i]) min = h[j]-h[i];
	}
	printf("%d\n",min);

	return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,i;
  string s;
  cin>>n;
  cin>>s;
  int l;
  l = s.length();
  for(i=0;i<l;i++)
  {
    s[i]=s[i]+n;
    if(s[i]>90)
    {
      s[i]=s[i]-26;
    }
  }
  for(i=0;i<l;i++)
  {
    cout<<s[i];
  }
  return 0;
}



Measured memory_bytes: 256
s_in = input()

def rec(s,n):
  if n==0:
    if eval(s)==7:
      return s+'=7'
    else:
      return ''
  else:    
    ret_p = rec(s[:n]+'+'+s[n:] ,n-1)
    ret_m = rec(s[:n]+'-'+s[n:] ,n-1)
  if ret_p:
    return ret_p
  if ret_m:
    return ret_m
  else:
    return ''

print(rec(s_in,len(s_in)-1))

Measured memory_bytes: 3060
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, Z, W = ni()
    val A = na(N)
    var ans = abs(W - A(N - 1))
    if (N > 1) ans = max(ans, abs(A(N - 2) - A(N - 1)))
    out.println(ans)
  }


  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  def debug(num: Long): Unit = {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 28504
import sys


def input() -> str:
    return sys.stdin.readline().rstrip("\r\n")


def main():
    s = input()
    if len(s) == 6 and s[-2] == s[-1] and s[2] == s[3]:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":

    main()


Measured memory_bytes: 2940
#include <stdio.h>
#define MOD (1000000007)
/*AGC,GAC,ACG,AG-C,A-GC=>023,203,032,02-3,0-23*/
/*
[2][3][-]は[0][2][3]
[0][3][-]は[2][0][3]
[3][2][-]は[0][3][2]
[2][-][3]は[0][2][-]
[-][2][3]は[0][-][2]からの寄与を受けない*/
int main(){
  int n;
  long dp[98][4][4][4],ans=0;/*dp[i]=>n=i+3までの並べ方*/
  if(scanf("%d",&n)){
  for (int i=0;i<98;i++){
    for (int j=0;j<4;j++){
      for (int k=0;k<4;k++){
        for (int l=0;l<4;l++){/*初期化*/
          dp[i][j][k][l]=1;
        }
      }
    }
  }
  dp[0][0][2][3]=0;
  dp[0][2][0][3]=0;
  dp[0][0][3][2]=0;
  for (int i=0;i<n-3;i++){
    for (int j=0;j<4;j++){
      for (int k=0;k<4;k++){
        for (int l=0;l<4;l++){/*dp[i][j][k][l]の処理*/
          if (j==0 && k==2 && l==3) dp[i+1][j][k][l]=0;
          else if (j==2 && k==0 && l==3) dp[i+1][j][k][l]=0;
          else if (j==0 && k==3 && l==2) dp[i+1][j][k][l]=0;
          else if (j==2 && l==3) 
            dp[i+1][j][k][l]
            =(dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%MOD;
          else if (k==2 && l==3) 
            dp[i+1][j][k][l]
            =(dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%MOD;
          else dp[i+1][j][k][l]
            =(dp[i][0][j][k]+dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%MOD;
        }
      }
    }
  }
  for (int j=0;j<4;j++){
    for (int k=0;k<4;k++){
      for (int l=0;l<4;l++){
        ans+=dp[n-3][j][k][l];
        ans%=MOD;
      }
    }
  }
  printf("%ld",ans);}
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rev2(i, s, n) for (int i = (int)(n) - 1; i >= (int)(s); i--)
#define bitrep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define all(v) v.begin(), v.end()
#define println(x) cout << x << endl
#define fi first
#define se second
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")
using pii = pair<int, int>;

int main()
{
    int n, m; cin >> n >> m;
    vector<int> k(m);
    vector<vector<int>> s(m, vector<int>());
    rep(i, m)
    {
        cin >> k[i];
        rep(j, k[i])
        {
            int sij; cin >> sij;
            s[i].push_back(sij - 1);
        }
    }
    vector<int> p(m);
    rep(i, m)
    {
        cin >> p[i];
    }
    int ans = 0;
    bitrep(t, n)
    {
        bitset<10> bs(t);
        int cnt = 0;
        rep(i, m)
        {
            int cnt_i = 0;
            rep(j, k[i])
            {
                if (bs[s[i][j]] == 1) cnt_i++;
            }
            if (cnt_i % 2 == p[i]) cnt++;
        }
        if (cnt == m) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}

int main() {
    long long A, B;
    cin >> A >> B;
    cout << LCM(A, B) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

template <class T>struct PairingHeap{
    struct node{
        T key;
        node *head,*next;
        explicit node(T key):key(key),head(nullptr),next(nullptr){}
    };
    node *r;
    PairingHeap():r(nullptr){}
    PairingHeap(node* r):r(r){}
    node* merge(node *a,node *b){
        if(!a||!b) return a?a:b;
        if(a->key<b->key){
            b->next=a->head,a->head=b;
            return a;
        }
        else{
            a->next=b->head,b->head=a;
            return b;
        }
    }
    node* mergelist(node *s){
        if(!s) return nullptr;
        node h((T()));
        while(s){
            node *a=s,*b=nullptr;
            s=s->next;a->next=nullptr;
            if(s) b=s,s=s->next,b->next=nullptr;
            a=merge(a,b);a->next=h.next;
            h.next=a;
        }
        node *t=h.next;
        s=t;
        t=t->next;
        while(t){
            node *u=t;
            t=t->next;
            s=merge(s,u);
        }
        return s;
    }
    T top(){
        if(!r) return numeric_limits<T>::min();
        return r->key;
    }
    void pop(){
        if(!r) return;
        r=mergelist(r->head);
    }
    void push(T k){r=merge(r,new node(k));}
    bool empty(){return !r;}
};

ll n,m;

void dkstr(vector<vector<P>>& e,ll s,vector<ll>& result){
    result.resize(0);result.resize(n+1);
    PairingHeap<P> pq;
    vector<bool> vis(n+1);
    pq.push(mp(0,s));
    while(!pq.empty()){
        ll i=pq.top().second,c=pq.top().first;pq.pop();
        if(vis[i]) continue;
        vis[i]=1;result[i]=c;
        fr(j,e[i].size()) if(!vis[e[i][j].first]) pq.push(mp(c+e[i][j].second,e[i][j].first));
    }
}

int main(){
    ll s,t,u,v,a,b,mn[100010];
    vector<ll> ra,rb;
    cin>>n>>m>>s>>t;
    vector<vector<P>> ea(n+1),eb(n+1);
    fr(i,m){
        cin>>u>>v>>a>>b;
        ea[u].pb(mp(v,a));
        ea[v].pb(mp(u,a));
        eb[u].pb(mp(v,b));
        eb[v].pb(mp(u,b));
    }
    dkstr(ea,s,ra);dkstr(eb,t,rb);
    mn[n+1]=1e15;
    iFr(i,n) mn[i]=min(ra[i]+rb[i],mn[i+1]);
    Fr(i,n) cout<<1000000000000000-mn[i]<<endl;
}

Measured memory_bytes: 29824
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 42
int n;
int a[N];
int b[N];
int c[N];
int ai = 1;
int ci = 1;
int used[N];
void rebuild(int left, int right){
    if(left == right) {
//        printf("%d ", b[left]);
        c[ci++] = b[left];
        used[b[left]] = 1;
         return ;
    }
//    int ax = a[ai++];
    int ax;
    if(used[a[ai]] == 0){
        ax = a[ai++];
    }
    else{
        while(used[a[ai]] != 0){
            ai++;
        }
        ax = a[ai++];
    }
    int m = 1;
    for(int i = 1; i <= n; i++){
        if(b[i] == ax) {
            m = i;
            break;
        }
    }
    if(m - 1 >= left) rebuild(left, m-1);
    if(m + 1 <= right) rebuild(m+1, right);
//    printf("%d ", ax);
    c[ci++] = ax;
    used[ax] = 1;
    return ;
}
int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
    for(int i = 1; i <= n; i++) used[i] = 0;
    rebuild(1, n);
    for(int i = 1; i <= n; i++){
        if(i == n) printf("%d\n", c[i]);
        else printf("%d ", c[i]);
    }
    return 0;
}


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

int main(){
	int n,a=0,b=0,c=0;
	cin>>n;
	for (int x,y,z,i = 0; i < n; ++i)
	{
		cin>>x>>y>>z;
		x += max(b,c);
		y += max(a,c);
		z += max(a,b);
		a=x,b=y,c=z;
	}
	cout<<max(a,max(b,c))<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    printf("%lld\n", (H * W) - (h * W + (H - h) * w));
    return 0;
}


Measured memory_bytes: 256
var line, i, eof_i;

line = require('fs').readFileSync('/dev/stdin', 'ascii').split("\n");
for (i = line.length - 1; i >= 0; i--) {
	if (line[i].indexOf("?") !== -1) {
		eof_i = i;
		line.pop();
		break;
	}
	line.pop();
}

for (i in line)
	line[i] = Math.floor(eval(line[i]));

console.log(line.join("\n"));

Measured memory_bytes: 15756
#include<bits/stdc++.h>
using namespace std;
int main(){
	string w;
	cin>>w;
	int l=w.size();
	char c[100];
	bool ans=true;
	for(int i=0;i<l;i++)c[i]=w[i];
	for(int i=0;i<l;i++){
		char x=c[i];
		int num=0;
		for(int j=0;j<l;j++) if(x==c[j]) num++;
		if(num%2)ans=false;
	}
	if(ans==true)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>



int main()
{
   int A, B, C, p, q;

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

   p = B + C;
   if(A>=p){

    printf("0");
   }
   else if(A<p){
      q = -(A -p);
     printf("%d\n", q);
   }


    return 0;
}


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

//http://agc010.contest.atcoder.jp/tasks/agc010_a

using namespace std;

typedef long long LL;
typedef pair<LL,LL> pp;


int main()
{
	int N;
	cin >> N;
	LL x;
	int numE = 0, numO = 0;
	for (int i = 0; i < N; i++) {
		cin >> x;
		numO += x%2;
	}
	numE = N-numO;
	numE += numO/2;
	numO %= 2;
	numE = numE>0;
	if (numO+numE == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	exit(0);
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
 int N,h,m,s;
 cin>>N;
 h = N / 3600;
 N %= 3600;
 m = N /60;
 s = N%60;
 cout<<h<<":"<<m<<":"<<s<<endl;
 return 0;
}

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

struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

int main() {
	long long N, M;
	cin >> N >> M;
	vector<int>A(M);
	vector<int>B(M);
	vector<long long>Ans(M + 1);
	for (int n = 0; n < M; ++n) {
		cin >> A[n] >> B[n];
		--A[n];
		--B[n];
	}
	UnionFind uf(N);
	Ans[M] = (N - 1)*N / 2;
	for (int n = 0; n < M; ++n) {
		Ans[M - 1 - n] = Ans[M - n];
		if (!uf.issame(A[M - 1 - n],B[M - 1 - n])) {
			int x = uf.size(A[M - 1 - n]);
			int y = uf.size(B[M - 1 - n]);
			//Ans[M - 1 - n] += (long long)(x * x + y * y - (x + y)*(x + y)) / 2;
			Ans[M - 1 - n] -= (long long) x* y;
		}
		uf.merge(A[M - 1 - n], B[M - 1 - n]);
	}
	
	for (int n = 0; n < M; ++n) {
		cout << Ans[n+1] << endl;
	}
	return 0;
}


Measured memory_bytes: 5036
#include <stdio.h>

int main(void) {
	int a, b;
	if (scanf("%d%d", &a, &b) != 2) return 1;
	if (a + b == 15) puts("+");
	else if (a * b == 15) puts("*");
	else puts("x");
	return 0;
}


Measured memory_bytes: 1632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const int inf=1000000000;
struct edge{
	int to,cost;
};

int main() {
	int n,p;

	cin>>n>>p;
	ll t0=1,t1=0;

	for(int i=0;i<n;++i){
		int a1;
		ll tn0,tn1;
		cin>>a1;
		if(a1%2==0){
			tn0=t0*2;
			tn1=t1*2;
		}else{
			tn0=t1+t0;
			tn1=t0+t1;
		}
		t0=tn0;
		t1=tn1;
	}
	if(p==0){
		cout<<t0<<endl;
	}else{
		cout<<t1<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
a=0 #"("
b=0 #")"
cnt=0
for i in range(n):
    if s[i]=="(":
        if a<b:
            cnt+=b-a
            a,b=1,0
        else:
            a+=1
    else:
        b+=1
if a<b:
    cnt+=b-a
s=(cnt*"("+s)
a=s.count("(")
b=len(s)-a
print(s+")"*(a-b))

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int n;
  cin >> n;
  cout << n / 3 << endl;
}


Measured memory_bytes: 892
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Dice dice = new Dice();

		for (int i = 1; i <= 6; i++) {
			dice.setFace(sc.nextInt());
		}

		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			dice.roll(sc.nextInt());
			dice.setFront(sc.nextInt());
			System.out.println(dice.getFace(3));
			dice.reset();
		}

	}
}

class Dice {
	List<Integer> faces;
	List<Integer> first;

	public Dice() {
		this.faces = new ArrayList<Integer>();
		faces.add(0);
		this.first = new ArrayList<Integer>();
		first.add(0);
	}

	public void setFace(Integer value) {
		faces.add(value);
		first.add(value);
	}

	public void roll(int direction) {
		faces.set(0, faces.get(1));
		switch (faces.indexOf(direction)) {
		case 'S':
		case 5:
			faces.set(1, faces.get(5));
			faces.set(5, faces.get(6));
			faces.set(6, faces.get(2));
			faces.set(2, faces.get(0));
			break;
		case 'W':
		case 3:
			faces.set(1, faces.get(4));
			faces.set(3, faces.get(6));
			faces.set(6, faces.get(4));
			faces.set(4, faces.get(0));
			break;
		case 'N':
		case 2:
			faces.set(1, faces.get(2));
			faces.set(2, faces.get(6));
			faces.set(6, faces.get(5));
			faces.set(5, faces.get(0));
			break;
		case 'E':
		case 4:
			faces.set(1, faces.get(4));
			faces.set(4, faces.get(6));
			faces.set(6, faces.get(3));
			faces.set(3, faces.get(0));
			break;
		case 6:
		    faces.set(1, faces.get(6));
			faces.set(6, faces.get(0));
			faces.set(0, faces.get(2));
			faces.set(2, faces.get(5));
			faces.set(5, faces.get(0));
			break;
		default :
		    break;
		}
	}
	
	public void spin(){
		    faces.set(0, faces.get(2));
			faces.set(2, faces.get(3));
			faces.set(3, faces.get(5));
			faces.set(5, faces.get(4));
			faces.set(4, faces.get(0));
	}

	public void setFront(int value) {
		while (faces.get(2) != value) {
			this.spin();
		}
	}

	public void reset() {
		for (int i = 1; i <= 6; i++) {
			faces.set(i, first.get(i));
		}
	}

	public int getFace(int face) {
		return faces.get(face);
	}

}


Measured memory_bytes: 26196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool dp[3009];
int main(){
    int a,b,c,d,e,f;
    while(cin>>a>>b>>c>>d>>e>>f){
        bool mark[55]={0};
        mark[0]=1;
        for(int i=a;i<=30;i++){
            mark[i]|=mark[i-a];
        }
        for(int i=b;i<=30;i++){
            mark[i]|=mark[i-b];
        }
        memset(dp,0,sizeof(dp));
        dp[0]=1;
        for(int i=c;i<=3000;i++){
            dp[i]|=dp[i-c];
        }
        int nowa=100*a,nowb=0;
        for(int i=d;i<=3000;i++){
            dp[i]|=dp[i-d];
        }
        for(int i=1;i<=30;i++){
            if(i*100>=f){
                break;
            }
            if(!mark[i])continue;
            int tmp=min(f-i*100,i*e);
            int ta=i*100,tb=0;
            for(int j=tmp;j>=0;j--){
                if(dp[j]){
                    tb=j;break;
                }
            }
            //cout<<ta<<'?'<<tb<<endl;
            if(tb*nowa>(ta+tb)*nowb){
                nowa=ta+tb;
                nowb=tb;
            }
        }
        cout<<nowa<<' '<<nowb<<endl;
        //printf("%d %d\n",nowa,nowb);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include  <set>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(i=0;i<n;i++)

int main() {
	ll a, b, n, d[10000]={}, e, f, g, h, i, j, c[10000], m, l, sum = 0;
	int s[10000][2];
	cin >> n;	
	rep(i, n-1) {
		cin >> s[i][0];
		cin >> s[i][1];
		s[i][0]--;
		s[i][1]--;
	}
	rep(i, n)cin >> c[i];
	sort(c, c + n);
	rep(i, n - 1)sum = sum + c[i];
	d[0] = c[n-1];
	for (i = n - 2; i >= 0; i--) {
		j = 0;
		e = 0;
		while ((j < n-1) && e==0) {
			g = s[j][0]; h = s[j][1];


			if (d[g] == 0 && d[h] >= c[i]) {

				d[g] = c[i];
				e = 1;
			}
			if (d[h] == 0 && d[g] >= c[i]) {
				d[h] = c[i];
				e=1;
			
			}
			j++;
		}
		
	}
	

	cout << sum << "\n";
	rep(i, n)cout << d[i] <<" ";

	cin >> n;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    int A,B,C,D,area1,area2;
    cin>>A>>B>>C>>D;
    area1=A*B;
    area2=C*D;
    if(area1==area2)
    cout<<area1;
    else 
    if(area1>area2)
    cout<<area1;
    else
     cout<<area2;
    
    
    
    
    
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
typedef long long int ll;
int main(){
    int N,L;
    cin>>N>>L;
    vector<string>S(N);
    rep(i,N){
        cin>>S.at(i);
    }
    
    sort(S.begin(),S.end());
    rep(i,N){
        cout<<S.at(i);
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#problem D
input_d41 = int(input())
input_d42 = input()

N = int(input_d41)
S = input_d42

R = S.count('R')
G = S.count('G')
B = N - (R + G)

ans = R*G*B
answ = 0

for i in range(0,N):
    for j in range(i+1,(N+i)//2 +1):
        if S[i] != S[j]:
            if 2*j-i < N and S[j] != S[2*j-i] and S[2*j-i] != S[i]:
                ans -= 1
print(ans)

Measured memory_bytes: 9188
#include<vector>
#include<unordered_map>
#include<algorithm>
template<typename T> class Compression {
 public:
  Compression(const std::vector<T>& list) : value_(list) {
    std::sort(begin(value_), end(value_));
    value_.erase(std::unique(begin(value_), end(value_)), end(value_));
    for(int i = 0; i < value_.size(); ++i) index_[value_[i]] = i;
  }
  int size() const {return value_.size();}
  int index(const T& v) const {return index_.at(v);}
  int operator[](const int i) const {return value_.at(i);}
 private:
  std::unordered_map<T, int> index_;
  std::vector<T> value_;
};

#include<vector>
using Size = int;
template<typename T> class SegmentTree {
 public:
  SegmentTree(Size N) : N(size(N)), node_(2 * size(N) - 1, 0) {}
  void add(Size i, T v) {
    i += N - 1;
    node_[i] += v;
    while(i != parent(i)) {
      i = parent(i);
      node_[i] = node_[lchild(i)] + node_[rchild(i)];
    }
  }
  T find(Size a, Size b) const {return find(a, b, 0, 0, N);}
 private:
  constexpr Size pop_lsb(Size N) const {return N & (N - 1);}
  constexpr Size msb(Size N) const {while(pop_lsb(N)) N = pop_lsb(N); return N;}
  constexpr Size size(Size N) const {return pop_lsb(N) ? msb(N) << 1 : N;}
  inline Size parent(Size n) const {return (n - 1) / 2;}
  inline Size lchild(Size n) const {return 2 * n + 1;}
  inline Size rchild(Size n) const {return 2 * n + 2;}
  T find(Size a, Size b, Size k, Size l, Size r) const {
    if(b <= l || r <= a) return 0;
    if(a <= l && r <= b) return node_[k];
    auto m = (l + r) / 2;
    return find(a, b, lchild(k), l, m) + find(a, b, rchild(k), m, r);
  }
  const Size N;
  std::vector<T> node_;
};

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
  LL N, K;
  cin >> N >> K;
  vector<LL> A(N);
  for(auto& i: A) cin >> i, i-=K;
  vector<LL> S = {0};
  for(auto i: A) S.emplace_back(S.back() + i);
  Compression<LL> C(S);
  SegmentTree<LL> T(C.size());
  for(auto i=1; i<=N; ++i) T.add(C.index(S[i]), 1);
  LL sum = 0;
  for(auto i=1; i<=N; ++i) {
    sum += T.find(C.index(S[i-1]), C.size());
    T.add(C.index(S[i]), -1);
  }
  cout << sum << endl;
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    A--,B--,C--,D--;
    string S;
    cin >> S;

    if (C<D){
        string ans = "Yes";
        bool cont = false;
        for (int i=A; i<=C; i++) {
            if (S[i]=='#' and cont) {
                ans = "No";
            }
            else if (S[i]=='#') {
                cont = true;
            }
            else {
                cont = false;
            }
        }
        cont = false;
        for (int i=B; i<=D; i++) {
            if (S[i]=='#' and cont) {
                ans = "No";
            }
            else if (S[i]=='#') {
                cont = true;
            }
            else {
                cont = false;
            }   
        }
        cout << ans << endl;
    }
    else {
        string ans = "Yes";
        bool cont = false;
        for (int i=A; i<=C; i++) {
            if (S[i]=='#' and cont) {
                ans = "No";
            }
            else if (S[i]=='#') {
                cont = true;
            }
            else {
                cont = false;
            }
        }
        cont = false;
        for (int i=B; i<=D; i++) {
            if (S[i]=='#' and cont) {
                ans = "No";
            }
            else if (S[i]=='#') {
                cont = true;
            }
            else {
                cont = false;
            }   
        }
        bool c3 = false;
        for (int i=B; i<= D; i++) {
            if (S[i-1]=='.' and S[i]=='.' and S[i+1]=='.') {
                c3 = true;
            }
        }
        if (c3) {
            cout << ans << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (s == "Cloudy") {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a+1,a+n+1);
    int l=a[n]/2,r=(a[n]+1)/2,ans=0,Min=a[n];
    for(int i=1;i<n;i++){
        if(abs(a[i]-l)<Min){
            Min=abs(a[i]-l);
            ans=a[i];
        }
        if(abs(a[i]-r)<Min){
            Min=abs(a[i]-r);
            ans=a[i];
        }
    }
    printf("%d %d\n",a[n],ans);
    return 0;
}
/*
5
6 9 4 2 11
*/


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#include <bitset>
using namespace std;
using ll = long long;
 
int main(){
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  int k = 0;
  if(x == w/2 && y == h/2){
    k = 1;
  }
  cout << fixed << setprecision(10);
  cout << w*h/2 << " ";
  cout << k << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;
    vector<int> a(N);
    int ma = -1e9, mi = 1e9, maidx, miidx;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        if (ma < a[i])
            ma = a[i], maidx = i;
        if (mi > a[i])
            mi = a[i], miidx = i;
    }

    vector<pii> ans;
    int tmp = (abs(ma) > abs(mi) ? ma : mi);
    if ((ll)ma * mi < 0) {
        int idx = (abs(ma) > abs(mi) ? maidx : miidx);
        for (int i = 0; i < N; ++i) {
            if ((ll)tmp * a[i] < 0) {
                ans.push_back({idx, i});
                a[i] += tmp;
            }
        }
    }

    if (tmp >= 0)
        for (int i = 1; i < N; ++i)
            ans.push_back({i - 1, i});
    else
        for (int i = N - 2; i >= 0; --i)
            ans.push_back({i + 1, i});

    cout << ans.size() << '\n';
    for (auto i : ans)
        cout << i.first + 1 << " " << i.second + 1 << endl;

    return 0;
}


Measured memory_bytes: 256