akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926435;

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

int main()
{
    ll K, S;
    cin >> K >> S;
    ll sum = 0;
    for (ll i = 0; i <= K; i++)
    {
        for (ll j = 0; j <= K; j++)
        {
            if (S - i - j >= 0 && S - i - j <= K) {
                sum += 1;
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2")

typedef long long ll;
long long a;
long double b;


int main()
{
	ios::sync_with_stdio(false);
    cin >> a;
    cin >> b;
	cout << ll(a * b) << endl; 
	return 0;
}


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

struct Trie {
    struct Node {
        vector<int> child;
        bool is_end = false;

        Node() : child(26, -1) {};
    };

    vector<Node> nodes;
    vector<vector<int>> paths;

    Trie(int N) : nodes(1), paths(N) {}

    void add(string& s, int id) {
        int node = 0;
        for (char c : s) {
            paths[id].push_back(node);
            if (nodes[node].child[c - 'a'] == -1) {
                nodes[node].child[c - 'a'] = nodes.size();
                nodes.emplace_back();
            }
            node = nodes[node].child[c - 'a'];
        }
        nodes[node].is_end = true;
    }

    int query(string& s, int id) {
        int ret = 0;
        set<char> suffix;
        for (int j = s.size() - 1; j >= 0; j--) {
            suffix.insert(s[j]);
            int node = paths[id][j];
            for (char c : suffix) {
                if (nodes[node].child[c - 'a'] != -1) {
                    ret += nodes[nodes[node].child[c - 'a']].is_end;
                }
            }
        }
        return ret;
    }
};

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

    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        reverse(S[i].begin(), S[i].end());
    }
    Trie trie(N);
    ll ans = 0;
    for (int i = 0; i < N; i++) trie.add(S[i], i);
    for (int i = 0; i < N; i++) ans += trie.query(S[i], i);
    ans -= N;
    cout << ans << endl;
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int a, b;
    cin >> a >> b;
    cout << (ll)a * b / gcd(a, b) << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

map<ll,ll> zip;
int unzip[1000010];

int compress(vector<ll> &x) {
   sort(x.begin(), x.end());
   x.erase(unique(x.begin(),x.end()),x.end());
   for(int i = 0; i < x.size(); i++){
       zip[x[i]] = i;
       unzip[i] = x[i];
   }
   return x.size();
}

int main() {
     ll a,b,q;
     vector<ll> values;
     ll s[100001],t[100001],x[100001];
     ll s_comp[100001],t_comp[100001],x_comp[100001];
     std::cin >> a>>b>>q;
     for (int i = 0; i < a; i++) {
         std::cin >> s[i];
         values.push_back(s[i]);
     }
     for (int i = 0; i < b; i++) {
         std::cin >> t[i];
         values.push_back(t[i]);
     }
     for (int i = 0; i < q; i++) {
         std::cin >> x[i];
         values.push_back(x[i]);
     }
     compress(values);
     
     for (int i = 0; i < a; i++) {
         s_comp[i] = zip[s[i]];
     }
     for (int i = 0; i < b; i++) {
         t_comp[i] = zip[t[i]];
     }
     for (int i = 0; i < q; i++) {
         x_comp[i] = zip[x[i]];
     }
     
     
     for (int i = 0; i < q; i++) {
         ll right_s = distance( s_comp , lower_bound( s_comp, s_comp + a, x_comp[i] ) );
         ll right_t = distance( t_comp , lower_bound( t_comp, t_comp + b, x_comp[i] ) );
         ll left_s = distance( s_comp , lower_bound( s_comp, s_comp + a, x_comp[i] ) ) -1 ;
         ll left_t = distance( t_comp , lower_bound( t_comp, t_comp + b, x_comp[i] ) ) -1 ;
         ll result = 100000000000;
         ll t1,t2,t3,t4;
         
         if( min( s[right_s], t[right_t] ) - x[i] >=0){
             result = min(  result ,  abs( max( s[right_s], t[right_t] ) - x[i]  ));
         }
         
         
         t1 = result;
         if(left_t >= 0 && left_s >=0){
             t2 = x[i] - min( s[left_s], t[left_t] );
             result = min(  result , x[i] - min( s[left_s], t[left_t] ));
         }
         if(left_t >=0){
             t3 = min( abs(t[left_t] - x[i]),abs(s[right_s] - x[i])) *2 +   max( abs(t[left_t] - x[i]),abs(s[right_s] - x[i])) ;
             result = min( result, min( abs(t[left_t] - x[i]),abs(s[right_s] - x[i])) *2 +   max( abs(t[left_t] - x[i]),abs(s[right_s] - x[i]))  );
         }
         if(left_s>=0){
             t4 = min( abs(s[left_s] - x[i]),abs(t[right_t] - x[i]) ) *2 +   max( abs(s[left_s] - x[i]),abs(t[right_t] - x[i])  );
             result = min( result, min( abs(s[left_s] - x[i]),abs(t[right_t] - x[i]) ) *2 +   max( abs(s[left_s] - x[i]),abs(t[right_t] - x[i])  ) );
         }
        //  std::cout << t1 <<" "<<t2<<" "<<t3 << " "<<t4 << std::endl;
         std::cout << result << std::endl;
     }
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

map< int, int > ret;

map< int, int > prime_factor(int n) {
    for(int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
  }
  if (n != 1) ret[n]++;
  return ret;
}
int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    for (int i = 2; i <= n; i++) {
        prime_factor(i);
    }
    for (auto p : ret) {
        (ans *= (p.second + 1)) %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    char s[3];
    cin >> s[0] >> s[1] >> s[2];
    int cnt = 0;
    if (s[0] == '1') cnt++;
    if (s[1] == '1') cnt++;
    if (s[2] == '1') cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int k; ll a[100000];
	cin >> k;
	rep(i, k) {
		cin >> a[i];
	}
	ll le = 2; ll ri = 2;
	bool f = true;
	per(i, k) {
		ll dle = (le + a[i] - (ll)1) / a[i];
		ll nele = dle * a[i];
		if (nele > ri) {
			f = false; break;
		}
		ll dri = ri / a[i];
		ll neri = dri * a[i];
		if (neri < le) {
			f = false; break;
		}
		le = nele; ri = neri + a[i] - (ll)1;
	}
	if (f) {
		cout << le << " " << ri << endl;
	}
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;



int main()

{

	int n;

	cin>>n;

	int m,c;

	cin>>m>>c;

	int t=0;

	int a[m],b[m];

	for(int i=0;i<m;i++)

	{

		cin>>b[i];

	}

	int d=0;

	for(int i=0;i<n;i++)

	{

		for(int j=0;j<m;j++)

		{

			cin>>a[j];

			d+=a[j]*b[j];

		}

		if(d+c>0)

		{

			t++;

		}

		d=0;

	 } 

	 cout<<t<<endl;

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <queue>

#define INF 922337203685477580
typedef long long ll;

using namespace std;

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

  cout << S / 60 / 60 << ":" << (S / 60) % 60 << ":" << S % 60 << endl;
  return 0;
}

Measured memory_bytes: 3084
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut ans = 0;
    for i in a..b + 1 {
        let s: String = format!("{}", i);
        let t: String = s.chars().rev().collect();
        if s == t {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)
const long double PI = (acos(-1));

int main() {

	int n;
	cin >> n;

	vector<int> p(n);
	rep(i, 0, n) cin >> p[i];

	int sum = 0;
	sort(p.begin(), p.end());

	rep(i, 0, n - 1) sum += p[i];
	sum += p[n - 1] / 2;

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a, b, c, d, n, x;
	for (;;) {
		d = 0;
		cin >> n >> x;
		if (n == 0 && x == 0) {
			return 0;
		}
		for (a = 1; a < n + 1; a = a + 1) {
			for (b = 1; b < n + 1; b = b + 1) {
				for (c = 1; c < n + 1; c = c + 1) {
					if (a != b && b != c && a != c) {
						if (a + b + c == x) {
							d = d + 1;
						}
					}
				}
			}
		}
		cout << d / 6 << endl;
	}
}


Measured memory_bytes: 3104
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)



signed main(){
	int A,B,C;
	cin>>A>>B>>C;
	if(C<min(A,B)||max(A,B)<C){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();
    if(s.length%2==1){
      System.out.println("No");
      return;
    }else{
      Arrays.sort(s);
      char x = s[0];
      int count = 0;
      for(int i=0;i<s.length;i++){
        if(x==s[i]){
          count++;
        }else{
          if(count%2==1){
            System.out.println("No");
            return;
          }
          count = 1;
          x = s[i];
        }
      }
      System.out.println("Yes");
    }
  }
}

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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define eb emplace_back
#define pb push_back
#define lli long long int
#define modn 1000000007
#define NL '\n'

using namespace std;

typedef vector< int > vi;
typedef vector< char > vc;
typedef vector< bool > vb;
typedef vector< string > vs;
typedef vector< lli > vli;
typedef vector< vector< char > > vvc;
typedef vector< vector< int > > vvi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef pair< lli, int> pli;
typedef pair< lli, lli> pll;
typedef set< int > si;
typedef set< ii > sii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	#ifdef LOCAL_TEST
		clock_t z = clock();
    	ifstream h("in");
	    ofstream g("out");
	#else
	    #define h cin
	    #define g cout
	#endif // LOCAL_TEST
	
	int n, m;
	h >> n >> m;
	vi v(n);
	vb vis(n);
	int x;
	string s;
	f(i, 0, m, 1){
		h >> x >> s;
		if (s == "WA" && !vis[x - 1])
			v[x - 1]++;
		else if (s == "AC")
			vis[x - 1] = true;
	}
	int ans = 0;
	f(i, 0, n, 1){
		if (vis[i])
			ans += v[i];
	}
	g << count(all(vis), true) << ' ' << ans;

	
	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif // LOCAL_TEST
}



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

using ll=long long;

int cnt[100010];
int n, a;

int main(){
  cin >> n;
  rep(i,n){
    cin >> a;
    if(a != 0) cnt[a-1]++;
    cnt[a]++;
    cnt[a+1]++;
  }
  int ans = 0;
  rep(i,100010) ans = max(ans, cnt[i]);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

multiset < int > s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	int a;
	set < int >::const_iterator it;
	for(int i=0; i<n; i++){
		cin >> a;
		if(!s.empty()){
			it=s.lower_bound(a);
			if(it==s.end()){
				it--;
			}
			while(it!=s.begin() && *it>=a){
				it--;
			}
//			cout << "manji " <<  *it << endl;
			if(*it<a){
//				cout <<"naso " << *it << endl;
				s.erase(it);
			}
		}
		s.insert(a);
	}
	cout << s.size() << '\n';
	return 0;
}

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

typedef long long ll;
typedef long double ld;

int MOD=1000000007;


int main(){
    ll K,A,B,ans=0;
    cin >> K >> A >> B;
    for(ll i=A; i<=B; i++){
        if(i%K==0) ans=1;
    }
    if(ans==1) cout << "OK" << endl;
    else cout << "NG" << endl;
    }


Measured memory_bytes: 3632
N = int(input())
H = list(map(int, input().split()))
cnt = 0
result = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        if cnt > result:
            result = cnt
        cnt = 0
if cnt > result:
  	result = cnt
print(result)

Measured memory_bytes: 14224
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    limit = 10**18

    _mul = 1
    for a in A:
        _mul *= a
        if _mul > limit:
            _mul = limit+1

    if _mul > limit:
        print(-1)
    else:
        print(_mul)

if __name__ == "__main__":
    resolve()

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

vector<bool> visited;
bool dfs(int v, const vector<vector<bool>> &E, int s){
    if (visited[v] and v == s) return false;
    if (visited[v]) return true;
    visited[v] = true;
    for (int i = 0; i < 26; i++){
        if (!E[v][i]) continue;
        if (!dfs(i, E, s)) return false;
    }
    return true;
}

bool solve(){
    const int INF = 1e9;
    int h, w;
    cin >> h >> w;
    vector<string> S(h);
    vector<vector<bool>> C(26, vector<bool>(26, 0));
    for (auto &s: S)
        cin >> s;
    for (char u = 'A'; u <= 'Z'; u++){
        int min_h = INF, min_w = INF, max_h = -INF, max_w = -INF;
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if (S[i][j] != u) continue;
                min_h = min(min_h, i);
                min_w = min(min_w, j);
                max_h = max(max_h, i);
                max_w = max(max_w, j);
            }
        }

        for (int i = min_h; i <= max_h; i++){
            for (int j = min_w; j <= max_w; j++){
                auto t = S[i][j];
                if (t == u) continue;
                if (t == '.') return false;
                C[u - 'A'][t - 'A'] = true;
            }
        }
    }
    for (int i = 0; i < 26; i++){
        visited.assign(26, false);
        if (!dfs(i, C, i)) return false;
    }
    return true;
}

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);
    
    int T_;
    cin >> T_;
    for (int t_ = 0; t_ < T_; t_++){
        puts(solve() ? "SAFE" : "SUSPICIOUS");
    }
}


Measured memory_bytes: 3124
n = int(input())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
for p in range(1, 5):
    if p < 4:
        print(sum(abs(x - y) ** p for x, y in zip(X, Y)) ** (1 / p))
    else:
        print(max(abs(x - y) for x, y in zip(X, Y)))

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

int main(){
  int N,K;
  cin >> N >> K;
  
  int count = 1;
  int i = 0;
  
  for(; count<K && i<N; i++){
    count *= 2;
  }    

  for(; i < N; i++){
    count += K;
  } 
  
  cout << count <<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

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

			int n = sc.nextInt();
			int m = sc.nextInt();

			int[] aArray = new int[n];
			int[] bArray = new int[n];
			Pair[] pArray = new Pair[n];

			for(int i = 0 ; i < n ; i++ ) {
				aArray[i] = sc.nextInt();
				bArray[i] = sc.nextInt();
				Pair p = new Pair();
				p.a = aArray[i];
				p.b = bArray[i];
				pArray[i] = p;
			}

			//
//			Arrays.stream(pArray).forEach(p -> System.out.println("## (" + p.a  + "," + p.b + ")"));

			//backward
			//rev_m = 0 to M-1 find max(a) where b <= rev_m
			//1,2,3,4,5
			//5,4,3,2,1

			Arrays.sort(pArray, new Comparator<Pair>() {

				@Override
				public int compare(Pair o1, Pair o2) {
					return Integer.compare(o1.a, o2.a);
				}
			});

//			Arrays.stream(pArray).forEach(p -> System.out.println("## (" + p.a  + "," + p.b + ")"));

			PriorityQueue<Pair> pq = new PriorityQueue<>(
					new Comparator<Pair>() {
						@Override
						public int compare(Pair o1, Pair o2) {
							return Integer.compare(o2.b, o1.b);
						}
					});
			
			int po = 0;
			long sum = 0;
			for(int revm = 1 ; revm <= m ; revm++ ) {
				while(po < pArray.length && pArray[po].a <= revm ) {
//					System.out.println("add " + pArray[po].a + "," + pArray[po].b);
					pq.add(pArray[po]);
					po++;
				}
				//get largest
				Pair max = pq.poll();
				if ( max != null ) {
					sum += max.b;
				}
			}
			
			System.out.println(sum);

		}
	}

	public static class Pair {
		public int a;
		public int b;
	}
}

Measured memory_bytes: 85004
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define _USE_MATH_DEFINES
#define mp       make_pair
#define pb       push_back
#define fst      first
#define snd      second
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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


int main()
{
    string abcd_str; cin >> abcd_str;
    int abcd[4];
    rep(i, 4) abcd[i] = abcd_str[i] - '0';

    
    int ope[3]; // 0: plus,  1: minus
    char opec[] = {'+', '-'};
    bool brk = false;
    for(ope[0] = 0; ope[0] < 2; ope[0]++) {
        for(ope[1] = 0; ope[1] < 2; ope[1]++) {
            for(ope[2] = 0; ope[2] < 2; ope[2]++) {
                int s = abcd[0];
                rep(i, 3) {
                    if(ope[i] == 0)
                        s += abcd[i+1];
                    else
                        s -= abcd[i+1];
                }

                if(s == 7) {
                    brk = true;
                    break;
                }
            }
            if(brk) break;
        }
        if(brk) break;
    }

    cout << abcd[0];
    rep(i, 3) cout << opec[ope[i]] << abcd[i+1];
    cout << "=7" << endl;

    return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 昇順にソート済みのarrから、n以上の最小の要素を探索して返します。
# 存在しない場合は、Noneを返します。
def bin_gte(arr, n, l):
    r = len(arr) - 1
    c = (l+r)//2
    while l < r:
        c = (l+r)//2
        if arr[c] >= n:
            r = c
        else :
            l = c+1
    c = max(0, (l+r)//2)
    if arr[c] >= n:
        return (c, arr[c])
    else:
        return None

def bin_lte(arr, n, l):
    r = len(arr) - 1
    c = (l+r)//2
    while l < r:
        # c = math.ceil((l+r)/2)
        c = (l+r+1)//2
        if arr[c] <= n:
            l = c
        else :
            r = c-1
    c = max(0, (l+r)//2)
    if arr[c] <= n:
        return (c, arr[c])
    else:
        return None

n = int(input())
lll = get_nums_l()
lll.sort()

ans=0

maxs = [None] * 2002
mi = 0
prev = lll[0]
for l in lll[1:]:
    for j in range(prev, l+1):
        maxs[j] = mi
    mi += 1
    prev = l
for j in range(prev, 2002):
    maxs[j] = mi

mins = [None] * 2002
mi = 0
prev = 0
for l in lll:
    for j in range(prev+1, l+1):
        mins[j] = mi
    mi += 1
    prev = l

for ai, a in enumerate(lll):
    if ai == n-2:
        break
    for bi in range(ai+1, n-1):
        b = lll[bi]

        _min = abs(a-b) + 1
        _max = a+b - 1

        left = mins[_min]
        right = maxs[_max]
        # left = bin_gte(lll, _min, bi+1)
        # right = bin_lte(lll, _max, bi+1)

        if left is None or right is None:
            continue
        
        if right < bi:
            continue
        left = max(bi+1, left)

        # ans += right[0]-left[0]+1
        ans += right-left+1

print(ans)

Measured memory_bytes: 43996
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000


int main(){

	int N,M;
	cin>>N>>M;
	
	vector<bool> v1(N,false),v2(N,false);
	
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		
		if(a>b)swap(a,b);
		if(a==1)v1[b-1]=true;
		if(b==N)v2[a-1]=true;
	}
	
	for(int i=0;i<N;i++){
		if(v1[i]&&v2[i]){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}
	
	cout<<"IMPOSSIBLE"<<endl;
	
    return 0;
}



Measured memory_bytes: 256
use proconio::input;

fn main() {
    input!(s: String, k: usize);
    let mut a = vec![];
    for d in 1..=k.min(s.len()) {
        for i in 0..=s.len() - d {
            a.push(s[i..i + d].to_string());
        }
    }
    a.sort();
    a.dedup();
    println!("{}", a[k - 1]);
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

const int INF = 1001001001;

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

    vector<int> fs(n);
    rep(i, n) {
        int f;
        cin >> f;
        f--;
        fs[i] = f;
    }
    int ds = 0;
    rep(i, n) {
        int d;
        cin >> d;
        ds += d;
    }
    vector<int> adds(n - 1);
    rep(i, n - 1) {
        int add;
        cin >> add;
        adds[i] = add;
    }

    for (int i = 0; i < n - 1; i++) {
        if (fs[i] == (fs[i + 1] - 1)) {
            ds +=  adds[fs[i]];
        }
    }
    cout << ds << endl;
}


Measured memory_bytes: 256
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        freebie: [String;n]
    }

    let mut getted: HashSet<&str> = HashSet::new();

    let mut ans = 0;

    for i in 0..n {
        let key: &str = &freebie[i];
        if !getted.contains(key) {
            ans += 1;
            getted.insert(key);
        }
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 18508
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
const LL MOD = 1e9+7;
LL n, ans = 0;

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

	cin >> n;
	//ans = ((n * (n-1))) % MOD;
	//n -= 2;
	LL p = 1, g = 1, d = 1;
	FOR(i, n){
		p *= 10;
		p %= MOD;
		g *= 9;
		g %= MOD;
		d *= 8;
		d %= MOD;
	}
	//ans *= p; ans %= MOD;
	p -= g; p -= g; p %= MOD; p += MOD; p %= MOD;
	p += d; p %= MOD;
	cout << p << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 3616
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-20;
const long double INF = 1e18;


int main(){
	long m,a,b;
	vector<long>prime;
	for(long i=2;i<=100009;i++){
		bool flag=true;
		for(long j=2;j*j<=i;j++)if(i%j==0)flag=false;
		if(flag)prime.PB(i);
	}
	while(cin>>m>>a>>b&&m){
		int resp=0,resq=0;long maxi=0;
		for(int i=0;prime[i]*prime[i]<=m;i++){
			int pos=upper_bound(ALL(prime),m/prime[i])-prime.begin();
			pos--;
			while(pos>=i){
				long p=prime[i],q=prime[pos];
				//cout<<p<<" "<<q<<endl;
				if((long double)p/q>=(long double)a/b){
					if(p*q>maxi){
						maxi=p*q;
						resp=p;resq=q;
					}
					break;
				}
				pos--;
			}
		}
		cout<<resp<<" "<<resq<<endl;
	}
	return 0;
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    int H, W;
    cin >> H >> W;

    vector<vector<char>> pixel(H + 2, vector<char>(W + 2));
    for (int i = 0; i < H + 2; i++)
    {
        for (int j = 0; j < W + 2; j++)
        {
            pixel[i][j] = '#';
        }
    }

    for (int i = 1; i < H + 1; i++)
    {
        for (int j = 1; j < W + 1; j++)
        {
            cin >> pixel[i][j];
        }
    }

    for (int i = 0; i < H + 2; i++)
    {
        for (int j = 0; j < W + 2; j++)
        {
            printf("%c", pixel[i][j]);
        }
        printf("\n");
    }

    return (0);
}

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

using namespace std;

int main()
{
    int n;
    string str;
    cin>>n;
    cin>>str;
    int i=0,cnt=0;
    while(str[i]!='\0'){

        if(str[i]==str[i+1]){
            cnt++;
        }

        i++;
    }

         cout<<n-cnt<<endl;



    return 0;

}


Measured memory_bytes: 512
import sys
import math

def get_divisor(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors

def main():
    _, K = map(int, input().split())
    *A, = map(int, input().split())

    aSum = sum(A)
    divs = get_divisor(aSum)

    for d in divs:
        r = [a % d for a in A]
        r.sort()

        sumRm = d*len(r) - sum(r)

        tmpSum = 0
        for _r in r:
            tmpSum += _r
            sumRm = sumRm - (d-_r)
            op = max(tmpSum, sumRm)
            if op <= K:
                print(d)
                sys.exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#pragma region Header
#define _CRT_SECURE_NO_WARNINGS
#define FOR(i,s, e) for(int i = s; i<e; ++i)
#define rFOR(i,s, e) for(int i=s-1; i>=e; --i)
#define loop(len) for(int i=0; i<len; ++i)
#define rloop(len) for(int i=len-1; i>=0; --i)
#define iPair pair<int,int>
#define LPair pair<ll,ll>
#define vecP(t,t2) vector<pair<t,t2>>
#define uoMP(t, t2) unordered_map<t, t2>
#define pb push_back
#define pp pop_back
#define beg_end(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define MrN ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long  ll;
typedef long double  ld;
#include<bits/stdc++.h>
using namespace std;
#pragma endregion

int n;
vector<ll> h;
ll DP[(int)1e5+5];

ll solve(int i, int cost){
	if(i == n-1) return cost;

	if(i == n-2) {
		DP[i] = abs(h[i] - h[n-1]);
		return DP[i] + cost;
	}

	if(DP[i] != -1) 
		return DP[i] + cost;

	DP[i] = min(
		solve(i+1, abs(h[i] - h[i+1])),
		solve(i+2, abs(h[i] - h[i+2]))
	);

	return DP[i] + cost;
}

int main() {
	MrN;
	// freopen("input.txt", "r", stdin);

	memset(DP, -1, sizeof(DP));

	cin >> n;
	h.resize(n);

	loop(n){
		cin >> h[i];
	}

	cout << solve(0, 0) << '\n';

  return 0;
}


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

using namespace std;

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

	vector<int> a(n * m, 0);
	for (int i = 0; i < n; ++i)
		for (int j = i * m; j < (i * m + m); ++j)
			cin >> skipws >> a[j];

	vector<int> b(m, 0);
	for (int i = 0; i < m; ++i)
		cin >> b[i];

	for (int i = 0; i < n; ++i)
	{
		int sum = 0;

		for (int j = i * m; j < (i * m + m); ++j)
			sum += a[j] * b[j % m];

		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1236
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

a,b,c=na()
print('No') if (a == b and b == c) or (a!=b and b!=c and c!=a) else print('Yes')


Measured memory_bytes: 38256
#include <stdio.h>

int main(){
	int s = 0;
	int t = 0;
	int u = 0;
	int v = 0;
	char a;
	char b;
	char c;
	char d;

	scanf("%c%c%c%c",&a,&b,&c,&d);
		if(a == '+'){
			s += 1;
		} else {
			s -= 1;
		}

		if(b == '+'){
			t =  s + 1;
		} else {
			t = s - 1;
		}

		if(c == '+'){
			u = t + 1;
		} else {
			u = t - 1;
		}

		if(d == '+'){
			v = u + 1;
		} else {
			v= u - 1;
		}

	printf("%d\n", v);
}

Measured memory_bytes: 128
n = int(input())
ans = -1
num = 0
for i in range(n):
    a,b = map(int,input().split())
    ans += b
    num += a * b
    if num > 9:
        ans += num // 9
        num %= 9
        if num == 0:
            ans -= 1
            num = 9
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
    using namespace std;
    #define PAIN___ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define ll long long int
    #define fi first
    #define se second
    #define pb push_back
    #define pii pair < int , int >
    #define mp make_pair
    #define vec vector < ll >
    #define vecp vector < pii  >
    #define forl(i,q1,n,q2) for(ll i=q1;i<q2;i++)
    #define null NULL
    #define mm 1000005

    int main()
    {
        PAIN___;
        ll t;
        t=1;
        while(t--)
        {
            ll n;
            cin>>n;
            ll a[n];
            forl(i,0,n,n)
            {
                cin>>a[i];
            }
            sort(a,a+n);
           // forl(i,0,n,n)cout<<a[i]<<" ";
           // cout<<endl;
            if(n&1){cout<<0<<endl;return 0;}
            else{
                ll mid=n/2;
                mid-=1;
              //  cout<<"mid "<<mid<<endl;

                if(a[mid]==a[mid+1]){cout<<0<<endl; return 0;}

                ll ans=abs(a[mid+1]-a[mid]-1);
                cout<<ans+1<<endl;

            }


    }
    }



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

int main(){
  
  int X,A;
  string S;

  cin >> S;

  if((S[0]==S[1])||(S[1]==S[2])||(S[2]==S[3])){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
 
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
constexpr long long MOD = 998244353;

int main() {
	int n, s; cin >> n >> s;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	vector<vector<long long>> dp(3, vector<long long>(s + 3003));
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		vector<vector<long long>> next(3, vector<long long>(s + 3003));
		for (int j = 0; j <= s; ++j) {
			(next[0][j] += dp[0][j]) %= MOD;
			(next[1][j] += dp[0][j] + dp[1][j]) %= MOD;
			(next[1][j + a[i]] += dp[0][j] + dp[1][j]) %= MOD;
			(next[2][j] += dp[0][j] + dp[1][j] + dp[2][j]) %= MOD;
			(next[2][j + a[i]] += dp[0][j] + dp[1][j]) %= MOD;
		}
		dp = next;
	}
	cout << dp[2][s];
	return 0;
}

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

int main(){
  // ifstream in("testcase_01");
  // cin.rdbuf(in.rdbuf());

  int N, K; cin >> N >> K;
  string S; cin >> S;
  char bef = S[0];
  int count = 0;
  for (int i=1; i<N; i++){
    if (S[i]!=bef){
      count++;
      bef = S[i];
    }
  }
  count -= K*2;
  if (count <= 0){
    cout << N-1 << endl;
  } else {
    cout << N-1-count << endl;
  }
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
    int first = 1;
    while(1){
        int pay;
        int coins[4];
        int val[4] = {10, 50, 100, 500};
        scanf("%d", &pay);
        if(pay == 0)
            break;

        int i;
        for(i = 0; i < 4; i++)
            scanf("%d", coins + i);
        if(first)
            first = 0;
        else
            printf("\n");

        int min_coins[4] = {0};
        int change_coins[4] = {0};
        int min = 100000;

        for(i = 0; i <= coins[0]; i++){
            int j;
            for(j = 0; j <= coins[1]; j++){
                int k;
                for(k = 0; k <= coins[2]; k++){
                    int l;
                    for(l = 0; l <= coins[3]; l++){
                        int money = 10 * i + 50 * j + 100 * k + 500 * l;
                        if(pay <= money){
                            int change = money - pay;
                            change_coins[3] = change / 500;
                            change %= 500;
                            change_coins[2] = change / 100;
                            change %= 100;
                            change_coins[1] = change / 50;
                            change %= 50;
                            change_coins[0] = change / 10;

                            if(change_coins[0] * i != 0 || change_coins[1] * j != 0 || change_coins[2] * k != 0 || change_coins[3] * l != 0)
                                continue;

                            int total = 0;
                            total += coins[0] - i + change_coins[0];
                            total += coins[1] - j + change_coins[1];
                            total += coins[2] - k + change_coins[2];
                            total += coins[3] - l + change_coins[3];
                            if(min > total){
                                min_coins[0] = i;
                                min_coins[1] = j;
                                min_coins[2] = k;
                                min_coins[3] = l;
                                min = total;
                            }
                        }
                    }
                }
            }
        }

        for(i = 0; i < 4; i++)
            if(min_coins[i] != 0)
                printf("%d %d\n", val[i], min_coins[i]);


    }
    return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

using ll = long long;

int cnt_digits(ll N) {
	int digits = 0;

	while (N > 0) {
		N /= 10;
		digits++;

	}

	return digits;

}

int main(void) {
	ll N;
	cin >> N;

	int ans = cnt_digits(N); // 1*N=N max(cnt_digits(1),cnt_digits(N))=cnt_digits(N)

	for (ll A = 1LL; A*A <= N; ++A) {
		if (N%A != 0) continue;
		const ll B = N / A;

		const int cur = max(cnt_digits(A), cnt_digits(B));

		if (ans > cur) {
			ans = cur;

		}

	}

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int MOD = 1000_000_007;
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int num[] = new int[n];
        long sum = 0;
        for (int i = 0; i < n; i++) {
        	num[i] = sc.nextInt();
            sum += num[i];
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            sum -= num[i];
            ans = (int) (ans + ((num[i] % MOD) * (sum % MOD)) % MOD) % MOD;
        }
        System.out.println(ans);
    }
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	string s; cin >> s;
	if (s[0] == s[2]) cout << "Yes";
	else cout << "No";
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
char stk[SIZE],s[SIZE];
int sn;
int main(){
    RS(s);
    int n=LEN(s);
    REP(i,n){
        if(sn&&stk[sn-1]=='S'&&s[i]=='T'){
            sn--;
        }
        else{
            stk[sn++]=s[i];
        }
    }
    printf("%d\n",sn);
    return 0;
}


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

typedef long long int ll;

const int MAX = 2e5 + 10;

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

	int res = (n-m)*100 + m*1900;

	cout<<pow(2,m)*res;
}

// abcab

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

int main(){
	string o,e; cin>>o>>e;
	int ko=o.size();
	int ke=e.size();
	rep(i,ko){
			cout<<o[i];
			if(i==ke) continue;
			else cout<<e[i];
	}
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Person[] persons = new Person[n];
		for (int i = 0; i < n; i++) {
		    persons[i] = new Person(i, sc.nextInt());
		}
		Arrays.sort(persons);
		long[][] dp = new long[n + 1][n + 1];
		for (int i = 1; i <= n; i++) {
		    for (int j = 0; j <= i; j++) {
		        if (j != 0) {
		            dp[j][i - j] = Math.max(dp[j][i - j], dp[j - 1][i - j] + Math.abs(j - 1 - persons[i - 1].idx) * (long)persons[i - 1].value);
		        }
		        if (j != i) {
		            dp[j][i - j] = Math.max(dp[j][i - j], dp[j][i - j - 1] + Math.abs(n - (i - j) - persons[i - 1].idx) * (long)persons[i - 1].value);
		        }
		    }
		}
		long max = 0;
		for (int i = 0; i <= n; i++) {
		    max = Math.max(max, dp[i][n - i]);
		}
		System.out.println(max);
   }
   
   static class Person implements Comparable<Person>{
       int idx;
       int value;
       
       public Person(int idx, int value) {
           this.idx = idx;
           this.value = value;
       }
       
       public int compareTo(Person another) {
           return another.value - value;
       }
   }
}



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

using namespace std;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) {
		is >> x;
	}
	return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (int i = 0; i<vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

void insertionSort(vector<int>& A) {
	for (int i = 1; i < A.size(); i++) {
		cout << A << endl;
		int tmp = A.at(i);
		int j = i - 1;
		while (j >= 0 && A.at(j) > tmp) {
			A.at(j + 1) = A.at(j);
			j--;
		}
		A.at(j + 1) = tmp;
	}
}

int main(void) {
	int num;
	cin >> num;
	vector<int> arr(num);
	cin >> arr;

	insertionSort(arr);

	cout << arr << endl;

	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N,w;
  cin >> N >> w;
  vector<ll> W(N),V(N);
  rep(i,N) cin >> W.at(i) >> V.at(i);
  if(W.at(0)<=297){
    vector<vector<ll>> dp(N,vector<ll>(30001,0));
    rep(i,N){
      if(i==0){
        rep(j,30001){
          if(j>=W.at(i)) dp.at(i).at(j)=V.at(i);
        }
      }else{
        rep(j,30001){
          if(j>=W.at(i)){
            dp.at(i).at(j)=max(dp.at(i-1).at(j),dp.at(i-1).at(j-W.at(i))+V.at(i));
          }else{
            dp.at(i).at(j)=dp.at(i-1).at(j);
          }
        }
      }
    }
    cout << dp.at(N-1).at(min((ll)30000,w)) << endl;
  }else{
    w=min((ll)297,w%W.at(0))+298*(w/W.at(0));
    rep(i,N){
      W.at(N-1-i)-=W.at(0);
      W.at(N-1-i)+=298;
    }
    vector<vector<ll>> dp(N,vector<ll>(30100,0));
    rep(i,N){
      if(i==0){
        rep(j,30100){
          if(j>=W.at(i)) dp.at(i).at(j)=V.at(i);
        }
      }else{
        rep(j,30100){
          if(j>=W.at(i)){
            dp.at(i).at(j)=max(dp.at(i-1).at(j),dp.at(i-1).at(j-W.at(i))+V.at(i));
          }else{
            dp.at(i).at(j)=dp.at(i-1).at(j);
          }
        }
      }
    }
    cout << dp.at(N-1).at(min((ll)30099,w)) << endl;
  }
}

Measured memory_bytes: 27024
#include<bits/stdc++.h>
using namespace std;
int main(){
  #define int long
  string s;
  int sum=0,psum=0,a=0;
  cin>>s;
  for(int i=0;i<(int)s.length();++i){
    if(s[i]=='A')a++;
    else if(i+1<(int)s.length()&&s[i]=='B'&&s[i+1]=='C'){ psum+=a; i++; }
    else{a=0; sum+=psum; psum=0;}
  }
  cout<<sum+psum;
  cerr<<"\n"<<s.length();
}

Measured memory_bytes: 640
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    print(n**3)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940