akhauriyash/Code-Regression huggingface dataset:
'''
Search - Allocation
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_D

Algorythm
Referenced #1670532 Solution for ALDS1_4_D: Allocation by Chris_Kobayashi

1. Decide the searching point -> (top of the range + bottom of the range) / 2
2. Check whether it is possible to load all of the luggage to the trugs
    in the weight limit of the searching point
3. If it is possible, then move the top to the searching point
   If it is impossible, then move the bottom to the searching point + 1
4. Continue 1~4 as long as the top is greater than bottom

Range
Serching the maximum loading capacity(MLC) number
 between the maximam weight item num and the total weight num

top: total weight num
.
.
. <- search the num point
.
.
bottom: maximam weight item num

Why?
A1. Why not "bot = sp" but "bot = sp + 1"?
Q1. for example
    top = 5
    bot = 3
    sp = (5 + 3) / 2 = 4
    ...
    bot = sp
    sp = (5 + 4) / 2 = 4
    ...
    bot = sp
    ...for inf

A2. Why the top is total weight and bot is max weight?
Q2. Sure it is ok "top = 99999999, bot = 0".
     But, MLC never pass the total weight
      and the limit never be lower than the max.
       So, it is the most effective range.

Note
1. This program contains the idea below
    - Using "binary search" idea
    - The appropriate range
2. To be the python program more fast
    - Using int(raw_input()) instead of input()
    - To rewrite the processings for the function is more fast 
'''

# input
n, k = map(int,raw_input().split())
w = []
for i in xrange(n):
    w.append(int(raw_input()))

def tempf(sp):
    tk = 0 # temp index of the trugs
    weight = 0 # temp total weight of a trug

    # check whether it is possible to load all of the luggage
    #  to the trugs in the weight limit of the searching point
    for tw in w:
        if weight + tw <= sp:
            weight += tw
        else:
            tk += 1
            if tk >= k:
                # when impossible, then raise the bottom
                return False
            weight = tw
    else:
        # when possible, then lowering the top
        return True

# initial searching range
top = sum(w) # the top of the searching range
bot = max(w) # the bottom of the searching range

# searching until there is no serching range
while top > bot:
    sp = (top + bot) / 2 # the searching point

    if tempf(sp):
        top = sp
    else:
        bot = sp + 1

# output MLC
print top

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

using namespace std;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int dx = x2 - x1;
    int dy = y2 - y1;

    int x3 = x2 - dy;
    int y3 = y2 + dx;
    int x4 = x1 - dy;
    int y4 = y1 + dx;

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

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(bf.readLine());
        int[] a = new int[n];
        int[] b = new int[n];
        long sum = 0;
        int min = Integer.MAX_VALUE;
        for(int i=0; i<n; i++) {
          StringTokenizer st = new StringTokenizer(bf.readLine());
          a[i] = Integer.parseInt(st.nextToken());
          b[i] = Integer.parseInt(st.nextToken());
          if(a[i] > b[i]) {
            if(b[i] < min) min = b[i];
          }
          sum += a[i];
        }
        if(min == Integer.MAX_VALUE) out.println(0);
        else out.println((sum - min));

        // int[] a = new int[n];
        // for(int i=0; i<n; i++) a[i] =  Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }


}


Measured memory_bytes: 28712
a = int(input())
def keisan(x, y):
	return y-4*x

if a%4==0 or a%11==0:
	print("Yes")
else:
	for i in range(a//4):
		keisan(i, a)
		#print(keisan(i, a))
		if keisan(i, a)%7==0:
			print("Yes")
			break
	else:
		print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <queue>
#include <utility>
#include <algorithm>

using namespace std;

bool mmp (const pair<int,int>& x,const pair<int,int>& y){
    if(x.first < y.first) return true;
    return false;
}

pair<int,int> ax[100005];
int main()
{
    int N,i,a,b;
    long long K;
    pair<int,int> x;
    scanf("%d%lld",&N,&K);
    for(i=0;i<N;i++){
        scanf("%d%d",&a,&b);
        ax[i] = make_pair(a,b);
    }
    sort(ax,ax+N,mmp);
    for(i=0;;i++){
        K -= ax[i].second;
        if(K<=0) break;
    }
    printf("%d",ax[i].first);
    return 0;
}


Measured memory_bytes: 1024
k=int(input())
a=list(map(int,input().split()))
a.reverse()
d=[2,2]
f=True
for i in a:
  d[0]=((d[0]-1)//i+1)*i
  d[1]=d[1]//i*i+i-1
  if d[0]>d[1]:
    f=False
if f:
  print(d[0],d[1])
else:
  print(-1)

Measured memory_bytes: 84896
#include<stdio.h>
#include<string.h>
#define MAX 10001

int LCSLength(char [MAX] , char [MAX]);
int A[MAX][MAX];

int main(){

  int i,j,n,Z[MAX];
  char X[MAX],Y[MAX];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    
    scanf("%s",X);
    scanf("%s",Y);
    Z[i]=LCSLength(X,Y);
     

  }
   for(i=0;i<n;i++)printf("%d\n",Z[i]);

  return 0;
}


int LCSLength(char X[MAX] , char  Y[MAX]){

  int m,n,i,j,max=0;

  m=strlen(X);
  n=strlen(Y);
  
  for(i=1;i<=m;i++)A[i][0]=0;
  for(j=0;j<=n;j++)A[0][j]=0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      A[i][j]=0;
      if(X[i-1]==Y[j-1]){
	A[i][j]=A[i-1][j-1]+1;
	
      }
      else if(A[i-1][j]>=A[i][j-1])
	A[i][j]=A[i-1][j];
      else A[i][j]=A[i][j-1];
    }
    }
  
  return A[m][n];
}

Measured memory_bytes: 39952
#!/usr/bin/env python3
import sys
from heapq import heappop, heappush

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
# INF = sys.maxsize
INF = 10 ** 27 + 1
# INF = float("inf")


def dp(*x):  # debugprint
    print(*x)


def solve(N, A, B, C, D):
    "void()"

    MIN_COST = min(A, B, C, D)

    to_visit = [-N]
    cost = {N: 0}

    answer = 1e+99

    def put(n, c):
        # dp("put: n,c", n, c)
        cost[n] = min(cost.get(n, INF), c)
        heappush(to_visit, -n)

    visited = N + 1
    while to_visit:
        n = -heappop(to_visit)
        if n == visited:
            continue
        # dp("visit: n", n, cost)

        visited = n
        c = cost[n]
        put(0, c + n * D)

        if n % 2 == 0:
            put(n // 2, c + A)
        else:
            put((n+1) // 2, c + A + D)
            put((n-1) // 2, c + A + D)

        if n % 3 == 0:
            put(n // 3, c + B)
        elif n % 3 == 1:
            put((n-1) // 3, c + B + D)
            put((n+2) // 3, c + B + D * 2)
        else:
            put((n+1) // 3, c + B + D)
            put((n-2) // 3, c + B + D * 2)

        if n % 5 == 0:
            put(n // 5, c + C)
        elif n % 5 == 1:
            put((n-1) // 5, c + C + D)
            put((n+4) // 5, c + C + D * 4)
        elif n % 5 == 2:
            put((n-2) // 5, c + C + D * 2)
            put((n+3) // 5, c + C + D * 3)
        elif n % 5 == 3:
            put((n+2) // 5, c + C + D * 2)
            put((n-3) // 5, c + C + D * 3)
        elif n % 5 == 4:
            put((n+1) // 5, c + C + D)
            put((n-4) // 5, c + C + D * 4)

    return cost[0]


def main():
    """
    >>> solve(4, 1000000000, 1000000000, 1000000000, 1)
    4
    >>> solve(4, 1, 1000000000, 1000000000, 1)
    3
    >>> solve(8, 1, 1000000000, 1000000000, 1)
    4
    """
    T = int(input())
    for t in range(T):
        print(solve(*[int(x) for x in input().split()]))


def _test():
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


Measured memory_bytes: 11232
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int cnt[100];
char board[200][200];
int h, w;

int solve() {
	VI V = { 0, 0, 0 };
	for (int i = 0; i < 26; i++) {
		if (cnt[i] % 2 == 1) V[0]++, cnt[i]--;
		if (cnt[i] % 4 == 2) V[1]++, cnt[i] -= 2;
		V[2] += cnt[i] / 4;
	}

	if ((h % 2) && (w % 2)) {
		if (V[0] != 1) {
			return 0;
		}
	}

	int tot = (h % 2) * (w / 2) + (w % 2) * (h / 2);
	if (V[1] > tot) {
		return 0;
	}
	tot -= V[1];
	if (tot % 2) {
		return 0;
	}
	V[2] -= tot / 2;
	return 1;
}

int main()
{
	scanf("%d %d", &h, &w);
	for (int i = 0; i < h; i++) {
		scanf("%s", board[i]);
		for (int j = 0; j < w; j++) {
			cnt[board[i][j] - 'a']++;
		}
	}

	int ans = solve();
	if (ans) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  vector<vector<pair<int, int> > > edge(N);
  for(int i=1;i<N;++i) {
    edge[i].push_back(mp(i-1, 0));
  }
  int L, R, C;
  for(int i=0;i<M;++i) {
    cin>>L>>R>>C;
    L--;
    R--;
    edge[L].push_back(mp(R, C));
  }
  priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > que;
  pair<ll, int> state;
  que.push(mp(0, 0));
  map<int, ll> amap;
  for(int i=0;i<N;++i) amap[i] = -1;
  ll node, cost;
  while(!que.empty()) {
    state = que.top();que.pop();
    node = state.se;
    cost = state.fi;
    if(amap[node]>-1) continue;
    amap[node] = cost;
    for(int i=0;i<edge[node].size();++i) {
      if(amap[edge[node][i].fi]>-1 && amap[edge[node][i].fi]<cost+edge[node][i].se) continue;
      que.push(mp(cost+edge[node][i].se, edge[node][i].fi));
    }
  }
  cout<<amap[N-1]<<endl;
}



Measured memory_bytes: 16956
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
    
        int N = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());
        int[] value = new int[N+1];
        int[] weight = new int[N+1];
        for(int i = 1; i <= N; i++){
            value[i] = Integer.parseInt(sc.next());
            weight[i] = Integer.parseInt(sc.next());
        }
    
        int[][] dp = new int[N+1][W+1];
        for(int i = 1; i <= N; i++){
            for(int w = 1; w <= W; w++){
                if(weight[i] <= w){
                    dp[i][w] = Math.max(dp[i][w - weight[i]] + value[i], dp[i-1][w]);
                }else{
                    dp[i][w] = dp[i-1][w];
                }
            }
        }
    
        System.out.println(dp[N][W]);
    }
}


Measured memory_bytes: 30940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; string s; cin >> n >> s;

    VI b(n), w(n);
    FOR(i, 0, n) {
        if (0 < i) {
            b[i] += b[i - 1];
            w[i] += w[i - 1];
        }
        if (s[i] == '#')++b[i];
        else ++w[i];
    }

    int ans = INF;
    eFOR(i, 0, n) {
        int cnt = w[n - 1];
        if (0 < i) {
            cnt += b[i - 1];
            cnt -= w[i - 1];
        }
        chmin(ans, cnt);
    }

    cout << ans << "\n";
}

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

int main() {
  int N, i=1;
  cin >> N;
  while(i<=9){
    if(N%i == 0 && N/i <=9){
        cout << "Yes" << endl;
        break;
    }
    i++;
  }
  if(i > 9)
    cout << "No" << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    M, K = get_li()
    if K >= 2 ** M:
        print(-1)
        return
    if M == 0 and K == 0:
        print(0, 0)
        return
    if M == 1:
        if K == 0:
            print(0, 0, 1, 1)
        else:
            print(-1)
        return
    q = deque()
    q.append(K)
    for i in range(2 ** M):
        if i == K:
            continue
        q.append(i)
        q.appendleft(i)
    q.append(K)
    print(' '.join(map(str, q)))
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Measured memory_bytes: 119896
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    size_t n;
    cin >> n;
    vector<int> a(n);
    for (size_t i = 0; i < n; ++i) cin >> a[i];
    size_t m;
    cin >> m;
    vector<int> b(m);
    for (size_t i = 0; i < m; ++i) cin >> b[i];
    vector<int> c;
    set_intersection(a.begin(), a.end(), b.begin(), b.end(), back_inserter(c));
    for (int x : c) cout << x << endl;
}



Measured memory_bytes: 4680
#include <bits/stdc++.h>
using namespace std;
  int main(){
    string S;
    cin >> S;
    if(S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(0) ){
    cout << "No" << endl;
    }
    else{
    cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3576
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){

	int n,limit,sum,tmp;
	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		sum = 0;
		limit = n/4;

		for(int i=0; i < limit;i++){
			scanf("%d",&tmp);
			sum += tmp;
		}
		printf("%d\n",sum);
	}

    return 0;
}

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

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

	int n, k; cin >> n >> k;
	vector<int> h(n);
	for(int i = 0; i < n; i++)
		cin >> h[i];

	sort(h.begin(), h.end());

	int res = 2000000000;

	for (int left = 0, right = k-1; right < n; ++left, ++right) {
		int diff = h[right] - h[left];
		res = min(res, diff);
	}

	cout << res << endl;
}

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

using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> A(n+1,0);
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    A[x]++;
  }
  sort(A.rbegin(),A.rend());
  int ret=n;
  for(int i=0;i<k;i++){
    ret-=A[i];
  }
  cout << ret << endl;
  return 0;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;



int main() {
	string s, ss;
	int i, j, k, l;

	cin >> s;
	k = s.length();

	j = 0;
	ss = s;
	rep(i, k - 1) {
		if (ss[i] == ss[i + 1]) {
			ss[i + 1] = ss[i + 1] == '1' ? '0' : '1';
			j++;
		}
	}

	l = 0;
	for (i = k - 1; i >= 1; i--) {
		if (s[i] == s[i - 1]) {
			s[i - 1] = s[i - 1] == '1' ? '0' : '1';
			l++;
		}
	}

	cout << min(j, l) << endl;

	return 0;
}


Measured memory_bytes: 512
'use strict'

function main(s) {
  
  const seqs = s.split('\n').slice(1, -1).map(el => el.split(' ').map(num => Number(num)));

  let ans = 0;
  for (const seq of seqs) {
    let num = seq[1] - (seq[0] - 1);
    ans += num;
  }

  console.log(ans);
}

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


Measured memory_bytes: 7844
#include<bits/stdc++.h>
using namespace std;
int h,w;string s;
int main(){
	cin>>h>>w;
	for(int i=0;i<w+2;i++)s+="#";
	cout<<s<<endl;
	for(int i=0;i<h;i++){
      string t;
      cin>>t;
      cout<<"#"<<t<<"#"<<endl;
	}
	cout<<s<<endl;
	return 0;
}


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

using ll = long long;

// 繰り返し自乗法(x^nをmで割った余り) O(logn)
ll power(ll x, ll n, ll m) {
  ll res = 1;
  if (n > 0) {
    res = power(x, n / 2, m);
    if(n % 2 == 0) res = (res * res) % m;
    else res = (((res * res) % m) * x) % m;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, p;
  string s;
  cin >> n >> p >> s;
  
  map<ll, ll> mp;
  mp[0]++;
  ll now = 0, ans = 0;
  if (p == 2 || p == 5) {
    for (int i = 0; i < n; i++) {
      now *= 10;
      now += s.at(i) - '0';
      now %= p;
      if (now == 0) ans += i + 1;
    }
    cout << ans << '\n';
    return 0;
  }
  for (int i = 0; i < n; i++) {
    now *= 10;
    now += s.at(i) - '0';
    now %= p;
    ll keep = now * power(10, n - i - 1, p);
    keep %= p;
    ans += mp[keep];
    mp[keep]++;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 1044
// Your code here!
use std::io::*;
use std::str::FromStr;
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main () {
    let n:u32 = read();
    let mut list = vec![];
    
    for i in 0..n {
        let l:usize = read();
        list.push(l);
    }
    
    let mut now:usize= 0;
    let mut visited = vec![];
    
    for i in 0..n {
        visited.push(0);
    }
    
    let mut count = 0;
    loop {
        if now == 1 {
            println!("{}",count);
            break
        } else if visited[now]==1 {
            println!("{}",-1);
            break
        } else {
            visited[now]=1;
            now = list[now]-1;
            count = count + 1;
        }
        
    }
    
    
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 100
#define maxw 100000

using namespace std;

pii v[maxn+5];///fi=greutate se=valoare
ll d[maxw+5];
bool viz[maxw+5];

void umax (ll &a, ll b) { a=max(a,b); }

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, w; cin >> n >> w;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> v[i].fi >> v[i].se;
  viz[0] = 1;
  for (i = 1; i <= n; i++)
    for (j = w; j-v[i].fi >= 0; j--)
      if (viz[j-v[i].fi]) {
        viz[j] = 1;
        umax(d[j], d[j-v[i].fi]+1LL*v[i].se);
      }
  ll ans = 0;
  for (i = 0; i <= w; i++) umax(ans, d[i]);
  cout << ans;
  return 0;
}


Measured memory_bytes: 1152
N = int(input())
a = tuple(sorted(map(int, input().split())))

ans = []
res = 0
m = a[0]  # 最後に引く側
p = a[-1]  # 最後に足す側
for aa in a[1:N - 1]:
    if aa < 0:
        res -= aa
        ans.append((p, aa))
        p -= aa
    else:
        res += aa
        ans.append((m, aa))
        m -= aa
ans.append((p, m))

res += a[-1] - a[0]
print(res)
for aa in ans:
    print(*aa)


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  vector<int> d(4);
  rep(i, 4) cin >> d[i];

  sort(d.begin(), d.end());

  if(d[0] == 1 && d[1] == 4 && d[2] == 7 && d[3] == 9){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int N, Q;
VI V, W;
VVLL DP2;

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//cout << 1e5 << "\n";
	//for (int n = 0; n < 1e5; n++) {
	//	cout << "1 1\n";
	//}
	//cout << 1 << "\n";
	//cout << 1e5 - 1 << " " << 30 << "\n";
	cin >> N;
	V.resize(N + 1);
	W.resize(N + 1);
	for (int n = 1; n <= N; n++) {
		cin >> V[n] >> W[n];
	}
	cin >> Q;
	vector<PI> querys(Q);
	int maxl = 0;
	for (int q = 0; q < Q; q++) {
		cin >> querys[q].first >> querys[q].second;
		maxl = max(maxl, querys[q].second);
	}
	DP2.resize(1024,VLL(maxl+1,-1));
	DP2[1][0] = 0;
	DP2[1][W[1]] = V[1];
	for (int n = 2; n <= min(N,(1 << 10)-1); n++) {
		VI vs(1, n);
		while (vs.back() > 1) {
			vs.push_back(vs.back() >> 1);
		}
		for (int code = 0; code < (1 << vs.size()); code++) {
			LL w = 0, v = 0;
			for (int t = 0; t < vs.size(); t++) {
				if ((code & (1 << t)) == 0)continue;
				w += W[vs[t]];
				v += V[vs[t]];
			}
			if (w > maxl)continue;
			DP2[n][w] = max(DP2[n][w], v);
		}
	}
	for (int n = 1; n <= min(N, (1 << 10) - 1); n++) {
		for (int w = 1; w <= maxl; w++) {
			DP2[n][w] = max(DP2[n][w], DP2[n][w - 1]);
		}
	}
	for (int q = 0; q < Q; q++) {
		int n, L;
		n = querys[q].first;
		L = querys[q].second;
		if (n < (1 << 10)) {
			std::cout << DP2[n][L] << "\n";
		}
		else {
			VI vs;
			vs.push_back(n);
			while (vs.back() >= (1 << 10)) {
				vs.push_back(vs.back() >> 1);
			}
			LL ans = 0;
			for (int code = 0; code < (1 << vs.size());code++) {
				LL w = 0, v = 0;
				for (int t = 0; t < vs.size(); t++) {
					if ((code & (1 << t)) == 0)continue;
					w += W[vs[t]];
					v += V[vs[t]];
				}
				if (w > L)continue;
				int p = (vs.back() >> 1);
				v += DP2[p][L - w];
				ans = max(ans, v);
			}
			cout << ans << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 809360
#include <stdio.h>

int data[50001];
int sosu[50000];
main(){
  int n, i, j, k, sa, count;

  data[2]=1;
  sosu[0]=2;
  k=1;
  for(i=3;i<50001;i++){
    for(j=0;;j++){
      if(sosu[j]*sosu[j]>i){
	data[i]=1;
	sosu[k]=i;
	k++;
	break;
      }
      if(i%sosu[j]==0) break;
    }
  }
  
  while(1){
    scanf("%d", &n);
    if(n==0) break;

    count=0;
    for(i=0;;i++){
      if(sosu[i]*2>n) break;
      sa=n-sosu[i];
      if(data[sa]==1){
	count++;
      }
    }

    printf("%d\n", count);
  }
  return 0;
}

Measured memory_bytes: 616
n=int(input())

for i in range(n):
    a,b,c=map(int,input().split())
    d=[a,b,c]
    d=sorted(d)
    
    
    if d[0]**2+d[1]**2 == d[2]**2:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<ll> H(N);
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    if (N <= K) {
        cout << 0 << endl;
        return 0;
    }
    SORT(H);
    ll ans = 0;
    for (int i = 0; i < N - K; ++i) {
        ans += H[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
int main(){
  double v,t,y,i;
  while(scanf("%lf",&v)!=EOF){
    t = v/9.8;
    y = 4.9*t*t;
    for(i=0;i*5<y;i++);
    printf("%.0lf\n",i+1);
  }
  return(0);
}



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

int n;
vector<lint> a, b;
lint mod = 1000000007;

// a^n mod pを計算　O(log n)
long long pow_mod(long long a, long long n, long long p) {
    if (n == 0) return 1;
    if (n & 1) return pow_mod(a, n - 1, p) * a % p;
    long long temp = pow_mod(a, n / 2, p);
    return temp * temp % p;
}

pair<lint, lint> reg(lint x, lint y) {
    lint div = gcd(x, y);
    x /= div, y /= div;
    if (y < 0) {
        x *= -1, y *= -1;
    }
    if (y == 0 && x < 0) {
        x *= -1;
    }
    return {x, y};
}

pair<lint, lint> auth(pair<lint, lint> p) {
    lint x = -p.second, y = p.first;
    if (y < 0) {
        x *= -1, y *= -1;
    }
    if (y == 0 && x < 0) {
        x *= -1;
    }
    return {x, y};
}

int main() {
    cin >> n;
    map<pair<lint, lint>, lint> count;
    a.resize(n), b.resize(n);
    vector<pair<lint, lint>> vec;
    lint zeros = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        if (a[i] == 0 && b[i] == 0) {
            zeros++;
            continue;
        }
        auto v = reg(a[i], b[i]);
        vec.push_back(v);
        count[v]++;
    }
    set<pair<lint, lint>> trash;
    lint ans = 1;
    for (int i = 0; i < (int)vec.size(); i++) {
        if (trash.count(vec[i])) {
            continue;
        }
        auto o = auth(vec[i]);
        lint mul = (pow_mod(2, count[vec[i]], mod) + pow_mod(2, count[o], mod) - 1) % mod;
        if (mul < 0) {
            return 1;
        }
        ans = ans * mul % mod;
        trash.insert(vec[i]);
        trash.insert(o);
    }
    lint res = (zeros % mod + ans % mod - 1) % mod;
    if (res < 0) {
        res = (res + mod) % mod;
    }
    cout << res << endl;
}

Measured memory_bytes: 59376
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N;
    cin>>N;
    string S;
    cin>>S;
    int R=0,W=N-1;
    int cou=0;
    while(1){
        while(S[R]=='R')R++;
        while(S[W]=='W')W--;
        if(R<W){
            swap(S[R],S[W]);
            cou++;
        }
        else{
            cout<<cou<<endl;
            return 0;
        }

    }
    return 0;
}


Measured memory_bytes: 3420
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' '; cout<<endl;
#define PI acos(-1.0)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define rt return true
#define rf return false
///................function.....................///
#define siz(s) (int)(s.size())
#define mod 1000000007
#define dbg(a) cout << #a << " = " << a << " ";
int main()
{
    FIO;
    ll n;
    cin>>n;
    cout<<(n/11)*2 + (n%11>0)+ (n%11>6)<<endl;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int n;
P t[1000];

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    int sum=0,sum2=0;
    for(int i=0;i<n;i++){
      cin>>t[i].first>>t[i].second;
      sum+=t[i].first;
      sum2+=t[i].second;
    }
    sort(t,t+n);
    int X=sum-t[n-1].first;
    if(t[n-1].first<=X){
      cout<<sum+sum2<<endl;
      continue; 
    }
    int Y=t[n-1].first-X;
    int dp[1002]={};
    for(int i=0;i<n-1;i++){
      int se=t[i].second;
      for(int j=Y;j>=se;j--)
        dp[j]=max(dp[j],dp[j-se]+se);
    }
    cout<<t[n-1].first*2+sum2-dp[Y]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-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;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll x, t;
  cin >> x >> t;

  cout << (x-t<0 ? 0:x-t) << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (int)(count); i++)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
const int MODULO = 100000 ;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;

using namespace std;

void solve(char* buf){
	char t[] = "abcdefghijklmnopqrstuvwxyz.?! ";
			int n = strlen(buf);
		if(n % 2 != 0){
			puts("NA"); return ;
		}
		n /= 2;
		char nw[256];
		FOR(i,n){
			if('1' <= buf[i*2] && buf[i*2] <= '6' && '1' <= buf[i*2+1] && buf[i*2+1] <= '5'){
			int a = (buf[i*2] - '0') * 5 + buf[i*2+1] - '0' - 6;
			nw[i] = t[a];
			} else {
				puts("NA"); return ;
			}
		}
		nw[n] = '\0';
		puts(nw);
}

int main()
{
	char buf[256];
	while(~scanf("%s",buf)){
		solve(buf);
	}
	return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
int main(void){

    long long input, sum = 0;
    cin >> input ;
    
    vector<long long> frs(input);
    for(long long i = 0; i < input; i++){
        cin >> frs.at(i) ;
    }
    
    sort(frs.begin(), frs.end());
    reverse(frs.begin(), frs.end());

    for(long long i = 0; i < input; i++){
        if(i == 0){
            sum += 0;
        } else {
            sum += frs.at(i / 2);
        }
    }

    cout << sum << endl;

}


Measured memory_bytes: 4704
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<ull> vul;
#define For(i, n) for(ll i = 0; i < n; i++)
#define len(n) (ll)(n).size()
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define Sort(a) sort(a.begin(), a.end())

ll dp[(ll)1e3 + 1][(ll)1e3 + 1];
vector<string> game_map;

int main() {
    FAST_IO;
    ll n, m;
    cin >> n >> m;
    For(i, n) {
        string line;
        cin >> line;
        game_map.push_back(line);
    }
    dp[1][1] = 1;
    for(ll i = 1; i <= n; i++) {
        for(ll j = 1; j <= m; j++) {
            if (game_map[i - 1][j - 1] != '#') {
                dp[i][j] += dp[i][j - 1] + dp[i - 1][j];
                dp[i][j] %= (ll)1e9 + 7;
            }
        }
    }
    cout << dp[n][m] << '\n';
    return 0;
}

Measured memory_bytes: 12420
#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 ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=105;
vi v1[26],v2[26];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  string s1,s2;
  cin>>s1>>s2;
  rep(i,0,sz(s1)) v1[(int)(s1[i]-'a')].pb(i);
  rep(i,0,sz(s2)) v2[(int)(s2[i]-'a')].pb(i);
  bool ok=true;
  rep(i,0,26)
    {
      if(sz(v1[i])==0) continue;
      bool ok2=true;
      int cnt=0;
      rep(j,0,26)
	{
	  if(sz(v1[i])!=sz(v2[j])) continue;
	  if(v1[i][0]==v2[j][0])
	    {
	      if(v1[i]==v2[j]) cnt++;
	      else
		ok2=false;
	      break;
	    }
	  else
	    continue;
	}
      if(!cnt || !ok2)
	{
	  cout<<"No"<<endl;
	  return 0;
	}
    }
  cout<<"Yes"<<endl;
  return 0 ;
}


Measured memory_bytes: 2836
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100005;
int main()
{
    int n, a=0, b=0;
    string s, t;
    cin >> n >> s >> t;
    for(int i=0;i<2*n;i++){
        if(i%2 == 0){
            cout << s[a];
            a++;
        }
        else{
            cout << t[b];
            b++;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    LL(S);
    pair<ll,ll> p1={0,0},p2={1000000000,1},p3;
    p3.second=updivide(S,p2.first);
    p3.first=abs(p3.second*p2.first-S);
    out(p1,p2,p3);
}


Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
long long Cn2(long long x){
	if(x%2 == 0) return (x/2)*(x-1);
	else return ((x-1)/2)*x;
}
int main()
{

long long n;
cin>>n;
map<string, long long> mp;
string s;
for(int i = 0; i < n; ++i){
	cin>>s;
	sort(s.begin(), s.end());
	mp[s]++;
}
long long count = 0;
for(auto it = mp.begin(); it!=mp.end(); ++it){
	long long x = Cn2(it->second);
	count+=x;
}
cout<<count;
return 0;
}

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

using namespace std;

int main()
{
    long long n, k;
    bool b[200001];
    int  a[200001];
    
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        b[i] = false;
    }
    int c = 0;
    int p = 1;
    while (b[p] == false) {
        b[p] = true;
        p = a[p];
        c++;
    }
//    cout << p << endl;
    int x = 1;
    int c0 = 0;
    while (x != p) {
        x = a[x];
        c0++;
    }
//    cout << c0 << endl;
//    cout << c << endl;
    
    if (k <= c) {
    } else {
        k = ((k - c0) % (c - c0)) + c0;
    }
    p = 1;
    while (k > 0) {
        p = a[p];
        k--;
    }
    cout << p << endl;
    
    
    return 0;
}


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

string S;
long long dp[100001][13] = {};
long long mod = 1e9 + 7;

int main(){
    cin >> S;
    dp[0][0] = 1;
    long long base = 1;
    for(int i = 0; i < S.length(); i++){
        if(S[S.length() - 1 - i] == '?'){
            for(int j = 0; j < 13; j++){
                for(int k = 0; k < 10; k++){
                    dp[i + 1][(j + (base * k)) % 13] += dp[i][j];
                    dp[i + 1][(j + (base * k)) % 13] %= mod;
                }
            }
        }else{
            int digit = S[S.length() - 1 - i] - '0';
            if(digit < 0 || digit >= 10){
                cout << "???" << endl;
            }
            for(int j = 0; j < 13; j++){
                dp[i + 1][(j + (base * digit)) % 13] += dp[i][j];
                dp[i + 1][(j + (base * digit)) % 13] %= mod;
            }
        }
        base *= 10;
        base %= 13;
    }
    cout << dp[S.length()][5] << endl;
}


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

int main(){
	int S, h, m, s;

	cin >> S;

	h = S/3600;
	m = (S-h*3600)/60;
	s = S - h*3600 - m*60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

Measured memory_bytes: 1164
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		sc.close();

		out.println((N + 1) / 2);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 23252
X = int(input())
for i in range(X, 9999999999999999):
    flag = 1
    for j in range(2, X//2 +1):
        if i % j == 0:
            flag = -1
            break
    if X == 2:
        print(2)
        break
    elif X == 3:
        print(3)
        break
    elif flag == 1:
        print(i)
        break

Measured memory_bytes: 9208
N, M = map(int, input().split())

if N < M//2:
    scc_min = max(1, N)
else:
    scc_min = M//2
scc_max = N + M//2

while scc_min < scc_max:
    scc = (scc_min + scc_max) // 2
    excess_c = M - scc*2
    if scc_min + 1 == scc_max:
        break
    if excess_c > 0 and excess_c//2 + N >= scc:
        scc_min = scc
    else:
        scc_max = scc - 1

excess_c = M - scc_max*2
if excess_c > 0 and excess_c//2 + N >= scc_max:
    print(scc_max)
else:
    print(scc_min)

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	int n,a[1001];
	cin >> n;
	for(int i = 0;i < 2 * n;i++){
		cin >> a[i];
		a[i] = -a[i];
	}
	sort(a,a + 2 * n);
	ll ans = 0;
	for(int i = 1;i < 2 * n;i += 2){
		ans += a[i];
	}
	cout << -ans << endl;
	return 0;
}

Measured memory_bytes: 256