akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <algorithm>

using namespace std;

using ll = long long int;

int main(){
    
    ll N;
    array<ll, 200000> A;
    
    cin >> N;
    for(ll i = 0; i < N; ++i){
        cin >> A[i];
    }
    
    sort(A.begin(), A.begin() + N, [](auto a, auto b)->bool{
        return a > b;
    });
    
    ll last = -1;
    ll lastcnt = 1;
    ll cnt = 0;
    ll ans[2] = {0};
    for(ll i = 0; i < N; ++i){
        if(A[i] == last){
            lastcnt += 1;
            if(lastcnt == 2){
                ans[cnt++] = last;
                if(cnt >= 2)break;
                lastcnt = 0;
            }
        }else{
            last = A[i];
            lastcnt = 1;
        }
    }
    
    cout << ans[0] * ans[1] << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define MP make_pair
#define VI vector<int>
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=55;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

ll d[MAXn];
int main(){
    IOS();
    ll n;
    cin >> n;
    REP (i,n) cin >> d[i];
    ll ans = 0;
    REP (i,n) for (ll j=i+1;j<n;j++) ans += d[i] * d[j];
    cout << ans << endl;
}


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

int k;
double f(int i, double ninv)
{
  int c = 1;
  while (i < k)
  {
    i *= 2;
    c *= 2;
  }
  ninv /= c;
  return ninv;
}

int main()
{
  int n;
  cin >> n >> k;
  double ninv = 1.0 / n;
  double ans = 0;
  for (int i=1; i<=n; i++)
    ans += f(i, ninv);
  printf("%.10lf\n", ans);
}

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

#define int long long

using namespace std;

const int MOD = 1e9+7;

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

	int N;
	cin >> N;

	int sum = 0;

	int res = 0;

	for(int i = 0 ; i < N ; i++)
	{
		int n;
		cin >> n;

		res = (res + sum*n)%MOD;

		sum = (sum + n)%MOD;
	}    

	cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3652
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    # グラフに頂点と距離を追加
    G[u-1].append((v-1,w))
    G[v-1].append((u-1,w))

from collections import deque



Q, K = map(int,input().split())
dist_from_K = [0]*N
used = [False] * N
used[K-1] = True
before = K-1

q = deque([K-1])
while len(q) > 0:
    a = q.popleft()
    Vs = G[a]
    for u, w in Vs:
        if not used[u]:
            q.append(u)
            dist_from_K[u] = dist_from_K[a] + w
            used[u] = True

ans = []
for _ in range(Q):
    x,y = map(int,input().split())
    ans.append(dist_from_K[x-1]+dist_from_K[y-1])
for a in ans:
    print(a)

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

void a(){
    ll a,b,c;
    cin >> a >>b >>c;
    cout << (a==b&&b==c?"No":
             a==b?"Yes":
             a==c?"Yes":
             b==c?"Yes":"No");
}
void b(){
    ll n; cin >> n;
    auto a = vector<ll>(n,0);
    bool f=true;
    rep(i,n) {
        cin >> a[i];
        if(a[i]%2==0){
            if(a[i]%5==0||a[i]%3==0) continue;
        }else continue;
        f = false;
        break;
    }
    cout << (f?"APPROVED":"DENIED");
}

int main(){
    b();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        
        Scanner sc = new Scanner(System.in);
        int M = sc.nextInt();
        int D = sc.nextInt();
        
        int count = 0;
        for(int m=4;m<=M;m++){
            
            for(int i=2;i<=D/10;i++){
                
                for(int j=2;j<=9;j++){
                    
                    if(i==D/10&&j>D%10){
                        
                        break;
                    }
                    
                    
                    if(i*j==m){
                    count++;
                    
                }
            }
        }
        
        }
        System.out.println(count);
        
        
        
    }
}


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

#define MAX 1400

int dp[MAX + 1][MAX + 1];
int A[MAX + 1][MAX + 1];

int main(){
    
    int H, W, ans = 0;
    
    cin >> H >> W;
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W ; j++) {
            cin >> A[i][j];
        }
    }
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W ; j++) {
            if (A[i][j] == 1) dp[i][j] = 0;
            else{
                if (i-1 >= 0 && j-1 >= 0 && dp[i][j-1] > 0 && dp[i-1][j] > 0) {
                    //dp[i][j] = dp[i-1][j-1] + 1;
                    dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
                }
                else{
                    dp[i][j] = 1;
                }
            }
        }
    }
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W ; j++) {
            ans = max(ans, dp[i][j] * dp[i][j]);
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

#define endl '\n'

using namespace std;

typedef long long int lli;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  
    lli n;
    cin >> n;

    lli arr[n];

    for (lli i = 0; i < n; ++i)
        cin >> arr[i];

    lli stools = 0, tallest = arr[0];

    for (lli i = 1; i < n; ++i)
        if (tallest > arr[i]){
            stools += tallest - arr[i];
        }else {
            tallest = arr[i];
        }

    cout << stools;

    return 0;
}

Measured memory_bytes: 5172
#include <iostream>
#include <string>

int main()
{
  int N;
  std::string S;
  std::cin>>N>>S;
  
  int result=0;
  for(int i=0;i<N-2;i++)
  {
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')
    {
      result++;
      i=i+2;
    }
  }
  
  std::cout<<result<<std::endl;
  
  return 0;
}

Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
cnt=0
while True:
    flag=True
    for i in range(n-1):
        if p[i]==(i+1):
            p[i],p[i+1]=p[i+1],p[i]
            cnt+=1
            flag=False
    if flag:
        break
    for i in range(n-1):
        if p[i+1]==(i+1+1):
            p[i],p[i+1]=p[i+1],p[i]
            cnt+=1
print(cnt)


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

const int MAXN = 100 + 10;
int a[MAXN];
long long ans = 0x7fffffff;
int n, MIN = 0x7fffffff, MAX = 0x80000000;

int main()
{
    cin >> n ;
    for(int i = 1; i <= n; i++)
        cin >> a[i] , MIN = min(a[i], MIN), MAX = max(a[i], MAX);

    for(int i = MIN; i <= MAX; i++)
    {
        long long tmp = 0;
        for(int k = 1; k <= n; k++)
            tmp += (a[k] - i) * (a[k] - i);
        ans = min(tmp, ans);
    }
    cout << ans << endl ;
}


Measured memory_bytes: 256
class Node:
    def __init__(self, key, pri):
        self.left = None
        self.right = None
        self.key = key
        self.pri = pri

    def print_pre(self):
        yield self.key
        if self.left:
            for k in self.left.print_pre(): yield k
        if self.right:
            for k in self.right.print_pre(): yield k

    def print_in(self):
        if self.left:
            for k in self.left.print_in(): yield k
        yield self.key
        if self.right:
            for k in self.right.print_in(): yield k

class Tree:
  root = None

  def rightRotate(self, node):
    s = node.left
    node.left = s.right
    s.right = node
    if self.root == node:
      self.root = s
    return s

  def leftRotate(self, node):
    s = node.right
    node.right = s.left
    s.left = node
    if self.root == node:
      self.root = s
    return s

  def insert1(self, node, key, pri):
    if node == None:
      return Node(key, pri)
    elif key == node.key:
      return node

    elif key < node.key:
      node.left = self.insert1(node.left, key, pri)
      if node.pri < node.left.pri:
        node = self.rightRotate(node)
    else:
      node.right = self.insert1(node.right, key, pri)
      if node.pri < node.right.pri:
        node = self.leftRotate(node)
    return node

  def insert(self, key, pri):
    self.insert1(self.root, key, pri)
    if self.root == None:
      self.root = Node(key, pri)

  def delete(self, node, key):
    if node == None:
      return None
    if key < node.key:
      node.left = self.delete(node.left, key)
    elif key > node.key:
      node.right = self.delete(node.right, key)
    else:
      return self.delete1(node, key)
    return node

  def delete1(self, node, key):
    if node.left == None and node.right == None:
      return None
    elif node.left == None:
      node = self.leftRotate(node)
    elif node.right == None:
      node = self.rightRotate(node)
    else:
      if node.left.pri > node.right.pri:
        node = self.rightRotate(node)
      else:
        node = self.leftRotate(node)
    return self.delete(node, key)

  def find(self, key):
        y = None
        x = self.root
        while x:
            y = x
            if key == x.key:
              break
            elif key < x.key:
              x = x.left
            else:
              x = x.right
            
        if key == y.key:
            return y

  def print(self):
        print(' ', end='')
        print(*self.root.print_in())
        print(' ', end='')
        print(*self.root.print_pre())

tree = Tree()
m = int(input())

while m:
  l = input().split()
  if len(l) == 3:
    tree.insert(int(l[1]), int(l[2]))
  elif len(l) == 2 and l[0] == "find":
    y = tree.find(int(l[1]))
    if y:
      print("yes")
    else:
      print("no")
  elif len(l) == 2 and l[0] == "delete":
    tree.delete(tree.root, int(l[1]))
  else:
    tree.print()
  m -= 1


Measured memory_bytes: 54784
import sys
n,k = map(int,input().split())
l = list(map(int, input().split()))
dp = [sys.maxsize] *n
dp[0] = 0
for i in range(n):
    for j in range(i+1,i+k+1):
        if(j<n):
            dp[j]=min(dp[j],dp[i]+abs(l[i]-l[j]))
print(dp[n-1])

Measured memory_bytes: 52448
#include <iostream>

struct point {
    int x, y;
} p1[1000001], p2[1000001], *cur, *last;
int len1, len2;
char mp[1001][1001];

int main() {
    int h, w;
    std::cin >> h >> w;
    cur = p2;
    last = p1;
    for (int i = 0; i < h; i++) {
        std::cin >> mp[i];
        for (int j = 0; mp[i][j] != '\0'; j++) {
            if (mp[i][j] == '.')
                continue;
            p1[len1].x = i;
            p1[len1++].y = j;
        }
    }
    int r = 0;
    while (true) {
        len2 = 0;
        for (int i = 0; i < len1; i++) {
            int x = last[i].x, y = last[i].y;
            if (y > 0 && mp[x][y-1] == '.') {
                cur[len2].x  = x;
                cur[len2++].y = y-1;
                mp[x][y-1] = '#';
            }
            if (x > 0 && mp[x-1][y] == '.') {
                cur[len2].x  = x-1;
                cur[len2++].y = y;
                mp[x-1][y] = '#';
            }
            if (y < w-1 && mp[x][y+1] == '.') {
                cur[len2].x  = x;
                cur[len2++].y = y+1;
                mp[x][y+1] = '#';
            }
            if (x < h-1 && mp[x+1][y] == '.') {
                cur[len2].x  = x+1;
                cur[len2++].y = y;
                mp[x+1][y] = '#';
            }
        }
        std::swap(cur, last);
        len1 = len2;
        if (len1 == 0)
            break;
        r++;
    }
    std::cout << r << std::endl;
    return 0;
}


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

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    vector<int> b(m);
    rep(i, n) cin >> a.at(i);
    rep(i, m) cin >> b.at(i);

    ll t = 0;
    rep(i, m) t += b.at(i);

    int j = m;
    int ans = 0;
    rep(i, n + 1) {

        while (j > 0 && t > k) {
            --j;
            t -= b.at(j);
        }

        if (t > k)break;
        ans = max(ans, i + j);

        if (i == n)break;
        t += a.at(i);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1001001001;

const int mod = 1000000007;


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

    // 全部マイナス
    if ((l + n) <= 0) {
        int a1 = l;
        n = n - 1;
        //一番おいしいものを除く
        cout << n * (2 * a1 + (n - 1)) / 2 << endl;

        // またぐ
    } else if ((l <= 0) && (l + n) >= 0) {
        cout << n * (2 * l + (n - 1)) / 2 << endl;
        // 全部プラス
    } else {
        // 一番まずいものを除く

        int a1 = l + 1;
        n = n - 1;
        cout << n * (2 * a1 + (n - 1)) / 2 << endl;

    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,v[56]={11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>n;
    for(int i=0;i<n;++i)
        cout<<v[i]<<" ";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,a[100],i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int max=0,min=1000;
  for(i=0;i<n;i++){
    if(a[i]>max) max=a[i];
  }
  for(i=0;i<n;i++){
    if(a[i]<min) min=a[i];
  }
  printf("%d",max-min);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    long long int a,b,c;
    cin >> a >> b >> c;
    
    if(c < a+b){
        cout << "No" << endl;
    }
    else{
    if(0 < a*a + b*b + c*c - 2*a*b - 2*b*c - 2*c*a){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    }
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

string str;
int idx;

int expr();
int term();
int number();

int number() {
  string res = "";
  while(idx < (int)str.size() && isdigit(str[idx])) res += str[idx++];
  reverse(all(res));
  return stoll(res);
}

int term() {
  if(isdigit(str[idx])) return number();
  if(str[idx] == '>') {
    idx++;
    int x = expr();
    assert(str[idx++] == '<');
    assert(str[idx++] == 'S');
    return x*x % mod;
  } else {
    assert(false);
    return 0;
  }
}

int expr() {
  int y = term();
  if(idx >= (int)str.size()) return y;
  if(str[idx] == '<') return y;
  else if(str[idx] == '>') {
    idx++;
    assert(str[idx++] == '>');
    int x = expr();
    return y > 30 ? 0 : x>>y;
  } else {
    assert(false);
    return 0;
  }
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string buf;
  while(getline(cin, buf), buf != "#") {
    str = "";
    rep(i, buf.size()) if(buf[i] != ' ') str += buf[i];
    reverse(all(str));
    idx = 0;
    cout << expr() << endl;
  }


  return 0;
}

Measured memory_bytes: 5452
#include <iostream>
#include <queue>

using namespace std;

namespace {

const char kOps[4] = {'S', 'N', 'E', 'W'};

struct State {
  const int* v;
  int top;
  int bottom;
  int front;
  int back;
  int left;
  int right;

  void Init(const int* a) {
    v = a;
    top = 1;
    bottom = 6;
    front = 2;
    back = 5;
    left = 4;
    right = 3;
  }

  bool Equal(const State& o) const {
    return v[top - 1] == o.v[o.top - 1] && v[bottom - 1] == o.v[o.bottom - 1] &&
           v[front - 1] == o.v[o.front - 1] && v[back - 1] == o.v[o.back - 1] &&
           v[left - 1] == o.v[o.left - 1] && v[right - 1] == o.v[o.right - 1];
  }
};

State Next(const State& s, char c) {
  State o;
  o.v = s.v;
  int temp = 0;
  switch (c) {
    case 'S':
      temp = s.front;
      o.front = s.top;
      o.top = s.back;
      o.back = s.bottom;
      o.bottom = temp;
      o.left = s.left;
      o.right = s.right;
      break;
    case 'N':
      temp = s.back;
      o.back = s.top;
      o.top = s.front;
      o.front = s.bottom;
      o.bottom = temp;
      o.left = s.left;
      o.right = s.right;
      break;
    case 'E':
      temp = s.right;
      o.right = s.top;
      o.top = s.left;
      o.left = s.bottom;
      o.bottom = temp;
      o.front = s.front;
      o.back = s.back;
      break;
    case 'W':
      temp = s.left;
      o.left = s.top;
      o.top = s.right;
      o.right = s.bottom;
      o.bottom = temp;
      o.front = s.front;
      o.back = s.back;
      break;
  }
  return o;
}

bool BFS(const int* values1, const int* values2) {
  State goal;
  goal.Init(values1);

  State start;
  start.Init(values2);
  queue<State> q;
  q.push(start);

  int n = 0;
  while (!q.empty()) {
    if (n >= 24) break;
    const State p = q.front();
    q.pop();

    for (size_t i = 0; i < 4; ++i) {
      State o = Next(p, kOps[i]);
      if (goal.Equal(o)) {
        return true;
      }
      q.push(o);
    }
    ++n;
  }

  return false;
}

}  // namespace

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

  int values[100][6];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 6; ++j) {
      cin >> values[i][j];
    }
  }

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (BFS(values[i], values[j])) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



typedef long long ll;
int N, M, A[101010], D[101010];
map<int, vector<int>> MA;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) MA[A[i]].push_back(i);

    ll count = 0;
    int cnt = 0;
    rep(i, 0, N - 1) {
        if (A[i] < A[i + 1]) {
            count += A[i + 1] - A[i];
            D[i] = A[i + 1] - A[i];
        }
        else {
            count += A[i + 1];
            D[i] = (A[i + 1] + M) - A[i];
        }

        if (A[i] > A[i + 1]) cnt++;
    }

    //rep(i, 0, N - 1) printf("%d -> %d\n", i, D[i]);



    ll ans = count;
    //printf("1 : %d %d\n", ans, cnt);
    rep(i, 2, M + 1) {
        count -= cnt;
        for (int j : MA[i - 1]) if(0 < j) {
            cnt--;
            count += D[j - 1];
        }
        for (int j : MA[i - 1]) if (j < N - 1) {
            cnt++;
        }

        ans = min(ans, count);

        //printf("%d : %d %d\n", i, count, cnt);
    }

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

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

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

    rep(i, x + 1)
    {
        int rg = i * 2 + (x - i) * 4;
        if (rg == y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var S = ReadLine();

        var freq = S.GroupBy(x => x).ToDictionary(k => k.Key, e => e.Count());

        var ok = freq.Count == 2 && freq.ElementAt(0).Value == 2;

        WriteLine(ok ? "Yes" : "No");
    }
}


Measured memory_bytes: 26704
#include <bits/stdc++.h>
// #include <math.h>
// #include <cmath>
#include <vector>
#include <utility> 
// #include <unordered_map>

using namespace std;
typedef long long int lli;

#define M_PI_H  3.14159265358979323846/2  /* pi by two*/
#define rep(i, start, end) for(int i = start; i < end; i++) 
#define repr(i, start, end) for(int i = s; i >= end; i--)   //INCLUSIVE

int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	
	int a, b;
  cin>>a>>b;
  cout<<a*b;

    return 0;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <algorithm>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using isize = std::intptr_t;
using usize = std::uintptr_t;

char ans[100];

auto main() -> i32 {
	i64 n;
	scanf("%ld", &n);
	--n;
	char* p = ans + 98;
	while (true) {
		*p-- = 'a' + n % 26;
		if (n < 26) {
			break;
		}
		n = n / 26 - 1;
	}
	puts(p + 1);
	return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    ll ans = 1000 * (n/500);
    n%=500;
    ans = ans + 5*(n/5);
    cout<<ans;
}



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

#define input int t;cin>>t;while(t--)
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++) 
#define fab(i,a,b) for(int i=a;i<=b;i++)
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll arr[3];
    arr[0]=a+b;
    arr[1]=a*b;
    arr[2]=a-b;
    sort(arr,arr+3);
    cout<<arr[2]<<endl;
    
	return 0;
}

Measured memory_bytes: 384
import scala.io.Source.stdin

object Main {

  def getFigure(a:Array[Array[Int]]):String = {
    def f(i:Int,j:Int) = if(i>=0 && j>=0 && i<8 && j<8) a(i)(j) else 0
    def loop(i:Int,j:Int):String = {
      (i,j) match {
        case (7,7) => "NG"
        case (i,j) =>
          if(a(i)(j) == 1) {
            (f(i,j+1),f(i,j+2),f(i+1,j),f(i+2,j),f(i+1,j+1),f(i+1,j-1)) match {
              case (1,0,1,0,1,0) => "A"
              case (0,0,1,1,0,0) => "B"
              case (1,1,0,0,0,0) => "C"
              case (0,0,1,0,0,1) => "D"
              case (1,0,0,0,1,0) => "E"
              case (0,0,1,0,1,0) => "F"
              case (1,0,1,0,0,1) => "G"
              case (_,_,_,_,_,_) => "NG"
            }
          } else { if(j==7) loop(i+1,0) else loop(i,j+1) }
      }
    }
    loop(0,0)
  }

  def main(args:Array[String]) = {
    stdin.getLines.filter(_!="").sliding(8,8).foreach { s =>
      println { getFigure({for(i <- s) yield i.toArray.map(_.asDigit)}.toArray) }
    }
  }
}

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

using namespace std;
   
        
      


    void solve(){
         int n, w ;
         cin>>n>>w;
         vector<int>values(n);
         vector<int>weights(n);
         for(int i = 0; i < n;++i) cin>>weights[i]>>values[i];
        int sum = 0;
         for(int x : values) sum += x;
         vector<long long> dp (sum+1,(long long )1e18);
         dp[0] = 0;
         for(int i = 0;i<n;++i){
             for(int temp = sum - values[i];temp>=0;--temp){
                    
                        dp[temp + values[i] ] = min(dp[temp + values[i] ], dp[temp] + weights[i]);
                    
             }
         }    
         long long an = 0;
            for(int i = 0;i<=sum;++i){
                if(dp[i]<=w) an = max(an,(long long)i);
            }

        
        cout<<an<<'\n';
    }

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int tc = 1;
    //cin>>tc;
    while (tc--)
    {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3972
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x, y;
		while (true) {
			x = sc.nextInt();
			y = sc.nextInt();
			if (x == 0 && y == 0)
				break;
			if (x < y)
				System.out.println(x + " " + y);
			else
				System.out.println(y + " " + x);
		}
	}
}



Measured memory_bytes: 36508
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n,m;
vector<vector<int>> s;
void make(vector<int> a){
    if(a.size()==0){
        for(int i=1;i<=m;i++){
            a.emplace_back(i);
            make(a);
            a.pop_back();
        }
    }else if(a.size()<n){
        for(int i=a[a.size()-1];i<=m;i++){
            a.emplace_back(i);
            make(a);
            a.pop_back();
        }
    }else{
        s.push_back(a);
    }
}
int main(){
    int q;
    cin>>n>>m>>q;
    vector<int> t(0);
    make(t);
    vector<int> a(q),b(q),c(q),d(q);
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;
        b[i]--;
    }
    int ret=0;
    for(int i=0;i<s.size();i++){
        int cnt=0;
        for(int j=0;j<q;j++){
            if(s[i][b[j]]-s[i][a[j]]==c[j])cnt+=d[j];
        }
        ret=max(ret,cnt);
    }
    cout<<ret<<endl;
}

Measured memory_bytes: 9868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

int main() {
    int n;
    cin >> n;
    int ans[n][n];
    rep (i, n) rep (j, n) ans[i][j] = 0;
    rep (i, n) {
        int a, k;
        cin >> a >> k;
        rep (j, k) {
            int b;
            cin >> b;
            ans[a - 1][b - 1] = 1;
        }
    }
    rep (i, n) {
        rep (j, n) {
            if (j != 0) cout << " ";
            cout << ans[i][j];
        }
        cout << "\n";
    }
}


Measured memory_bytes: 3108
# -*- coding: utf-8 -*-

n, m = list(map(int, input().split()))

A = [[0 for _ in range(m)] for _ in range(n)]
b = [0 for _ in range(m)]
c = [0 for _ in range(n)]

for row in range(n):
    arow = list(map(int, input().split()))
    for j in range(m):
        A[row][j] = arow[j]

for row in range(m):
    b[row] = int(input())

for row in range(n):
    for k in range(m):
        c[row] += A[row][k] * b[k]

for j in c:
    print(j)


Measured memory_bytes: 6008
import java.util.*;
import java.math.*;
import java.lang.String;
import java.lang.System;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();
		String[] arr = s.split("");
		int m = a + b;
		int count = 0;
		int countb = 0;
		
		for (int i = 0; i < n; i++) {
			if (arr[i].equals("a")) {
				count++;
				if (count <= m) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			} else if (arr[i].equals("b")) {
				count++;
				countb++;
				if (count <= m && countb <= b) {
					System.out.println("Yes");
				} else {
					count--;
					countb--;
					System.out.println("No");
				}
			} else {
				System.out.println("No");
			}
		}
		
		
	}
}

Measured memory_bytes: 33752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int AB1 = A + B;
		int AB2 = A - B;
		int AB3 = A * B;
		if (AB3 > AB2 && AB3 > AB1) {
			System.out.println(AB3);
		} else if (AB2 > AB3 && AB2 > AB1) {
			System.out.println(AB2);
		} else {
			System.out.println(AB1);
		}
	}
}

Measured memory_bytes: 23892
using System;

namespace myApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] arr = Console.ReadLine().Split(' ');
            
            int n = int.Parse(arr[0]);
            int a = int.Parse(arr[1]);
            int b = int.Parse(arr[2]);
            int sum = 0;
            int total = 0;
            int alt;
            for(int i = 1; i <= n ; i++)
            {
                alt = i;
                bool check = true;
                do{
                    sum += alt % 10;
                    alt /= 10;
                    if(alt == 0)
                        check = false;
                } while( check);
                if( a<= sum && sum <= b)
                    total += i;
                sum = 0;
            }

            Console.WriteLine(total);
        }
    }
}


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

int main() {
	string S;
	cin >> S;
	bool judge = false;
	for (int i = 1; i < S.length(); i++) {
		if (S[i] == S[i - 1]) {
			judge = true;
		}
	}
	cout << (judge ? "Bad" : "Good") << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    while (input.hasNext()){
      int N = input.nextInt();

      if (N % digitSum(N) == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }
  
  private static int digitSum (int N){
     int digitSum = 0;
     
     while(N > 0){
        digitSum += N % 10;
        N /= 10;
     }
    
     return digitSum;
  }
}

Measured memory_bytes: 21332
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<stdlib.h>
using namespace std;
int a[109];
int main()
{
    int i,T,j,sum1,sum2,n,Min=1009;
    cin>>n;
    for( i=1; i<=n; i++)
        cin>>a[i];
    for(i=1; i<=n-1; i++)
    {

        sum1=0;
        sum2=0;
        T=i;
        for(j=1; j<=T; j++)
            sum1+=a[j];
        for(j=T+1; j<=n; j++)
            sum2+=a[j];
        if(abs(sum1-sum2)<Min)
        {
            Min=abs(sum1-sum2);
        }
    }
    cout<<Min<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	int a,b; cin>>a>>b;
	int s=abs(a-n);
	int t=abs(b-n);
	if(s>t) cout<<"B"<<endl;
	else cout<<"A"<<endl;
	
	return 0;
}

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

using namespace std;

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

	int ans = N;
	while (1) {
		if (ans % 2 == 0 && ans % N == 0)
		{
			cout << ans << endl;
			break;
		}
		ans++;
	}


}


Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

    string ans = "No";

    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (i * j == n) ans = "Yes";
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import Data.Bits ((.&.))
import Data.Array.IO(IOArray,newListArray,readArray)

main = do
    n <- read <$> getLine
    list <- (fmap read . words) <$> getLine
    arr <- newListArray (1,n) list
    ans <- solve n 1 1 0 arr 0
    putStrLn $ show $ ans

solve :: Int -> Int -> Int -> Int -> IOArray Int Int -> Int -> IO Int
solve lim l r bsum arr ac
    | l>lim  = return ac
    | lim>=r = do
        rVal <- readArray arr r
        case bsum.&.rVal==0 of
            True -> solve lim l (r+1) (bsum+rVal) arr (ac+r-l+1)
            False -> shiftL
    | otherwise = shiftL
        where
            shiftL = do
                lVal <- readArray arr l
                solve lim (l+1) r (bsum-lVal) arr ac

Measured memory_bytes: 88828
<?php
 
$input = file_get_contents('php://stdin');
 
$alphabet = array_fill_keys(range('a', 'z'), 0);
foreach (str_split($input) as $c) {
    if (! ctype_alpha($c)) { continue; }
 
    $alphabet[strtolower($c)]++;
}
 
foreach ($alphabet as $char => $count) {
    printf('%s : %d%s', $char, $count, PHP_EOL);
}

Measured memory_bytes: 6796
//AtCoder-arc072F
#include <bits/stdc++.h>
using namespace std;

template <typename _tp> inline void read(_tp&x) {
	char ch=getchar(),ob=0;x=0;
	while(ch!='-'&&!isdigit(ch))ch=getchar();if(ch=='-')ob=1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();if(ob)x=-x;
}

const int N = 501000;
int n, L;

struct node {
	double t, v;
	friend inline node operator * (const node&A, const node&B) {
		return (node) {(A.t*A.v + B.t*B.v) / (A.v + B.v), A.v + B.v};
	}
} p[N];

int main() {
	read(n), read(L);
	int l = 1, r = 0, t, v;
	double heat = 0, volume = 0;
	for(int i=1;i<=n;++i) {
		read(t), read(v);
		while(volume + v > L) {
			double dec = min(p[l].v, volume + v - L);
			volume -= dec;
			heat -= p[l].t * dec;
			if(!(p[l].v -= dec)) ++l;
		}
		heat += (double)t * v, volume += v;
		p[++r] = (node) {t, v};
		while(l < r and p[r-1].t > p[r].t) p[r-1] = p[r-1] * p[r], --r;
		printf("%.7lf\n", (double)heat / volume);
	}
	return 0;
}

Measured memory_bytes: 16896
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }

    val ans = (1..n).map {

        var c = 0
        var p = it

        while (p < k) {
            p *= 2
            c++
        }

        1.0 / n.toDouble() * Math.pow(0.5, c.toDouble())
    }.sum()

    println(ans)
}


Measured memory_bytes: 38716
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
const double pie  =3.141592653589793238463;
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define POP(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(),A.end());
#define REV(A) reverse(A.begin(), A.end());
#define lenth length()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n" 
const ll dx[4] = { -1, 1, 0, 0};
const ll dy[4] = {0, 0, -1, 1};
ll XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
ll YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
#define precise(x) cout<<fixed<<setprecision(x)
#define t1(x)                cerr<<#x<<": "<<x<<endl
#define t2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
void SieveOfEratosthenes(ll n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // for (ll p=2; p<=n; p++) 
       // if (prime[p]) 
          // cout << p << " "; 
} 

ll power(ll x, ll y) 
{ 
    ll res = 1; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x * x; 
    } 
    return res; 
}
int main()
{
    fastio
    ll t,i,j,k,l,s,m,n,a,x,b,y,z,c,h,d,e,p,o,nl,np,q,r;
    cin>>n;
    if(n%1000==0)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<1000-n%1000<<endl;
    }

}

Measured memory_bytes: 3604
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define P pair<ll,ll>
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	ll a; ld b;
	cin >> a >> b;
	cout << (ll)(a*b) << endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  string s;
  cin >> s;

  int ans = 1000;
  rep(i, s.size() - 2) {
     string ss = s.substr(i, 3);
     ans = min(ans, abs(753 - stoi(ss))); 
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
	int D;
	cin >> D;
	if (D == 22)cout << "Christmas Eve Eve Eve" << endl;
	else if (D == 23)cout << "Christmas Eve Eve" << endl;
	else if (D == 24)cout << "Christmas Eve" << endl;
	else cout << "Christmas" << endl;
	return 0;
}


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

void solve(int K)
{
    if (K % 2 == 0 || K % 5 == 0)
    {
        cout << -1 << endl;
        return;
    }

    int res = 1;
    int64_t x = 7 % K;
    while (x != 0)
    {
        res++;
        x = (x * 10 + 7) % K;
    }
    cout << res << endl;
}

int main()
{
    int K;
    cin >> K;
    solve(K);
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

int GCD(int x, int y) {
	return x ? GCD(y % x, x) : y;
}

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using uint1024_t = mp::uint1024_t;
using namespace std;
int main() {
	vector<int> ss(26), tt(26);
	string s, t;
	cin >> s >> t;
	bool ans = true;
	rep(i, s.size()) {
		int a = s[i] - 97;
		int b = t[i] - 97;
		ss[a]++;
		tt[b]++;
	}
	sort(all(ss));
	sort(all(tt));
	rep(i, 26) {
	//	cout << ss[i] << " " << tt[i] << endl;
		if (ss[i] != tt[i]) {
			ans = false;
		}
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 776
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <complex>
using namespace std;

int main() {
	string S;
	cin >> S;
	int min = 1000;
	for (int i = 0; i < S.length()-2; i++) {
		string str = "";
		for (int j = i; j < i+3; j++) {
			str += S[j];
		}
		int num = atoi(str.c_str());
		min = std::min(min, abs(num-753));
	}
	cout << min << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
long calc(string s) {
  long ans = 0;
  string n = "";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '+') {
      ans += std::stol(n);
      n = "";
    } else {
      n += s[i];
    }
  }
  ans += std::stol(n);
  return ans;
}

void solve(string S, long *ans, int n, int sharp) {
  if (n+sharp == S.size()) {
    // cout << "(then節)n: " << n << endl;
    // cout << "(then節)S: " << S << endl;
    (*ans) += calc(S);
  } else {
    // cout << "(else節)n " << n << endl;
    // cout << "(else節)S " << S << endl;
    solve(S,ans,n+1,sharp);
    solve(S.substr(0,n+sharp)+"+"+S.substr(n+sharp,S.size()-(n+sharp)),ans,n+1,sharp+1);
  }
}


int main() {
  string S;
  cin >> S;
  long ans = 0;
  //cout << calc("1+2+3+4") << endl;
  solve(S,&ans,1,0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  for (int i = 0; i < S.size(); i++) {
    if (i%2 == 0 && S.at(i) == 'L'){
      cout << "No" << endl;
      return 0;
    }
    else if (i%2 == 1 && S.at(i) == 'R'){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  string s; cin >> s;
  char c = *min_element(begin(s), end(s));
  if (k >= __lg(2 * n - 1)) {
    cout << string(n, c) << '\n';
  } else {
    string res = s;
    for (int i = 0; i <= n; ++i) {
      string crr = s + s;
      reverse(begin(crr) + n, end(crr));
      crr = crr.substr(i, n);
      res = min(res, crr);
      for (int t = 1; t < k; ++t) {
        crr += crr;
        reverse(begin(crr) + n, end(crr));
        if (t == k - 1) {
          int j = n;
          while (j and crr[j - 1] == crr[n]) --j;
          crr = crr.substr(j, n);
          res = min(res, crr);
        } else {
          int j = n;
          while (crr[j] == crr[n]) ++j;
          crr = crr.substr(j - n, n);
        }
      }
    }
    cout << res << '\n';
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
//ここまで共通
llong FUNC(llong i, llong j) {
	llong ANS = i * i * i * i * i - j * j * j * j * j;
	return ANS;
}
llong X;
int main() {
	cin >> X;
	vector<llong> V = AllDivisors(X);
	for (llong i = 0; i < V.size(); i++) {
		llong x = V[i];
		for (llong B = -x; ; B++) {
			llong tmp = FUNC(B + x, B);
			if (tmp == X) {
				cout << B + x << " " << B << endl;
				return 0;
			}
			if (tmp > X && B >= 10) break;
		}
	}
}

Measured memory_bytes: 3528
#include <stdio.h>

#define NODE (3000)
#define INF (100000000)

int v[NODE + 1];
int dist[NODE + 1];
int w[NODE + 1][NODE + 1];

int n, m, k;

int max(int a, int b)
{
    return (a > b ? a : b);
}

void dijkstra(int start)
{
    int i, j;
    int node;
    
    for (i = 1; i <= n; i++){
        v[i] = 0;
    }
    
    dist[start] = 0;
    
    while (1){
        node = -1;
        for (i = 1; i <= n; i++){
            if (v[i] == 0 && (node == -1 || dist[node] > dist[i])){
                node = i;
            }
        }
        
        if (node == -1){
            break;
        }
        
        v[node] = 1;
        
        for (i = 1; i <= n; i++){
            if (dist[i] > dist[node] + w[node][i] && v[i] == 0){
                dist[i] = dist[node] + w[node][i];
            }
        }
    }
}

int main(void)
{
    int i, j;
    int from, to, cost, res;
    
    scanf("%d%d%d", &n, &m, &k);
    
    for (i = 1; i <= n; i++){
        dist[i] = INF;
        for (j = 1; j <= n; j++){
            w[i][j] = INF;
            if (i == j){
                w[i][j] = 0;
            }
        }
    }
    
    for (i = 1; i <= m; i++){
        scanf("%d%d%d", &from, &to, &cost);
        w[from][to] = w[to][from] = cost;
    }
    for (i = 1; i <= k; i++){
        scanf("%d", &from);
        dist[from] = 0;
    }
    dijkstra(from);
    res = 0;
    
    for (i = 1; i <= n; i++){
        for (j = i + 1; j <= n; j++){
            if (w[i][j] != INF){
                res = max(res, (w[i][j] + dist[i] + dist[j] + 1) / 2);
            }
        }
    }
    
    printf("%d\n", res);
    
    return (0);
}

Measured memory_bytes: 0