akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl
 
#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
 
#define INF 1000000000000000000

ll dp1[10001][101];
ll dp2[10001][101];
ll mod = 1000000007;

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

    string k;
    ll d;
    cin >> k >> d;

    dp1[0][0] = 1;

    ll n = k.length();

    fr(i,1,n)
    {
        fr(j,0,d-1)
        {
            fr(x,0,9)
            {
                if(x<k[n-i]-'0')
                {
                    dp1[i][j] = (((dp1[i][j])%mod + (dp1[i-1][(j + (10*d) - x)%d])%mod)%mod + (dp2[i-1][(j + (10*d) - x)%d]%mod))%mod;
                }
                else if(x==k[n-i]-'0')
                {
                    dp1[i][j] = ((dp1[i][j]%mod) + (dp1[i-1][(j + (10*d) - x)%d])%mod)%mod;
                    dp2[i][j] = ((dp2[i][j]%mod) + (dp2[i-1][(j + (10*d) - x)%d])%mod)%mod;
                }
                else
                {
                    dp2[i][j] = (((dp2[i][j])%mod + (dp1[i-1][(j + (10*d) - x)%d])%mod)%mod + (dp2[i-1][(j + (10*d) - x)%d]%mod))%mod;
                }
            }

            // cout << dp1[i][j] << " " << dp2[i][j] << " " << i << " " << j << endl;
        }
    }

    cout << (dp1[n][0]-1+mod)%mod << endl;
}

Measured memory_bytes: 16000
#include<stdio.h>
#include <stdlib.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)

int main(){
	int n,ai,ch[100002]={0},ans = 0,pow = 1;

	scanf("%d",&n);
	FOR(i,0,n){
		scanf("%d",&ai);
		ch[ai]++;
	}

	int tmp = n-1;
	while(tmp>0){
		if(ch[tmp] != 2) ans++;
		tmp -= 2;
	}
	if(n%2 - ch[0] != 0) ans++;

	if(ans != 0) printf("0\n");
	else{
		FOR(i,0,n/2) pow = (pow * 2) % 1000000007;
		printf("%d",pow);
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, K; cin >> N >> K;
	double ans = 0;
	rep(i, 1, N + 1) {
		int x = 0;
		ll num = i;
		while (num < K) {
			num *= 2;
			++x;
		}
		ans += 1 / pow(2, x) / N;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void getMax(int* h, int size, int *max1, int *max2) {
	*max1 = 0;
	*max2 = 0;

	for (int i = 0; i < size; i++) {
		if (h[i] > *max1) {
			*max2 = *max1;
			*max1 = h[i];
		}
		else if ((h[i] != *max1)
			&& (h[i] > *max2)) {
			*max2 = h[i];
		}
	}
}

int main()
{
	int N;
	int max1, max2;
	int count = 0;
	bool seq = false;

	cin >> N;

	int* h = new int[N];
	for (int i = 0; i < N; i++) cin >> h[i];

	getMax(h, N, &max1, &max2);

	while (max1) {
		if (max1 == max2) {
			count += max1;
			break;
		}

		for (int i = 0; i < N; i++) {
			if (h[i] == max1) {
				h[i] = max2;

				if (seq) continue;

				count += max1 - max2;
				seq = true;
			}
			else seq = false;
		}

		seq = false;
		getMax(h, N, &max1, &max2);
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
int n[10];
for(int i=0;i<10;i++)
 cin >> n[i];

 int a,b=0;
 for(int j=0;j<3;j++){
   for(int i=0;i<10;i++){
     if(b<n[i]){
       b = n[i];
       a = i;
     }
   }
   cout << b << endl;
   n[a] = 0;
   b = 0;
 }
 
 return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <stack>
#include <algorithm>

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

using namespace std;

int main() {
  while(1){
    stack<char> s;
    string str;
    getline(cin, str);
    if (str == ".") break;
    bool valid = true;
    for(char c : str) {
      switch(c){
       case '(':
       case '[':
        s.push(c);
        break;
       case ')':
        if(s.empty() || s.top() != '('){
          valid = false;
        }else{
          s.pop();
        }
        break;
       case ']':
        if(s.empty() || s.top() != '['){
          valid = false;
        }else{
          s.pop();
        }
        break;
      }
    }
    if(valid && s.empty())
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include <iostream>
using namespace std;
int main(void)
{
    // Your code here!
    unsigned long n,k;
    cin >> n >> k;
    //cout << n << "," << k << endl;
    unsigned long y = n % k;
    if( y > 0 )
    {
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
// ~maqsat~
/*    
**	  “Anyone who has never made a mistake has never tried anything new.”
**    © Albert Einstein
*/

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 2e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 1e10 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int main() {
    fre("");
    ACCELERATE;
	
	int n;
	cin >> n;

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

	sort(a, a + n, greater<int>());

	int ans1 = a[0];
	int ans2 = -1;
	int m = (ans1 + 1)/ 2;
	for(int i = 1; i < n; i++) {
		if(abs(a[i] - m) < abs(ans2 - m)) ans2 = a[i];
	}

	cout << ans1 << ' ' << ans2;
    return 0;
}
/*
 
*/


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  string s;
  cin>>s;
  bool ans=false;
  sort(s.begin(),s.end());
  if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]){
    ans=true;
  }
  if(ans) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 256
H, N = gets.split.map(&:to_i)
pair = Array.new(N)

max = 0
N.times do |i|
  x = gets.split.map(&:to_i)
  pair[i] = [*x, x[0].to_f / x[1]]
  if x[0] > max
    max = x[0]
  end
end
pair = pair.sort_by{|x| x[3]}
dp = Array.new(H+1)
dp[0] = 0
a = (H / pair[0][0])
start = 1
if H > 2 * max
  start = H - 3 * max
end
1.upto(H) do |i|
  # if i > 2 * max
  #   dp[i] = dp[i-pair[0][0]] + pair[0][1]
  #   next
  # end
  dp[i] = (i.to_f/pair[0][0]).ceil * pair[0][1]
  pair.each do |pa|
    if i <= pa[0]
      if dp[i] > pa[1]
        dp[i] = pa[1]
      end
    else
      b = dp[i-pa[0]] + pa[1]
      if b < dp[i]
        dp[i] = b
      end
    end
  end
end
puts dp[H]

Measured memory_bytes: 1916
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

void Main() {
    int n;
	cin >> n;
	rep(i, n) {
		cout << "ACL";
	}
	cout << endl;
}

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

Measured memory_bytes: 3612
#include<iostream>
#include<queue>
#include<map>
#include<cstring>
using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> PP;

int bfs();
int n;
int bill[2][222];
bool flag[2][222];

int main(){
  while(1){
    memset(bill,0,sizeof(bill));
    cin >> n;
    if(n == 0) break;
    for(int i=0;i<n;i++){
      cin >> bill[0][i];
    }
    for(int i=0;i<n;i++){
      cin >> bill[1][i];
    }
    memset(flag,0,sizeof(flag));
    int ans = bfs();
    if(ans == -1) cout << "NA" << endl;
    else cout << ans << endl;
  }
}

int bfs(){
  queue<PP> que;
  que.push(PP(0,P(0,0)));
  que.push(PP(0,P(1,0)));
  while(!que.empty()){
    PP a = que.front();
    que.pop();
    int cou = a.first;
    int b = a.second.first;
    int k = a.second.second;
    if(bill[b][k] == 1){
      while(bill[b][k+1] == 1) k++;
    }
    else if(bill[b][k] == 2){
      while(bill[b][k] == 2) k--;
    }
    if(k == n-1) return cou;
    int v = 0;
    if(b == 0) v = 1;
    if(flag[v][k] == false){
      flag[v][k] = true;
      for(int i=0;i<3;i++){
	if(k+i < n){ 
	  que.push(PP(cou+1,P(v,k+i)));
	}
      }
    }
  }
  return -1;
}

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

int main() {
    int n, m; cin >> n >> m;
    int d = 0;
    int i = 1;
    while(i*i <= m){
        if(m%i == 0){
            int j = m/i;
            if(i >= n) d = max(j,d);
            if(j >= n) d = max(i,d);
        }
        i++;
    }
    cout << d << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;

    int ml_limit = a-b;

    int c_nokori = c - ml_limit;

    if(c_nokori < 0) {
        cout << 0 << endl;
    } else {
        cout << c_nokori << endl;
    }
    return 0;
}

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

#define ll long long int

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);	cout.tie(0);
	int n,k;
	cin >> n >> k;
	int cnt=0,tmp = 0;
	for(int i=0;i<n;i++){
		cin >> tmp;
		cnt += (tmp >= k);
	}	
	cout << cnt << '\n';

	return 0;
}

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

int main()
{
	int r, c;
	std::cin >> r >> c;
	int nums[101][101] = {};
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < c; ++j) {
			std::cin >> nums[i][j];
		}
	}
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < c; ++j) {
			std::cout << nums[i][j] << " ";
			nums[i][c] += nums[i][j];
			nums[r][j] += nums[i][j];
		}
		nums[r][c] += nums[i][c];
		std::cout << nums[i][c] <<  std::endl;
	}
	for (int i = 0; i < c; ++i) {
		std::cout << nums[r][i] << " ";
	}
	std::cout << nums[r][c] << std::endl;

	return 0;
}


Measured memory_bytes: 3152
/*

        শুভ নববর্ষ ।
        ঘরে থাকুন , সুস্থ থাকুন ।
    wan-_-s
*/

#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define stay_home_stay_safe return 0
#define pb push_back
const ll N = 200007 ;
void scan(ll &n) { scanf("%lld",&n) ; }
void scan(ll &n, ll &m) { scanf("%lld%lld",&n,&m) ; }
void scan(vector<ll> &v) { ll n = v.size() ; for(ll i=0 ;i<n;i++) scanf("%lld",&v[i]) ; }
vector<ll> adj[N] ;
ll vis[N] , lvl[N] ,lvl1[N],vis1[N] ;
void edge (ll u , ll v) {
    adj[u].pb(v) ;
    adj[v].pb(u) ;
}


int main() {

   double a = 6.28318530 , r ;
   cin >> r ;
   cout << fixed<< setprecision(9) ;
   cout << r*a << endl ;

    stay_home_stay_safe ;
}






Measured memory_bytes: 8480
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;


int main(){
    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, k;
    cin >> n >> k;
    cout << ((n + 1) / 2 >= k ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

long long int MOD = 1e9+7;

long long int hogemod(long long int x){
  if(x > 0)return x%MOD;
  else if(x == 0)return 0;
  else if(x < 0 && (-x)%MOD == 0)return 0;
  else return MOD- ((-x)%MOD);
}

int main(){
  
  // read problem
  long long int N, K;
  scanf("%lld%lld", &N, &K);
  
  //std::cerr << "N = " << N << ", K = " << K << std::endl;
  
  long long int rootN = 1;
  long long int l = 1, r = N+1, mid;
  while(r-l > 1){
    mid = (r+l)/2;
    if(mid*mid <= N)l = mid;
    else r = mid;
  }
  rootN = l;
  
  //std::cerr << "rootN = " << rootN << std::endl;
  
  // prepare n
  std::vector<long long int> n;
  n.push_back(0);
  for(long long int i = 1; i <= rootN; i++){
    n.push_back(N/i - rootN);
    n[i] = (n[i]+MOD)%MOD;
  }
  
  /*std::cerr << "n:" << std::endl;
  for(long long int i = 0; i <= rootN; i++){
    std::cerr << n[i] << " ";
  }std::cerr << std::endl << std::endl;*/
  
  // prepare dp table
  std::vector<std::vector<long long int> > dp(rootN+1), dp2(rootN+1);
  for(long long int i = 0; i <= rootN; i++){
    for(long long int j = 0; j <=K; j++){
      dp[i].push_back(0);
      dp2[i].push_back(0);
    }
  }
  for(long long int i = 1; i <= rootN; i++){
    dp[i][0] = 1;
    dp2[i][0] = dp2[i-1][0] + (dp[i][0] - dp[i-1][0])*n[i];
  }
  for(long long int i = 1; i <= rootN; i++){
    dp[i][1] = i;
    dp2[i][1] = dp2[i-1][1] + (dp[i][1] - dp[i-1][1])*n[i];
  }
  
  for(long long int j = 2; j <= K; j++){
    for(long long int i = 1; i <= rootN; i++){
    
      dp[i][j] = dp[i-1][j] + dp[rootN][j-1] + (dp2[rootN][j-2] - dp2[i-1][j-2]) + dp[i-1][j-2]*n[i];
      dp[i][j] = hogemod(dp[i][j]);
      
      dp2[i][j] = dp2[i-1][j] + (dp[i][j]-dp[i-1][j])*n[i];
      dp2[i][j] = hogemod(dp2[i][j]);
    }
  }
  
  /*std::cerr << "dp:" << std::endl;
  for(long long int i = 0; i <= rootN; i++){
    for(long long int j = 0; j <= K; j++){
      std::cerr << dp[i][j] << " ";
    }std::cerr << std::endl;
  }std::cerr << std::endl;
  
  std::cerr << "dp2:" << std::endl;
  for(long long int i = 0; i <= rootN; i++){
    for(long long int j = 0; j <= K; j++){
      std::cerr << dp2[i][j] << " ";
    }std::cerr << std::endl;
  }std::cerr << std::endl;*/
  
  long long int ans = 0;
  ans = dp[rootN][K] + dp2[rootN][K-1];
  ans = hogemod(ans);
  
  std::cerr << "Answer:" << std::endl;
  std::cout << ans << std::endl;
  
  return 0;
  
}


Measured memory_bytes: 66172
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    
    vec<int> a(N), b(N), c(N);
    rep(i, N) cin >> a[i] >> b[i] >> c[i];

    vec<vec<int>> dp(N+1,vec<int>(3,0));
    dp[1][0] = a[0];
    dp[1][1] = b[0];
    dp[1][2] = c[0];
    for(int i=1;i<=N-1;++i)rep(j,3){
        if(j!=0) dp[i+1][0] = max(dp[i+1][0],dp[i][j]+a[i]);
        if(j!=1) dp[i+1][1] = max(dp[i+1][1],dp[i][j]+b[i]);
        if(j!=2) dp[i+1][2] = max(dp[i+1][2],dp[i][j]+c[i]);
    }
    cout << max({dp[N][0],dp[N][1],dp[N][2]}) << endl;
}


Measured memory_bytes: 9744
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

ans = 0
for i in range(N):
    atk1 = min(A[i], B[i])
    atk2 = min(A[i + 1], B[i] - atk1)
    A[i + 1] -= atk2
    ans += atk1 + atk2

print(ans)


Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string YES[2] = {"NO", "YES"};
string yes[2] = {"No", "Yes"};

int main(){
    ll n;   cin >> n;
    vector<ll> a(n);
    rep(i, n)   cin >> a[i];
    sort(ALL(a));
    deque<ll> que;
    rep(i, n)   que.push_back(a[i]);
    deque<ll> res;
    res.push_back(a[0]); que.pop_front();   
    while(!que.empty()){
        ll pre=que.front(), suf=que.back();
        ll rpre = res.front(), rsuf=res.back();
        if(max(abs(pre-rpre), abs(suf-rpre))>max(abs(pre-rsuf), abs(suf-rsuf))){
            if(abs(pre-rpre)<abs(suf-rpre)){
                res.push_front(suf);    que.pop_back();
            }else{
                res.push_front(pre);    que.pop_front();
            }
        }else{
            if(abs(pre-rsuf)<abs(suf-rsuf)){
                res.push_back(suf);    que.pop_back();
            }else{
                res.push_back(pre);    que.pop_front();
            }
        }
    }
    ll sum=0, pre=res.front();  res.pop_front();

    while(!res.empty()){
        
        ll x=res.front();   res.pop_front();
        //cout << x << ' ';
        sum += abs(x-pre);
        pre = x;
    }
    cout << sum << endl;
}


Measured memory_bytes: 5040
#include <stdio.h>

typedef long long ll;

int main() {

	ll Q, H, S, D, N;

	scanf("%lld %lld %lld %lld", &Q, &H, &S, &D);
	scanf("%lld", &N);

	ll price[3] = { 4ll * Q ,2ll * H ,S };

	int index;

	int i;

	ll mi = 1000000000ll;

	for (i = 0; i < 3; i++) {
		if (price[i] < mi) {
			mi = price[i];
			index = i;
		}
	}

	ll ans;

	if (mi * 2ll > D) {
		if ((N % 2ll) == 0ll) { ans = N*D / 2ll; }
		else { ans = (N / 2ll)*D + price[index]; }
	}
	else {
		ans = N*mi;
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
char a[102][102];
 
void dfs(int  m,int n,char o){
  if(a[m][n]!=o){
    return ;
  }
  a[m][n]=0;
  dfs(m+1,n,o);
  dfs(m,n+1,o);
  dfs(m-1,n,o);
  dfs(m,n-1,o);
}
int main(){
  while(1){
    int b,c;
    cin >> b >> c;
    if(b==0 && c==0)
      break;
    for(int i=1;i<=b;i++){
      for(int j=1;j<=c;j++){
    cin >> a[i][j];
      }
    }
    int d=0;
    for(int i=1;i<=b;i++){
      for(int j=1;j<=c;j++){
    if(a[i][j]!=0){
      d++;
      dfs(i,j,a[i][j]);
    }
      }
    }
    cout << d << endl;
  }
  return 0;
}

Measured memory_bytes: 1472
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <cmath>

int main(void){
    int a,b,c;
    std::cin >> a >> b >> c;

    if(c >= a && c <= b){
        std::cout << "Yes";
        return 0;
    }
    else if( a > c && c > b ){
        std::cout << "Yes";
        return 0;
    }
    else{
        std::cout << "No";
        return 0;
    }
}


Measured memory_bytes: 888
use std::process;

fn read_line() -> String {
    use std::io;
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

fn main() {
    let line = read_line();
    let mut iter = line.split_whitespace();
    let N = iter.next().unwrap().parse::<i32>().unwrap();
    let Y = iter.next().unwrap().parse::<i32>().unwrap() / 1000;
    for z in 0..(N+1) {
        let x5 = Y - 5 * N + 4 * z;
        if x5 % 5 == 0 {
            let x = x5 / 5;
            let y = N - z - x;
            if x >= 0 && y >= 0 {
                println!("{} {} {}", x, y, z);
                process::exit(0);
            }
        }
    }
    println!("-1 -1 -1");
}


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

int main(){
  long long int N ,ans = 0 ;
  string S ;
  cin >> N ;
  vector<int> d(N);
  for(int i = 0; i < N; i++) cin >> d[i];

  vector<long long int> e(N + 1);
  for(int i = 0; i < N ; i++) e[i + 1] = e[i] + d[i];
  for(int i = 0; i < N ; i++) ans += d[i] * (e[N] - e[i + 1]);
  cout << ans << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int K,N,p;
    vector<int> pv;
    scanf("%d %d",&N,&K);
    
    for(int i = 0; i < N; i++)
    {
        scanf("%d",&p);
        pv.push_back(p);
    }
    
    std::sort(pv.begin(),pv.end());
    
    int sum = 0;
    
    for(int i = 0; i < K; i++)
    {
        sum += pv[i];
    }
    
    printf("%d\n", sum);
}


Measured memory_bytes: 3792
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T3;
const int INF = 1000000000;
int main(){
	int h,w;
	cin >> h >> w;
	vector<string> grid(h);
	for(int i = 0;i < h;i++)cin >> grid[i];

	vector<vector<int>> d(h,vector<int>(w,INF));

	d[0][0] = 0;
	if(grid[0][0] == '#')d[0][0] = 1;

	priority_queue<T3,vector<T3>,greater<T3>> q;
	q.push(T3(d[0][0],0,0));
	while(q.size()){
		int nowd,x,y;
		tie(nowd,x,y) = q.top();
		q.pop();
		if(nowd > d[y][x])continue;
		if(0 <= x+1 && x+1 < w){
			int dif = 0;
			if(grid[y][x] == '.' && grid[y][x+1] == '#')dif = 1;
			if(d[y][x+1] > d[y][x] + dif){
				d[y][x+1] = d[y][x] + dif;
				q.push(T3(d[y][x+1],x+1,y));
			}
		}
		if(0 <= y+1 && y+1 < h){
			int dif = 0;
			if(grid[y][x] == '.' && grid[y+1][x] == '#')dif = 1;
			if(d[y+1][x] > d[y][x] + dif){
				d[y+1][x] = d[y][x] + dif;
				q.push(T3(d[y+1][x],x,y+1));
			}
		}
	}

	cout << d[h-1][w-1] << endl;
}


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

int main(){
    LL d, ans = 0;
    cin>>n>>d;
    for(int i = 1; i <= n; i++){
        LL x, y;
        cin>>x>>y;
        if(x * x + y * y <= d * d) ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
from itertools import accumulate
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a_acc = list(accumulate(a))
for i in range(n):
    if a_acc[i] > x:
        print(i)
        exit()
if sum(a) == x:
    print(n)
else:
    print(n-1)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

const char *YES = "YES";
const char *NO = "NO";

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

    if (scanf("%d%d%d", &A, &B, &C) < 3) return 0;

    bool flg = false;
    for (int i = A; i <= B * A; i++)
    {
        if (i % A == 0 && i % B == C)
        {
            flg = true;
            break;
        } 
    }

    printf("%s\n", flg ? YES : NO);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
int main(){
  int n;
  cin>>n;
  vll a(n);
  bool ans=true;
  REP(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  REP(i,n-1){
    if(a[i]==a[i+1]){
      cout<<"NO"<<endl;
      ans=false;
      break;
    }
  }
  if(ans){cout<<"YES"<<endl;}
  
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<map>

using namespace std;

int main(){
    int N;
    cin>>N;
    int a[100];
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    int ans=0;
    for(int i=1;i<N;i++){
        if(a[i]==a[i-1]){
            a[i]=-1;
            ans++;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n, i = 1;

	while (1) {
		scanf("%d", &n);
		if (n == 0) {
			break;;
		}
		else {
			printf("Case %d: %d\n", i, n);
			i++;
		}
	}
	
	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"
const int N = 1e6 + 10;


signed main()
{
    FAST;
    int t;
    t=1;
    
    while(t--)
    {
        int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
        int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
        int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
        int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
        int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
        
        cin>>n;
        int a[n];
        map<int,int> mp,mp1;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            mp[a[i]]++;
        }
        
        ans=0;
        
        if(mp.count(1))
        {
            if(mp[1]==1)
            {
                cout<<1<<endl;
            }
            
            else
            {
                cout<<0<<endl;
            }
            
            return 0;
        }
        
        for(auto it : mp)
        {
            int num = it.first;
            count = it.second;
            
            for(i=2;i*num<N;i++)
            {
                mp1[i*num]++;
            }
            
            if(count==1 && !mp1.count(num))
            ans++;
            
        }
        
        cout<<ans<<endl;
        
        
    }
        
    
    
    
    
}


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

int main(){
  double a,b,h,m;
  cin >>a >>b >>h >>m;
  h *= 30;
  h += 0.5*m;
  m*=6;
  if(abs(h-m)>180) m += 360;
  double theta = abs(h-m);
  double c;
  c = sqrt(a*a + b*b - 2*a*b*cos(theta*pi/180));
  cout << fixed << setprecision(12) << c << endl;
  return 0;
}

Measured memory_bytes: 4164
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair <int, int> P;

int main() {
    ll n, x, m;
    cin >> n >> x >> m;

    vector<ll> ord(m, -1), sum(m, -1);
    ll ans = 0, cycle_sum = 0;
    ll cycle = 0, i = 0;
    for (; i < n; i++) {
        if (ord[x] != -1) {
            cycle = i - ord[x];
            ans += x;
            cycle_sum = ans - sum[x];
            x = x * x % m;
            break;
        }

        ord[x] = i;
        ans += x;
        sum[x] = ans;
        x = x * x % m;
    }

    i++;

    if (cycle) {
        ll cycle_num = (n - i) / cycle;
        ans += cycle_num * cycle_sum;
        i += cycle * cycle_num;
    }

    for (; i < n; i++) {
        ans += x;
        x = x * x % m;
    }

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

Measured memory_bytes: 4828
#include<iostream>
#include<map>
using namespace std;
int main(){
  int N,temp,ans=0;
  cin>>N;
  map<long,int> mp;
  for(int i=0;i<N;i++){
    cin>>temp;
    mp[temp]++;
  }
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    if(itr->second%2!=0)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> t(N + 1), x(N + 1), y(N + 1);
    t[0] = 0; x[0] = 0; y[0] = 0;
    for (int i = 1; i <= N; i++) cin >> t[i] >> x[i] >> y[i];

    string ans = "Yes";
    for (int i = 0; i < N; i++) {
        int dt = t[i + 1] - t[i];
        int md = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        if (dt%2 != md%2 || dt < md) {
            ans = "No";
            break;
        }
    }

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


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    int sum = 0;
    rep(i,m) {
        cin >> a[i];
        sum+=a[i];
    }
    if (n < sum){
        cout << -1;
    } else {
        cout << n-sum;
    }
    return 0;
}

Measured memory_bytes: 3200
import math

N = int(input())
P = input().split()
Q = input().split()
for a in range(N):
    P[a] = int(P[a])
    Q[a] = int(Q[a])

temp = [a for a in range(1, N+1)]
ans1 = 0
ans2 = 0

for a in range(N):
    ans1 += temp.index(P[a]) * math.factorial(N-a-1)
    temp.pop(temp.index(P[a]))


temp = [a for a in range(1, N+1)]

for a in range(N):
    ans2 += temp.index(Q[a]) * math.factorial(N-a-1)
    temp.pop(temp.index(Q[a]))

ans = ans1 - ans2
if ans < 0:
    ans *= -1

print(ans)

Measured memory_bytes: 3064
<?php

$a = str_split(trim(fgets(STDIN))); 
$b = str_split(trim(fgets(STDIN)));
$c = str_split(trim(fgets(STDIN)));

$t = 'a';
$win = '';
while(true){
  if ($t == 'a'){
    if (count($a) == 0) {
      $win = 'A';
      break;
    } else {
      $t = $a[0];
      array_splice($a,0,1);
      array_values($a);
    }
  } else if ($t == 'b'){
    if (count($b) == 0) {
      $win = 'B';
      break;
    } else {
      $t = $b[0];
      array_splice($b,0,1);
      array_values($b);
    }
  } else if ($t == 'c'){
    if (count($c) == 0) {
      $win = 'C';
      break;
    } else {
      $t = $c[0];
      array_splice($c,0,1);
      array_values($c);
    }
  }  
}

echo $win;


?>

Measured memory_bytes: 4604
a, b = map(str, input().split())

ans_a = []
for i in range(int(b)):
  ans_a.append(a)

ans_b = []
for i in range(int(a)):
  ans_b.append(b)

if "".join(ans_a) > "".join(ans_b):
  print("".join(ans_b))
else:
  print("".join(ans_a))



Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#define ll long long
#define int ll
using namespace std;
int suma,sumb,n,m,ans,k,cnt;
char s[(int)1e6+7];
main()
{
	cin>>n;
	scanf("%s",s+1);
	int t;
	cin>>t;
	while(t--){
		cin>>k;ans=suma=sumb=cnt=0;
		int l=1,r=1;
		for(int i=1;i<=n;i++){
			if(r-l<k){
				if(s[i]=='D') suma++;
				if(s[i]=='M') sumb++,cnt+=suma;
				if(s[i]=='C') ans+=cnt;
				r++;
			} else {
				if(s[l]=='D') suma--,cnt-=sumb;
				if(s[l]=='M') sumb--;
				l++;
				if(s[i]=='D') suma++;
				if(s[i]=='M') sumb++,cnt+=suma;
				if(s[i]=='C') ans+=cnt;
				r++;
			}
		}
		cout<<ans<<endl;
	}
}

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

int main() {
    while (1) {
        int H, W;
        cin >> H >> W;
        if (!(H)) break;
        
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if ((i > 0) && (i < (H - 1))) {
                    if ((j == 0) || (j == (W - 1))) {
                        cout << '#';
                    } else {
                        cout << '.';
                    }
                } else {
                    cout << '#';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3072
//-- Araz Jabrayilov --
//-- araz17---zuna#1041 --

#include <bits/stdc++.h>

#define ll long long
#define endl '\n'
#define F first
#define S second

using namespace std;

///int a[1005];

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

    int s = 0;

    cin >> s >> w;


    if(w >= s){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD = 1000000007LL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int a[1000005];
int sieve[1000005];
vector<int> prime;
int h[1000005];
int check(int x) {
  int tmp = sieve[x];
  while (x != 1) {
    tmp = sieve[x];
    if (x % tmp == 0 && h[tmp] > 1)
      return 0;
    while (x % tmp == 0)
      x /= tmp;
  }
  return 1;
}
void fact(int x) {
  int tmp = sieve[x];
  while (x != 1) {
    tmp = sieve[x];
    if (x % tmp == 0)
      h[tmp]++, x /= sieve[x];
    while (x % tmp == 0)
      x /= tmp;
  }
}
int main() {
  IOS;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int g = a[1];
  for (int i = 2; i <= n; i++) {
    g = __gcd(g, a[i]);
  }
  for (int i = 1; i <= 1000000; i++)
    sieve[i] = (i & 1 ? i : 2);
  for (int i = 3; i <= 1000000; i++) {
    if (sieve[i] == i)
      for (int j = i; j <= 1000000; j += i) {
        if (sieve[j] == j)
          sieve[j] = i;
      }
  }
  for (int i = 1; i <= n; i++) {
    fact(a[i]);
  }
  int ok = 1;
  for (int i = 1; i <= n; i++) {
    if (!check(a[i]))
      ok = 0;
  }
  if (ok) {
    cout << "pairwise coprime" << endl;
  } else if (!ok && g == 1) {
    cout << "setwise coprime" << endl;
  } else if (!ok) {
    cout << "not coprime" << endl;
  }
}


Measured memory_bytes: 15264
#include <iostream>
#include <cstdio>
using namespace std;
const int mod = 998244353;
int n, k, ans;
int jc[500010], ny[500010];
inline int ksm (int a, int p) {
	int res = 1;
	while (p) {
		if (p & 1) res = 1ll * res * a % mod;
		a = 1ll * a * a % mod, p >>= 1;
	}
	return res;
}
inline int C (int n, int m) { if (n < 0 || m < 0 || m > n) return 0; return 1ll * jc[n] * ny[m] % mod * ny[n - m] % mod; }
inline int solve (int x, int y, int t) { return C (x + y, x) - C (x + y, y - t); }
int main () {
	scanf ("%d%d", &n, &k);
	jc[0] = 1; for (int i = 1; i <= 500000; i++) jc[i] = 1ll * jc[i - 1] * i % mod;
	ny[500000] = ksm (jc[500000], mod - 2);
	for (int i = 500000; i >= 1; i--) ny[i - 1] = 1ll * ny[i] * i % mod;
	for (int r = max (n, (k + 1) / 2), b = k - r; r <= k; r++, b--)
		if (r == b) (ans += solve (r, b - 1, r - n + 1)) %= mod;
		else (ans += solve (r, b, r - n + 1)) %= mod;
	printf ("%d\n", (ans + mod) % mod);
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(ll factor[],ll n){
    ll a = 2;
    bool flag = false;
    for(int p = 2;p*p <= n;p++){
        while(n%p == 0){
            n/=p;
            factor[p]++;
        }
    }
    if(n!=1)  factor[n]++; //prime num
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}


void solve(void){
   ll n;
   cin >> n;
   ll a = 1;
   ll factor[n+1];

   rep(i,0,n+1){
       factor[i] = 1;
   }

   rep(i,1,n+1){
       Integer_factorization(factor,i);
   }

   rep(i,1,n+1){
      a =  (a * factor[i] % MOD);
    }

    cout << a << endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(a <= b) System.out.println(a);
      else System.out.println(a-1);
      sc.close();
    }
}

Measured memory_bytes: 21972
//disco2019_b.cpp
//Sat Nov 23 20:40:28 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll a[n];
	ll total = 0;
	for (int i=0;i<n;i++){
		cin >> a[i];
		total += a[i];
	}

	ll left = 0;
	ll right = total;

	ll ans = total;
	for (int i=0;i<n;i++){
		left += a[i];
		right -= a[i];
		if (abs(right-left)<ans){
			ans = abs(right-left);
		}
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);rep(i,0,n)cin>>var[i];
#define linit(type,var,n) list<type> var;rep(i,0,n){type _v;cin>>_v;var.push_back(_v);}
#define range(container) container.begin(),container.end()
#define rep(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull ntype;

typedef vector<ntype> vntype;
typedef list<ntype> lntype;

int main(void)
{
	init(ntype, a);
	init(ntype, b);
	init(ntype, c);
	init(ntype, d);

	int cb = c / b;
	if (c % b)cb++;
	int ad = a / d;
	if (a % d)ad++;

	outl(cb<=ad?"Yes":"No");

	return 0;
}

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

int main(){
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;
  if(x==w || y==h){
    cout << "No\n";
  }else if(w-x<r || h-y<r){
    cout << "No\n";
  }else if(r>x || r>y){
    cout << "No\n";
  }else{
    cout << "Yes\n";
  }
  return 0;
}



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

int main() {
  string S;
  cin >> S;
  if(S.at(0) == S.at(1) && S.at(1) != S.at(2) && S.at(2) == S.at(3)){
    cout << "Yes" << endl;
  }
  else if(S.at(0) == S.at(2) && S.at(3) != S.at(2) && S.at(1) == S.at(3)){
    cout << "Yes" << endl;
  }
  else if(S.at(0) == S.at(3) && S.at(1) != S.at(0) && S.at(1) == S.at(2)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,d[100];
	int i,j,sum;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&d[i]);
	}
	sum=0;
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			sum+=d[i]*d[j];
		}
	}
	printf("%d",sum);
	return 0;
}


Measured memory_bytes: 128
*> C + T = X
*> 2 * C + 4 * T = Y
*> T = X - C
*> 2 * C + 4 * (X - C) = Y
*> - 2 * C = Y - 4 * X
*> C = 2 * X - Y / 2
*> T = -X + Y / 2
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(30).
01 X          PIC 9(10).
01 Y          PIC 9(10).
01 C          PIC S9(10).
01 T          PIC S9(10).
01 ans        PIC X(30).
01 zs         PIC Z(9)9.

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO X Y.
  COMPUTE C = 2 * X - Y / 2.
  COMPUTE T = -X + Y / 2.
  IF ZERO <= C AND ZERO <= T AND C + T = X AND 2 * C + 4 * T = Y THEN
    DISPLAY "Yes"
  ELSE
    DISPLAY "No"
  END-IF.
  STOP RUN.


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }


struct UnionFind { // UnionFindTree
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int find(int x) {
    if(d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return false;
    if(-d[x] < -d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};


int main(){
    
    int n, q;
    cin >> n >> q;

    UnionFind uf(n);

    rep(i,q) {
        int type, u, v;
        cin >> type >> u >> v;
        if(type == 0) uf.unite(u,v);
        if(type == 1) cout << uf.same(u,v) << endl;
    }
}

Measured memory_bytes: 3876
#include <stdio.h>

void C(int n, int x){
	int i,j;
	int count=0;
	for(i=1;i<=x/3;i++){
		for(j=1;j<=(x-i)/2;j++){
			if(i<j && j<x-i-j && i<=n && j<=n && x-i-j<=n) count++;
		}
	}
	printf("%d",count);
}

int main(void){
	int n,x;
	scanf("%d %d",&n,&x);
	while(n>=1 || x>=1){
		C(n,x);
		printf("\n");
		scanf("%d %d",&n,&x);
	}
	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n/2;i++) swap(a[i],a[n+1-i]);
	for(int i=1;i<=n;i++)
		if(i+1>a[i+1]){
			for(int j=i+1;a[j]==i;j++) ans^=1;
			ans|=(a[i]-i)&1;
			return puts(ans? "First":"Second"),0;
		}
	return 0;
} 

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int rooms[4][3][10];
	int b, f, r, v, n, i1, i2, i3;

	for (i1 = 0; i1 < 4; i1++) {
		for (i2 = 0; i2 < 3; i2++) {
			for (i3 = 0; i3 < 10; i3++) {
				rooms[i1][i2][i3] = 0;
			}
		}
	}

	cin >> n;
	
	for (i1 = 0; i1 < n; i1++) {
		cin >> b >> f >> r >> v;
		rooms[b - 1][f - 1][r - 1] += v;
	}

	for (i1 = 0; i1 < 4; i1++) {
		for (i2 = 0; i2 < 3; i2++) {
			for (i3 = 0; i3 < 10; i3++) {
					printf(" %d", rooms[i1][i2][i3]);
			}
			printf("\n");
		}
		if(i1 < 3)
			printf("####################\n");
	}
	return 0;
}


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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl

ll n;
vector<ll> a(200000),dp(200000,1<<30),ans(200000);
vector<set<ll>> e(200000);

int dfs(ll v,ll prev){
    ll pos = lower_bound(all(dp),a[v])-dp.begin();
    ll temp = dp[pos];
    dp[pos] = a[v];
    ans[v]=(lower_bound(all(dp),1<<30)-dp.begin());
    
    for(ll i:e[v]) if(i!=prev) dfs(i,v);
    dp[pos] = temp;
    return 0;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll u,v;

    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n-1){
        cin >> u >> v;
        e[u-1].insert(v-1);
        e[v-1].insert(u-1);
    }
    dfs(0,0);

    rep(i,n) print(ans[i]);
    return 0;
}

Measured memory_bytes: 47472
N = int(input())

F = []
for i in range(N):
    F.append(list(map(int, input().split())))
    
P = []
for i in range(N):
    P.append(list(map(int, input().split())))

ans = -(10**10)
for i in range(2**10):
    one_or_zero = [0] * 10
    for j in range(10):
        if ((i >> j) & 1):
            one_or_zero[10 - 1 - j] = 1
    if 1 not in one_or_zero:
        pass
    else:
        tmp_ans = 0
        for m in range(N):
            count = 0
            for k in range(10):
                if F[m][k] == 1 and one_or_zero[k] == 1:
                    count += 1
            tmp_ans += P[m][count]
        if tmp_ans > ans:
            ans = tmp_ans

print(ans)


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


int main(){
    ll n,k;
    cin >> n >> k;
    ll i = 1;
    ll ans = 0;
    while(i <= n){
        i *= k;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    long long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if((a < b && a+v*t >= b+w*t) || (a > b && a-v*t <= b-w*t)) puts("YES");
    else puts("NO");
}


Measured memory_bytes: 3124