akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair <int,int> P;

int main(){
    ll N,A,B,C,D,E;
    cin >> N >> A >> B >> C >> D >> E;

    cout << 5 + max({(N-1)/A,(N-1)/B,(N-1)/C,(N-1)/D,(N-1)/E}) << endl;
}

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

using namespace std;

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

#define TT template<typename T>
TT T    sq(T x){ return x*x; }
TT int  ubnd(vector<T>& v,T x){ return upper_bound(v.begin(), v.end(), x) - v.begin(); }
TT int  lbnd(vector<T>& v,T x){ return lower_bound(v.begin(), v.end(), x) - v.begin(); }
TT void sort(T& v){ sort(v.begin(), v.end()); }
TT void revs(T& v){ reverse(v.begin(), v.end()); }
TT void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TT void show(T& v,char d=' ',char e='\n'){for(int i=0;i<v.size();++i)cout<<v[i]<<((i==v.size()-1)?e:d);}
TT void inpt(vector<T>& v,int n){ v.reserve(n);for(int i=0;i<n;++i){T x; cin>>x; v.push_back(x);} }
TT T In(){ T x; cin >> x; return x; }

static inline void fast_io(){ ios::sync_with_stdio(0); cin.tie(0); }
static inline int in(){ int x; scanf("%d", &x); return x; }
static inline string instr(){ string x; cin >> x; return x; }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

int main()
{
  int n = in();
  vector<int> v;
  inpt(v, n);
  int maxi = *max_element(v.begin(), v.end());
  for (int i = 1; i <= maxi; i++){
    bool ok = true;
    for (int j = 0; j < n; j++){
      if (v[j] % i){
        ok = false;
        break;
      }
    }
    if (ok) printf("%d\n", i);
  }
  return (0);
}

Measured memory_bytes: 1228
#include <stdio.h>

int func(int n){
	if(n % 2 == 0){
		return n/2;
	}else{
		return 3*n+1;
	}
}

int main(void)
{
	int s;
	scanf("%d",&s);
	
	int a[1000000]={};
	
	a[0] = s;
	
	int i,j;
	for(int i = 0;i < 1000000;i++){
		a[i+1]=func(a[i]);
	}
	
	for(i = 0; i < 1000000; i++){
		for(j = i + 1; j < 1000000; j++){
			if(a[i] == a[j]){
				goto end;
			}
		}
	}
	
	end: printf("%d\n",j+1);
	
	return 0;
}
			
	
	
		
		
	
	
	
	
	
	
	
	
	

Measured memory_bytes: 4096
/*
 *
 */
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

#define INF 1e9

int N, K;
vector<int> edge[100005]; // edge[i] connect from i to edge[i][j].
int v[100005];   // v[i] is written in vertex i
int par[100005]; // vertex i's parent is par[i]
int lb[100005], ub[100005];  // Range [lb[i], ub[i]] is allowed at vertex i, v[i] must be in [lb[i], ub[i]]

int root;

void dfs(int vertex) {
    for (int i = 0; i < edge[vertex].size(); ++i) {
        int nextVertex = edge[vertex][i];
        if (nextVertex != par[vertex]) {
            par[nextVertex] = vertex;
            dfs(nextVertex);
        } else {
            // skip this
        }
    }

    for (int i = 0; i < edge[vertex].size(); ++i) {
        int nextVertex = edge[vertex][i];
        lb[vertex] = max(lb[vertex], lb[nextVertex] - 1);
        ub[vertex] = min(ub[vertex], ub[nextVertex] + 1);
    }
}

// Decide the example of v[i]
void dfs2(int vertex) {
    for (int i = 0; i < edge[vertex].size(); ++i) {
        int nextVertex = edge[vertex][i];
        if (nextVertex != par[vertex]) {
            par[nextVertex] = vertex;
            int tmp;
            tmp = v[vertex] + 1;
            if (lb[nextVertex] <= tmp && tmp <= ub[nextVertex]) {
                v[nextVertex] = tmp;
            } else {
                tmp = v[vertex] - 1;
                if (lb[nextVertex] <= tmp && tmp <= ub[nextVertex]) {
                    v[nextVertex] = tmp;
                } else {
                    // Error, impossible
                    lb[root] = INF;
                    ub[root] = -INF;
                    return;
                }
            }
            dfs2(nextVertex);
        } else {
            // skip this
        }
    }
}

int main(){
    //freopen("e3.in", "r", stdin);
    scanf("%d", &N);
    int a, b;
    for (int i = 0; i < N-1; ++i) {
        scanf("%d %d", &a, &b);
        edge[a].push_back(b);
        edge[b].push_back(a);

    }
    // init
    for (int i = 1; i <= N; ++i) {
        v[i] = INF;
        lb[i] = -INF;
        ub[i] = INF;
    }

    scanf("%d", &K);
    for (int i = 0; i < K; ++i) {
        int vertex, p;
        scanf("%d %d", &vertex, &p);
        v[vertex] = p;
        lb[vertex] = ub[vertex] = p;
        root = vertex;
    }
    par[root] = root;
    dfs(root);
    dfs2(root);

    if (lb[root] == v[root] && ub[root] == v[root]) {
        // possible
        printf("Yes\n");
        for (int i = 1; i <=N; ++i) {
            printf("%d\n", v[i]);
        }
    } else {
        printf("No\n");
    }



    return 0;
}


Measured memory_bytes: 14208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
int N;
int tmp[26];
int mn[26];

int main() {
	cin >> N;
	rep(c, 26){ mn[c] = 100; }

	rep(i, N){
		rep(c, 26) { tmp[c] = 0; }

		string s; cin >> s;
		rep(j, s.length()){
			tmp[s[j] -'a']++;
		}

		rep(c, 26) mn[c] = min(mn[c], tmp[c]);
	}

	rep(c, 26){
		rep(k, mn[c]) {cout << (char)('a' + c); }
	}
	cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  string s, t;
  cin >> N >> s >> t;
  int ans = N;
  rep(i, N)
  {
    //cout << s.substr(i, N) << ", " << t.substr(0, N - i) << endl;
    if (s.substr(i, N) == t.substr(0, N - i))
      break;
    else
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import random
from copy import deepcopy

d = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(d)]
"""
def min_max(l):
    l_min = min(l)
    l_max = max(l)
    return [1+(i-l_min)/(l_max-l_min) for i in l]

dd = [max(s[i]) for i in range(d)]
qq = min_max(c)
dd = min_max(dd)

ddd = [i for i in range(d)]
qqq = [i for i in range(26)]
"""
ans = []
last = [0]*26
for i in range(d):
    ma_po = -10**10
    ma_di = 0
    for j in range(26):
        po = s[i][j]
        for k in range(26):
            if k == j:
                continue
            po -= c[k]*(i+1-last[k])
        if po > ma_po:
            ma_po = po
            ma_di = j
    last[ma_di] = i+1
    ans.append(ma_di+1)

def score(l):
    lastd = [0]*26
    point = 0
    for j,k in enumerate(l):
        kk = k-1
        point += s[j][kk]
        lastd[kk] = j+1
        for l in range(26):
            point -= c[l]*(j+1-lastd[l])
    return point

ma = score(ans)

def random_search():
    global ans,ma
    li = deepcopy(ans)
    D = random.randrange(d)
    Q = random.randrange(26)
    li[D] = Q+1
    if score(li) > ma:
        ans = deepcopy(li)
        ma = score(li)

for i in range(10000):
    random_search()

for i in ans:
    print(i)

Measured memory_bytes: 88332
def check(k, v)
  idx = 0 
  k.times.each do
    vv = v 
    while vv > 0 do
      vv -= @items[idx]
      next if vv < 0 
      return true if idx == @items.count-1
      idx += 1
    end 
  end 
  false
end

n, k = STDIN.gets.split(' ').map(&:to_i)
@items = n.times.map { STDIN.gets.to_i }

l, r = 0, @items.reduce(:+)

while r - l > 1 do
  m = (r + l) / 2 
  check(k, m) ? r = m : l = m 
end

puts r

Measured memory_bytes: 9816
//
//  around_lake.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/01.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>

int main(int argc, const char* argv[]) {
    int k, n;
    std::cin >> k >> n;
    int a[n];
    
    if (k<2 || k>1000000) {
        std::cout << "invalid number of K" << std::endl;
        exit(1);
    }
    
    if (n<2 || n>200000) {
        std::cout << "invalid number of N" << std::endl;
        exit(1);
    }
    
    for (int i=0; i<n; i++) {
        std::cin >> a[i];
        if ((i==0 && a[i]<0) || (i>0 && a[i]<a[i-1])) {
            std::cout << "invalid number of A" << std::endl;
            exit(1);
        }
    }
    int biggest_distance = a[0] + k - a[n-1];
    for (int i=1; i<n; i++) {
        int distance = a[i] - a[i-1];
        if (biggest_distance < distance) {
            biggest_distance = distance;
        }
    }
    std::cout << k-biggest_distance << std::endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int a,b,c,n;
	1<=a<=100;
	1<=b<=100;
	1<=c<=100;
	scanf("%d%d%d",&a,&b,&c);
	if(a!=b&&a!=c&&b!=c)
	n=3;
	else if(a==b&&a!=c||a==c&&a!=b||b==c&&b!=a)
	n=2;
	else
	n=1;
	printf("%d",n);
	return 0;
} 

Measured memory_bytes: 128
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={default_val and {__index=function()return default_val end}}for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
local unpack = table.unpack or unpack
local insert = table.insert or insert
----
local S = setmetatable(read.l():totable(), {__index=function()return '!' end})
local T = setmetatable(read.l():totable(), {__index=function()return '@' end})
local tbl1 = array(2, 0)
local tbl2 = array(2, nil)

for i=1,#S do
    local tbl1_i = tbl1[i]
    local tbl1_i_1 = tbl1[i-1]
    local tbl2_i = tbl2[i]
    local tbl2_i_1 = tbl2[i-1]
    for j=1,#T do
        local ns = S[i]
        local nt = T[j]
        if ns == nt then
            local a = tbl1_i_1[j-1]
            local ra = '\\'
            tbl1_i[j] = a+1
            tbl2_i[j] = ra
        else
            local a = tbl1_i_1[j]
            local b = tbl1_i[j-1]
            if a > b then
                tbl1_i[j] = a
                tbl2_i[j] = '|'
            else
                tbl1_i[j] = b
                tbl2_i[j] = '-'
            end
        end
    end
end
if false then
    print(tbl1[#S][#T])
    return
end
local ans_revt = {}
local i, j, next = #S, #T, tbl2[#S][#T]
while next do
    if next == '\\' then
        insert(ans_revt, S[i])
        i, j = i-1, j-1
        next = tbl2[i][j]
    elseif next == '|' then
        i, j = i-1, j
        next = tbl2[i][j]
    elseif next == '-' then
        i, j = i, j-1
        next = tbl2[i][j]
    end
end
local ans_revs = table.concat(ans_revt, "")
print(ans_revs:reverse())

Measured memory_bytes: 196224
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] moji  = sc.next().toCharArray();
        int max =0;
        int cnt = 0;

        for(int i =0;i<moji.length;i++){
            if(moji[i]=='I'){
                cnt++;
            }else{
                cnt--;
            }
            if(max<cnt){
                max=cnt;
            }
        }
        
        System.out.println(max);

    }
}






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

int main(void) {
	long long A, B, C, K;
	cin >> A >> B >> C >> K;

	long long res = 0;
	res += min(A, K);
	K -= min(A, K);

	if (K <= 0) {
		cout << res << endl;
		return 0;
	}

	res += 0 * min(B, K);
	K -= min(B, K);
	if (K <= 0) {
		cout << res << endl;
		return 0;
	}

	res += -1 * min(C, K);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3636
def resolve():

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

    ans = 0
    for i in range(1, n-1):
        if (p[i-1] < p[i] < p[i+1]) or (p[i+1] < p[i] < p[i-1]):
            ans += 1
    print(ans)
    
resolve()

Measured memory_bytes: 3060
def main():
    import sys
    input = sys.stdin.readline
    from bisect import bisect_left,bisect
    
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    S = [list(map(int, input().split())) for i in range(M)]
    A.sort()
    A = A[::-1]
    S = sorted(S, key=lambda x: x[1])[::-1]
    
    T = []
    count = 0
    
    for i in range(M):
        T += [S[i][1]]*S[i][0]
        count += S[i][0]
        if count >= N:
            break
    
    a = 0
    t = 0
    SUM = 0
    for _ in range(N):
        if t >= count:
            SUM += A[a]
            a += 1
        elif A[a] > T[t]:
            SUM += A[a]
            a += 1
        else:
            SUM += T[t]
            t += 1
    print(SUM)
    
    

main()

Measured memory_bytes: 81432
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
typedef long long ll;
const ll MD = 1e9+7;
const int MN = 210;
const int MM = 4;
const int MS = MN*MM;

int n;
string s[MN];
int si[MN];
int sd[MN];

ll inv2;
ll po10[MS];
ll facdp[MN];

ll dp1[MN][MS], dp2[MN][MS];
ll calc() {
    inv2 = (MD+1)/2;
    po10[0] = 1;
    for (int i = 1; i < MS; i++) {
        po10[i] = po10[i-1] * 10;
        po10[i] %= MD;
    }

    for (int i = 0; i < MN; i++) {
        facdp[i] = 0;
        for (int j = 1; j <= i+1; j++) {
            ll sm = 1;
            for (int k = j; k <= i; k++) {
                sm *= k;
                sm %= MD;
            }
            facdp[i] += sm;
            facdp[i] %= MD;
        }
    }

    // for (int i = 0; i < 5; i++) {
    //     cout << facdp[i] << " ";
    // } cout << endl;
    for (int i = 0; i < n; i++) {
        si[i] = stoi(s[i]);
        sd[i] = (int)s[i].size();
    }
    memset(dp1, 0, sizeof(dp1));
    dp1[0][0] = 1;
    for (int fe = 0; fe < n; fe++) {
        int nsd = sd[fe];
        for (int i = 0; i < MN; i++) {
            for (int j = 0; j < MS; j++) {
                dp2[i][j] = dp1[i][j];
                if (i >= 1 && j >= nsd) {
                    dp2[i][j] += i*dp1[i-1][j-nsd];
                    dp2[i][j] %= MD;
                }
            }
        }
        memcpy(dp1, dp2, sizeof(dp1));
    }

    // for (int i = 0; i <= n; i++) {
    //     for (int j = 0; j < 10; j++) {
    //         cout << dp1[i][j] << " ";
    //     } cout << endl;
    // }
    ll sm = 0;
    for (int fe = 0; fe < n; fe++) {
        int nsd = sd[fe];
        for (int i = 0; i < MN; i++) {
            for (int j = 0; j < MS; j++) {
                dp2[i][j] = dp1[i][j];
                if (i >= 1 && j >= nsd) {
                    dp2[i][j] -= i*dp2[i-1][j-nsd];
                    dp2[i][j] = (dp2[i][j]%MD+MD) % MD;
                }
                sm += po10[j] * dp2[i][j] %MD * si[fe] %MD * facdp[n-i-1] %MD;
                sm %= MD;
            }
        }
    }
    return sm;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s, s+n, [&](const string &l, const string &r){
        return stoi(l) < stoi(r);
    });

    ll u = calc();
    if (s[0] == "0") {
        reverse(s, s+n);
        reverse(s, s+n-1);
        n--;
        u -= calc();
        u = (u+MD) % MD;
    }
    cout << u << endl;
    return 0;
}

Measured memory_bytes: 6008
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');

            //解毒剤入の美味しくないクッキー 3 
            var a = int.Parse(input[0]);

            //解毒剤入りの美味しいクッキー 1
            var b = int.Parse(input[1]);

            //毒入りの美味しいクッキー 4
            var c = int.Parse(input[2]);

            var gedokuyaku = a + b;
            //4

            var doku = 0;

            if (c < gedokuyaku + 1)
            {
                doku = c;
            }
            else
            {
                doku = gedokuyaku + 1;
            }

            var oisii = b;



            Console.WriteLine(doku +oisii);
        }    
    }
}


Measured memory_bytes: 13140
#![allow(non_snake_case, unused_imports)]

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

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        S: [String; N],
    }
    for c in "abcdefghijklmnopqrstuvwxyz".chars(){
        let mut cnt = 999;
        for i in 0..N{
            cnt = min(cnt, S[i].chars().filter(|&x| x==c).collect::<Vec<char>>().len());
        }
        for _i in 0..cnt{
            print!("{}",c);
        }
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define INF         1e9
#define MOD         998244353
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;



///a^b % MOD
ll bigMod(ll a , ll b) {

    ll p ;
    if( b == 0) return 1;
    p = ( bigMod(a , b/2) % MOD );
    p = ( p * p) % MOD;
    if( b & 1 ) p = ( p * a) % MOD;
    return p;
}
/// (1/x) % MOD
ll modInverse( ll x ) {
    return bigMod(x, MOD-2);
}
ll fre[MAX] , sum[MAX] , sqsum[MAX] , ans[MAX];

int main()
{
    fastRead;
    
    int n ;
    cin>>n;
    for(int i =0 ; i < n ; i++ ) {
        int tmp;
        cin>>tmp;
        fre[tmp]++;
    }
    
    for(ll i =1 ; i <MAX ; i++ ) {
        
        for(ll j =i ; j < MAX ; j+=i) {
            
            sum[i] = (sum[i] + fre[j]*j)%MOD;
            sqsum[i] = (sqsum[i] + fre[j]*(j *j)%MOD )%MOD;
        }
    }
    
    for(int i =1 ; i <MAX ; i++ ) {
        
        ans[i] = ( (sum[i]*sum[i])%MOD + MOD-  sqsum[i] )%MOD;
        ans[i] = ( ans[i] *modInverse(2) )%MOD;
    }
    
    ll ret = 0;
    
    for(int i = MAX-1; i >=1 ; i--) {
        
        for(int j = i+i ; j< MAX ; j+=i) {
            
            ans[i] = (ans[i] + MOD - ans[j] )%MOD;
        }
        
        ret = (ret + ( ans[i] * modInverse(i) ) %MOD )%MOD;
    }
    
    cout<<ret<<'\n';
    return 0;
}

Measured memory_bytes: 31488
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000007

typedef  long long ll;

using namespace std;

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

ll deg(int i){
  ll ret = 1;
  while(i != 0){
    if(i/10 == 0){
      break;
    }
    i/=10;
  }
  
  return i;
}

void solve(){
  int a,b;
  cin >> a >> b;
  cout << a*(a-1)/2+b*(b-1)/2 << endl;
  
}


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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 A,B;
    cin>>A>>B;
    cout<<max(A+B,max(A-B,A*B))<<endl;
    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                ans += 1
print(ans)

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

using namespace std;

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

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

	int s = 0;
	for (int i = 0; i < N; ++i)
	{
		if ((i +1)% 2 == 1 && a[i] % 2 == 1) s++;
	}
	cout << s;
}

Measured memory_bytes: 3628
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
diff1 = (A1 - B1) * T1
diff2 = (A2 - B2) * T2

if diff1 > 0:
    diff1, diff2 = -1 * diff1, -1 * diff2

if diff1 + diff2 < 0:
    print(0)
elif diff1 + diff2 == 0:
    print('infinity')
else:
    q, r = divmod(-diff1, diff1 + diff2)
    print(2*q + (1 if r != 0 else 0))

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

#define ll long long

ll tfs(ll x)
{
    bool t = false;
    bool f = false;
    bool s = false;
    for(;0 < x;x /= 10) {
        if(x%10 == 3) {
            t = true;
        }else if(x%10 == 5) {
            f = true;
        }else if(x%10 == 7) {
            s = true;
        }else{
            return 0;
        }
    }
    return t && f && s ? 1 : 0;
}

ll dfs(ll x, ll y)
{
    if(y < x) {
        return 0;
    }
    ll p = 0;
    p += tfs(x);
    p += dfs(x*10 + 3, y);
    p += dfs(x*10 + 5, y);
    p += dfs(x*10 + 7, y);
    return p;
}

int main()
{
    ll N;
    scanf("%ld", &N);
    printf("%d\n", dfs(0, N));
    return 0;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  int N,K;

  cin>>N>>K;

  int a[200001];

  int cnt[200001]={ };
  
  for(int i=0;i<N;i++){
    cin>>a[i];

    cnt[a[i]]++;
    
  }


  sort(a,a+N);

  long long ans=0;
  long long temp=0;
  for(int i=0;i<N;i++){
    if(a[i]!=a[i+1]){
      temp++;
    }
  }

  if(temp<=K){
    cout<<"0"<<endl;
  }else{
    
    sort(cnt,cnt+200000);
    
    for(int i=1;i<=200000;i++){
      
      if(temp<=K){
	break;
      }
      
      if(cnt[i]!=0){

	temp--;
	ans+=cnt[i];
      }
   
    }

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

}


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

int main() {
 int N;
 cin >> N;
 vector<int> d(N);
  for(int i =0; i < N; i++) cin >> d.at(i);
  
  int total = 0;
  for(int i = 0; i < N; i++){
   for(int j = i+1; j < N; j++){
     total += d.at(i) * d.at(j);
   }
  }
  cout << total << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

struct UnionFindTree{
    vector<int32_t>par,sz;
    UnionFindTree(int32_t n=0):par(n),sz(n){
        for(int32_t i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int32_t find(int32_t x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int32_t x,int32_t y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool same(int32_t x,int32_t y){
        return find(x)==find(y);
    }
    int32_t size(int32_t x){
        return sz[find(x)];
    }
};

int N,M,Q;
int A[111111],B[111111],C[111111];

signed main(){
    cin>>N>>M>>Q;
    rep(i,Q)cin>>A[i]>>B[i]>>C[i];

    UnionFindTree uf(N);
    rep(i,Q)if(C[i]==0)uf.unite(A[i],B[i]);

    rep(i,Q){
        if(C[i]==1&&uf.same(A[i],B[i])){
            cout<<"No"<<endl;
            return 0;
        }
    }

    int cnt=0;
    rep(i,Q)if(C[i]==1)cnt++;
    
    if(M==N-1){
        if(cnt==0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
        return 0;
    }

    int up=0;
    cnt=0;
    rep(i,N){
        if(uf.find(i)!=i)continue;
        cnt++;
    }

    if(cnt==2){
        cout<<"No"<<endl;
        return 0;
    }
    up=N-cnt+cnt*(cnt-1)/2;
    if(M<=up)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(){
  int a;
  cin >> a;
  if(a<1200){
    cout << "ABC" << endl;
  }
  else if(a>=1200&&a<2800){
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> B(N - 1);
    rep(i,N - 1){
        cin >> B[i];
    }
    int ans = 0;
    vector<int> A(N);
    A[0] = B[0];
    for (int i = 1; i < N - 1; i++){
        A[i] = min(B[i - 1], B[i]);
    }
    A[N - 1] = B[N - 2];
    rep(i,N){
        ans += A[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());int A = int.Parse(Console.ReadLine());int B = int.Parse(Console.ReadLine());

            X = X - A;//ケーキ一個買う
            X = X % B;
            Console.WriteLine(X);

        }
    }
}

Measured memory_bytes: 11092
#include<cstdio>

int n, m;

int main() {
  scanf("%d %d", &n, &m);
  int sum = 0;
  for (int i = 0; i < m; i++) {
    int a;
    scanf("%d", &a);
    sum += a;
  }
  if (sum <= n) {
    printf("%d\n", n - sum);
  } else {
    printf("-1\n");
  }
}


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

int main() {
  int n, m, s, c;
  bool a = true;
  cin >> n >> m;
  vector<int> v(4, -1);
  for(int i = 0;i < m;i++) {
    cin >> s >> c;
    if(v[s] == -1 || v[s] == c) v[s] = c;
    else a = false;
  }
  if(n != 1 && v[1] == 0) a = false;
  if(a) {
    if(n == 1) cout << ((v[1] == -1) ? 0 : v[1]) << endl;
    else {
      if(v[1] == -1) v[1] = 1;
      if(v[2] == -1) v[2] = 0;
      if(v[3] == -1) v[3] = 0;
      for(int i = 1;i <= n;i++) cout << v[i];
      cout << endl;
    }
  } else cout << -1 << endl;
}

Measured memory_bytes: 3616
import java.io.*;
import java.util.*;
 
class Main {
 
	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
		}
		solve(N, A);
	}
 
	static void solve(int N, long[] A) {
		long[] sum = new long[N + 1];
		for (int i = 0; i < N; i++) {
			sum[i + 1] = sum[i] + A[i];
		}
 
		int l = 1;
		int r = 3;
		long answer = Long.MAX_VALUE;
		for (int i = 2; i < N - 1; i++) {
			while (l < i - 1 && Math.abs(sum[i] - sum[l] * 2) >
					Math.abs(sum[i] - sum[l + 1] * 2)) {
				l++;
			}
 
			while (r < N - 1 && Math.abs(sum[N] - sum[i] - (sum[r] - sum[i]) * 2) >
					Math.abs(sum[N] - sum[i] - (sum[r + 1] - sum[i]) * 2)) {
				r++;
			}
 
			long[] a = new long[]{sum[l], sum[i] - sum[l], sum[r] - sum[i], sum[N] - sum[r]};
			Arrays.sort(a);
 
			answer = Math.min(answer, Math.abs(a[3] - a[0]));
		}
 
		System.out.println(answer);
	}
}

Measured memory_bytes: 93628
#include<iostream>
#include<unordered_map>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    unordered_map<int,int>ump;
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        for(int j=0;j<k;j++)
        {
            int element;
            cin>>element;
            ump[element]++;
        }
    }
    int count=0;
    for(auto it=ump.begin();it!=ump.end();it++)
    {
        if(it->second==n){
            count++;
        }
    }
    cout<<count;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define f(i,a,b) for(i=a;i<b;i++)
#define f_(i,a,b) for(i=a;i>=b;i--)
#define T_ ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define read(a,n) for(ll  i=0;i<n;i++) cin>>a[i]
#define pr(a,n)  for(ll  i=0;i<n;i++) cout<<a[i]<<" "; cout<<"\n"
#define ff first
#define ss second
#define all(s) s.begin(),s.end()

typedef long long ll ; typedef long double ld;
using namespace std;
bool isPrime(int N){for (int i = 2; i * i <= N; ++i){if (N % i == 0)return false;}return true;}
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b){return (a.first > b.first);}
int gcd(int a, int b){if(b==0) return a;return gcd(b, a%b);}


int main() {
    fast;
//    T_ {
//     int  x,i,y,l,r,n,k,z,sum=0,m,flag=0,j,f;
            ll n, t,sum,i,j,a[100005],val[100005];
            cin >> n >> sum;
            for(i=0;i<n;i++)
            {
                cin >> a[i];
                cin >> val[i];
            }
            ll dp[n+1][sum+1];
            for(i=0;i<=n;i++)
            {
                for(j=0;j<=sum;j++)
                    if(i==0 || j==0)
                        dp[i][j]=0;
            }
            for(i=1;i<=n;i++)
            {
                for(j=1;j<=sum;j++)
                {
                    if(a[i-1]<=j) {
                        dp[i][j] = max(val[i - 1] + dp[i - 1][j - a[i - 1]], dp[i - 1][j]);
                    }
                    else {
                        dp[i][j]=dp[i - 1][j];
                    }
                }
            }
            cout << dp[n][sum];

//    }




    return 0;
}
//cout << fixed << setprecision(12) << sum;

Measured memory_bytes: 82500
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

ll mod_pow(ll n, ll p, ll mod){
    // return (n^p) % mod
    if(p==0) return 1;
    ll res = mod_pow(n*n%mod, p/2, mod);
    if(p%2==1) res = res * n % mod;
    return res;
}

int main(){
    string L;  cin >> L;
    ll N = L.length();
    ll mod = 1e9+7;
    ll ans = 0;

    vector<ll> cnt(N,0);
    cnt[0] = 2;
    for(int i=1; i<N; i++){
        if(L[i]=='0') cnt[i] = cnt[i-1];
        else cnt[i] = 2*cnt[i-1]%mod;
    }

    ans += cnt[N-1];

    for(int i=0; i<N; i++){
        if(L[i]=='0') continue;
        ll tmp = 1;
        if(i>0){
            tmp = tmp*cnt[i-1]%mod;
        }
        if(i<N){
            tmp = tmp*mod_pow(3, N-i-1, mod)%mod;
        }
        ans = (ans +tmp)%mod;
    }    
    cout << ans << endl;
}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int x = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			Queue<int> queue = new Queue<int>();
			HashSet<int> hashset = new HashSet<int>();
			queue.Enqueue(0);
			int ans = 0;
			while (queue.Count > 0) {
				int i = queue.Dequeue();
				if (x == i) {
					ans = 1;
					break;
				}
				int tmp;
				if (x >= (tmp = i + 100) && !hashset.Contains(tmp)) { queue.Enqueue(tmp); hashset.Add(tmp); }
				if (x >= (tmp = i + 101) && !hashset.Contains(tmp)) { queue.Enqueue(tmp); hashset.Add(tmp); }
				if (x >= (tmp = i + 102) && !hashset.Contains(tmp)) { queue.Enqueue(tmp); hashset.Add(tmp); }
				if (x >= (tmp = i + 103) && !hashset.Contains(tmp)) { queue.Enqueue(tmp); hashset.Add(tmp); }
				if (x >= (tmp = i + 104) && !hashset.Contains(tmp)) { queue.Enqueue(tmp); hashset.Add(tmp); }
				if (x >= (tmp = i + 105) && !hashset.Contains(tmp)) { queue.Enqueue(tmp); hashset.Add(tmp); }
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = (N / 1000);
  b = ((N % 1000) / 100);
  c = ((N % 100) / 10);
  d = (N % 10);

  if ((a == b && b == c) || (b == c && c == d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import deque

inf = 10**18
mod = 10**9+7

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
edge = [[]for k in range(n)]
for i in range(m):
    a,b = ab[i]
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
ans = 0
for i in range(m): # i番目の編を無視したらどうなるか
    s,g = ab[i]
    s-=1
    g-=1
    visited = [False for j in range(n)]
    q = deque([s])
    while q:
        now = q.popleft()
        visited[now]=True
        for nn in edge[now]:
            if (now!=s or nn!=g) and (not visited[nn]):
                q.append(nn)
    if not all(visited):
        ans += 1
print(ans)

Measured memory_bytes: 40048
/**
 * author: said_v15
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
typedef long long  ll;

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define pb push_back 
#define sc second 
#define f first 
#define kek cout<<"\n"; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 


const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int MAXN = 1000100;
const int INF = 1e8;
const ll LL_INF=1e18;
const double pi=3.1415926535;
using namespace std;
int divide(int a, int b)
{
          return (a+b-1)/b;
}

int main()
{
    #if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
 fast;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 
 int questions=1;
 // cin>>questions;
 while(questions--)
 {
    int n;
    cin>>n;
    vector<pair<int,int>> v(n);
    forn cin>>v[i].f>>v[i].sc;
    bool ok=false;
    for(int i=0;i<n-2;i++) 
    {
          if(v[i].f==v[i].sc && v[i+1].f==v[i+1].sc && v[i+2].f==v[i+2].sc) ok=true;    
    }
    if(ok) cout<<"Yes";
    else cout<<"No";
    
           
       
 }
 
 
 // !!! LOOK AT NUMBER OF QUESTIONS IN A PROBLEM !!! (cin>>questions)
 

  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
}

Measured memory_bytes: 3656
import java.util.*;

public class Main
{
    private final static int MOD = 1_000_000_007;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
	String[] temp = in.nextLine().split(" ");
	int R = Integer.parseInt(temp[0]);
	int C = Integer.parseInt(temp[1]);
	char[][] map = new char[R][C];
	for (int i = 0; i < R; i++) {
	    String tmp = in.nextLine();
	    for (int j = 0; j < C; j++) {
		map[i][j] = tmp.charAt(j);
	    }
	}
	int[][] dp = new int[R][C];
	dp[0][0] = 1;
	for (int i = 0; i < R; i++) {
	    for (int j = 0; j < C; j++) {
		if (i - 1 > -1 && map[i-1][j] != '#') {
		    dp[i][j] += dp[i-1][j];
		    dp[i][j] %= MOD;
		}
		if (j-1 > -1 && map[i][j-1] != '#') {
		    dp[i][j] += dp[i][j-1];
		    dp[i][j] %= MOD;
		}
	    }
	}
	System.out.println(dp[R-1][C-1]);
	in.close();
    }
}


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

#define rep(i,l,r) for(int i=l;i<=r;++i)
#define pb push_back
const int N=1e5+5;
int n;
vector<int>lk[N],son[N];

int A;
namespace GET_A
{
void dfs(int x,int fr)
{
	for(auto y:lk[x])
	if(y!=fr)
	{
		son[x].pb(y);
		dfs(y,x);
	}
//	cerr<<x<<" "<<son[x].size()<<endl;
//	for(auto y:son[x])cerr<<y<<" ";puts("");
	if(x!=1)A+=son[x].size()/2;
	else A+=(son[x].size()+1)/2;
}
};
namespace GET_B
{
int len[N];
int mid;
bool dfs(int x)
{
	if(!son[x].size())
	{
		len[x]=1;
		return 0;
	}
	vector<int>a;
	for(auto y:son[x])
	{
		if(dfs(y))return 1;
		a.pb(len[y]);
	}
if(x==1)
{
	sort(a.begin(),a.end());
	int l=0,r=a.size()-1;
	if(r%2==0)
	{
		if(a[r]+1>mid)return 1;
		--r;
	}
	while(l<r)
	{
		if(a[l]+a[r]+1>mid)return 1;
		++l;--r;
	}
	return 0;
}
	if(a.size()%2==0)a.pb(0);
	sort(a.begin(),a.end());
	int l=0,r=a.size()-1;
	--r;
	while(l<r)
	{
		if(a[l]+a[r]+1>mid)return 1;
		++l;--r;
	}
	r=a.size()-1;l=0;
	while(r&&a[r]+a[l]+1<=mid)
	{
		--r;++l;
		if(l==r)++l;
	}
	len[x]=a[r]+1;
	return 0;
}
bool ok()
{
	if(dfs(1))return 0;
	return 1;
}
int erfen()
{
	int l=1,r=n;
	while(l+1!=r)
	{
		mid=(l+r)/2;
		if(ok())r=mid;
		else l=mid;
	}
//	mid=5;
//	ok();
	return r;
}
};

int main()
{
//	freopen("1.in","r",stdin);freopen("1.out","w",stdout);
	cin>>n;
	rep(i,1,n-1)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		lk[x].pb(y);lk[y].pb(x);
	}
	GET_A::dfs(1,0);
	int B=GET_B::erfen();
	cout<<A<<" "<<B-1<<endl;
}

Measured memory_bytes: 20864
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
int main(){
	ios::sync_with_stdio(false);
	int gcda=0,maxa=0;
	int n,r,x;
	cin>>n>>r;
	for(int i=0;i<n;i++){
		cin>>x;
		gcda=gcd(gcda,x);
		maxa=max(maxa,x);
	}
	if(maxa>=r&&r%gcda==0)cout<<"POSSIBLE\n";
	else cout<<"IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

S = input()
T = input()

if S==T:
    print("Yes")
    exit()

ls1 = ["?"]*26
ls2 = ["?"]*26
for i in range(len(S)):
    s = S[i]
    t = T[i]
    no1 = ord(s) - 97
    no2 = ord(t) - 97
    if ls1[no1]=="?":
        ls1[no1] = t
    else:
        if ls1[no1]==t:
            pass
        else:
            print("No")
            exit()
    if ls2[no2]=="?":
        ls2[no2] = s
    else:
        if ls2[no2]==s:
            pass
        else:
            print("No")
            exit()

print("Yes")
exit()

Measured memory_bytes: 43612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;

ll a[N];
vector<int> adj[N];
bool flag = true;

void dfs(int v, int p)
{
	ll sum = 0;
	int find = 0;
	ll mx = 0;
	for (auto u : adj[v])
	{
		if (u == p)
			continue;
		dfs(u, v);
		find++;
		sum += a[u];
		mx = max(mx, a[u]);
	}
	if (find > 1)
	{
		if (sum < a[v] || sum > 2 * a[v] || mx > a[v])
			flag = false;
		a[v] = 2 * a[v] - sum;
	}
	else if (find == 1)
	{
		if (a[v] != sum)
			flag = false;
	}
	//cout << v << " ~ " <<  a[v] << "\n";
}

int main()
{
	int n;
	cin >> n;
	for (int i=0; i<n; i++)
		cin >> a[i];
	for (int i=1; i<n; i++)
	{
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	if (n == 2)
	{
		cout << (a[0] == a[1] ? "YES\n" : "NO\n") << "\n";
		return 0;
	}
	int v = 0;
	for (int i=0; i<n; i++)
		if ((int)adj[i].size() > 1)
		{
			v = i;
			dfs(i, -1);
			break;
		}
	if (a[v] || !flag)
		cout << "NO\n";
	else
		cout << "YES\n";
}

Measured memory_bytes: 13184
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;

lli mod197 = 1000000007LL;

// 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 N, K;
	cin >> N >> K;
	
	cout.precision(18);

	if (K % 2 == 0) {
		COUT((lli)((lli)pow((lli)(N / K), 3) + (lli)pow((lli)(((N + K / 2) / K)), 3)));
	}
	else {
		COUT(((lli)pow((lli)(N / K),3)));
	}

	return 0;
}

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

int main() {
    // input(sunippets: inpv, inpn)
    ll A, B, C;
    cin >> A >> B >> C;
    
    // calculation
    cout << min(C, B/A) << "\n";
    
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize1; n - 1]
    }
    let mut t = vec![vec![]; n];
    for i in 1..n {
        t[v[i - 1]].push(i);
    }
    println!("{}", dfs(0, &t));
}

fn dfs(v: usize, t: &Vec<Vec<usize>>) -> usize {
    let mut a = vec![0];
    for &c in &t[v] {
        a.push(dfs(c, t));
    }
    a.sort_by(|x, y| y.cmp(x));
    for i in 0..t[v].len() {
        a[i] += i + 1;
    }
    a.iter().cloned().max().unwrap()
}


Measured memory_bytes: 37500