akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1;
const ll inf = hell, N=200005;
inline ll mult(ll x,ll y){return (x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
vector<ll> adj[N], revg[N], dist(N,inf);
void solve(){
	ll x;
	cin>>x;
	cout<<(x/500)*1000+((x%500)/5)*5<<"\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    static double[][] dp;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());

        double[] prob = new double[N];
        dp = new double[N+1][N/2 + 1];

        String[] input = br.readLine().split(" ");

        for(int i = 0; i < N; i++) {
            prob[i] = Double.parseDouble(input[i]);
        }

        System.out.println(calculateProbability(prob, N));
    }

    private static double calculateProbability(double[] prob, int N) {
        dp[0][0] = 1;

        for(int i=1; i<=N/2; i++) {
            dp[0][i] = dp[0][i-1] * (1 - prob[i-1]);
        }

        for(int i=1; i<=N; i++) {
            dp[i][0] = dp[i-1][0] * prob[i-1];
        }

        for(int i=1; i<=N; i++) {
            for(int j=1; j<=N/2; j++) {
                if(i + j <= N) {
                    dp[i][j] = prob[i+j-1] * dp[i-1][j] + (1- prob[i+j-1]) * dp[i][j-1];
                }
            }
        }

        double result = 0;

        for(int i=N; i>N/2; i--) {
            result += dp[i][N-i];
        }

        return result;
    }
}


Measured memory_bytes: 86816
n = int(input())
last_a_cnt = 0
top_b_cnt = 0
last_a_top_b_cnt = 0
ab_cnt = 0

for _ in range(n):
    s = input()
    ab_cnt += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A': last_a_top_b_cnt += 1
    elif s[0] == 'B' and s[-1] != 'A': top_b_cnt += 1
    elif s[0] != 'B' and s[-1] == 'A': last_a_cnt += 1


if last_a_cnt > 0:
    ans = 0
    last_a_cnt -= 1
    ans += last_a_top_b_cnt    
    ans += min(last_a_cnt+1, top_b_cnt)
    ans += ab_cnt

else:
    ans = 0
    if last_a_top_b_cnt > 0:
        ans += (last_a_top_b_cnt-1)
        ans += min(1, top_b_cnt)
    ans += ab_cnt

print(ans)

Measured memory_bytes: 9184
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m,k=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
AA=[0]
for i in range(n):
  AA.append(AA[-1]+A[i])
BB=[0]
for i in range(m):
  BB.append(BB[-1]+B[i])
ans=0
import bisect
for i in range(n+1):
  if AA[i]>k:
    break
  else:
    ans=max(ans,i+bisect.bisect_right(BB,k-AA[i])-1)
print(ans)


Measured memory_bytes: 47528
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int M,N;
vector<int> G[MAXN];
int ans[MAXN];

int inq[MAXN];
void BFS(){
    queue<int> q;
    q.push(1);
    inq[1]=1;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        int siz=G[u].size();
        for(int i=0;i<siz;i++){
            int v=G[u][i];
            if(inq[v]) continue;
            ans[v]=u;
            inq[v]=1;
            q.push(v);
        }
    }
}

void work(){
    scanf("%d%d",&N,&M);
    for(int i=1;i<=M;i++){
        int u,v; scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    BFS();
    printf("Yes\n");
    for(int i=2;i<=N;i++) printf("%d\n",ans[i]);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}











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

typedef long long ll;
typedef pair<int,int> pii;
int main(){
  string S;
  cin >> S;
  string ans = "";
  for(int i = 0; i < S.size(); i++){
    if(i % 2 == 0) ans += S[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  string s;
  cin>>s;
  stack<char> st;
  
  for(int i = 0; i < s.size(); i++)
  {
    if(s[i] == 'B') {
      if(!st.empty()) st.pop();
    } else {
      st.push(s[i]);
    }
  }
  int j = st.size();
  char ans[st.size()];
  int i = st.size() - 1;
  while(!st.empty()) {
    ans[i--] = st.top();
    st.pop();
  }
  
  for(int i = 0; i < j; i++)
  {
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
string toStr(int n) {
    ostringstream os; os << n;
    return os.str();
}
string add(string a, string b) {
    while (a.size() > b.size()) b = "0" + b;
    while (b.size() > a.size()) a = "0" + a;
    string res = "";
    int carry = 0;
    for (int i=a.size()-1; i>=0; --i) {
        int t = (a[i] - '0') + (b[i] - '0') + carry;
        res = toStr(t % 10) + res;
        carry = t / 10;
    }
    if (carry) res = "1" + res;

    return (res.size() <= 80) ? res : "overflow";
}
int main() {
    int n; cin >> n;
    string a, b;
    while (n--) {
        cin >> a >> b;
        cout << add(a, b) << endl;
    }
    return 0;
}

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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

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

class segtree{

    public:
    int N;
    ll init_val;
    vector<ll>dat;

    segtree(int _n,ll _init_val):init_val(_init_val){
        N=1;while(N < _n)N*=2;
        dat.resize(2*N - 1,_init_val);
    }

    void error_op(){cout<<init_val<<endl;}//クエリの例外処理

    void UpD_RMQ(int k,ll a){
        k += N-1;dat[k]=a;
        while(k > 0){
            k = (k-1)/2;//親へ移動
            dat[k] = min( dat[2*k+1],dat[2*k+2] );//子を比較(片方はさっき更新したやつ)
        }
    }

    void UpD_RSQ(int k,ll add){
        k += N-1;dat[k]+=add;
        while(k > 0){
            k=(k-1)/2; dat[k]+=add;
        }
    }

    ll Query_RSQ(int st,int ed,int idx,int l,int r){//st<=x<edのRSQを返す  ※dat[idx]は、l<=idx<rのクエリを持つ。
        //db3(dat[idx],l,r);ln;
        
        if(r <=st || ed <= l){return init_val;}
        else if(st <= l && r <= ed)return dat[idx];//答えが判明するのはここ
        else{
            ll ar = Query_RSQ(st,ed,idx*2 + 1, l , (l+r)/2 );
            ll al = Query_RSQ(st,ed,idx*2 + 2, (l+r)/2 , r);
            return ar+al;
        }
    }
    ll Query_RMQ(int st,int ed,int idx,int l,int r){//st<=x<edのRMQを返す  ※dat[idx]は、l<=idx<rのクエリを持つ。
        if(r <=st || ed <= l){return init_val;}
        else if(st<=l && r<=ed)return dat[idx];//答えが判明するのはここ
        else{
            ll ar = Query_RMQ(st,ed,idx*2 + 1, l , (l+r)/2 );//子へ再帰的にクエリを渡す
            ll al = Query_RMQ(st,ed,idx*2 + 2, (l+r)/2 , r );//
            return min(ar,al);
        }
    }

};

int main(){

    ll ans=0;
    int n,q;
    cin>>n>>q;

    segtree sgt(n,0);
    //db(sgt.N);ln;

    rep(i,q){
        int com;
        cin>>com;

        if(com==0){
            int i,x;
            cin>>i>>x;
            sgt.UpD_RSQ(--i,x);
        }else{
            int s,t;
            cin>>s>>t;--s;
            cout << sgt.Query_RSQ(s,t,0,0,(sgt.N)) <<endl;
        }
    }

    //cout<<ans<<endl;
    //cout <<fixed<<setprecision(16)<< << endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    return 0;
}



Measured memory_bytes: 4932
#include <bits/stdc++.h>
using namespace std;
struct Node {
  int parent, left, right;
};
using Nodes = vector<Node>;
void preWalk(const Nodes &nodes, int id) {
  if (id == -1) return;
  auto node = nodes[id];
  cout << ' ' << id;
  preWalk(nodes, node.left);
  preWalk(nodes, node.right);
}
void inWalk(const Nodes &nodes, int id) {
  if (id == -1) return;
  auto node = nodes[id];
  inWalk(nodes, node.left);
  cout << ' ' << id;
  inWalk(nodes, node.right);
}
void postWalk(const Nodes &nodes, int id) {
  if (id == -1) return;
  auto node = nodes[id];

  postWalk(nodes, node.left);
  postWalk(nodes, node.right);
  cout << ' ' << id;
}
int main() {
  int n, id;
  cin >> n;
  Nodes nodes(n, Node{-1, -1, -1});
  for (size_t i = 0; i < n; i++) {
    cin >> id;
    cin >> nodes[id].left >> nodes[id].right;
    if (nodes[id].left != -1) nodes[nodes[id].left].parent = nodes[id].left;
    if (nodes[id].right != -1) nodes[nodes[id].right].parent = nodes[id].right;
  }

  int rootId =
      distance(nodes.begin(), find_if(nodes.begin(), nodes.end(),
                                      [](Node x) { return x.parent == -1; }));

  cout << "Preorder" << endl;
  preWalk(nodes, rootId);
  cout << endl;
  cout << "Inorder" << endl;
  inWalk(nodes, rootId);
  cout << endl;
  cout << "Postorder" << endl;
  postWalk(nodes, rootId);
  cout << endl;
}


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

int main() {
    int A, B;
    cin >> A >> B;
    if (A == B) cout << 2 * A << endl;
    if (A < B) cout << 2 * B - 1 << endl;
    if (A > B) cout << 2 * A - 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <cassert>
#include <iterator>
using namespace std;
using VI = vector<int>;
VI adj[101010];
int dp[101010][11];

int main() {
    int n, m, q;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    cin >> q;
    VI vs, ds, cs;
    for (int i = 0; i < q; i++) {
        int v, d, c;
        cin >> v >> d >> c;
        v--;
        vs.push_back(v);
        ds.push_back(d);
        cs.push_back(c);
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 11; j++) {
            dp[i][j] = -1;
        }
    }
    
    for (int i = 0; i < q; i++) {
        dp[vs[i]][ds[i]] = i;
    }
    
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < n; j++) {
            if (j == 1) {
                
            }
            for (int k = 10; k > 0; k--) {
                if (dp[j][k] != -1) {
                    dp[j][k - 1] = max(dp[j][k - 1], dp[j][k]);
                    for (auto v: adj[j]) {
                        dp[v][k - 1] = max(dp[v][k - 1], dp[j][k]);
                    }
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (dp[i][0] == -1) {
            cout << 0 << endl;
        } else {
            cout << cs[dp[i][0]] << endl;
        }
    }
}


Measured memory_bytes: 12152
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(' ').map(String::toInt)
    val c = readLine()!!.split(' ').map(String::toInt)
    val ans = (0 until n).map { v[it] - c[it] }
        .filter { 0 <= it }
        .sum()
    println(ans)
}


Measured memory_bytes: 36452
$N=<>;
@B=sort{$b-$a}glob<>;
@T=shift@B;
$i=(@T=sort{$a-$b}@T)-1,@B=grep$i<0||!($_<$T[$i]&&$i--+push@T,$_),@B for 1..$N;
print@B?No:Yes


Measured memory_bytes: 77484
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

bool used[26];
bool used2[26];

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

    string s;
    cin >> s;
    int n = s.length();
    for(int i = 0; i < n; ++i)  used[(s[i] - 'a')] = true;
    
    bool update = false;
    for(int i = 0; i < 26; ++i){
        if(used[i]) continue;
        s += 'a' + i;
        update = true;
        break;
    }
    if(update){
        cout << s << endl;
        return 0;
    }
    string ans = "";
    used2[(s[n - 1] - 'a')] = true;
    for(int i = n - 2; i >= 0; --i){
        if(s[i] > s[i + 1]){
            used2[(s[i] - 'a')] = true;
            continue;
        }
        char c = s[n - 1];
        for(int j = s[i] - 'a' + 1; j < 26; ++j){
            if(used2[j]){
                c = j + 'a';
                break;
            }
        }
        ans += s.substr(0, i);
        ans += c;
        cout << ans << endl;
        return 0;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan =new Scanner(System.in);
        int k= scan.nextInt();
        int a= scan.nextInt();
        int b= scan.nextInt();

        for(int i=a;i<=b;i++){
            if(i%k==0){
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
    }
}


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

typedef long long ll;
#define nl "\n"
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define bs binary_search
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define sll stack<ll>
#define qll queue<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define vc vector <char>
#define matrix vector<vector<ll>>
#define all(x) x.begin(),x.end()
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define rloop(i,s,n) for(ll i=s;i>=n;i--)
#define test ll t ; cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
ll mod = 1000000007;  double pi = 3.1415926535;

// const ll mxn = 1e6 + 1;
// ll a[mxn];

// ll num_generator()
// {
// 	return rand() % 1000;
// }

// void array_generator(ll n)
// {
// 	loop(i, 0, n)		a[i] = rand() % 100;
// }

void solve()
{
	ll n;		cin >> n;
	ll a[n][3];
	loop(i, 0, n)
	{
		loop(j, 0, 3)		cin >> a[i][j];
	}
	ll dp[n + 1][4];
	memset(dp, 0, sizeof(dp));
	loop(i, 1, n + 1)
	{
		loop(j, 1, 4)
		{
			if (j == 1)	dp[i][j] = a[i - 1][j - 1] + max(dp[i - 1][j + 1], dp[i - 1][j + 2]);
			else if (j == 2)	dp[i][j] = a[i - 1][j - 1] + max(dp[i - 1][j - 1], dp[i - 1][j + 1]);
			else	dp[i][j] = a[i - 1][j - 1] + max(dp[i - 1][j - 2], dp[i - 1][j - 1]);
		}
	}
	cout << max({dp[n][1], dp[n][2], dp[n][3]}) << nl;
}

int main() {
	fast_io;
// #ifndef ONLINE_JUDGE
// 	freopen("input1.txt", "r", stdin);
// 	freopen("output1.txt", "w", stdout);
// #endif

	// test{
	solve();
	// }
	return 0;
}




Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, ans = 0;
  cin >> n;
  
  vector<int> l(n);

  for(int i = 0; i < n; i++)
    cin >> l.at(i);
  
  std::sort(l.begin(), l.end(), greater<int>());
  
  int a, b, c, i = 0, j, k;
  bool frag = 0;
  
  while(i < n - 2){
    a = l.at(i);
    j = i + 1;
    while(j < n - 1){
      b = l.at(j);
      k = j + 1;
      frag = 0;
      while(k < n){
        c = l.at(k);
        if(a >= b + c)
          break;
        ans++;
        //cout << a << ' ' << b << ' ' << c << endl;
        k++;
        frag = 1;
      }
      if(frag == 0)
        break;
      j++;
    }
    i++;
  }
  
  //for(int v = 0; v < n; v++)
   // cout << l.at(v) << endl;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;

signed main() {
	int a, b; cin >> a >> b;
	if ((a + b) & 1)puts("IMPOSSIBLE");
	else cout << (a + b) / 2 << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000


int main() {
	long long a[N];
	long long b[N];
	f(i, N) {
		a[i] = 0;
		b[i] = 0;
	}
	long long n, k;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%lld", &n);
	s = 0;
	f(i, n) {
		scanf("%lld", &a[i]);
		if (i % 2 == 0)s += a[i];
		else s -= a[i];
	}
	b[0] = s;
	f(i, n-1) {
		b[i + 1] = (2*a[i]) - b[i];
	}
	f(i, n) {
		printf("%lld", b[i]);
		if (i < n - 1)printf(" ");
		else printf("\n");
	}



	return 0;
}

Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next(), t = sc.next();
		String ans[] = { "Yes", "No" };
		sc.close();
		char s2[] = s.toCharArray();
		char t2[] = t.toCharArray();

		Arrays.sort(s2);
		Arrays.sort(t2);
		int n = t2.length;
		for (int i = 0; i < n / 2; ++i) {
			char tmp = t2[n - i - 1];
			t2[n - i - 1] = t2[i];
			t2[i] = tmp;
		}
		int a = 0;
		int n2 = s2.length;
		for (int i = 0; i < n2; ++i) {
			if (s2[i] > t2[i]) {
				a = 1;
				break;
			} else if (s2[i] < t2[i])
				break;
			if (i > n - 2) {
				a = 1;
				break;
			}
		}
		System.out.println(ans[a]);
	}

}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;  cin >> n >> m;
    cout << (n - 1) * (m - 1) << '\n';

    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
S = list(accumulate(A))
mod = 1000000007

ans = 0
for i in range(1, N):
  ans += (S[i-1]%mod)*(A[i]%mod)
  ans %= mod
print(ans%mod)

Measured memory_bytes: 31252
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define se second
#define ll long long
using namespace std;
    const ll N = 1e3 + 7;
ll used[N];
ll n , x , y , m ,a,  mx, cnt , b , ans ;
string s , s1 , s2;
deque<int>v;
int main(){
    cin >> n >> m;
    cout << 100 * max( 0ll , 10  - n ) + m;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
struct vs{
  modint val;
  int size;
};
struct aff{
  modint mul;
  modint add;
};
vs op(vs x,vs y){
  vs xy;
  xy.val=x.val+y.val;
  xy.size=x.size+y.size;
  return xy;
}
vs e(){
  vs x;
  x.val=0;
  x.size=0;
  return x;
}
vs app(aff f,vs s){
  vs fs;
  fs.val=f.mul*s.val+f.add*s.size;
  fs.size=s.size;
  return fs;
}
aff com(aff f,aff g){
  aff fg;
  fg.mul=f.mul*g.mul;
  fg.add=f.mul*g.add+f.add;
  return fg;
}
aff id(){
  aff f;
  f.mul=1;
  f.add=0;
  return f;
}
int main(){
  int n,q;
  cin>>n>>q;
  modint::set_mod(998244353);
  vector<vs> a(n);
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    a.at(i).val=x;
    a.at(i).size=1;
  }
  lazy_segtree<vs,op,e,aff,app,com,id> ls(a);
  for(int _=0;_<q;_++){
    int t,l,r;
    cin>>t>>l>>r;
    if(t==0){
      int b,c;
      cin>>b>>c;
      aff f;
      f.mul=b;
      f.add=c;
      ls.apply(l,r,f);
    }
    if(t==1)
      cout<<ls.prod(l,r).val.val()<<endl;
  }
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    ll x3 = x2 - (y2 - y1);
    ll y3 = y2 + (x2 - x1);
    ll x4 = x3 - (y3 - y2);
    ll y4 = y3 + (x3 - x2);

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

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

int main()
{
  int N, a=0;
  cin>>N;
  for(int i=1;i<=N;i++)
    for(int j=1;i<=N;j++){
      if((long long)(i*j)>=N) break;
      a++;
    }
  cout<<a<<endl;
}


Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>

using std::endl;
using std::string;

#define ll long long int
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std
ll N, K;
int main()
{
	IN >> N >> K;

	ll ans = 1;
	N -= K;

	while (N > 0)
	{
		N -= (K - 1);
		ans++;
	}

	OUT << ans << endl;


	return 0;
}

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

int main(){
  string a;
  cin >> a;
  string ans = "";
  for(int i = 0; i < a.size(); i ++){
      if(a[i] == ','){
          ans += ' ';
          continue;
      }
      ans += a[i];
  }
  
  cout << ans;
  return 0;
}


Measured memory_bytes: 3612
k, n = map(int, input().split())
a = list(map(int, input().split()))

max_dist = 0
for i in range(n - 1):
    max_dist = max(max_dist, abs(a[i] - a[i + 1]))
max_dist = max(max_dist,abs(k - a[n - 1] + a[0]))
print(k - max_dist)

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, m, a[5050], b[5050], c[5050], k;
i64 dp[3030];
bool route[3030], route2[3030];
vector<int> v[3030], v2[3030];
void serch(bool *r, int s, vector<int> vec[3030]){
	queue<int> q;
	q.push(s);
	while(!q.empty()){
		int now = q.front(); q.pop();
		if(r[now]) continue;
		r[now] = 1;
		for(int i = 0; i < vec[now].size(); i++){
			q.push(vec[now][i]);
		}
	}
}
void solve(){
	cin >> n >> m >> k;
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i] >> c[i];
		c[i] -= k;
		v[b[i]].push_back(a[i]);
		v2[a[i]].push_back(b[i]);
	}
	serch(route, n, v);
	serch(route2, 1, v2);
	for(int i = 0; i < m; i++){
		route[i] = (route[i]&route2[i]);
	}
	
	fill(dp,dp+3030,-LINF);
	dp[1] = 0;
	for(int t = 0; t <= n; t++){
		bool ok = 0, g = 0;
		for(int i = 0; i < m; i++){
			if(chmax(dp[b[i]], dp[a[i]]+c[i])){
				ok = 1;
				if(route[b[i]]) g = 1; 
			}
		}
		if(t == n && g){
			cout << -1 << endl;
			return;
		}
		if(!ok) break;
	}
	
	if(dp[n] < 0) cout << 0 << endl;
	else cout << dp[n] << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

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

using pii = pair<int, int>;

class union_find {
public:
    union_find(int n) : par(n, -1) {}

    int root(int x) {
        return par[x] < 0 ? x : par[x] = root(par[x]);
    }

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

private:
    vector<int> par;
};

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

    vector<vector<int>> g(n); // tree
    vector<int> pari(n);
    union_find uf(n);
    vector<pii> ans;
    for(int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        a--, b--;
        if(uf.unite(a, b)) {
            g[a].push_back(b);
            g[b].push_back(a);
        } else {
            ans.emplace_back(a,  b);
            pari[a] ^= 1;
        }
    }

    function<void(int, int)> dfs = [&] (int v, int p) {
        for(auto to : g[v]) {
            if(p == to) continue;
            dfs(to, v);
        }
        if(p != -1) { // not root
            if(pari[v]) {
                ans.emplace_back(v, p);
            } else {
                ans.emplace_back(p, v);
                pari[p] ^= 1;
            }
        }
    };
    dfs(0, -1);

    if(pari[0]) {
        cout << -1 << endl;
    } else {
        for(auto const& e : ans) {
            cout << e.first + 1 << " " << e.second + 1 << endl;
        }
    }
}


Measured memory_bytes: 12532
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let d: Vec<usize> = read_vec();
    if d[0] != 0 {
        println!("0");
        return;
    }
    let mut cntv: Vec<u64> = vec![0; n];
    for i in 0..n {
        cntv[d[i]] += 1;
    }

    let mut ans: u64 = 1;
    let mut cnt: usize = 1;
    for i in 1..n {
        if cnt >= n {
            break;
        }
        if cntv[i] == 0 {
            println!("0");
            return;
        }
        cnt += cntv[i] as usize;
        for _ in 0..cntv[i] {
            ans = ans * cntv[i - 1] % 998244353;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        string ans;
/*
        if (N % 26 == 0) {
                while (N) {
                        ans += 'z';
                        N /= 26;
                }
                cout << ans << endl;
                return 0;
        }
        
*/
        vll dig;
        while (N) {
                bool flg = false;
                ll num = N%26;
                if (num == 0) flg = true;
                // cout << num << endl;
                dig.push_back(num);

                N /= 26;
                if (flg) N -= 1;
        }

        //print1d(dig);
        
        rep(i, 0, len(dig)) {
                ll tmp = dig[len(dig)-1-i];
                char x = 'a' + tmp - 1;
                if (x == '`') x = 'z';
                cout << x;
        }
        cout << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <numeric>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define pb push_back
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};

int divNumBy100(int x) {
  int ret = 0;
  while (x % 100 == 0) {
    ret++;
    x /= 100;
  }
  return ret;
}
 
signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int D, N;
  cin >> D >> N;

  int ans = 1;
  while (true) {
    if (divNumBy100(ans) == D) {
      N--;
      if (N == 0) {
        cout << ans << endl;
        return 0;
      }
    }
    ans++;
  }
}

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

public class Solution
{
    static bool[] visited;
    static List<int> GetFriends(HashSet<int>[] graph, int start)
    {
        var friends = new List<int>() { start };
        var currents = new List<int>() { start };
        visited[start] = true;

        while (currents.Count > 0)
        {
            var nexts = new List<int>();
            foreach (var cur in currents)
            {
                foreach (var nei in graph[cur])
                {
                    if (visited[nei])
                    {
                        continue;
                    }
                    nexts.Add(nei);
                    friends.Add(nei);
                    visited[nei] = true;
                }
            }
            currents = nexts;
        }

        return friends;
    }

    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var M = vals[1];
        var K = vals[2];
        var friends = Enumerable.Range(0, N + 1).Select(_ => new HashSet<int>()).ToArray();
        var blocks = Enumerable.Range(0, N + 1).Select(_ => new HashSet<int>()).ToArray();
        visited = new bool[N + 1];

        for (int i = 0; i < M; i++)
        {
            vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var a = vals[0];
            var b = vals[1];
            friends[a].Add(b);
            friends[b].Add(a);
        }
        for (int i = 0; i < K; i++)
        {
            vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var c = vals[0];
            var d = vals[1];
            blocks[c].Add(d);
            blocks[d].Add(c);
        }

        var groups = new HashSet<int>[N + 1];
        for (int i = 1; i <= N; i++)
        {
            if (groups[i] == null)
            {
                var g = new HashSet<int>(GetFriends(friends, i));
                foreach (var f in g)
                {
                    groups[f] = g;
                }
            }
        }

        var candConts = new int[N + 1];
        for (int i = 1; i <= N; i++)
        {
            var count = groups[i].Count();
            count -= friends[i].Count(f => groups[i].Contains(f));
            count -= blocks[i].Count(f => groups[i].Contains(f));
            count--;
            candConts[i] = count;
        }

        Console.WriteLine(string.Join(" ", candConts.Skip(1)));
    }
}

Measured memory_bytes: 68208
'''
AtCoder Grand Contest 030
A - Poisonous Cookies
'''


def main():
    a, b, c = map(int, input().split())

    '''
    A + B + 1 ≥ C ならすべての毒入りの
    クッキーを食べることができるので B + C。
    そうでないなら答えはB + (A + B + 1) 。
    ※「+1」は最後にCを食べるので
    '''
    print(b + min(c, a + b + 1))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll w, h, x, y;
    cin >> w >> h >> x >> y;

    ll cnt = 0;
    if (2*x ==w && 2*y == h) cnt = 1;

    cout.precision(20);
    cout << (double) w * h / 2.0 << " " << cnt << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

int main(void) {
	string str;
	int num = 0;

	cin >> str;

	for (int i = 0; i < 4; i++) {
		if (str[i] == '+')
			num++;
		else if (str[i] == '-')
			num--;
	}

	cout << num << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF LONG_LONG_MAX
#define int long long
#define ar array
#define db double
#define pi 3.14159265358979323846
#define pow pw
int pw(int a,int b){
    int ans=1;
    while(b){
    if (b%2) ans*=a;
    a*=a;
    b/=2;
    }
    return(ans);
}
int n;
string st;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>st;
    int r=n-1,ans=0;
    while(st[r]=='W') r--;
    for (int i=0;i<n-1;i++)
    {
        if (st[i]=='W')
        {
            while(st[r]=='W') r--;
            if (r>i)
            {
            swap(st[i],st[r]);
            ans++;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3684
'use strict';

function Main(INPUT) {
    const input = INPUT.split("\n")[0].split(" ").map(n => Number(n));
    if (input[0] + input[1] == input[2] + input[3]) {
        console.log("Balanced");
    } else {
        console.log(input[0] + input[1] > input[2] + input[3] ? "Left" : "Right");
    }
}

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


Measured memory_bytes: 7624
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int H = 9;
const int W = 9;

int main() {
  int T; cin >>T;
  bool ff = false;
  REP(t, T){
    if(ff) cout <<endl; ff = true;
    int v[H][W];
    REP(i, H) REP(j, W) cin >>v[i][j];
    bool f[H][W];
    memset(f, 0, sizeof(f));

    REP(i, H) REP(j, W) FOR(k, j + 1, W) if(v[i][j] == v[i][k]) f[i][j] = f[i][k] = true;
    REP(i, W) REP(j, H) FOR(k, j + 1, H) if(v[j][i] == v[k][i]) f[j][i] = f[k][i] = true;
    REP(i, 9){
      int y = (i / 3) * 3, x = (i % 3) * 3;
      REP(a, 3) REP(b, 3) REP(c, 3) REP(d, 3) if(a != c && b != d && v[a + y][b + x] == v[c + y][d + x]) f[a + y][b + x] = f[c + y][d + x] = true;
    }
    REP(i, H){
      REP(j, W) cout <<(f[i][j] ? "*" : " ") <<v[i][j];
      cout <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define int ll
#define pll pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

void dfs(vector<int> adj[], int sv, vector<bool> &vis){
	vis[sv] = true;
	for(int i = 0; i < adj[sv].size(); i++){
		if(!vis[adj[sv][i]]){
			dfs(adj, adj[sv][i], vis);
		}
	}
}
ll power(ll x, ll y){  
	if(x == 1 || y == 0)
		return 1;
    ll res = 1;   
    x = x % mod; 
    if (x == 0) 
		return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res * x) % mod;  
        y = y >> 1; 
        x = (x * x) % mod;  
    }  
    return res;  
}  
ll nCr(ll n, ll r) {
    ll x = 1, y = 1;
    rep(i, 0, r) {
        x = x * (n - i) % mod;
        y = y * (i + 1) % mod;
    }
    return x * power(y, mod - 2) % mod;
}

signed main(){
	FASTIO
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	ll p[a], q[b], r[c];
	rep(i, 0, a)
		cin >> p[i];
	rep(i, 0, b)
		cin >> q[i];
	rep(i, 0, c)
		cin >> r[i];
	sort(p, p + a, greater<ll>());
	sort(q, q + b, greater<ll>());
	sort(r, r + c, greater<ll>());
	ll i = 0, j = 0, k = 0, ans = 0;
	while(x > 0 && y > 0 && i < a && j < b && k < c){
		if(max(p[i], q[j]) < r[k]){
			if(p[i+x-1] < q[j+y-1]){
				x--;
				ans += r[k];
				k++;
//				a--;
			}
			else{
				y--;
				ans += r[k];
				k++;
//				b--;
			}
		}
		else {
			if(x > 0 && p[i] >= r[k]){
				x--;
				ans += p[i];
				i++;
			}
			if(y > 0 && q[j] >= r[k]){
				y--;
				ans += q[j];
				j++;
			}
		}
	}
	while(x > 0){
		x--;
		if(k == c || p[i] >= r[k]){
			ans += p[i];
			i++;
		}
		else{
			ans += r[k];
			k++;
//			a--;
		}
	}
	while(y > 0){
		y--;
		if(k == c || q[j] >= r[k]){
			ans += q[j];
			j++;
		}
		else{
			ans += r[k];
			k++;
//			b--;
		}
	}
	cout << ans;
    return 0;
}
/*
1 2 2 2 1
2 4
5 1
1000
*/

Measured memory_bytes: 5972
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

antena = [a,b,c,d,e]
flag = 0
for i in range(len(antena)):
  for j in range(len(antena)):
    if abs(antena[i] - antena[j]) > k: flag = 1
      
if flag == 1:
  print(":(")
else:
  print("Yay!")

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

int main() {
  int K,S;
  cin >> K >> S;
  int counter = 0;

  for(int i = 0;i <= K;i++){
    for(int j = 0;j <= K;j++){
      if(i + j <= S && S - (i + j) <= K && S - (i + j) >= 0) counter++;
    }
  }

  cout << counter << endl;
}

Measured memory_bytes: 256
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: a,b,c,d,cd

    read*, a,b,c,d
    cd = lcd(c,d)
    print'(i0)', (b-a+1) - (b/c-(a-1)/c) - (b/d-(a-1)/d) + (b/cd-(a-1)/cd)


contains
function lcd(x,y) result(ret)
    integer(int64):: x,y,ret
    ret = x*y/gcd(x,y)
end function

recursive function gcd(x,y) result(ret)
    integer(int64):: x,y,ret

    if (mod(x,y) == 0) then
        ret = y
        return
    end if

    ret = gcd(y,mod(x,y))
end function
end program name

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Io.Read();
            switch (S)
            {
                case "SUN":
                    Console.WriteLine(7);
                    break;
                case "MON":
                    Console.WriteLine(6);
                    break;
                case "TUE":
                    Console.WriteLine(5);
                    break;
                case "WED":
                    Console.WriteLine(4);
                    break;
                case "THU":
                    Console.WriteLine(3);
                    break;
                case "FRI":
                    Console.WriteLine(2);
                    break;
                case "SAT":
                    Console.WriteLine(1);
                    break;
            }
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }

        class Io
        {
            public static string Read()
            {
                return Console.ReadLine();
            }

            public static IEnumerable<string> ReadRepeat(int count)
            {
                return Enumerable.Range(0, count).Select(_ => Read());
            }

            public static T Read<T>()
            {
                return (T)Convert.ChangeType(Read(), typeof(T));
            }

            public static IEnumerable<T> ReadRepeat<T>(int count)
            {
                return Enumerable.Range(0, count).Select(_ => Read<T>());
            }

            public static string[] ReadList(char devide = ' ')
            {
                return Read().Split(devide);
            }

            public static T[] ReadList<T>(char devide = ' ')
            {
                return ReadList(devide)
                    .Select(s => (T)Convert.ChangeType(s, typeof(T)))
                    .ToArray();
            }

            public static IEnumerable<T[]> ReadListRepeat<T>(int count, char devide = ' ')
            {
                return Enumerable.Range(0, count).Select(_ => ReadList<T>(devide));
            }

            public static void Write(string value)
            {
                Console.WriteLine(value);
            }
        }
    }
}


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

namespace _081
{
    class Program
    {
        static void Main(string[] args)
        {
        var n = int.Parse(Console.ReadLine());
        var input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var count = int.MaxValue;
        for (var i = 0; i < n; i++)
        {
            var tmp = 0;
            //偶数出なくなるまでwhileループ
            while (input[i] % 2 == 0)
            {
                //2で割った数をいれる
                input[i] /= 2;
                tmp++;
            }
            count = Math.Min(count, tmp);
        }   
        Console.WriteLine($"{count}");
        }
    }
}

Measured memory_bytes: 13268
def c(f)s=t=0;$a.map{|b|s+=b.to_i;if f&&s>=0;t+=s+1;s=-1 end;if !f&&s<=0;t-=s-1;s=1 end;f=!f};t;end;gets;$a=gets.split;p [c(p),c(!p)].min

Measured memory_bytes: 9348
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            double result = 1;

            for (var i = n; i > 1; i--)
            {
                result = (result * i) % (1e9 + 7);
            }


            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 105;
int n,m,c;
int b[N],a[N][N];

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>m>>c;
    for(int i=1;i<=m;i++) cin>>b[i];
    int ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) cin>>a[i][j];
        int sum = 0;
        for(int j=1;j<=m;j++) sum+=a[i][j]*b[j];
        sum+=c;
        if(sum>0) ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if a>=c or b>=c:
	print("No")
else:
	x=4*a*b
	y=(c-(a+b))*(c-(a+b))

	if x<y:
		print("Yes")
	else:
		print("No")

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

using namespace std;
typedef double db;
struct P{
    db x, y;
    P(){}
    P(db x, db y) : x(x) , y(y) {}
    db dot(P a){ return a.x*x + a.y*y; }
    P operator - (P a){ return P(x-a.x, y-a.y); }
    P operator + (P a){ return P(x+a.x, y+a.y); }
    P operator * (db a){ return P(x*a, y*a); }
    db len(){ return sqrt(x*x+y*y); }
};
typedef P V;
struct L{ P p, q; };

P projection(P a, L l){ //求得点a在l上的投影点坐标
    P tl = l.q - l.p;  //表示l的两个点形成的线段
    db ll = tl.len();  //线段长度
    db k = (a-l.p).dot(tl)/ll/ll;  //投影长度与线段长度的比值
    return P( l.p.x + k*tl.x, l.p.y + k*tl.y ); //最终结果
}

P reflection(P a, L l){ //点a关于点l的对称点
    P tmp = projection(a, l);
    return a+(tmp-a)*2;
}

int main(){
    //freopen("owo.in","r",stdin);
    int n;
    L l;
    scanf("%lf%lf%lf%lf",&l.p.x, &l.p.y, &l.q.x, &l.q.y);
    cin >> n;
    P a;
    while(n--){
        scanf("%lf%lf", &a.x, &a.y);
        P ta = reflection(a, l);
        printf("%.9lf %.9lf\n", ta.x, ta.y);
    }
    return 0;
}


Measured memory_bytes: 3224