akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
    }
    if(n % 2 == 0){
        ll dp[n][2];
        fill(dp[0], dp[n], -LINF);
        dp[0][0] = a[0];
        dp[1][1] = a[1];
        for (int i = 0; i < n; i++) {
            rep(j, 2) {
                if (i - 2 >= 0) dp[i][j] = max(dp[i][j], dp[i - 2][j] + a[i]);
            }
            if (i - 3 >= 0) dp[i][1] = max(dp[i][1], dp[i - 3][0] + a[i]);
        }
        cout << max(dp[n - 1][1], dp[n - 2][0]) << endl;
    }else{
        ll dp[n][3];
        fill(dp[0], dp[n], -LINF);
        dp[0][0] = a[0];
        dp[1][1] = a[1];
        dp[2][2] = a[2];
        for (int i = 0; i < n; i++) {
            rep(j, 3) {
                if (i - 2 >= 0) dp[i][j] = max(dp[i][j], dp[i - 2][j] + a[i]);
            }
            if (i - 3 >= 0) dp[i][1] = max(dp[i][1], dp[i - 3][0] + a[i]);
            if (i - 3 >= 0) dp[i][2] = max(dp[i][2], dp[i - 3][1] + a[i]);
            if (i - 4 >= 0) dp[i][2] = max(dp[i][2], dp[i - 4][0] + a[i]);
        }
        cout << max({dp[n - 1][2], dp[n - 2][1], dp[n - 3][0]}) << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

int n, m, q;
int a[50], b[50], c[50], d[50];
void read() {
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
}

int ans = 0;

void relax(vector<int> & have) {
   /* cout << "have = " << endl;
    for (auto i : have)
        cout << i << " ";
    cout << endl; */
    int fans = 0;
    for (int i = 0; i < q; i++) {
        if (have[b[i] - 1] - have[a[i] - 1] == c[i]) {
            fans += d[i];
        }
    }
    chkmax(ans, fans);
}

void solve(vector<int> have) {
    if (have.size() == n) {
        relax(have);
        return;
    }
    if (have.empty()) {
        have.push_back(1);
    } else {
        have.push_back(have.back());
    }
    while (have.back() <= m) {
        solve(have);
        have[have.size() - 1]++;
    }
}

void run() {
    solve({});
}

void write() {
    cout << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    read();
    run();
    write();
    return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

#define int long long

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct unionFind{
    vector<int> par;
    int siz;

    void init(int N){
        par.resize(N);
        fill(par.begin(), par.end(), -1);
        siz = N;
        return;
    }

    int root(int X){
        if(par[X] < 0){
            return X;
        }
        return par[X] = root(par[X]);
    }

    bool unite(int X, int Y){
        X = root(X);
        Y = root(Y);

        if(X == Y){
            return false;
        }

        if(par[X] < par[Y]){
            swap(X, Y);
        }

        par[Y] += par[X];
        par[X] = Y;
        --siz;

        return true;
    }

    bool same(int X, int Y){
        return root(X) == root(Y);
    }

    int size(int X){
        return -par[root(X)];
    }
};

struct edge{
    int a, b;
    lint c;

    bool operator<(const edge & right) const {
        return c < right.c;
    }
};

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

    int n;
    cin >> n;

    vector<edge> edges(n - 1);
    rep(i, n - 1){
        int a, b;
        lint c;
        cin >> a >> b >> c;
        edges[i] = {a, b, c};
    }
    SORT(edges);

    unionFind uf;
    uf.init(n);

    lint ans = 0;
    for(auto e : edges){
        lint a = uf.size(e.a), b = uf.size(e.b);
        ans += a * b * e.c;
        uf.unite(e.a, e.b);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9156
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int cnt_digits(ll N)
{
  int digits = 0;
  
  while(N > 0)
  {
    N /= 10;
    digits++;
  }
  return (digits);
}

int main()
{
  ll N;
  cin >> N;
  
  int ans = cnt_digits(N);
  
  for (ll A = 1LL; A * A <= N;A++)
  {
    if (N % A != 0)
      continue;
    const ll B = N / A;
         
    const int cur = max(cnt_digits(A), cnt_digits(B));
                  
    if (ans > cur)
      ans = cur;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split(" "))
ab = [list(map(int, input().split(" "))) for _ in range(m)]

s = [set() for _ in range(n)]
for ab_i in ab:
	a_i, b_i = map(lambda x: x-1, ab_i)
	s[a_i].add(b_i)
	s[b_i].add(a_i)

# print(s)

def dfs(num, visited=set()):
	visited = visited | {num}
	can_moves = s[num] - visited
	# print(num, can_moves, visited)
	if not can_moves:
		return (len(visited) == n)
	return sum(dfs(can_move, visited) for can_move in can_moves)

print(dfs(0))

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

ld time_multi(int,int);

ll ctoi(const char c){if('0'<=c&&c<='9') return (c-'0');return -1;}
#define ALL(x) begin(x),end(x)
  
int main(){
  ll n,k;
  cin >> n >> k;
  ld ans = 0;
  for(int i = 1; i <= n; i++){
    ld tmp = (ld)1/n * pow((ld)0.5,time_multi(i,k));
    ans += tmp;
  }
  cout << setprecision(30) << ans << endl;
}

ld time_multi(int i, int k){
  ll num = i;
  ld time = 0.0;
  while(num<k){
    num *= 2;
    time++;
  }
  return time;
}
    

Measured memory_bytes: 3724
using System;
using System.Diagnostics;
using System.Linq;

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var oneLine = Console.ReadLine();
            var centerIndex = oneLine.Length / 2;
            var oddOffset = oneLine.Length % 2;
            var startSideWord = oneLine.Substring(0, centerIndex);
            var endSideWord = oneLine.Substring(centerIndex + oddOffset);
            Debug.Assert(startSideWord.Length == endSideWord.Length);
            var hugCount = 0;
            for (int i = 0; i < startSideWord.Length; i++)
            {
                var inverseIndex = startSideWord.Length - 1 - i;
                if (startSideWord[i] != endSideWord[inverseIndex])
                {
                    ++hugCount;
                }
            }
            Console.WriteLine(hugCount);
        }
    }
}



Measured memory_bytes: 11092
import java.util.Scanner;

/**
 * Created by DELL on 2017/7/1.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int a=in.nextInt();
        int b=in.nextInt();
        int c=in.nextInt();
        System.out.println(a+b+c-Math.max(Math.max(a,b),c));
    }

}

Measured memory_bytes: 21716
import java.util.Scanner;

class A {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int A = sc.nextInt();
        final int B = sc.nextInt();
        if (A <= 8 && B <= 8)
            System.out.println("Yay!");
        else
            System.out.println(":(");
    }
}
public class Main {
    public static void main(String...args) {
        A.main();
    }
}

Measured memory_bytes: 22612
using System;
using System.Collections;

public class Test{
  public static void Main(){
    
    //文字列の読み込み
    var line1 = System.Console.ReadLine();
    string[] str1 = line1.Split(' ');
    
    //何番目のルンルン数を求めるか
  	long k = int.Parse(str1[0]);

    //ルンルン数格納用キューと初期化(1~9を格納)
    Queue queue = new Queue();
    for(int i=1; i<10; ++i){
      queue.Enqueue(i);
    }
    
    //k回繰り返したら終了
    long count = 0;
    long lun = 0;
    while(count < k){
      lun = Convert.ToInt64(queue.Dequeue());
      if(lun % 10 != 0){
        queue.Enqueue(lun * 10 + (lun % 10) - 1);
      }
      queue.Enqueue(lun * 10 + (lun % 10));
      if(lun % 10 != 9){
        queue.Enqueue(lun * 10 + (lun % 10) + 1);
      }
      count++;
    }
	System.Console.WriteLine(lun);
  }
}


Measured memory_bytes: 25052
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,a,n) for(int i=n;i>a;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define fs first
#define sc second

#define MOD 1000000007
#define INF 1LL<<55

#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)

using namespace std;

using ll = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pll = P<ll,ll>;
using Pdd = P<double,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<ll>;
using Vs = V<string>;

template<typename T1,typename T2> using M = map< T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

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

int lcm(ll a, ll b)
{
    int temp = gcd(a, b);

    return temp ? (a / temp * b) : 0;
}

// please declaration dx[8], dy[8]
#define DX {-1,0,1,0,-1,-1,1,1}
#define DY {0,-1,0,1,-1,1,1,-1}
#define DX2 {-1,0,1,0}
#define DY2 {0,-1,0,1}

signed main() {
  ll n, x;
  in(n, x);
  Vi vec(n);
  in(vec);
  ll ans = abs(x - vec[0]);

  REP(i,1, n) {
    ans = gcd(ans, abs(x - vec[i]));
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if(b % a == 0){
        cout << a + b << endl;
    }
    else {
        cout << b - a << endl;
    }
    return 0;
}

Measured memory_bytes: 888
# pythonっぽい書き方
N = int(input())
A = list(map(int, input().split()))


# まつり縫いみたいなやり方
# aの要素でアクセスできる形式で、何番目の要素だったのかを保持しておけば良い
tmp = [None] * (N + 1)
for i, a in enumerate(A, start=1):
    tmp[a] = i
A.sort()
print(*[tmp[a] for a in A])

Measured memory_bytes: 13880
integer Q
integer(16) A,B
read*,Q
do i=1,Q
  read*,A,B
  print"(i0)",ans(A,B)
end do
contains

function ans(A,B)
  integer(16) A,B
  integer(16) ans
  integer(16) C,root
  c=a*b
  root=floor(sqrt(dble(c)))
  if(root**2==c)then
    if(a==b)then
      ans=2*(root-1)
    else
      ans=2*root-3
    end if
  else if(root*(root+1)<c)then
    ans=2*root-1
  else 
    ans=2*(root-1)
  endif
end function
end

Measured memory_bytes: 640
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()

if n == m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38420
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define ll long long
using namespace std;
const int nmax=101234;

ll h,w,s[1012][1012];
char a[1012][1012];

int main()
{
    scanf("%lld %lld",&h,&w);
    for(int i=1; i<=h; ++i)
    {
        scanf("%s",&a[i][1]);
    }
    s[0][1]=1;
     for(int i=1; i<=h; ++i)
    {
        for(int j=1; j<=w; ++j){
            if(a[i][j]=='#')
                s[i][j]=0;
            else
                s[i][j]=(s[i-1][j]+s[i][j-1])%MOD;
        }

    }
    printf("%lld",s[h][w]);
    return 0;
}


Measured memory_bytes: 9088
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]

INF = 10 ** 20
ans = INF
for div in range(1 << (h - 1)):
    id = []
    g = 0
    for i in range(h):
        id.append(g)
        if div >> i & 1:
            g += 1
    g += 1

    c = [[0 for _ in range(w)] for _ in range(g)]
    for i in range(h):
    	for j in range(w):
            c[id[i]][j] += (s[i][j] == "1")

    tmp_ans = g - 1
    now = [0] * g

    def add(j):
        for i in range(g):
            now[i] += c[i][j]
            if now[i] > k:
                return False
        return True

    for j in range(w):
        if not add(j):
            tmp_ans += 1
            now = [0] * g
            if not add(j):
                tmp_ans = INF
                break

    # impossible = 0
    # for j in range(w):
    #     if impossible:
    #         tmp_ans = INF
    #         break
    #     for i in range(g):
    #         if c[i][j] > k:
    #             impossible = 1
    #             break
    #         now[i] += c[i][j]
    #         if now[i] > k:
    #             now = [c[gi][j] for gi in range(g)]
    #             tmp_ans += 1
    #             continue

    ans = min(ans, tmp_ans)

print(ans)

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

int main(){
	int N,i;
	scanf("%d",&N);
	long long A[100000]={0},large=0;
	for(i=0;i<N;i++){
		scanf("%lld",&A[i]);
	}
	std::sort(A,A+N);

	int color_num=N;


	large=A[0];

	for(i=1;i<N;i++){
		if(large*2<A[i]){
			color_num=N-i;
		}
		large+=A[i];
	}
	printf("%d",color_num);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll inputLValue(){
    ll a;
    cin >> a;
    return a;
};

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

int main()
{
    ll N = inputLValue();
    ll ans = 0;
    if(N % 2 == 0){
        ll v = 10;
        while(v <= N){
            ans += N / v;
            v *= 5;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){

	vector<int> mountains;
	
	for(int i= 0 ; i<10 ; i++){
		int a;
		cin>>a;
		mountains.push_back(a);
	}

	for(int i=0 ; i<mountains.size()-1 ; i++){
		for(int j=0 ; j<mountains.size()-1 ; j++){
			if(mountains[j] < mountains[j+1]){
				int tmp;
				
				tmp = mountains[j];
				mountains[j] = mountains[j+1];
				mountains[j+1] = tmp;
			}
		}
	}

	for(int i ; i<3 ; i++){
		cout<<mountains[i]<<endl;
	}

return 0;
}

Measured memory_bytes: 1212
r, g, b, n = map(int, input().split())
c = sorted([r, g, b])[::-1]
ans = 0
for i in range(n // c[0] + 1):
    x = n - i * c[0]
    for j in range(x // c[1] + 1):
        y = x - j * c[1]
        if y < 0:
            break
        elif y % c[2] == 0:
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include <cmath>

using namespace std;

bool isSqN(int n){
    int x = (int)sqrt(n);
    return x*x == n;
}


int main()
{
    int H = 0, W = 0;
    while(cin >> H >> W, H){
        int R2 = H*H + W*W;
        int R = (int)sqrt(R2);
        for(int r2 = R2; true; ++r2){
            int iniH = (r2 == R2 ? H+1 : 1);
//            cout << r2 << " " << R2 << " " << iniH << endl;
            for(int h = iniH; h < R; ++h){
//                cout << h << endl;
                int w2 = r2  - h*h;
                if(w2 > h*h && isSqN(w2)) {
                    cout << h << " " << (int)sqrt(w2) << endl;
                    goto Next;
                }
            }
        }
    Next:
        int dummy;
    }
    return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
    static int dx[]={-1,0,1,0};
    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int m=sc.nextInt();
        int d[]=new int[n];

        for (int i = 0; i < n; i++) {
        	d[i]=sc.nextInt();
		}
        sort(d);
        P p[] = new P[m];
        for (int i = 0; i < p.length; i++) {
			p[i]=new P(sc.nextInt(),sc.nextInt());
		}
        sort(p);
        int c=0;
        for (int i = 0; i < p.length; i++) {
			db(p[i].a,p[i].b);			
			while(c<n && p[i].a > 0 && d[c]<p[i].b) {
				d[c]=p[i].b;
				c++;
				p[i].a--;
			}
//			db(i,d);
		}
        long ans=0;
        for (int i = 0; i < n; i++) {
			ans+=d[i];
		}
        
        
        out.println(ans);
        out.flush();
    }
    



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
	int a,b; 
	P(int a, int b) {
	  this.a=a;
	  this.b=b;
	}
	public int compareTo(P p){			
	  return -b+p.b;
	}
}


//class P implements Comparable<P>{
//    long a,b; 
//    int id;
//    P(long a, long b,int id) {
//        this.a=a;
//        this.b=b;
//        this.id=id;
//    }
//    public int compareTo(P p){
//    	if(a*b-p.a*p.b>0) return 1;
//    	if(-a*b+p.a*p.b>0) return -1;    	
//        return 0;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 75068
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 2e5 + 10;

int P[MR], suf[MR];

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	REP(i, N)
		scanf("%d", &P[i]);

	set<int> S;
	REP(i, K)
		S.insert(P[i]);

	// wyznacz pozycje, gdzie powstaje potencjalnie nowa permutacja
	vector<int> pos; pos.push_back(K - 1);
	FOR(i, K, N)
	{
		bool ok = P[i - K] == *S.begin() && P[i] > *S.rbegin();

		if (!ok)
			pos.push_back(i);

		S.erase(P[i - K]);
		S.insert(P[i]);
	}

	// wylicz dlugosci sufiksow malejacych
	suf[0] = 1;
	FOR(i, 1, N)
		if (P[i] > P[i - 1])
			suf[i] = suf[i - 1] + 1;
		else
			suf[i] = 1;

	int sortSegment = 0;

	// dla kazdej pozycji zobacz, czy tam sie nie konczy posortowany segment
	for (int p : pos)
		if (suf[p] >= K)
			sortSegment++;

	printf("%d\n", pos.size() - max(1,sortSegment) + 1);

	return 0;
}

// FOR GNU C++ use the following pattern:
// Uncomment the code below and change your main into main2
// It does not build in MS C++
// But it does increase the stack size from 256 MB on CF and uses GNU C++

//#include <Processthreadsapi.h>
//#include <iostream>
//#include <Synchapi.h>
//#include <windows.h>
//#include <process.h>
//
//DWORD WINAPI MyThreadFunction(LPVOID lpParam) {
//    main2(nullptr);
//    return 0;
//}
//int main() {
//    auto h = CreateThread(nullptr, 1024 << 20, MyThreadFunction, nullptr, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
//    WaitForSingleObject(h, INFINITE);
//}

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

public class Hello
{
    public static void Main()
    {
        // Your code here!
        
        int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int H = a[0];
        int W = a[1];
    　　int[] goodX = new int[101];
    　　int[] goodY = new int[101];
        char[,] matrix = new char[H,W];
        
        for(int h = 0; h < H; h++)
        {
            string line = Console.ReadLine();
            
            for(int w = 0; w < W; w++)
            {
                matrix[h, w] = line[w];
            }
        }
        
        //すべてのマスをみて#がある行と列を記憶
        for(int h = 0; h < H; h++)  //行を消す
        {
            for(int w = 0; w < W; w++)
            {
                if(matrix[h, w] == '#' )//黒があったら
                {
                　　goodX[h] = 1;
                　　goodY[w] = 1;
                }
            }
            
        }
        /*
        for(int h = 0; h < H; h++)//デバッグ用
        {
            Console.Write(goodX[h]);
        }
        Console.WriteLine();
        
        for(int w = 0; w < W; w++)//デバッグ用
        {
            Console.Write(goodY[w]);
        }
        Console.WriteLine();
        /*
        for(int h = 0; h < H; h++) //出力 デバッグ用
        {
           
            for(int w = 0; w < W; w++)
            {
                Console.Write(matrix[h, w]);
            }
            Console.WriteLine();
            
            
        }
        */
        
        for(int h = 0; h < H; h++) //出力
        {
            if(goodX[h] == 1)
            {
                for(int w = 0; w < W; w++)
                {
                    if(goodY[w] == 1)
                    {
                        Console.Write(matrix[h,w]);
                    }
                }
                Console.WriteLine();
            }
            
        }
        
        
    }
}

Measured memory_bytes: 13368
from itertools import permutations
from collections import Counter


n = int(input())
balls = []

for _ in range(n):
    x, y = map(int, input().split())
    balls.append((x, y))

if n == 1:
    print(1)
else:
    counter = Counter()
    for b1, b2 in permutations(balls, 2):
        p, q = b1[0] - b2[0], b1[1] - b2[1]
        counter[(p, q)] += 1

    (p, q), val = counter.most_common(1)[0]
    print(n - val)

Measured memory_bytes: 3828
using System;
using System.Linq;
using static System.Console;

class P
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        var waza = ReadLine().Split().Select(int.Parse).Sum();
        WriteLine(n[0] > waza ? "No" : "Yes");
    }
}

Measured memory_bytes: 18272
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int main()
{
	int n;
	int a[M];
	int min, max;
	long long sum;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	min = a[0];
	for (int i = 1; i < n; i++) {
		if (min > a[i]) {
			min = a[i];
		}
	}

	max = a[0];
	for (int i = 0; i < n; i++) {
		if (max < a[i]) {
			max = a[i];
		}
	}

	sum = 0;
	for (int i = 0; i < n; i++) {
		sum = sum + a[i];
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b;
  cin >> a >> b;
  cout << (a <= 8 && b <= 8 ? "Yay!" : ":(") << endl;
}

Measured memory_bytes: 3532
#include <iostream>

using namespace std;

long n, res;
long c[505], s[505], f[505];

int main()
{
	cin >> n;

	for (int i = 1; i < n; ++i)
		cin >> c[i] >> s[i] >> f[i];

	for (int i = 1; i < n; ++i)
	{
		res = s[i];

		for (int j = i + 1; j < n; ++j)
		{
			res += c[j - 1];

			if (res <= s[j])
			{
				res = s[j];
			}
			else
			{
				long tmp = s[j] + f[j];
				while (tmp < res)
					tmp += f[j];
				res = tmp;
			}
		}

		res += c[n-1];

		cout << res << endl;
	}

	cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

N = int(input())

witnesses = []
for i in range(N):
    A = int(input())
    witness = []
    for j in range(A):
        [x, y] = [int(i) for i in input().split()]
        x -= 1
        witness.append((x, y))

    witnesses.append(witness)

honest_binary = 2 ** N - 1
while (honest_binary > 0):
    honest_list = [int(i) for i in list(format(honest_binary, '0' + str(N) + 'b'))]

    # 証言を見ていって、honest_listと相違ないか調査
    # 見るのはhonest_listで正直認定している人だけ
    flag = False
    for i in range(len(honest_list)):
        if honest_list[i] == 0:
            continue

        witness = witnesses[i]
        for w in witness:
            (x, y) = w
            if honest_list[x] != y:
                flag = True
                break
        if flag is True:
            break
    else:
        print(honest_list.count(1))
        sys.exit()

    honest_binary -= 1

print(0)



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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    string s; cin >> s;
    int ll[6] = {1, 0, 0, 1, 1, 1};
    vector<int> lis;
    int ch = 0;
    string ss = "KIHBR";
    int count = 0;
    if(s.size() > 9){
        cout << "NO" << endl;
        return 0;
    }
    REP(i, 0, s.size()){
        if(ch >= 5 && s[i] != 'A'){
            cout << "NO" << endl;
            return 0;
        }
        if(ch < 5 && s[i] == ss[ch]){
            lis.pb(count);
            ch++;
            count = 0;
        }else if(s[i] == 'A'){
            count++;
        }else if(s[i] != ss[ch]){
            cout << "NO" << endl;
            return 0;
        }
    }
    lis.pb(count);
    if(lis.size() != 6){
        cout << "NO" << endl;
        return 0;
    }
    REP(i, 0, lis.size()){
        if(ll[i] < lis[i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

using namespace std;

#define ALL(x) x.begin(), x.end()

typedef long long int lld;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(15);
    cout << fixed;

    lld a, b;
    cin >> a >> b;

    lld g = __gcd(a, b);

    vector<lld> p;

    for (int i = 1; i <= sqrt(g); i++) {
        if (g % i == 0) {
            p.push_back(i);
            p.push_back(g / i);
        }
    }

    sort(ALL(p));
    auto it = unique(ALL(p));
    p.resize(it - p.begin());

    vector<lld> ans;

    for (int i = 0; i < p.size(); i++) {
        bool f = true;
        for (int j = 0; j < ans.size(); j++) {
            if (__gcd(ans[j], p[i]) != 1) {
                f = false;
                break;
            }
        }
        if (f)
            ans.push_back(p[i]);
    }

    cout << ans.size() << '\n';

    



    
    return 0;
}

Measured memory_bytes: 384
import numpy as np
n, m, x = map(int, input().split())
C = np.zeros(n, dtype=int)
AA = np.zeros([n, m], dtype=int)
for i in range(n):
    CA = np.array(list(map(int, input().split())))
    C[i] = CA[0]
    AA[i] = CA[1:]

ans = np.inf
for bit in range(2**n):
    Skill = np.zeros(m, dtype = int)
    cost = 0
    for i in range(len(AA)):
        mask = 1 << i
        if bit & mask:
            Skill += AA[i]
            cost  += C[i]
    if all(map(lambda skill: skill >= x, Skill)):
#        print(Skill, cost)
        ans = min(ans, cost)
if ans != np.inf:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 27296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

int n = 1e5;
const ll INF = 1e9*n;
vl dis(n, INF);
vector<vector<pii>> G(n);

void dfs(int i, ll d) {
  if (dis[i] != INF) return;
  dis[i] = d;

  for (auto&& j : G[i]) {
    dfs(j.first, d+j.second);
  }
}

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

  int n, q, k;
  cin >> n;
  rep(i, n-1) {
    int a, b, c;
    cin >> a >> b >> c;
    G[a-1].push_back({b-1, c});
    G[b-1].push_back({a-1, c});
  }
  cin >> q >> k;
  vi x(q), y(q);
  rep(i, q) {
    cin >> x[i] >> y[i];
  }

  dfs(k-1, 0);

  rep(i, q) {
    cout << dis[x[i]-1] + dis[y[i]-1] << endl;
  }
}


Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll n,i,j;
    cin>>n;
    ll t;
    cin>>t;
    vector<ll> a(n);
    for(i=0;i<n;i++) cin>>a[i];
    ll ans = 0;
    for(i=1;i<n;i++)
    {
        if(a[i]<=a[i-1]+t) ans+=(a[i]-a[i-1]);
        else ans+=t;
    }
    ans+=t;
    cout<<ans;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define maxs 202020
#define mme(i,j) memset(i,j,sizeof(i))
#define ll long long
using namespace std;
ll a[maxs];

int main()
{
    ll n,x;
    while(~scanf("%lld%lld",&n,&x))
    {
        for(int i=1;i<=n;i++)
            scanf("%lld",&a[i]);

        ll sum=0,t;
        for(int i=1;i<n;i++){
            t = max(0ll,a[i]+a[i+1]-x);
            a[i+1]-=t;
            if(a[i+1]<0) a[i+1]=0;
            sum+=t;
        }
        printf("%lld\n",sum);
    }
    return 0;

}
/*
3 3
2 2 2
6 1
1 6 1 2 0 4
5 9
3 1 4 1 5
2 0
5 5
*/

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    rep(i, 0, N) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    rep(i, 0, N)
    {
        if (i == N - 1)
        {
            if (x == a[i])
            {
                ++ans;
            }
            break;
        }

        if (x >= a[i])
        {
            x -= a[i];
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

int main()
{
    ll n,cnt = 1,ans = 0;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    sort(a.begin(), a.end());
    rep(i, n - 1){
        if (a[i] == a[i + 1]) {
            ++cnt;
        }else{
            if (cnt % 2 == 1)++ans;
            cnt = 1;
        }
    }
    if (cnt % 2 == 1)++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import deque

N, M = map(int, input().split())
AB = []
for _ in range(M):
    a, b = map(int, input().split())
    AB.append((a - 1, b - 1))
ans = 0
for i in range(M):
    to = [[] for _ in range(N)]
    for j, (a, b) in enumerate(AB):
        if i != j:
            to[a].append(b)
            to[b].append(a)
    visited = [False] * N
    q = deque()
    q.append(0)
    visited[0] = True
    while len(q):
        a = q.pop()
        for b in to[a]:
            if not visited[b]:
                q.append(b)
                visited[b] = True
    if not all(visited):
        ans += 1
print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010
#define OK cout << "POSSIBLE" << endl
#define NG cout << "IMPOSSIBLE" << endl

int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> a(M),b(M);

    rep(i,M){
        cin >> a[i] >> b[i];
    }
    vector<queue<int>> ship(N+1);
    rep(i,M){
        ship[a[i]].push(b[i]);
    }
    bool result=false;
    while(!ship[1].empty()){
        int val=ship[1].front();
        while(!ship[val].empty()){
            if(ship[val].front()==N){
                result=true;
                break;
            }
            ship[val].pop();
        }
        ship[1].pop();
        if(result)break;
    }

    if(result){
        OK;
    }else{
        NG;
    }

}

Measured memory_bytes: 136576
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli H, ans = 0, a = 1;;
	cin >> H;

	while (H != 0) {

		H /= 2;

		ans += a;

		a *= 2;
	}

	COUT(ans);

	return 0;
}


Measured memory_bytes: 256
/* DELAPAN.3gp */
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
using namespace std;
 
#ifdef DEBUG
	#define debug(...) printf(__VA_ARGS__)
	#define GetTime() fprintf(stderr,"Running time: %.3lf second\n",((double)clock())/CLOCKS_PER_SEC)
#else
	#define debug(...) 
	#define GetTime() 
#endif
 
//type definitions
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vint;
 
//abbreviations
#define A first
#define B second
#define MP make_pair
#define PB push_back
 
//macros
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n)-1; 0 <= i; --i)
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for (int i = (a); (b) <= i; --i)
#define FORIT(it,c) for (__typeof ((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define RESET(a,x) memset(a,x,sizeof(a))
#define EXIST(a,s) ((s).find(a) != (s).end())
#define MX(a,b) a = max((a),(b));
#define MN(a,b) a = min((a),(b));
 
inline void OPEN(const string &s) {
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}
 
/* -------------- end of DELAPAN.3gp's template -------------- */
 
int n, avg, a[55];
ll dp[55][2525];
 
int main(){
	scanf("%d%d", &n, &avg);
	FOR(i, 1, n) {
		scanf("%d", &a[i]);
	}
 
	dp[0][0] = 1;
	FOR(i, 1, n) {
		FORD(k, n, 1) {
			FORD(s, 2500, a[i]) {
				dp[k][s] += dp[k - 1][s - a[i]];
			}
		}
	}
	ll ans = 0;
	FOR(i, 1, n) {
		ans += dp[i][avg * i];
	}
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i(a);i<=b;i=-~i)
using namespace std;
inline int read(){
	int X(0);bool d(0);char ch(0);
	while(!isdigit(ch)) d|=ch=='-',ch=getchar();
	while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return d?-X:X;
}
const int maxn=2e3+3;
int a,n,s[maxn*maxn],cnt,sum;
bitset<maxn*maxn>b;
int main(){
	int n=read();
	b[0]=1;
	f(i,1,n) a=read(),sum+=a,b|=b<<a;
	f(i,sum+1>>1,sum) if(b[i]) return printf("%d\n",i),0;
	return 0;
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin >> s >> t;
    int n=s.size();
    map<char,char> mps,mpt;
    bool jud=true;

    for(int i = 0; i < n; i++) {
        if(mps.count(s[i]) == 0) mps[s[i]]=t[i];
        if(mpt.count(t[i]) == 0) mpt[t[i]]=s[i];
        if(mps[s[i]] != t[i] || mpt[t[i]] != s[i]){
            jud=false;
        }
    }
    if(jud) cout << "Yes" << "\n";
    else    cout << "No" << "\n";

    return 0;
}


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

int main() {
    int n;cin>>n;
    int MAX_N = 100003;
    int a[MAX_N];
    rep(i,MAX_N)a[i]=0;
    
    int tmp;
    rep(i,n){
        cin>>tmp;
        ++a[tmp];
        ++a[tmp+1];
        if(tmp!=0)++a[tmp-1];
    }
    sort(a,a + MAX_N,greater<int>());
    cout<<a[0]<<endl;
	return 0;
}

Measured memory_bytes: 4024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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 gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll a,b;
cin>>a>>b;
if(a==1){
    a+=13;
}
if(b==1){
    b+=13;
}
if(a>b){
    cout<<"Alice"<<endl;
}else if(a==b){
    cout<<"Draw"<<endl;
}else{
    cout<<"Bob"<<endl;
}
}










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

int main() {
  int k;
  string s;
  cin >> k >> s;

  if (s.length() <= k) {
    cout << s << endl;
    return 0;
  }

  s = s.substr(0, k);
  s += "...";
  cout << s << endl;
}


Measured memory_bytes: 3572
#include <stdio.h>
#include <math.h>

int main(void){
  int K,S;
  int X,Y;
  scanf("%d%d", &K,&S);


  int count = 0;

  for (X = 0; X <= K; X++) {
    for (Y = 0; Y <= K; Y++) {
      int Z = S - X - Y;
      if (0 <= Z && Z <= K) {
        count++;
      }
    }
  }

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
signed main(){
	ll N;
	cin >> N;
	string c;
	cin >> c;
	ll r_num = 0, w_num = 0;
	for(int i = 0; i < N; i++){
		if(c[i] == 'R'){
			++r_num;
		}else{
			++w_num;
		}
	}
	ll r_diff = 0, w_diff = 0;
	for(int i = 0; i < r_num; i++){
		if(c[i] == 'W'){
			++r_diff;
		}
	}
	cout << max(r_diff, w_diff) << endl;

	return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
int par[100005];
vector<int>adj[100005];
bool vis[100005];
void bfs(){
	queue<int>q;
	q.push(1);
	while(!q.empty()){
		int t=q.front();
		//cout<<t<<endl;
		q.pop();
		vis[t]=true;
		for(int j:adj[t]){
			if(vis[j]) continue;
			q.push(j);
			par[j]=t;
			vis[j]=true;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	memset(vis, false, sizeof vis);
	int n, m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x, y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	bfs();
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	for(int i=2;i<=n;i++) cout<<par[i]<<"\n";
}

Measured memory_bytes: 10676