akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

struct data{
    int d,end,ind;//識別子、長さ、最初のセクタ番号
};

vector<data> v;

int main(void) {
    int i,j;
    int n;
    while(cin >> n, n){

        v.clear();
        data t;
        t.ind = 0;
        t.end = INF+10;
        t.d = -1;
        v.push_back(t);

        rep(i,n){
            string s;
            cin >> s;
            if(s == "W"){
                int l,s;
                cin >> l >> s;
                for(j = 0; s > 0; j++){
                    if(v[j].d != -1)continue;
                    int tmp = v[j].end - v[j].ind + 1;
                    if(tmp <= s){
                        v[j].d = l;
                        s -= tmp;
                    }else{
                        data t;
                        t.ind = v[j].ind;
                        t.d = l;
                        t.end = v[j].ind + s - 1;
                        v.insert(v.begin()+j,t);
                        v[j+1].ind = v[j].end + 1;
                        j++;
                        s = 0;
                    }
                }
            }
            if(s == "D"){
                int l;
                cin >> l;
                rep(j,v.size()){
                    if(v[j].d == l)v[j].d = -1;
                }
            }
            if(s == "R"){
                int p;
                cin >> p;
                j = 0;
                while(v[j].end < p)j++;
                cout << v[j].d << endl;
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3188
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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

#define P (1'000'000'007)

inline int fast_pow(int x, int n, int mod) {
    long long signed res = 1;
    long long accumulation = x;
    for (int i = 0; n >> i > 0; ++ i) {
        if ((n >> i) % 2) {
            res *= accumulation;
            res %= mod;
        }
        accumulation *= accumulation;
        accumulation %= mod;
    }

    return res;
}

inline int fast_comb(int n, int r, int mod) {
    long long a = 1;
    long long b = 1;
    for (int i = 0; i < r; ++i) {
        a = a * (n - i) % mod;
        b = b * (i + 1) % mod;
    }

    b = fast_pow(b, mod - 2, mod);
    return a * b % mod;
}

signed main() {
    int x, y;
    cin >> x >> y;

    if ((x + y) % 3 == 0) {
        int c = (x + y) / 3;
        if (c <= x && x <= c * 2 && c <= y && y <= c * 2) {
            int t = 2 * c - x;
            cout << fast_comb(c, t, P);
        } else {
            cout << 0;
        }
    } else {
        cout << 0;
    }

    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <climits> 



int main()
{
    long N;
    std::cin >> N;
    std::vector<std::string> S;
    for(long i=0; i<N; i++){
        std::string temp;
        std::cin >> temp;
        S.push_back(temp);
    }
    std::sort(S.begin(),S.end());
    long max=0;
    long count=1;
    std::vector<std::string> result;
    for(long i=1; i<N; i++){
        if(S[i]==S[i-1]){
            count++;
            if(i==N-1){
                if(max<count){
                    max=count;
                    result.clear();
                    result.push_back(S[i-1]);
                }else if(max==count){
                    result.push_back(S[i-1]);
                }
            }
        }else{
            if(max<count){
                max=count;
                result.clear();
                result.push_back(S[i-1]);
            }else if(max==count){
                result.push_back(S[i-1]);
            }
            count=1;
        }
        if(max==1 && i==N-1){
            result.push_back(S[N-1]);
        }
    }
    if(N==1){
        result.push_back(S[0]);
    }
    std::sort(result.begin(),result.end());
    for(long i=0; i<result.size(); i++){
        std::cout << result[i] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 15984
#include<stdio.h>
int main(){
    int n,d;
    scanf("%d %d",&n,&d);
    int hanni = 2*d+1;
    if(n%hanni == 0){
        printf("%d\n",n/hanni);
    }
    else{
        printf("%d\n",n/hanni+1);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	int n=0;
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
		if(s[i]!=t[i])
			n++;
	cout<<n;
	return 0;
}


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

template<typename T> class UnionFind {
 public:
  void unite(const T& a, const T& b) {
    auto x = find(a), y = find(b);
    if(rank_[x] < rank_[y]) std::swap(x, y);
    if(rank_[x] == rank_[y]) ++rank_[x];
    parent_[y] = x;
  }
  T find(const T& x) {
    if(!parent_.count(x)) rank_[x] = 1, parent_[x] = x;
    return (parent_[x] == x) ? x : (parent_[x] = find(parent_[x]));
  }
 private:
  std::map<T, T> parent_;
  std::map<T, int> rank_;
};

template<typename T> class SegmentTree {
 public:
  SegmentTree(int n) : n(size(n)), dat(size(n) << 1), laz(size(n) << 1) {}
  void add(int a, int b, T v) {add(a, b, v, 1, 0, n);}
  T sum(int a, int b) {return sum(a, b, 1, 0, n);}
 private:
  constexpr int size(int n) const {return n & (n - 1) ? size(n + (n & -n)) : n;}
  inline int lchild(int k) const {return (k << 1);}
  inline int rchild(int k) const {return (k << 1) | 1;}
  inline void propagate(int k, int l, int r) {
    if(k < n) {
      laz[lchild(k)] += laz[k];
      laz[rchild(k)] += laz[k];
    }
    dat[k] += (r - l) * laz[k];
    laz[k] = 0;
  }
  T add(int a, int b, T v, int k, int l, int r) {
    propagate(k, l, r);
    if(b <= l || r <= a) return dat[k];
    if(a <= l && r <= b) return dat[k] + (r - l) * (laz[k] = v);
    auto m = (l + r) >> 1;
    auto vl = add(a, b, v, lchild(k), l, m);
    auto vr = add(a, b, v, rchild(k), m, r);
    return dat[k] = vl + vr;
  }
  T sum(int a, int b, int k, int l, int r) {
    propagate(k, l, r);
    if(b <= l || r <= a) return 0;
    if(a <= l && r <= b) return dat[k];
    auto m = (l + r) >> 1;
    auto vl = sum(a, b, lchild(k), l, m);
    auto vr = sum(a, b, rchild(k), m, r);
    return vl + vr;
  }
  int n;
  std::vector<T> dat, laz;
};

using Graph = vector<vector<int>>;

using LL = long long;

int main() {
  int N;
  cin >> N;
  Graph G(N);
  for(auto i=1; i<N; ++i) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  SegmentTree<LL> ST(N);
  UnionFind<int> UF;
  auto n = 0;
  for(auto r=0; r<N; ++r) {
    for(auto v: G[r]) if(v < r) if(UF.find(v) != UF.find(r)) UF.unite(v, r), --n;
    ST.add(r, r+1, ++n);
  }

  LL ans = 0;
  for(auto l=0; l<N; ++l) {
    sort(begin(G[l]), end(G[l]), greater<int>());
    ans += ST.sum(0, N);
    for(auto v: G[l]) if(l < v) ST.add(v, N, 1);
    ST.add(l, N, -1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 41968
#include<iostream>
#include<cmath>
#include<cstdio>
#define PI 3.14159265358979
using namespace std;
struct P{
    double x,y;
};
int n;
int Koch(P p1,P p2,int counter){
    if(counter >= n) return 0;
    double th = 60.0*(PI/180.0); 
    P s,t,u;
    s.x = (2.0 * p1.x + 1.0 * p2.x)/3.0;
    s.y = (2.0 * p1.y + 1.0 * p2.y)/3.0;
    t.x = (1.0 * p1.x + 2.0 * p2.x)/3.0;
    t.y = (1.0 * p1.y + 2.0 * p2.y)/3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y ) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y ) * cos(th) + s.y;
    counter++;
    Koch(p1,s,counter);
    printf("%.8lf %.8lf\n",s.x,s.y);
    Koch(s,u,counter);
    printf("%.8lf %.8lf\n",u.x,u.y);
    Koch(u,t,counter);
    printf("%.8lf %.8lf\n",t.x,t.y);
    Koch(t,p2,counter);
}
int main(){
    const P first = {0.0,0.0},second = {100.0,0.0};
    cin >> n;
    printf("%.8lf %.8lf\n",first.x,first.y);
    Koch(first,second,0);
    printf("%.8lf %.8lf\n",second.x,second.y);
    return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int tmp=j-i;
            int ret=1;
            while(tmp%2==0){
                tmp/=2;
                ++ret;
            }
            cout << ret << ((j==n)?"\n":" ");
        }
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 1000010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll fact[MAX];

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

void precomp()
{
    fact[0] = fact[1] = 1;

    for (ll i = 2; i < MAX; ++i)
        fact[i] =  mod(fact[i - 1] * i, MOD);
}

ll mod_pow(ll a, ll n, ll m)
{
    ll res = 1, base = a;

    while (n)
    {
        if (n & 1)
            res = mod(res * base, m);

        base = mod(base * base, m);
        n >>= 1;
    }

    return res;
}

ll binom(ll n, ll m)
{
    auto num = fact[n];
    auto den = mod(fact[m] * fact[n - m], MOD);
    auto inv = mod_pow(den, MOD - 2, MOD);

    return mod(num * inv, MOD);
}

ll solve(ll N, ll K, vector<ll>& xs)
{
    map<ll, ll> hs;

    for (auto x : xs)
        ++hs[x];

    ll L = 0, R = N, ans = 0;

    for (auto p : hs)
    {
        auto x = p.first, n = p.second;
#ifdef DEBUG
    cout << "x = " << x << ", n = " << n << ", L = " << L << ", R = " << R << endl;
#endif
        R -= n;
        ll min_count = 0;

        for (int i = 1; i <= n; ++i)
        {
            auto ways = (R >= K - i) ? binom(R, K - i) : 0;
            min_count = mod(min_count + mod(binom(n, i) * ways, MOD), MOD);
        }

#ifdef DEBUG
    cout << "min_count = " << min_count << ", R = " << R << endl;
#endif

        ll max_count = 0;

        for (int i = 1; i <= n; ++i)
        {
            auto ways = (L >= K - i) ? binom(L, K - i) : 0;
            max_count = mod(max_count + mod(binom(n, i) * ways, MOD), MOD);
        }

        L += n;
#ifdef DEBUG
    cout << "max_count = " << max_count << ", L = " << L << endl;
#endif

        ans = mod(ans + mod(max_count*x, MOD), MOD);        
#ifdef DEBUG
    cout << "--- ans 1 = " << ans << endl;
#endif
        ans = mod(ans - mod(min_count*x, MOD), MOD);        

#ifdef DEBUG
    cout << "--- ans 2 = " << ans << endl;
#endif
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    precomp();

    ll N, K;
    cin >> N >> K;

    vector<ll> xs(N);

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

    auto ans = solve(N, K, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 16384
#include<bits/stdc++.h>
using namespace std;
 
 
int main(){
  int h,n;
  long long b=0;
  cin>>h;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b+=a[i];
  }
  if(b>=h){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
map<ll,ll> m;
void solve()
{
    ll n;
    cin>>n;
    ll x,ans=0;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        ll y=i-x;
        ans+=m[y];
        y=i+x;
        m[y]++;
    }
    cout<<ans;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
}

Measured memory_bytes: 26392
import java.util.*;
import java.util.stream.*;
class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),k=s.nextInt();
		System.out.println(
				IntStream.range(0,n).map(o->s.nextInt())
				.map(o->Math.min(o,k-o))
				.sum()*2
				);
	}
}

Measured memory_bytes: 26964
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

long long k,m,n,now;
int main(){
	n=read();
	printf("%lld\n",n*(n-1)/2);
	//m=read();	
	//k=n;now=1;
	//while(k<m){
	//	k+=n-1;
	//	now++;
	//}
	//printf("%lld\n",now);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int SIZEN = 100010;
int N;
int L[SIZEN];
int R[SIZEN];
int a[SIZEN];
int b[SIZEN];
int mnb[SIZEN];
int id[SIZEN];
int tmp[SIZEN];
bool Cmp(const int &A,const int &B){
    return a[A] > a[B];
}

int main(){
    scanf("%d",&N);
    int mxl = 0;
    int mnr = INF;
    int mxn = 0;
    for(int i = 1;i <= N;i++){
        scanf("%d%d",&L[i],&R[i]);
        if(mxl < L[i])mxl = L[i];
        if(mnr > R[i])mnr = R[i];
        mxn = max(mxn,R[i] - L[i] + 1);
    }
    int ans = max(mnr - mxl + 1,0) + mxn;
    // printf("ans = %d,mxl = %d,mnr = %d\n",ans,mxl,mnr);

    for(int i = 1;i <= N;i++){
        a[i] = max(0,R[i] - mxl + 1);
        b[i] = max(0,mnr - L[i] + 1);
        id[i] = i;
    }
    sort(id + 1,id + 1 + N,Cmp);
    mnb[N] = b[id[N]];
    for(int i = N-1;i >= 1;i--)mnb[i] = min(mnb[i+1],b[id[i]]);

    // for(int i = 1;i <= N;i++)printf("L = %d,R = %d,a = %d,b = %d\n",L[id[i]],R[id[i]],a[id[i]],b[id[i]]);
    // printf("mnb : ");for(int i = 1;i <= N;i++)printf("%d ",mnb[i]);printf("\n");
    
    for(int i = 1;i <= N;i++){
        int x = id[i];
        ans = max(ans,a[x] + mnb[i+1]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4048
N, K = gets.split.map(&:to_i)
M = 1000000007
positives = []
negatives = []
zeros = []
A = gets.split.map(&:to_i)
A.sort_by! {|k| k > 0 ? k : -k }
A.each do |a|
  if a > 0
    positives << a
  elsif a < 0
    negatives << a
  else
    zeros << a
  end
end
positives.reverse!
negatives.reverse!

if positives.size + negatives.size < K
  puts 0
  exit
end

posisize = [positives.size, K].min
negasize = K - posisize
if negasize > 0 and negasize%2==1 and !(positives.size > 0 and negasize < negatives.size)
  # negative case
  unless zeros.empty?
    puts 0
  else
    ans=1
    0.upto(K-1) do |i|
      ans = (ans * A[i]) % M
    end
    puts ans
  end
else
  if negasize%2 == 1
    negasize += 1
    posisize -= 1
  end

  # fix
  while posisize >= 2 &&
        negasize + 2 <= negatives.size &&
        positives[posisize-1]*positives[posisize-2] < negatives[negasize]*negatives[negasize+1]
    posisize -= 2
    negasize += 2
  end

  ans=1
  0.upto(posisize-1) do |i|
    ans = (ans * positives[i]) % M
  end
  0.upto(negasize-1) do |i|
    ans = (ans * negatives[i]) % M
  end
  puts ans
end


Measured memory_bytes: 33952
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  size_t W, H, N;
  scanf("%zu %zu %zu", &W, &H, &N);

  std::vector<std::vector<int>> g(H, std::vector<int>(W));
  for (size_t i = 0; i < N; ++i) {
    size_t x, y;
    int a;
    scanf("%zu %zu %d", &x, &y, &a);

    size_t xl = 0;
    size_t xr = W;
    size_t yl = 0;
    size_t yr = H;
    if (a == 1) {
      xr = x;
    } else if (a == 2) {
      xl = x;
    } else if (a == 3) {
      yr = y;
    } else if (a == 4) {
      yl = y;
    }

    for (size_t j = xl; j < xr; ++j)
      for (size_t k = yl; k < yr; ++k)
        g[k][j] = 1;
  }

  int res = 0;
  for (size_t i = 0; i < H; ++i)
    for (size_t j = 0; j < W; ++j)
      if (g[i][j] == 0) ++res;

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

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

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    
    for(int i = 0; i < n; i++)
      cin >> a.at(i); 

    int diff;
    if( n != 1 )
        diff = a.at(1) - a.at(0);
    int ans = 1;
    for(int i = 2; i < n; i++){
        
        if( diff > 0 ){ 
          if ( a.at(i) < a.at(i-1) ){
              ans++;
              diff = 0;
          }
        }else if( diff < 0 ){
          if( a.at(i) > a.at(i-1) ){
              ans++;
              diff = 0;
          }
        }else{
            diff = a.at(i) - a.at(i-1);
        }

    }
  
    cout << ans << endl;

}


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

void outchar(char c, int n);

int main(){
	int i, c, tmp;
	string s;int len;
	int p = -1;
	int m[10] = {};
	
	cin >> s;
	len = s.length();
	
	//?????¢?????????????????????
	outchar('+', 10);
	cout << '[';
	for(i = 3; i <= 12; i++){
		cout << '>';
		outchar('+', i);
	}
	outchar('<', 10);
	cout << "-]";
	
	//????????¨???
	for(i = 0; i < len; i++){
		c = s[i];
		
		tmp = (c-30) / 10;
		if(p < tmp) outchar('>', tmp - p);
		if(tmp < p) outchar('<', p - tmp);
		p = tmp;
		
		tmp = c % 10;
		if(m[p] < tmp) outchar('+', tmp - m[p]);
		if(tmp < m[p]) outchar('-', m[p] - tmp);
		m[p] = tmp;
		
		cout << '.';
	}
	
	return 0;
}

void outchar(char c, int n){
	while(n--) cout << c;
}

Measured memory_bytes: 1168
class Acc2D:
    def __init__(self, src):
        self.acc2d = self._build(src)

    def _build(self, src):
        h, w = len(src), len(src[0])
        ret = [[0] * w for _ in range(h)]
        for r in range(h):
            for c in range(w):
                ret[r][c] = src[r][c]
                if r > 0:
                    ret[r][c] += ret[r - 1][c]
                if c > 0:
                    ret[r][c] += ret[r][c - 1]
                if r > 0 and c > 0:
                    ret[r][c] -= ret[r - 1][c - 1]
        return ret

    def get(self, r1, c1, r2, c2):
        """[(r1,c1),(r2,c2)]"""
        acc2d = self.acc2d
        ret = acc2d[r2][c2]
        if r1 > 0:
            ret -= acc2d[r1 - 1][c2]
        if c1 > 0:
            ret -= acc2d[r2][c1 - 1]
        if r1 > 0 and c1 > 0:
            ret += acc2d[r1 - 1][c1 - 1]

        return ret


def main():
    import sys

    input = sys.stdin.readline

    N, M, Q = map(int, input().split())

    table = [[0] * (N + 1) for _ in range(N + 1)]

    for _ in range(M):
        L, R = map(int, input().split())
        table[L][R] += 1

    acc2d = Acc2D(table)

    for _ in range(Q):
        p, q = map(int, input().split())
        res = acc2d.get(p, p, q, q)
        print(res)


if __name__ == '__main__':
    main()


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

int main() {
  ll N;
  cin >> N;
  map<string,ll> vote;
  for(ll i=0;i<N;i++){
    string S;
    cin >> S;
    vote[S]++;
  }
  ll max=0;
  for(auto j=vote.begin(); j!=vote.end();++j){
    if(j->second > max){
      max=j->second;
    }
  }
  for(auto j=vote.begin(); j!=vote.end();++j){
    if(j->second ==max){
      cout << j->first << endl;
    }
  }
}

Measured memory_bytes: 19224
#include <bits/stdc++.h>
using namespace std;
 
int N,l,r,A[300100];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	
	l = r = 150000; l--;
	cin >> N;
	for(int i = 1;i<=N;i++)	if(i%2) cin >> A[r++]; else cin >> A[l--];
	if(N%2)	for(int i = r-1;i>l;i--) cout << A[i] << ' ';
	else for(int i = l+1;i<r;i++) cout << A[i] << ' ';
}

Measured memory_bytes: 2944
s = input()
t = input()
if set(t).issubset(set(s)):
    i = 0
    x = s
    for k in t: 
        p = x.find(k) + 1
        if p == 0:
            i += len(x)
            p = s.find(k) + 1
            x = s
        i += p
        x = x[p:]
    print(i)
else:
    print(-1)

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

int main(){
    int n = 0;
    cin >> n;
    ll ans = 1;
    vector<ll> a(n);
    ll b = pow(10,18);
    bool fin = false;

    rep(i,n) {
        cin >> a[i];
        if(a[i] == 0) {
            fin = true;
            ans=0;
        }
    }
    
    if(fin == false){
        rep(i,n) {
            if(a[i] <= b/a[i]){
                ans = ans * a[i];
            }else{
                ans = -1;
                break;
            }

            if(ans > b){
                ans = -1;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4052
N, D = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for _ in range(N)]

answer = 0
for i in range(N):
  for j in range(i+1, N):
    dist = 0
    x_i = X[i]
    x_j = X[j]
    for d in range(D):
      dist += (x_i[d] - x_j[d])**2
    if (dist**0.5).is_integer():
      answer += 1

print(answer)


Measured memory_bytes: 3060
{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Char
import Control.Monad
import Control.Applicative


readInt :: IO Int
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-'
                then (c :) <$> input
                else return []

main = putStrLn . f =<< replicateM 2 readInt
  where f [a, b]
          | a < b = "a < b"
          | a > b = "a > b"
          | otherwise = "a == b"


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){
  int N;
  cin>>N;
  vector<int> a,b;
  rep(i,N){
    int aa;cin>>aa;
    a.emplace_back(aa);
  }

  rep(i,N){
    int aa;cin>>aa;
    b.emplace_back(aa);
  }

  ll ans=0;

  rep(k,29){
    ll t= 1<<(k);
    vector<ll> ax,bx;
    rep(i,N){ // a+bがt<= <2t, 3t<= <4t
      ax.emplace_back(a[i]%(2*t));
      bx.emplace_back(b[i]%(2*t));
    }

    SORT(bx);

    ll buff=0;

    rep(i,N){
      ll A=ax[i];
      // cout<< "A="<<A<<"\n";
      //cout<<lower_bound(bx.begin(),bx.end(),2*t-A)-lower_bound(bx.begin(),bx.end(),t-A) <<" "<<lower_bound(bx.begin(),bx.end(),4*t-A)-lower_bound(bx.begin(),bx.end(),3*t-A) <<"\n";
      buff+=(lower_bound(bx.begin(),bx.end(),2*t-A)-lower_bound(bx.begin(),bx.end(),t-A))+(lower_bound(bx.begin(),bx.end(),4*t-A)-lower_bound(bx.begin(),bx.end(),3*t-A));
    }
    //cout<< "buff="<<buff<<"\n";
    ans+=(buff%2)*(1<<k);
  }

  cout<< ans<<"\n";

}

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


Measured memory_bytes: 7032
N,K = list(map(int,input().split()))
data = []
def insert(num,N,K):
    for i in range(N):
        if num[i][1] >= K:
            print(num[i][0])
            break
        else:
            K -= num[i][1]
num = [list(map(int,input().split())) for i in range(N)]
num.sort(key=lambda x:x[0])
insert(num,N,K)


Measured memory_bytes: 29144
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int A, B, C, K; cin >> A >> B >> C >> K;
  int ans = max({(A << K) + B + C, A + (B << K) + C, A + B + (C << K)});
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定

#define ll long long int
#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a,b);
}

//degree → radian
ll chg_DegRad(ll deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(ll rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

ll x;
ll n = 100100;
bool isprime[100100];
ll ans, tmp, j;



int main() {
	
	cin >> x;

	rep(i, n) isprime[i] = true;
	isprime[0] = false;
	isprime[1] = false;

	for (ll i = 2; i < n; i++){
		if (isprime[i]){
			j = i + i;
			while (j < n){
				isprime[j] = false;
				j += i;
			}
			j = 0;
		}
	}
	for(ll i = x;i < n;i++){
		if (isprime[i]){
			ans = i;
			break;
		}
	}
	cout << ans << endl;



	return 0;
}





Measured memory_bytes: 384
///#pragma GCC optimize("Ofast")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
///#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
using namespace std;

///#include<ext/pb_ds/assoc_container.hpp>
///#include<ext/pb_ds/tree_policy.hpp>
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///(X).order_of_key(value) /// return lower_bound(value)
///(*X).find_by_order(index) /// return value (0 index)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); /// mt19937_64 (long long)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vii> vvii;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<bool> vbb;

const int N = 1000001;
const int MOD = 1000000007;
const ll INF = LLONG_MAX;

#define fast() ios_base::sync_with_stdio(false),cin.tie(NULL)
#define next(x) next_permutation(all(x))
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rev(a) reverse(all(a))
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl
#define space ' '
#define nl '\n'
#define PI acos(-1)
#define Case(x) cout<<"Case "<<x<<": "
#define strtoint(a) atoi(a.c_str())
#define dbg(x) cerr<<#x<<" is "<<x<<'\n';
#define fix(x) cout<<fixed<<setprecision(x)
#define leastonepos(x) __builtin_ffs(x)
#define leadingoff(x) __builtin_clz(x)
#define trailingoff(x) __builtin_ctz(x)
#define numofone(x) __builtin_popcount(x)
#define time() cerr<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<'\n'

#define coutv(v) for(auto it:v)cout<<it<<space;cout<<nl;
#define cinv(v) for(auto &it:v)cin>>it;

///................Graph's Move.................
///const int dx[] = {+1,-1,+0,+0}; ///Rock's Move
///const int dy[] = {+0,+0,+1,-1}; ///Rock's Move
///const int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
///const int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int dx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's Move
///const int dy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's Move
///*.....................-_-........................*///



int main()
{
    fast();
    int tc=1,cs=0;
    //cin>>tc;
    while(tc--)
    {
        ll n,W,i,j;
        cin>>n>>W;
        vll w(n),val(n),dp(W+1,-1);
        for(i=0; i<n; i++)
            cin>>w[i]>>val[i];
        dp[0]=0;
        for(i=0; i<n; i++)
            for(j=W; j>=0; j--)
                if(dp[0]!=-1&&j+w[i]<=W)
                    dp[j+w[i]]=max(dp[j+w[i]],dp[j]+val[i]);
        ll ans=*max_element(all(dp));
        cout<<ans<<nl;
    }
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll k;
  string s;
  cin >> k >> s;
  if(sz(s) > k){
    cout << s.substr(0, k) << "..." << endl;
  }else{
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define MAXN 1000002
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod=1e9+7;

void solve()
{
  string str;
  cin>>str;
  string a="ABC";
  string b="ARC";
  if(str==a)
  cout<<b<<endl;
  else
  cout<<a<<endl;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'
signed main() {
  int n;
  cin >> n;
  map<pii, ll> mp;
  for (int t = 1; t <= 9; t++) {
    for (int l = 1; l <= 9; l++) {
      if (t == l) {
        if (n >= t) mp[pii(t, l)]++;
      }
      for (int b = 10; b <= 100000; b *= 10) {
        int y = t * b + l;
        if (y > n) break;
        int z = y + 10 * (b / 10 - 1);
        if (z <= n) {
          mp[pii(t, l)] += b / 10;
          continue;
        }
        for (int x = 0; x < b / 10; x++) {
          int y = t * b + x * 10 + l;
          if (y <= n) mp[pii(t, l)]++;
          else break;
        }
      }
    }
  }

  ll ans = 0;
  rep1 (t, 9) {
    rep1 (l, 9) {
      ans += mp[pii(t, l)] * mp[pii(l, t)];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
long long int A,B;
long long int C,D;
int gcd(int a,int b) {
	if(b==0)return a;
	return gcd(b,a%b);
}

int main() {
	cin >> A >> B >> C >> D;
	long long int a1=B/C-(A-1)/C;
	long long int a2=B/D-(A-1)/D;
	long long int g=C*D/gcd(C,D);
	long long int a3=B/g-(A-1)/g;
	cout << (B-A+1)-a1-a2+a3;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int dp[1010][1010];
int const MOD = 1e9 + 7;
int main(void)
{
    string s, t;
    cin >> s >> t;

    int n = s.size();
    int m = t.size();

    for (int i = 0; i < 1010; ++i)
        for (int j = 0; j < 1010; ++j)
            dp[i][j] = MOD;
    for (int i = 0; i <= n; ++i)
    {
        dp[0][i] = i;
    }
    for (int i = 0; i <= m; ++i)
    {
        dp[i][0] = i;
    }

    for (int i = 0; i < m; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            int tmp = 0;
            if (s[j] != t[i])
                tmp++;

            dp[i + 1][j + 1] = min({dp[i][j + 1] + 1, dp[i + 1][j] + 1, dp[i][j] + tmp});
        }
    }
    cout << dp[m][n] << endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 2e5 + 5;
const long long MOD = 1e9 + 7;

int N, M, K, sum, res, mm[10][10];
char c;

int main() { speedhack()
	
	cin >> N >> M >> K;

	form (i, N)
		form (j, M) {
			cin >> c;
			if (c == '#')
				mm[i][j] = 1;
			sum += mm[i][j];
		}
	
	++N, ++M;

	int n = (1 << N) - 1;
	int m = (1 << M) - 1;

	--N, --M;

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

			vector<int> rows, cols;
			map<pair<int, int>, bool> used;
			int cnt = 0;

			for (int bit = 0; bit <= 10; bit++) {
				int bit_i = (i >> bit) & 1;
				int bit_j = (j >> bit) & 1;

				if (bit_i)
					rows.push_back(bit);
				if (bit_j) 
					cols.push_back(bit);
			}

			for (int r : rows) {
				for (int k = 0; k < M; k++) {
					used[{r, k}] = true;
					cnt += mm[r][k];
				}
			}
			for (int c : cols) {
				for (int k = 0; k < N; k++) {
					if (!used[{k, c}]) {
						used[{k, c}] = true;
						cnt += mm[k][c];
					}
				}
			}

			if (sum - cnt == K)
				++res;
		}
	}
	
	cout << res / 4 << endl;

	return 0;
}

Measured memory_bytes: 3608
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ANS = sum(B)
for i in range(N-1):
  if A[i] + 1 == A[i+1]:
    ANS += C[A[i]-1]
print(ANS)

Measured memory_bytes: 61900
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<ld> vld;

#define fi first
#define se second

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);

ll n,w;
ll arr[101][2];
ll dp[111][101111];
const int su = 1000*100+100;

int main()
{

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
	#ifdef DEBUG_
		freopen("input.txt","r",stdin);
	#endif
	
	cout.setf(ios::fixed), cout.precision(20);

	cin >> n >> w;
	//ll su=0;
	arr[0][0]=-1;
	arr[0][1]=-1;
	for(int i=1;i<=n;i++){
		cin >> arr[i][0] >> arr[i][1];
		//su+=arr[i][1];
	}

	
	// for(int i=0;i<101;i++){
	// 	for(int j=0;j<100001;j++)
	// 		dp[i][j]=inf;
	// }
	
	for(int j=1;j<=su;j++){
		dp[0][j]=inf;
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=su;j++){
			dp[i][j]=dp[i-1][j];
			//if(i==1 && j==0) cout<<dp[i][j]<<"\n";
			if(j-arr[i][1]>=0) 
				dp[i][j]=min(dp[i][j],dp[i-1][j-arr[i][1]]+arr[i][0]);
		}
	}
	
	ll ans=0;
	for(int i=0;i<=su;i++){
		if(dp[n][i]<=w) ans=max((ll)i,ans);
	}
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 80128
N=gets.to_i
h=Hash.new(0)
a=gets.chomp.split.map(&:to_i)
a.each do |v|
  h[v] += 1
end

ans=0
h.each do |k,v|
  ans += v*(v-1)/2
end

a.each do |v|
  puts ans - h[v]*(h[v]-1)/2 + (h[v]-1)*(h[v]-2)/2 
end

Measured memory_bytes: 31236
X = int(input())

prime_num = range(2, 32)
num_list = [1]

for p in prime_num:
    i = 2
    while p ** i <= X:
        i += 1
    if i > 2:
        num_list += [p ** (i - 1)]

print(max(filter(lambda x: x <= X, num_list)))

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    int x = Integer.parseInt(sc.next());
    int y = Integer.parseInt(sc.next());
    
    int N = s.length();
    if (x < -N || x > N || y < -N || y > N) {
      System.out.println("No");
      return;
    }
    byte okXe[] = new byte[2 * N + 1];
    byte okXo[] = new byte[2 * N + 1];
    byte okYe[] = new byte[2 * N + 1];
    byte okYo[] = new byte[2 * N + 1];
    for (int i = 0; i < 2 * N + 1; i++) {
      okXe[i] = 0;
      okXo[i] = 0;
      okYe[i] = 0;
      okYo[i] = 0;
    }
    okXe[N] = 1;
    okYe[N] = 1;
    
    int state = 0;
    int count = 0;
    for (int i = 0; i < N; i++) {
      if (s.charAt(i) == 'F') {
        count++;
      }
      if (s.charAt(i) == 'T' || i == N - 1) {
        if (state == 0) {
          okXo[N + count] = 1;
          okXe[N] = 0;
          count = 0;
          state = 1;
        } else if (state == 1) {
          move(okYe, okYo, count);
          count = 0;
          state = 2;
        } else if (state == 2) {
          move(okXo, okXe, count);
          count = 0;
          state = 3;
        } else if (state == 3) {
          move(okYo, okYe, count);
          count = 0;
          state = 4;
        } else if (state == 4) {
          move(okXe, okXo, count);
          count = 0;
          state = 1;
        }
      }
    }
    if (okXe[N + x] + okXo[N + x] == 1 && okYe[N + y] + okYo[N + y] == 1) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
  
  public static void move(byte a[], byte b[], int step) {
    for (int i = 0; i < a.length; i++) {
      if (a[i] == 1) {
        b[i - step] = 1;
        b[i + step] = 1;
        a[i] = 0;
      }
    }
  }
}


Measured memory_bytes: 24148
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int d[100];

int main()
{
	int N;
	int ans = 1;
	cin >> N;
	rep(i, N) cin >> d[i];
	sort(d, d + N);
	rep(i, N - 1) {
		if (d[N - 1 - i] > d[N - 2 - i]) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
public class Hello{
    public static void Main(){
        
        string [] str=Console.ReadLine().Split(' ');
        double a=double.Parse(str[0]);
        double b=double.Parse(str[1]);
        double c=double.Parse(str[2]);
        
        Console.WriteLine(0.5*a*b*Math.Sin(c*(Math.PI / 180)));
        Console.WriteLine(a+b+Math.Sqrt(a*a+b*b-2*a*b*Math.Cos(c*(Math.PI / 180))));
        Console.WriteLine(b*Math.Sin(c*(Math.PI / 180)));
    }
}


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

const int N = 200005;

int n;
long long a[N], b[N], c[N];
double ans = 0;
vector<pair<int, long long>> ve;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    int mx = distance(a, max_element(a, a + n));
    rotate(a, a + mx, a + n);
    rotate(b, b + mx, b + n);
    a[n] = a[0]; b[n] = b[0];
    for (int i = 1; i < n; i++) {
        c[i + 1] = 2 * (c[i] + b[i]) - c[i - 1];
    }
    for (int i = 0; i <= n; i++) {
        int x = i;
        long long y = a[i] - c[i];
        while (ve.size() >= 2) {
            auto [px, py] = ve[ve.size() - 2];
            auto [cx, cy] = ve.back();
            if ((x - px) * (cy - py) - (y - py) * (cx - px) <= 0) {
                ve.pop_back();
            } else {
                break;
            }
        }
        ve.push_back({x, y});
    }
    for (int i = 0; i < ve.size() - 1; i++) {
        auto [lx, ly] = ve[i];
        auto [rx, ry] = ve[i + 1];
        for (int x = lx; x < rx; x++) {
            ans += c[x] + ly + 1.0 * (ry - ly) / (rx - lx) * (x - lx);
        }
    }
    cout << fixed << setprecision(12) << ans / n;
}


Measured memory_bytes: 12028
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 300;

int n;
int pre[MaxN + 5];
LL a[MaxN + 5], flow[MaxN + 5];
LL cap[MaxN + 5][MaxN + 5];

void prepare() {
	int S = n + 1, T = n + 2;
	for(int i = 1; i <= n; i++) {
		if(a[i] <= 0) cap[S][i] = -a[i];
		else if(a[i] > 0) cap[i][T] = a[i];
	}
	for(int i = 1; i <= n; i++) {
		for(int j = 2 * i; j <= n; j += i)
			cap[i][j] = (1LL << 40);
	}
}

LL Bfs(int S, int T) {
	queue <int> q;
	memset(pre, -1, sizeof(pre));
	pre[S] = 0;
	flow[S] = (1LL << 50);
	q.push(S);
	while(!q.empty() ) {
		int v = q.front();
		q.pop();
		if(v == T) break;
		for(int i = 1; i <= n + 2; i++) {
			if(i != S && cap[v][i] > 0 && pre[i] == -1) {
				pre[i] = v;
				flow[i] = min(flow[v], cap[v][i]);
				q.push(i);
			}
		}
	}
	if(pre[T] == -1) return -1;
	else return flow[T];
}

LL EK(int S, int T) {
	LL augment = 0;
	LL sumflow = 0;
	while(true) {
		augment = Bfs(S, T);
		if(augment == -1) break;
		int node = T;
		while(node != S) {
			int last = pre[node];
			cap[last][node] -= augment;
			cap[node][last] += augment;
			node = last;
		}
		sumflow += augment;
	}
	return sumflow;
}

int main()
{
	while(scanf("%d", &n) != EOF)
	{
		LL sum = 0;
		for(int i = 1; i <= n; i++) {
			scanf("%lld", &a[i]);
			if(a[i] > 0) sum += a[i];
		}
		prepare();
		LL ans = EK(n + 1, n + 2);
		printf("%lld\n", sum - ans);
		memset(cap, 0, sizeof(cap));
	}
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int,int>;
const int MXN = 55;
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);
vector<PII> G[MXN], cond;
vector<int> route[MXN][MXN];

bool dfs(int s, int t, int u, int p)
{
    if(t == u)
    {
        return true;
    }
    for(auto edge: G[u])
    {
        if(edge.first == p)
        {
            continue;
        }
        if(dfs(s, t, edge.first, u))
        {
            route[s][t].push_back(edge.second);
            return true;
        }
    }
    return false;
}

int main()
{
    // IOS;
    int n, m;
    cin >> n;
    for (int i = 0, x, y; i < n - 1; ++i)
    {
        cin >> x >> y;
        G[x].push_back({y, i});
        G[y].push_back({x, i});
    }
    cin >> m;
    cond.resize(m + 5);
    for (int i = 0; i < m; ++i)
    {
        cin >> cond[i].first >> cond[i].second;
        dfs(cond[i].first, cond[i].second, cond[i].first, -1);
    }
    LL ans = (1LL << (n - 1));
    bitset<MXN> chosen;
    for (int i = 1; i < (1 << m); ++i)
    {
        // cout << i << " here\n";
        chosen.reset();
        for (int j = 0; j < m; ++j)
        {
            if((i >> j) & 1)
            {
                int s = cond[j].first, t = cond[j].second;
                for(auto r: route[s][t])
                {
                    chosen[r] = true;
                }
            }
        }
        int cnt = chosen.count();
        // cout << "cnt:" << cnt << ' ' << (1LL << (n - 1 - cnt)) << '\n';
        if(__builtin_popcount(i) & 1)
        {
            ans -= (1LL << (n - 1 - cnt));
        }
        else
        {
            ans += (1LL << (n - 1 - cnt));
        }
    }
    cout << ans << '\n';
}

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

int main() {
	string S;
	int s = 0, j = 0;
	char A;
	cin >> S;
	for (int i = 0; i < 4;i++) {
		if (S[0]==S[i]) {
			s++;
		}
		else {
			A = S[i];
		}
	}
	for (int i = 0; i < 4;i++) {
		if (S[i]==A) {
			j++;
		}
	}
	if (s==2&&j==2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

now = 0
time = int(input())
fi = 1
ans = 1
while now < time:
    thi = int(input())
    ans = lcm(ans, thi)
    now += 1
print(ans)

Measured memory_bytes: 3064