akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string s;
  cin >> s;
  int K;
  cin >> K;
  K--;
  for (int i = 0; i < N; i++)
    if (s[i] != s[K]) s[i] = '*';
  cout << s << '\n';
  return 0;
}


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

int main(void) {
    double x0, y0, px, py, x, y, s = 0;

    scanf("%lf,%lf", &x0, &y0);
    px = x0;
    py = y0;
    while (scanf("%lf,%lf", &x, &y) == 2) {
        s += (x - px) * (y + py);
        px = x;
        py = y;
    }
    s += (x0 - px) * (y0 + py);
    printf("%.6lf", fabs(s) * .5);

    return 0;
}

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

int main(){
  ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
  int n; cin >> n;
  int odd = 0;
  while(n--){
    int tmp;
    cin >> tmp;
    odd += tmp%2;
  }
  if(odd%2==0) cout << "YES";
  else cout << "NO";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define repn(a,b,c) for(int a=b; a>=c; a--)
#define ll long long
#define sum(a,b) a=a+b
#define mem(a, b) memset(a, (b), sizeof(a))

int ganjil[100005];
int genap[100005];

int main(){
    
    mem(ganjil,0);
    mem(genap,0);
    
    int n;
    cin>>n;
    
    rep(i,1,n){
        
        int x;
        cin>>x;
        
        if(i%2==0){
            genap[x]++;
        }else if(i%2==1){
            ganjil[x]++;
        }
        
    }
    
    
    
    int even=-1;
    int odd=-1;
    int pos_o=0;
    int pos_e=0;
    rep(i,1,100005){
    
        if(ganjil[i]>odd){
            odd=ganjil[i];
            pos_o=i;
        }
        
        
        if(genap[i]>even){
            even=genap[i];
            pos_e=i;
        }
        
    }
    
    int jumlah=n/2;
    
    int dif_e=jumlah-even;
    int dif_o=jumlah-odd;
////
    if(pos_o>pos_e || pos_e > pos_o){
        int sum=dif_e+dif_o;
        cout<<sum<<endl;
    }else if(pos_o==pos_e ){
        
        int sum1=0; // for odd
        int sum2=0; // for even
        
        int pos=0;
        int cnt=0;
        int mx=-1;
        rep(i,1,100005){
            if(ganjil[i] > mx && i != pos_o){
                pos=i;
                mx=ganjil[i];
                
            }
        }
            
            int tambah=dif_o;
            
            tambah = tambah-mx;
            
            sum1=odd + tambah +dif_e;
            
            
            pos=0;
            mx=-1;
            
         
            rep(i,1,100005){
                if(genap[i]>mx && i!=pos_e){
                    pos=i;
                    mx=genap[i];
                }
            }
            
            tambah=dif_e;
            tambah=tambah-mx;
            
            sum2=even+tambah + dif_o;
            
            int ans=min(sum1,sum2);
            
            cout<<ans<<endl;
            
        
        
    }
    
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define pb push_back
int n;
long int max(long int a,long int b){
return a>b?a:b;    
}
int main() {
    
        int i,x,j;
    cin>>n;
    long int dp[n+1][3];int a[n][3];dp[0][0]=0,dp[0][1]=0,dp[0][2]=0;
        for(i=0;i<n;i++){
           for(j=0;j<3;j++){
           cin>>a[i][j];
          }
        }
            for(i=0;i<n;i++){
           for(j=0;j<3;j++){
             dp[i+1][j]=a[i][j]+max(dp[i][(j+1)%3],dp[i][(j+2)%3]);
           }
        }
     cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
        
    
	return 0;
}


Measured memory_bytes: 3712
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n;cin>>n;
    int res=0;
    for(int i=0;i<n;i++){
        int l,r;cin>>l>>r;
        res += r-l+1;
    }
    cout<<res<<endl;
}


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

using namespace std;

int n,dispo,ans;
priority_queue<int> card;
int state =1;

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>dispo;
        card.push(dispo);
    }
    while(card.size()!=0){
        ans+=state*card.top();
        state*=-1;
        card.pop();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    int n;
    cin >> n;
    vi d(n);
    rep(i, 0, n) cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[n / 2] - d[n / 2 - 1] << endl;
}


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

int main() {
 int n; string s;
 cin >> n >> s;
 int m=s.size();
 for(int i=0;i<m;i++){
   if(s[i]<='Z'-n){
   s[i]=s[i]+n;
   }
   else{
    s[i]=s[i]-26+n; 
   }
 }
 cout << s << endl;



}


Measured memory_bytes: 256
ary = []
ans = "No"
3.times do
  a = gets.split().map(&:to_i)
  ary << a
end
x = readlines.map(&:to_i)
x.each do |a|
  ary[0].map!{|x| x==a ? 0 : x}
  ary[1].map!{|x| x==a ? 0 : x}
  ary[2].map!{|x| x==a ? 0 : x}
end
if ary[0].inject(:+) == 0
  ans = "Yes"
elsif ary[1].inject(:+) == 0
  ans = "Yes"
elsif ary[2].inject(:+) == 0
  ans = "Yes"
elsif ary[0][0] + ary[1][0]  + ary[2][0] == 0
  ans = "Yes"
elsif ary[0][1] + ary[1][1]  + ary[2][1] == 0
  ans = "Yes"
elsif ary[0][2] + ary[1][2]  + ary[2][2] == 0
  ans = "Yes"
elsif ary[0][0] + ary[1][1]  + ary[2][2] == 0
  ans = "Yes"
elsif ary[0][2] + ary[1][1]  + ary[2][0] == 0
  ans = "Yes"
end
puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>

using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int k;
    cin >> k;
    for(int i = 0; i < n; i++){
        if(s[i] != s[k - 1]){
            s[i] = '*';
        }
    }
    cout << s;
}


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


int main()
{
  std::vector<std::string> v;

  // test "aba"
  
  std::string str;
  std::cin >> str;
  
  // str = "z";

  // test 4 - 1
   
  
  std::string tmpnum;
  std::cin >> tmpnum;
  int num;
  int m = std::atoi(tmpnum.c_str());
  num = m;
  
  // int num = 1;

  std::string tmp = "";

  for(int i = 0; i <= (int)str.length(); i++) {
    for(int j = 1; j <= num; j++) {
        tmp = str.substr(i, j);
        auto check = std::find(v.begin(), v.end(), tmp);
        if(check == v.end()) {
          if(tmp != "") {
            v.push_back(tmp);
          }
          tmp = "";
        }
    }
  }

  std::sort(v.begin(), v.end());
  
  /*
  for(auto n : v) {
      printf("%s\n", n.c_str());
  }
  */
  

  /*
  auto check = std::find(v.begin(), v.end(), "");
  if(check != v.end()) {
    v.erase(std::remove(v.begin(), v.end(), ""));
  }
  */

  printf("%s\n", v[num - 1].c_str());

}


Measured memory_bytes: 1024
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  map<string, int> mp;
  int q; cin >> q;
  for (int i = 0; i < q; ++i) {
    int op; cin >> op;
    if (op == 0) {
      string k; int x; cin >> k >> x;
      mp[k] = x;
    } else if (op == 1){
      string k; cin >> k;
      if (mp.find(k) == mp.end()) {
        cout << 0 << '\n';
      }
      else cout << mp[k] << '\n';
    } else {
      string k; cin >> k;
      mp.erase(k);
    }
  }

  return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int res = 0;
    for (int i = 0; i < s.size(); i++) {
        res += (s[i] == t[i]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    vals = []
    scores = []

    for i in range(n):
        a, b = [int(strn) for strn in input().split()]
        vals.append([a, b, True])
        scores.append([a + b, i])

    scores.sort(key=lambda x: x[0])

    total = 0
    count = 0
    while True:
        # Turn A
        candidate = scores[-1][1]
        total += int(vals[candidate][count % 2] * (count % 2 - 0.5) * -2)
        count += 1
        vals[candidate][2] = False
        del scores[-1]
        if count == len(vals):
            break

    print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 37876
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x;cin >> x;return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    ll x = nxt();
    if(x >= 30)Yes;
    else No;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    while(TC--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3812
#include <iostream>
#include <stdlib.h>
using namespace std;

int main() {
	int num;
	cin >> num;
	int cur;

	cur = num / 100;
	if (cur == 7) {
		cout << "Yes" << endl;
		return 0;
	}
	num = num % 100;
	cur = num / 10;
	if (cur == 7) {
		cout << "Yes" << endl;
		return 0;
	}
	cur = num % 10;
	if (cur == 7) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3596
#define GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<cassert>
using namespace std;

// BIT
template<class T> class BIT {
private:
	int n;
	vector<T> dat;//[1,n]
public:
	BIT(int maxn, int _n) {
		dat.assign(maxn + 1, 0);
		n = _n;
	}
	T sum(int i) {
		T res = 0;
		while (i > 0) {
			res += dat[i];
			i -= i & -i;
		}
		return res;
	}
	void add(int i, T x) {
		while (i <= n) {
			dat[i] += x;
			i += i & -i;
		}
	}
};
template<class T> vector<T> compress(vector<T>& a) {
	vector<T> b = a;
	vector<T> res(a.size());
	sort(b.begin(), b.end());
	b.erase(unique(b.begin(), b.end()), b.end());
	for (int i = 0; i < a.size(); i++)res[i] = 1 + (lower_bound(b.begin(), b.end(), a[i]) - b.begin());
	return res;
}
template<class T> long long inversion(vector<T> a, int maxn) {
	BIT<T> B(maxn, a.size());
	T res = 0;
	for (int i = 0; i < a.size(); i++) {
		res += i - B.sum(a[i]);
		B.add(a[i], 1);
	}
	return res;
}

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	a = compress(a);
	assert(*max_element(a.begin(),a.end()) <= 200020);
	cout << inversion(a, 200020) << '\n';
	return 0;
}


Measured memory_bytes: 7632
#include <bits/stdc++.h>
using namespace std;
template<typename M>
bool rMin(M &a, M b) {
    return b < a ? a = b, true : false;
}
const int maxV = 1e5 + 1;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n, w;
    cin>>n>>w;
    vector<long long> dp(maxV, 1e12);
    vector<long long> nextDP(maxV);
    dp[0] = 0;
    for(int i = 0; i< n; i++){
        long long a, b;
        cin>>a>>b;
        for(int j = 0; j<maxV; j++){
            nextDP[j] = dp[j];
            if(j - b < 0) continue;
            if(dp[j-b] || j - b == 0) 
                rMin(nextDP[j], dp[j-b] + a);
        }
        dp = nextDP;
    }
    int ans = 0;
    for(int i = 0; i< maxV; i++)
        if(dp[i] <= w)
            ans = i;
    cout<<ans<<"\n";
}


Measured memory_bytes: 4784
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

#define INF 1000000007

int main(){
  int n; cin >> n;
  vector<int> a(n);
  long long ans = 1;
  vector<int> used(100001, 0);
  used[0] = 3;
  vector<int> pre(100001, 0);
  for(int i = 0 ; i < n; i++){
    cin >> a[i];
    a[i]++;
    pre[a[i]]++;
  }

  for(int i = 0; i < n; i++){
    if(!pre[a[i]]) break;
    ans *= used[a[i]-1] - used[a[i]];
    ans %= INF;
    used[a[i]]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
n = int(input())
p = [item for sublist in [[int(input().split()[1])] if i != 0 else list(map(int, input().split())) for i in range(n)] for item in sublist]

def memolize(f):
    cache = {}

    def helper(x, y):
        if (x, y) not in cache:
            cache[(x, y)] = f(x, y)
        return cache[(x, y)]
    return helper

@memolize
def calcMatrixOrder(i, j):
    if i == j :
        return 0
    return min([calcMatrixOrder(i, k) + calcMatrixOrder(k + 1, j) + p[i]*p[k+1]*p[j + 1] for k in range(i, j)])

print(calcMatrixOrder(0, n - 1))



Measured memory_bytes: 6520
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
string s;
int ans;
signed main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			if (s[i] == 'p')ans--;
		}
		else {
			if (s[i] == 'g')ans++;
		}
	}
	cout << ans << endl;
	endre;
}


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

int main() {
  ll N,L;
  cin>>N>>L;
  int sum(0);
  if (L>=0){
    for (int i(L+1);i<L+N;i++) sum+=i;
    cout << sum << endl;
    return 0;
  } else if (L+N>0){
    for (int i(L);i<L+N;i++) sum+=i;
    cout << sum << endl;
    return 0;
  }else{
    for (int i(L);i<L+N-1;i++) sum+=i;
    cout << sum << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

c=sorted([a[i]-b[i] for i in range(n)],reverse=True)

if sum(c)<0:
    print(-1)
else:
    d=[i for i in c if i<0]
    cnt=len(d)
    d=abs(sum(d))
    i=0
    while d>0:
        d-=c[i]
        cnt+=1
        i+=1
    print(cnt)

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

string s, ans;
int calc(string t){
    int ans = t[0] - '0';
    int i = 1;
    while(i < 7){
        char op = t[i], n = t[i+1];
        if(op == '+') ans += n - '0';
        if(op == '-') ans -= n - '0';
        i+=2;
    }
    return ans;
}

void brute(int k = 0){
    if(k == 3){
        if(calc(s) == 7) ans = s;
        return;
    }

    s.insert(k*2 + 1, "+");
    brute(k+1);
    s.erase(k*2+1, 1);
    s.insert(k*2 + 1, "-");
    brute(k+1);
    s.erase(k*2+1, 1);
}

int main(){
    cin >> s;

    brute(0);
    cout << ans << "=7" << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>

struct Node {
	long long int value;
	int weight;
};
int bit_length(const int value) {
	return value == 0 ? 0 : 1 + bit_length(value >> 1);
}
int main() {
	constexpr int l_max = 100000;
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	int n; std::cin >> n;
	std::vector<Node> nodes(n); for (auto& node : nodes) std::cin >> node.value >> node.weight;
	std::vector<std::vector<Node>> cache(1 << (bit_length(n) >> 1));
	cache[0].push_back(Node{ 0, 0 }); cache[0].push_back(nodes[0]);
	for (auto i = 1; i < cache.size(); ++i) {
		const auto prev = ((i + 1) >> 1) - 1;
		cache[i] = cache[prev];
		const auto current = nodes[i];
		for (const auto& p : cache[prev]) {
			if (p.weight + current.weight > l_max) continue;
			cache[i].push_back(Node{ current.value + p.value, current.weight + p.weight });
		}
	}
	const auto comparator = [](const Node& a, const Node& b) {return a.weight == b.weight ? a.value > b.value : a.weight < b.weight; };
	for (auto& s : cache) {
		std::sort(s.begin(), s.end(), comparator);
		for (auto i = 1; i < s.size(); ++i) {
			s[i].value = std::max(s[i].value, s[i - 1].value);
		}
	}
	const auto find = [](const int weight, const Node& a) {return a.weight > weight; };
	int q;
	std::vector<Node> until; until.reserve(n - cache.size());
	for (std::cin >> q; q > 0; --q) {
		int u, l; std::cin >> u >> l;
		if (u <= cache.size()) {
			const auto pos = std::distance(cache[u - 1].begin(), std::upper_bound(cache[u - 1].begin(), cache[u - 1].end(), l, find));
			if (pos > 0) {
				std::cout << cache[u - 1][pos - 1].value << '\n';
			}
			else {
				std::cout << 0 << '\n';
			}
		}
		else {
			until.clear(); until.push_back(Node{ 0, 0 });
			while (u > cache.size()) {
				const auto node = nodes[u - 1];
				for (int i = until.size() - 1; i >= 0; --i) {
					if (until[i].weight + node.weight > l) continue;
					until.push_back(Node{ until[i].value + node.value, until[i].weight + node.weight });
				}
				u >>= 1;
			}
			long long int result{ 0 };
			for (const auto& n : until) {
				const auto pos = std::distance(cache[u - 1].begin(), std::upper_bound(cache[u - 1].begin(), cache[u - 1].end(), l - n.weight, find));
				if (pos > 0) {
					result = std::max(result, cache[u - 1][pos - 1].value + n.value);
				}
			}
			std::cout << result << '\n';
		}
	}
}


Measured memory_bytes: 10252
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<int> ans = new List<int>();
		List<int> a = A.ToList();
		for(int i=0;i<N;i++){
			for(int j=a.Count - 1;j>=0;j--){
				if(a[j] == j + 1){
					ans.Add(a[j]);
					a.RemoveAt(j);
					break;
				}
			}
			if(a.Count != (N - 1 - i)){
				Console.WriteLine(-1);
				return;
			}
		}
		
		ans.Reverse();
		Console.WriteLine(String.Join("\n",ans));
		
	}
	
	
	
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

const int MAXN = 101;

int N;
vector<vector<int> > q;

int lcm(int a, int b) {
  return a * b / __gcd(a, b);
}

int main() {
  while(cin >> N && N) {
    q.clear();
    vector<int> a(13), b(17), c(19), d(23);
    for(int i = 0; i < N; ++i) {
      int s, t; cin >> s >> t;
      vector<int> v(s);
      for(int j = 0; j < s; ++j) cin >> v[(j-t+s)%s];
      if(s == 13) for(int j = 0; j < 13; ++j) a[j] += v[j];
      else if(s == 17) for(int j = 0; j < 17; ++j) b[j] += v[j];
      else if(s == 19) for(int j = 0; j < 19; ++j) c[j] += v[j];
      else if(s == 23) for(int j = 0; j < 23; ++j) d[j] += v[j];
      else q.push_back(v);
    }
    int T = 1;
    for(int i = 0; i < q.size(); ++i) {
      T = lcm(T, q[i].size());
    }
    int res = 0;
    for(int t = 0; t < T; ++t) {
      int sum = 0;
      for(int i = 0; i < q.size(); ++i) {
	sum += q[i][t%q[i].size()];
      }
      res = max(res, sum);
    }
    res += *max_element(a.begin(), a.end());
    res += *max_element(b.begin(), b.end());
    res += *max_element(c.begin(), c.end());
    res += *max_element(d.begin(), d.end());
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
c = [0,0,0]
c[0] = [int(i) for i in input().split()]
c[1] = [int(i) for i in input().split()]
c[2] = [int(i) for i in input().split()]
for i in range(3):
    for j in range(3):
        d = [c[i][k] - c[j][k] for k in range(3)]
        if sum(d) != 3*d[0]: 
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
def S(n):
    return n*(n+1)//2

N, K = map(int, input().split())

ans = 0
mod = (10**9)+7
for i in range(K, N+2):
    min_sum = S(i-1)
    max_sum = S(N) - S(N-(i))
    ans += max_sum - min_sum + 1
    ans %= mod
print(ans%mod)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//都市iから伸びる道路の数=a,bに含まれるiの数
int main(){
 int N,M;
 cin >> N >> M;
 vector<int> a(M);
 vector<int> b(M);
 rep(i,M){
   cin >> a[i];
   cin >> b[i];
 }
 vector<int> num(N+1);//num[i]は都市iから伸びる道路の数
 for(int i = 1;i<=N;i++){
   int c = 0;
   for(int j = 0;j<M;j++){
     if(a[j] == i) c++;
     if(b[j] == i) c++;
   }
   num[i] = c;
 }

 for(int i = 1;i<=N;i++){
   cout << num[i] << endl;
 }
}

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

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

    ll n, x, m;
    cin >> n >> x >> m;

    ll prev = x;
    vector<ll> a;
    a.push_back(x);
    vector<ll> mods(m, -1);
    ll t = -1;
    ll si = -1;
    rep1(i, n){
        ll curr = prev*prev % m;
        if(mods[curr] == -1) mods[curr] = i;
        else{
            t = i - mods[curr];
            si = mods[curr];
            break;
        }
        a.push_back(curr);
        prev = curr;
    }
    // rep(i, a.size()) cout << a[i] << " ";
    // cout << endl;
    if(t == -1){
        ll res = 0;
        rep(i, static_cast<int>(a.size())) res += a[i];
        cout << res << endl;
        return 0;
    }

    ll res = 0;
    rep(i, si) res += a[i];
    ll loop = 0;
    for(int i = si; i < si+t; ++i) loop += a[i];
    ll times = (n-si) / t;
    res += loop * times;
    ll remain = (n-si) % t;
    for(int i = si; i < si+remain; ++i) res += a[i];
    // cout << si << " " << t << " " << loop << " " << times << " " << remain << endl;

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 4664
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n; string s;
    cin >> n >> s;
    bool answer = true;
    if(n%2 == 1) answer = false;
    rep(i,n/2){
        if(s[i] != s[i + n/2]) answer = false;
    }
    cout << (answer ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
int a[100005];
int b[100005];
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    int m = 0;
    for(int i=0; i<n; i++)
    {
        if(i+k>n)
            break;
        b[i] = a[i+k-1]-a[i];
        m++;
        //printf("**%d\n",b[i]);
    }
    sort(b,b+m);
    printf("%d\n",b[0]);
    return 0;
}


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

int main(){
	int n, m, l;
	long long int a[100][100];
	long long int b[100][100];
	long long int c[100][100] = {0};
	cin >> n >> m >> l;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++){
		for (int j = 0; j < l; j++){
			cin >> b[i][j];
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			for (int k = 0; k < m; k++){
				c[i][j] += a[i][k] * b[k][j];
			}
			if (j == 0){
				cout << c[i][j];
			}
			else{
				cout << " " << c[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1404
#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'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
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; }

const ll mod = 1e9+7;
ll n, k;

ll func(ll now, ll parent, const vii &tree) {
  ll res = 1;
  if(parent == -1) {
    res *= k;
    ll can_use = k-1;
    for(ll child : tree[now]) {
      if(child == parent) continue;
      res = res * can_use % mod;
      res = res * func(child, now, tree) % mod;
      can_use--;
    }
  }
  else {
    ll can_use = k-2;
    for(ll child : tree[now]) {
      if(child == parent) continue;
      res = res * can_use % mod;
      res = res * func(child, now, tree) % mod;
      can_use--;
    }
  }
  return res;
}

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

  cin >> n >> k;
  vii tree(n);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  ll ans = func(0, -1, tree);
  cout << ans << endl;
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i, s.size()){
      if(s[i] == t[0]){
	bool out = false;
	for(int j = i;j < s.size();j ++){
	  if(s[j] != t[j - i]){
	    out = true;
	  }
	}
	if(!out){
	  cout << n + i << '\n';
	  return 0;
	}
      }
    }
    cout << n * 2 << '\n';
    return 0;
}


Measured memory_bytes: 256
n,k,q=[int(i) for i in input().split()]
a=[]
for i in range(q):
    a.append(int(input()))
    
point=[k-q]*n

for i in a:
    point[i-1]+=1
    
for i in point:
    if i>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 56536
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum = 0;
    for (int i = 0; cin >> ch; i++)
    {
        if (ch == '\\')
            S1.push(i);
        else if (ch == '/' && S1.size() > 0)
        {
            int j = S1.top();
            S1.pop();
            sum += i - j;
            int a = i - j;
            while (S2.size() > 0 && S2.top().first > j)
            {
                a += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    while (S2.size() > 0)
    {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for (int i = 0; i < ans.size(); i++)
    {
        cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 x;
    cin >> x;

    s64 ans = 0;
    ans += (x / 500) * 1000;
    ans += (x % 500) / 5 * 5;

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
class UnionFind:
  def __init__(self,n):
    self.n=n
    self.parent=[i for i in range(n)] # 親
    self.rank=[1]*n # 木の高さ
    self.size=[1]*n # size[i]はiを根とするグループのサイズ
    
  def find(self,x): # xの根を返す
    if self.parent[x]==x:
      return x
    else:
      self.parent[x]=self.find(self.parent[x]) # 経路圧縮
      return self.parent[x]
  
  def unite(self,x,y): # x,yの属する集合を併合する
    x=self.find(x)
    y=self.find(y)
    if x != y:
      if self.rank[x]<self.rank[y]:
        self.parent[x]=y
        self.size[y]+=self.size[x]
      else:
        self.parent[y]=x
        self.size[x]+=self.size[y]
        if self.rank[x]==self.rank[y]:
          self.rank[x]+=1
  
  def is_same(self,x,y): # x,yが同じ集合に属するか判定する
    return self.find(x)==self.find(y)
  
  def group_size(self,x): # xが属する集合の大きさを返す
    return self.size[self.find(x)]
  
  def group_members(self,x): # xが属する集合の要素を返す
    root=self.find(x)
    return [ i for i in range(self.n) if self.find(i)==root]
  
  def roots(self): # すべての根をリストで返す
    return [ i for i,x in enumerate(self.parent) if i==x]
  
  def group_count(self): # 木の数を返す
    return len(self.roots())


N,M,K=map(int,input().split())
A,B=[0]*M,[0]*M
C,D=[0]*K,[0]*K

direct=[[] for i in range(N)]
uf=UnionFind(N)

for i in range(M):
  A[i],B[i]=map(int,input().split())
  A[i]-=1
  B[i]-=1
  direct[A[i]].append(B[i])
  direct[B[i]].append(A[i])
  uf.unite(A[i],B[i])

for i in range(K):
  C[i],D[i]=map(int,input().split())
  C[i]-=1
  D[i]-=1
  if uf.is_same(C[i],D[i]):
    direct[C[i]].append(D[i])
    direct[D[i]].append(C[i])

ans=[0]*N
for i in range(N):
  ans[i]=uf.group_size(i)-len(direct[i])-1
print(*ans)

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

int main() {
  int A,B;char op;cin>>A>>op>>B;
  if(op=='+') cout << A+B << endl;
  else cout << A-B << endl;
}


Measured memory_bytes: 256
import math
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))


# a, bの公約数の集合 と a, bの最大公約数の約数の集合 は同値
# a, bの最大公約数の約数のうち、互いに素なもの <= a, bの最大公約数の素因数と(と 1)
# n の素因数分解はO(√ n)で行える

# ↑の方法とは異なる解法
def prime_factrize(n: int) -> list:
    # 素因数のリストを取得(重複する素因数を含む)
    # 例 : 18 -> [2, 3, 3]
    if n < 2:
        return []
    p_factors = []
    # 2だけ先に取り分けておく
    while n % 2 == 0:
        p_factors.append(2)
        n //= 2
    # 残りの奇数の素因数を探す
    f = 3
    while f * f <= n:
        if n % f == 0:
            p_factors.append(f)
            n //= f
        else:
            f += 2
    # nが素数の場合
    if n != 1:
        p_factors.append(n)
    return p_factors


def main():
    a, b = LI()
    gcd = math.gcd(a, b)
    pf = prime_factrize(gcd)
    pf = set(pf)  # 素因数だけ取り出す
    # 1 を加える
    pf.add(1)
    print(len(pf))


main()


Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<P> ab(m);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        ab[i] = make_pair(a, b);
    }
    sort(ab.begin(), ab.end());
    int ans = 0;
    int minb = 0;
    rep(i, m){
        chmin(minb, ab[i].second);
        if (minb <= ab[i].first){
            minb = ab[i].second;
            ans++;
        }
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
  int d;
  cin >> d;
  if(d == 25) cout << "Christmas";
  else if(d == 24)cout << "Christmas Eve";
  else if(d == 23)cout << "Christmas Eve Eve";
  else cout << "Christmas Eve Eve Eve";
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val Vector(sx, sy, tx, ty) = Vector.fill(4)(sc.nextInt)

  val dx = tx - sx
  val dy = ty - sy

  val ur1 = "U" * dy + "R" * dx
  val dl1 = "D" * dy + "L" * dx
  val ur2 = "LU" + ur1 + "RD"
  val dl2 = "RD" + dl1 + "LU"

  println(ur1 + dl1 + ur2 + dl2)
}


Measured memory_bytes: 25416
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

bool kaibun(string s){
    size_t len = s.length();
    for(int i = 0; i < len/2; i++){
        if(s[i] != s[len-i-1]) return false;
    }
    return true;
}

int main(){
    string s;
    long long int N,M,K=0;
    cin >> s;
    string seven="7";
    if(s[0]=='7'|| s[1]=='7'||s[2]=='7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
  int N,K,T,U,V,L;
  cin>>N>>K>>T>>U>>V>>L;
  queue<int> que;
  double lv[10005];
  for(int i=0;i<=10000;i++){
    lv[i]=U;
  }
  for(int i=0;i<N;i++){
    int val;
    cin>>val;
    que.push(val);
  }
  int l=1,k=0,vl=0;
  while(l<=L){
    if(l<vl) lv[l]=V;
    if(l==que.front()){
      k++;
      que.pop();
    }
    if(k>0&&l>=vl){
      k--;
      lv[l]=V;
      vl=l+T*V;
    //  cout<<"a"<<vl<<endl;
    }
    if(l<vl && k>K){
      k--;
      vl=l+T*V;
  //    cout<<vl<<endl;
    }
    l++;
  }
  double ans=0.0;
  int x=0,y,v=lv[1],h=0;
  for(int i=0;i<L;i++){
    ans+=1.00/lv[i];
  }
  printf("%.10lf\n",ans);
  return 0;
}



Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;
using int64 = long long;
#define ForInt(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define ForItr(it, itBegin, itEnd) for (auto (it) = (itBegin); (it) != (itEnd); ++(it))


int main()
{
	int n;
	cin >> n;
	map<string, int> map;
	ForInt(i, n)
	{
		string tmp;
		cin >> tmp;
		char chs[11];
		ForInt(j, 10)
		{
			chs[j] = tmp[j];
		}
		sort(chs, chs + 10);
		chs[10] = '\0';
		string key = chs;
		++map[key];
	}
	int64 c = 0;
	ForItr(it, map.begin(), map.end())
	{
		ForInt(i, it->second)
		{
			c += i;
		}
	}
	cout << c << endl;


	return 0;
}


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

int main() {
    string s;
    cin >> s;
    string t;
    cin >> t;
    int flag = 0;
    if(s == t){
        flag = 1;
    }
    char tmp = '0';
    for(int i = 0; i < s.size(); i++){
        tmp = s[s.size()-1];
        for(int j = s.size()-1; j >= 0; j--){
            s[j+1] = s[j];
        }
        s[0] = tmp;
        if(s == t){
            flag = 1;
            break;
        }
    }
    if(flag == 0){
        cout << "No";
    } else {
        cout << "Yes";
    }
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    set<int> s;
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    int ans = 0;
    for (auto x : a) {
        s.insert(x);
        ans += (*s.begin() >= x);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 11264
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll calc(ll x,ll y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

int N;
ll day_len[100],now_t[100],access[100][24];
ll table1[60000],table2[100000];



void func(){

	for(int i = 0; i < 60000; i++)table1[i] = 0;
	for(int i = 0; i < 100000; i++)table2[i] = 0;

	ll cicle1 = 1,cicle2 = 1,common;

	for(int i = 0; i < N; i++){
		scanf("%lld %lld",&day_len[i],&now_t[i]);
		if(day_len[i] == 13 || day_len[i] == 17 || day_len[i] == 19 || day_len[i] == 23){
			if(cicle2 >= day_len[i]){
				common = calc(cicle2,day_len[i]);
			}else{
				common = calc(day_len[i],cicle2);
			}
			cicle2 = (cicle2*day_len[i])/common;
		}else{
			if(cicle1 >= day_len[i]){
				common = calc(cicle1,day_len[i]);
			}else{
				common = calc(day_len[i],cicle1);
			}
			cicle1 = (cicle1*day_len[i])/common;
		}

		for(int k = 0; k < day_len[i]; k++)scanf("%d",&access[i][k]);
	}

	for(int i = 0; i < N; i++){
		if(day_len[i] == 13 || day_len[i] == 17 || day_len[i] == 19 || day_len[i] == 23){
			for(int k = 0; k < cicle2; k++){
				table2[k] += access[i][(now_t[i]+k)%day_len[i]];
			}
		}else{
			for(int k = 0; k < cicle1; k++){
				table1[k] +=  access[i][(now_t[i]+k)%day_len[i]];
			}
		}
	}

	ll maximum1 = 0,maximum2 = 0;
	for(int k = 0; k < cicle1; k++)maximum1 = max(maximum1,table1[k]);
	for(int k = 0; k < cicle2; k++)maximum2 = max(maximum2,table2[k]);

	printf("%lld\n",maximum1+maximum2);

}


int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

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

int main()
{
	ll A, B, C;
	cin >> A >> B >> C;
	ll sum = 0;

	while (A + B > 0 && C > 0)
	{

		if (A > 0 && C > 0)
		{
			C--;
			A--;
			sum++;
		}

		if (B > 0 && C > 0)
		{
			C--;
			B--;
			sum += 2;
		}
	}
	
	if (C > 0) {
		sum++;
	}
	
	sum += B;
	cout << sum <<endl;
	return 0;
}


Measured memory_bytes: 256
def gcd(m, n):
    while n:
        m, n = n, m % n
    return m


N = int(input())

A = list(map(int, input().split()))

hoge = [A[0]]

for i in range(1, len(A)):
    hoge.append(gcd(hoge[-1], A[i]))

print(hoge[-1])


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

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<vector<char>> pic(h+2, vector<char>(w+2));
    for (int i = 0; i < h+2; i++) {
        for (int j = 0; j < w+2; j++) {
            if (i == 0 || i == h+1 || j == 0 || j == w+1) pic[i][j] = '#';
            else cin >> pic[i][j];
        }
    }

    for (int i = 0; i < h+2; i++) {
        for (int j = 0; j < w+2; j++) {
            cout << pic[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
        char ch;
        char cmpA[] = {'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'};
        char result;
        int i,j,N,count;

        scanf("%c",&ch);

        for(j = 0; j < 26;j++){
                if(ch == cmpA[j]){
                        result = cmpA[j+1];
                        break;
                }
        }
        printf("%c",result);


        return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long int n, x;
  cin >> n >> x;
  long long int a, prev;
  cin >> prev;
  long long int ans=0;
  for(int i=1; i<n; i++){
    cin >> a;
    if(a+prev>x){
      ans += a+prev-x;
      if(x-prev<0) prev = 0;
      else prev = x-prev;
    }else{
      prev = a;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
main = do
    str <- getLine
    n <- getLine
    oCommands <- getContents
    let commands = map words $ lines oCommands
    runCommand commands str


runCommand [] _ = return ()
runCommand (x:xs) str = do
    let cmd = x!!0
    case cmd of
        "print"   -> do
                         putStrLn $ slice str (read (x!!1) :: Int) (read (x!!2) :: Int)
                         runCommand xs str
        "reverse" -> runCommand xs $ rev str (read (x!!1) :: Int) (read (x!!2) :: Int)
        "replace" -> runCommand xs $ rep str (read (x!!1) :: Int) (read (x!!2) :: Int) (x!!3)

slice str from to = take (to - from + 1) $ drop from str

rev str from to = (take from str) ++ (reverse (slice str from to)) ++ (drop (to+1) str)

rep str from to nstr = (take from str) ++ nstr ++ (drop (to+1) str)



Measured memory_bytes: 5536
n,m,x,y = map(int, input().strip().split())
mx = max([int(t) for t in input().strip().split()])
my = min([int(t) for t in input().strip().split()])
for z in range(mx+1, my+1):
    if x < z < y:
        print("No War")
        exit(0)
print("War")

Measured memory_bytes: 3060