akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

int ncr(int n, int r)
{
    int sol = 1;
    for (int i = n - r + 1; i <= n; ++i)
        muls(sol, i);
    for (int i = 1; i <= r; ++i)
        muls(sol, inv(i));
    return sol;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    cout << sub(sub(sub(pwr(2, n), ncr(n, a)), ncr(n, b)), 1);
}


Measured memory_bytes: 256
S = list(input().split("T"))
x, y = map(int, input().split())

X_command = [len(i) for i in S[0::2]]
Y_command = [len(i) for i in S[1::2]]

x_reachd = {X_command.pop(0)}
y_reachd = {0}

for X in X_command:
    tmp = set()
    for xi in x_reachd:
        tmp.add(xi + X)
        tmp.add(xi - X)
    x_reachd = set(tmp)

for Y in Y_command:
    tmp = set()
    for yi in y_reachd:
        tmp.add(yi + Y)
        tmp.add(yi - Y)
    y_reachd = set(tmp)

if x in x_reachd and y in y_reachd:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  ll K, A, B;
  ll res=1;
  ll m = 0;
  cin >> K >> A >> B;

  while(K > 0) {
    if(K >=2 && res >=A && (B-A) >= 2) {
      res += B-A;
      K-=2;
    }
    else {
      res++;
      K--;
    }
    //printf("K=%lld bis#:%lld\n", K, res);                                              
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

const ll INF = 100100100100;

int main(){
    ll n, m; cin >> n >> m;
    vector<vector<ll>> dp(m+1,vector<ll>(1<<n,INF));
    dp[0][0] = 0;
    rep(i,m){
        ll a, b; cin >> a >> b;
        ll count = 0;
        rep(j,b){
            ll c; cin >> c;
            count |= 1<<(c-1);
        }
        rep(j,1<<n){
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
            dp[i+1][j|count] = min(dp[i+1][j|count],dp[i][j]+a);
        }
    }
    if(dp[m][(1<<n)-1] == INF) cout << -1 << endl;
    else cout << dp[m][(1<<n)-1] << endl;
}

Measured memory_bytes: 35404
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    long long A;
    float B;
    string B_s;
    
    cin >> A >> B_s;
    
//    int B_int = B*100;
    int B_int = stoi(B_s.substr(0, B_s.length()-2))*100 + stoi(B_s.substr(B_s.length()-2));
    long long result = A*B_int;
    
    string S = to_string(result);
    
//    cout << S << endl;
    if (S.length()<=2) {
        cout << 0 << endl;
    }
    else {
        cout << S.substr(0, S.length()-2) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3688
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	double T, X;
	cin >> T >> X;
	printf("%.15lf\n", T / X);
}

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

int main() {
	int n;
	scanf("%d", &n);
	vector<int> c(n-1), s(n-1), f(n-1);
	for(int i = 0; i < n-1; i++) {
		scanf("%d %d %d", &c[i], &s[i], &f[i]);
	}
	for(int i = 0; i < n; i++) {
		int timex = 0;
		int j = i;
		while(j < n-1) {
			timex = max(s[j], ((int)ceil((1.0*timex)/f[j])) * f[j]);
			timex += c[j];
			j++;
		}
		printf("%d\n", timex);
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int c = 0;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] != t[i]) {
      c++;
    }
  }
  cout << c << endl;
}

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

int main(){
  string s; int m;
  while(true){
    cin >> s;
    if(s == "-") break;
    cin >> m;
    for(int i = 0; i < m; i++){
      int h; cin >> h;
      s.insert(s.end(), s.begin(), s.begin() + h);
      s.erase(s.begin(), s.begin() + h);
      /*
      string s1 = s.substr(0, h);
      string s2 = s.substr(h, (int)s.size() - h);
      s = s2 + s1;
      */
    }
    cout << s << endl;
  }
}



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

int main () {
  int W ;
  cin >> W ;
  int a , b ;
  cin >> a >> b ;
  
  int ans = max(a,b) - ( min(a,b) + W ) ;
  
  if(ans >= 0 ) cout << ans << endl ;
  else cout << 0 << endl ;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

n = int(input())

graph = [[] for i in range(n)]
edge_cnt = [0] * n
for i in range(n-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
    edge_cnt[a-1] += 1
    edge_cnt[b-1] += 1


c = list(map(int, input().split()))
c.sort()

v = 0
for i in range(n):
    if edge_cnt[i] == 1:
        v = i
        break

nodes = [0] * n
total_score = -c[-1]


def dfs(v):
    global total_score
    if nodes[v] > 0:
        return
    nodes[v] = c.pop()
    total_score += nodes[v]
    for nv in graph[v]:
        if nodes[nv] > 0:
            continue
        dfs(nv)


dfs(v)
print(total_score)
print(*nodes, sep=' ')


Measured memory_bytes: 56280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 1;
  char t = s[0];
  rep(i,n){
    if(t == s[i]) continue;
    else{
      t = s[i];
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
def BubbleSort(A):
    loop = len(A)-1
    for i in range(loop):
        for j in range(loop-i):
            if A[j][1] > A[j+1][1]:
                A[j],A[j+1] = A[j+1],A[j]

    
def SelectionSort(A):
    loop = len(A)-1
    for i in range(loop):
        mini = i
        for j in range(i+1,loop+1):
            if A[j][1] < A[mini][1]:
                mini = j
        if i != mini:
            A[i],A[mini]=A[mini],A[i]            

    
N = int(input())
S = input().strip().split()
SS = S.copy()

BubbleSort(S)
for i in range(N):
    if i == N-1:
        print(S[i])
    else:
        print(S[i],end=' ')
print('Stable')

        
SelectionSort(SS)
for i in range(N):
    if i == N-1:
        print(SS[i])
    else:
        print(SS[i],end=' ')
if SS == S:
    print('Stable')
else:
    print('Not stable')


Measured memory_bytes: 5616
using System;
using static System.Console;
using System.Collections.Generic;

namespace dp
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = ReadLine().Split(' ');
            var n = int.Parse(nm[0]);
            var m = int.Parse(nm[1]);

            var pathList = new List<int>[n + 1];
            for (var i = 0; i < m; ++i)
            {
                var xy = ReadLine().Split();
                var x = int.Parse(xy[0]);
                var y = int.Parse(xy[1]);
                if (pathList[x] == null)
                {
                    pathList[x] = new List<int>();
                }
                pathList[x].Add(y);
            }

            var dp = new int[n + 1];
            for (var i = 0; i <= n; ++i)
            {
                dp[i] = -1;
            }
            var max = 0;
            for (var i = 1; i <= n; ++i)
            {
                max = Math.Max(max, Rec(i, pathList, dp));
            }
            Console.WriteLine(max);
        }
        private static int Rec(int start, List<int>[] pathList, int[] dp)
        {
            if (dp[start] > -1)
            {
                return dp[start];
            }
            var max = 0;
            if (pathList[start] != null)
            {
                foreach (var next in pathList[start])
                {
                    max = Math.Max(max, Rec(next, pathList, dp) + 1);
                }
            }
            dp[start] = max;
            return max;
        }
    }
}


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

int n, a[100000*3];

int main() {
	cin >> n;
	for (int i = 0; i < n * 3; i++) {
		cin >> a[i];
	}
	sort(a, a + n*3);
	//for (int i = 0; i < n * 3; i++)cout << a[i] << "\t";
	long long sum = 0, left = 0, right = n*3-1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			if (j != 2) {
				if (j == 1) {
					//cout << a[right] << endl;
					sum += a[right];
				}
				right--;
			}
			else {
				left++;
			}
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
const int mod=998244353;
const int maxn=3000+5;
int n,s;
int a[maxn];
int sum[maxn];
int f[maxn][maxn];
int main()
{
    cin>>n>>s;
    for(int i=1;i<=n;++i)
    {
        cin>>a[i];
        if(a[i]<=s) f[i][a[i]]=i;
    }
    for(int i=1;i<=n;++i)
    {
        for(int j=a[i];j<=s;++j)
        {
            f[i][j]=(f[i][j]+sum[j-a[i]])%mod;
        }
        for(int j=0;j<=s;++j) sum[j]=(sum[j]+f[i][j])%mod;
    }
    int an=0;
    for(int i=1;i<=n;++i)
    {
        an=(an+(ll)f[i][s]*(n-i+1))%mod;
    }
    cout<<an<<endl;
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (i = k; i >= n; --i)

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

void solve() {
    double D, T, S;
    cin >> D >> T >> S;
    cout << (T * S >= D ? "Yes" : "No");
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();

    return 0;
}


Measured memory_bytes: 3732
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 2e5 + 5;
#define bug(x) printf("  %s = %d \n",#x,x);
#define mem(arr,x) memset(arr,x,sizeof arr);
int par[maxn];

int dfs(int pos){
	if(par[pos] != pos)
		return dfs(par[pos]);
	else
	 	return pos;
}

int main() {
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(0);
	int N,Q;
	while(scanf("%d%d",&N,&Q) == 2){
		if(N == 0 && Q == 0) break;
		par[1] = 1;
		for(int i = 2; i <=  N; i++){
			scanf("%d",par + i);
		}
		char op;
		int  pos;
		long long  Sum = 0;
		getchar();
		for(int i = 1; i <= Q;i++){
			scanf("%c %d",&op,&pos);
//			bug(op);
			if(op == 'Q'){
				Sum += dfs(pos);
			}
			else{
				par[pos] = pos;
			}
			getchar();
		}
		printf("%lld\n",Sum);
	}
}

Measured memory_bytes: 3484
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        String Str = input.nextLine();
        print(Str);
    }
    private static int Search(String in){
        int result = in.indexOf("AC");
        return result;
    }
    private static void print(String inPut){
        if(Search(inPut) != -1){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,a,b) for(int i = (int)(a); (i) < (b); i++)
#define rep(i,n) REP(i,0,n)

const int MOD = 1e9 + 7;

int main(){
	string s;
	cin >> s;
	int n = s.size();
	int m = 13;
	int target = 5;
	int offset = '0';

	int mod[m][10];
	rep(p,m) rep(q,10) mod[p][q] = (p*10 + q) % m;

	int dp[n+1][m];
	memset(dp,0,sizeof(dp));
	dp[0][0] = 1;

	REP(i,1,n+1) rep(j,m){
		int lower_lim = (s[i-1] == '?' ? 0 : s[i-1] - offset);
		int upper_lim = (s[i-1] == '?' ? 9 : s[i-1] - offset);
		
		REP(k,lower_lim, upper_lim+1){
			int index = mod[j][k];
			(dp[i][index] += dp[i-1][j]) %= MOD;		
		}
	}

	cout << dp[n][target] << endl;
	return 0;
}

Measured memory_bytes: 5504
n,k = list(map(int,input().split()))
data = [int(s) for s in input().split()]
ans =[]
for i in range(n-k + 1):
    ans.append(abs(data[i]) + abs(data[i+k-1] - data[i]))
for i in range(n-k + 1):
    ans.append(abs(data[i+k -1]) + abs(data[i+k-1] - data[i]))

print(min(ans))



            
    



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

typedef unsigned long long ll;
typedef std::pair<int, int> P;

#define frep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) frep(i, 0, (n))
#define rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100010;
const int INF = 1e9;
const int MOD = 1000000007;
const string END = "\n";

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

void solve(){
	ll n, m; cin >> n >> m;
	string s, t; cin >> s >> t;
	ll k = gcd(n, m); n /= k; m /= k;
	bool flag = true;
	ll s_step = 0, t_step = 0;
	rep(i, k){
		if(s[s_step] != t[t_step]) flag = false;
		s_step += n; t_step += m;
	}
	if(flag){
		cout << n * m * k << END;
	}else{
		cout << -1 << END;
	}
}

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


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

int main() {
  int a;
  int b;
  int c;
  int d;
  
  cin >> a >> b >> c >> d;
  if (a + b > c + d) {
    cout << "Left" << endl;
  }
  else if (a + b < c + d) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
  
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut pooled = 0;
    let mut ans = 1;
    for i in 1..s.len() {
        if s[i] == s[i - 1] && (pooled == 0) {
            pooled = 2;
        } else {
            pooled -= 1;
            if pooled < 0 {
                pooled = 0;
            }
            ans += 1;
        }
        // debug!(i, ans);
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define maxn 300000
#define LL long long
int a[maxn+5],ans[maxn+5];LL b[maxn+5];
int main(){
	int n,x;scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&x),a[x]++,b[a[x]]++;
	for(int i=1;i<=n;i++)b[i]+=b[i-1];
	int now=0;
	for(int i=n;i;i--){
		while(b[now+1]>=1ll*(now+1)*i)now++;
		ans[i]=now;
	}
	for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 5504
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int  a, b, c;
    cin >> a >> b >> c;
    a -= b;
    cout << a%c;
    cout << endl;
}


Measured memory_bytes: 256
mod = 10**9+7


def inv(x):
    return pow(x, mod - 2, mod)


N = int(input())
A = [int(x) for x in input().split()]
fact = [1, 1]

for i in range(2, N + 1):
    fact.append(fact[-1] * i % mod)
inv_sum = [0]
for i in range(1, N + 1):
    inv_sum.append((inv_sum[-1] + fact[N] * inv(i) % mod) % mod)

ans = 0
for i in range(N):
    ans += (inv_sum[i + 1] + inv_sum[N - i] - fact[N] + mod) % mod * A[i] % mod
    ans %= mod
print(ans)


Measured memory_bytes: 15252
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

class Union_Find
{
	std::vector<LL>per, rank, cnt;
public:
	void init(LL size)
	{
		rep(i, size)
		{
			per.push_back(i);
			rank.push_back(0);
			cnt.push_back(1);
		}
	}
	LL get_per(LL x)
	{
		if (x == per[x]) return x;
		return per[x] = get_per(per[x]);
	}
	bool is_same_per(LL x, LL y)
	{
		return get_per(x) == get_per(y);
	}
	void unite(LL x, LL y)
	{
		LL x_per = get_per(x), y_per = get_per(y);
		if (x_per == y_per) return;
		if (rank[x_per] < rank[y_per])
		{
			per[x_per] = y_per;
			cnt[y_per] += cnt[x_per];
			cnt[x_per] = 0;
		}
		else
		{
			per[y_per] = x_per;
			cnt[x_per] += cnt[y_per];
			cnt[y_per] = 0;
			if (rank[x_per] == rank[y_per]) ++rank[x_per];
		}
	}
	LL get_cnt(LL x)
	{
		return cnt[get_per(x)];
	}
};

int main()
{
	LL N, M;
	in >> N >> M;
	std::vector<LL>A(M), B(M);
	rep(i, M) in >> A[i] >> B[i];

	Union_Find tree;
	tree.init(N + 1);

	std::vector<LL>ans;
	LL res = N * (N - 1) / 2;
	ans.push_back(res);
	rep(i, M - 1)
	{
		if (!tree.is_same_per(A[M - i - 1], B[M - i - 1])) res -= tree.get_cnt(A[M - i - 1])*tree.get_cnt(B[M - i - 1]);
		tree.unite(A[M - i - 1], B[M - i - 1]);
		ans.push_back(res);
	}
	std::reverse(ans.begin(), ans.end());
	rep(i, M) out << ans[i] << std::endl;
}


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

int main() {
  cout<<setprecision(10)<<fixed;
  double L;
  cin>>L;
  double ans;
  ans = L/3*L/3*L/3;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())
ans = [0] * (n - 1)
for i in range(1, n):
    for j in range(i + 1, n + 1):
        d = min(j - i, abs(j - y) + 1 + abs(x - i))
        ans[d - 1] += 1
for i in ans:
    print(i)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int a, b;
    scanf("%d%d", &a, &b);
    rep(i, MAX){
        if(i*8/100 == a && i*10/100 == b){
            printf("%d\n", i);
            return 0;
        }
    }
    puts("-1");
}

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

int main()
{
	string s;
	cin >> s;
	int mozisu = s.length();
	int flag = 0;
	for (int i = 0; i < mozisu-1; i++) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			flag = 1;
		}
	}
	if (flag == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
import sys
input = sys.stdin.readline


def main():
    n, k = map(int, input().split())

    result = 0
    if n < k:
        for i in range(1, n + 1):
            x = math.ceil(math.log(k / i, 2))
            result += (1 / n) * (0.5 ** x)
    else:
        for i in range(1, k):
            x = math.ceil(math.log(k / i, 2))
            result += (1 / n) * (0.5 ** x)
        result += (n - k + 1) / n
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
N = int(input())
h = [int(x) for x in input().split()]
h.append(0)
base = [0 for i in range(N+1)]
ans = 0

while h != base:
    ans += 1
    f = h.index(max(h))
    i = 0
    while h[f+i] == h[f+i+1]:
        h[f+i] -= 1
        i += 1
    h[f+i] -= 1

print(ans)
    


Measured memory_bytes: 3064
import java.util.*;
public class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] list1 = new int[180];
		int[] dp1 = new int[1000000];
		int[] dp2 = new int[1000000]; 
		for(int i = 0; i < 180; i++) {
			list1[i] = (i+1)*(i+2)*(i+3)/6;
		}

		Arrays.fill(dp1, 2 << 27);
		Arrays.fill(dp2, 2 << 27);

		dp1[0] = dp2[0] =  0;

		for(int i = 0; i < 180; i++) {
			int tmp = list1[i];
			if(list1[i] % 2 == 0)
			for(int j = tmp; j < 1000000; j++) {
				dp1[j] = Math.min(dp1[j-tmp]+1, dp1[j]);
			}
			else
			for(int j = list1[i]; j < 1000000; j++) {
				dp1[j] = Math.min(dp1[j-tmp]+1, dp1[j]);
				dp2[j] = Math.min(dp2[j-tmp]+1, dp2[j]);
			}
		}
		while(true) {
			int a = sc.nextInt();
			if(a == 0) break;
			System.out.println(dp1[a] + " " + dp2[a]);
		}
	}
	

	
}

Measured memory_bytes: 29592
//
// Created by kinok on 2020/04/19.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>

using namespace std;


#define ll long long
#define rep(t) for(int i=0;i<t;i++)
#define deb(a) cout<<#a<<" : "<<a<<endl
#define debv(v) do{cout<<#v<<" : ";for(auto a:v){cout << a <<" ";} cout<<endl;}while(0);
#define PI 3.141592653589793
#define limit (ll)pow(10,9)+7



void a(){
    int a;
    cin>>a;
    cout<<fixed<<setprecision(8)<<a*2*PI<<endl;
}

void b(){
    ll n,m,total=0,k;
    cin>>n>>m;
    rep(m){
        cin>>k;
        total+=k;
    }
    cout<<(n<total?-1:n-total)<<endl;
}
void c(){
ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> ans(n,0);
    rep(n-1){
        cin>>a.at(i);
        ans.at(a.at(i)-1)+=1;
    }
    rep(n){
        cout<<ans.at(i)<<endl;
    }
}

void d(){
    ll n,k,ans=0,f,e;
    cin>>n>>k;
    f=(k*(k-1))/2;
    for(ll i=k;i<=n+1;i++){
        e=n*i-((i*(i-1))/2);
        //deb(i);
        //deb(f);
        //deb(e);
        ans+=e-f+1;
        ans%=limit;
        //deb(ans);
        //cout<<endl;
        f+=i;
    }
    ans%=limit;
    cout<<ans<<endl;
}

void e(){

}

void f(){

}


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


Measured memory_bytes: 3628
a=list(map(int,input()))
n=len(a)

def dfs(tmp,cur,strs):
  if cur==n:
    if tmp==7:
      print("".join(strs)+"=7")
      exit()
    else:
      return
  ret0=dfs(tmp+a[cur],cur+1,strs+["+"]+[str(a[cur])])
  ret1=dfs(tmp-a[cur],cur+1,strs+["-"]+[str(a[cur])])
dfs(a[0],1,[str(a[0])])

Measured memory_bytes: 3064
using System;

namespace ABC102B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var target = Console.ReadLine().Split(' ');
            int[] a = new int[N];
            for(int i = 0; i < N; i++){
                a[i] = int.Parse(target[i]);
            }
            Array.Sort(a);
            Console.WriteLine("{0}", a[N-1]-a[0]);
        }
    }
}


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

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int arr[101]={};
int main(){
  ll n;cin>>n;
  int d1,d2;
  for(int i=1;i<=n;i++){
    cin>>d1>>d2;
    if(d1==d2){
      arr[i]++;
    }
  }
  for(int i=1;i<=n-2;i++){
    if(arr[i]+arr[i+1]+arr[i+2]==3){
      cout<<"Yes";
      return 0;
    }
  }cout<<"No";
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	string S;
	cin >> S;
	
	cout << "2018" + S.substr(4, S.length() - 4);
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i,x) for(int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(),x.end())
#define dupl(s) s.erase(unique(s.begin(), s.end()), s.end());//重複取り除き
#include <bits/stdc++.h>
using namespace std;
int sum(vector<int> s){return accumulate(s.begin(),s.end(),0);}
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int n,m;
    cin >> n;
    map<int,int> ld;
    rep(i,n){
        int d;
        cin >> d;
        ld[d]++;
    }
    cin >> m;
    rep(i,m){
        int t;
        cin >> t;
        if(ld[t] > 0)ld[t]--;
        else{cout << "NO";return 0;}
    }
    cout << "YES";
}

Measured memory_bytes: 12840
#include <stdio.h>
#include <string.h>

typedef struct {
    int ax, ay;
    int bx, by;
    int time;
} TWIN;

TWIN queue[300000];
int head, tail;

void enq(TWIN t)
{
    queue[tail % 300000] = t;
    queue[(tail + 1) % 300000].time = -1;
    tail++;
}

void deq(TWIN *t)
{
    *t = queue[head % 300000];
    head++;
}

int main(void)
{
    TWIN first, temp;
    int x, y;
    int i, j;
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    char map[51][51];
    static char v[51][51][51][51];
    int flag;
    
    while (1){
        scanf("%d%d", &x, &y);
        
        if (x + y == 0){
            break;
        }
        
        scanf("%d%d", &first.ax, &first.ay);
        scanf("%d%d", &first.bx, &first.by);
        
        first.ax -= 1;
        first.ay -= 1;
        first.bx -= 1;
        first.by -= 1;
        
        for (i = 0; i < y; i++){
            for (j = 0; j < x; j++){
                scanf("%d", &map[i][j]);
            }
        }
        first.time = temp.time = 0;
        head = tail = 0;
        memset(v, 0, sizeof(v));
        v[first.ay][first.ax][first.by][first.bx] = 1;
        enq(first);
        flag = 0;
        while (1){
            deq(&temp);
            
            if (temp.time == -1 || temp.time >= 100){
                break;
            }
            
            if (temp.ax == temp.bx && temp.ay == temp.by){
                flag = 1;
                break;
            }
            
            for (i = 0; i < 4; i++){
                first = temp;
                if (0 <= first.ax + dx[i] && first.ax + dx[i] < x && 0 <= first.ay + dy[i] && first.ay + dy[i] < y && map[first.ay + dy[i]][first.ax + dx[i]] == 0){
                    first.ax += dx[i];
                    first.ay += dy[i];
                }
                if (0 <= first.bx - dx[i] && first.bx - dx[i] < x && 0 <= first.by - dy[i] && first.by - dy[i] < y && map[first.by - dy[i]][first.bx - dx[i]] == 0){
                    first.bx -= dx[i];
                    first.by -= dy[i];
                }
                first.time++;
                if (!v[first.ay][first.ax][first.by][first.bx]){
                    v[first.ay][first.ax][first.by][first.bx] = 1;
                    enq(first);
                }
            }
        }
        if (flag == 1 && temp.time < 100){
            printf("%d\n", temp.time);
        }
        else {
            printf("NA\n");
        }
    }
    
    return (0);
}

Measured memory_bytes: 0
S = input()
N = len(S)

def palindrome(string):
  return 0 if string==string[::-1] else 1

ls1 = S[0:int((N-1)/2)]
ls2 = S[int((N+3)/2-1):N]

#print(ls1)
#print(ls2)


if palindrome(S) == palindrome(ls1) == palindrome(ls2) == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 8884
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int[] nums=new int[200000];
        for(int i=0;i<n;i++){
            nums[sc.nextInt()-1]++;
        }
        Arrays.sort(nums);
        int ans=0;
        for(int i=200000;i>200000-k;i--){
            ans+=nums[i-1];
        }
        System.out.println(n-ans);
    }

    
}

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

int main(){
  string s;
  cin >> s;
  cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        int a, b, c, d;
        string[] str = Console.ReadLine().Split(' ');
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);
        c = 2*(a + b);
        d = a * b;
        Console.WriteLine(d + " " + c);
    }
}

Measured memory_bytes: 9040
#include <bits/stdc++.h>
#include <iomanip>
#define M 100000
#define MAX 1000000001
#define MIN -10000000000000000
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;


int main(){
    string s,t;
    cin>>s>>t;
    int n = s.length(),m = t.length();
    int ans = n;
    for(int i=0;i<n;i++){
        if(i+m-1 >= n)
            break;
        else{
            int temp = 0;
            for(int j=0;j<m;j++){
                if(s[i+j] != t[j])
                    temp++;
            }
            ans = min(ans,temp);
        }
    }
    cout<<ans<<"\n";
    return 0;
        
}


Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;



int main(){
	int k;
	while(cin>>k && k){
		int s = 0, t;
		rep(i, k*(k-1)/2) cin>>t, s += t;
		cout<<s/(k-1)<<endl;
	}	
}

Measured memory_bytes: 1156
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int inf = 1000000000;
ll INF = 1000000000000000000;
int n, k, a[100010];
ll ans = INF;
int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i <= n - k; i++) {
		ll cnt = a[i + k - 1] - a[i] + min(abs(a[i]), abs(a[i + k - 1]));
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
vector <int> v;
#define soort(v) sort(v.begin(),v.end())
#define foor(i,n) for(int i=0; i<n; i++)
//#define vecprint(v){for(int i=0; i<v.size(); i++)cout << v[i] << " ";}
int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}
//int string_sum(string s){int b = 0;auto k =s.size();for(int j=0; j<k; j++){b +=(s[j]-48);}return b;}
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
 
//int cnt =0;
 
//void SieveOfEratosthenes(int n=20000000)
//{
//   // v.push_back(1);
//
//   bool prime[n+1];
//   memset(prime, true, sizeof(prime));
//
//    vector <bool>prime(n+1,true);
//
//    for (int p=2; p*p<=n; p++)
//    {
//
//        if (prime[p] == true)
//        {
//
//            for (int i=p*p; i<=n; i += p)
//                prime[i] = false;
//        }
//    }
//
//
//    for (int p=2; p<=n; p++)
//       if (prime[p])
//          mp[p]++;
//}
 
 
//vector <int> arr(100,-1);
//
//int fib(int n)
//{
//    if(n<=1)return 1;
//
//    if(arr[n]==-1)
//    {
//        arr[n] = fib(n-1)+fib(n-2);
//    }
//    //else return arr[n];
//
//   return arr[n];
//}
 
//set <int>s;
//void primeFactors(long double n)
//{
//
//    while(fmod(n, 2)==0)
//    {
//        s.insert(2);
//        n /= 2;
//    }
//
//
//    for(int i=3; i<=sqrt(n); i+=2)
//    {
//
//        while(fmod(n, i)==0)
//        {
//            s.insert(i);
//            n /= i;
//        }
//
//    }
//
//    if(n>2){
//       s.insert(n);
//    }
//
//}
 
 
//bool fun(int n,int i){
//    bool flag, flag2;
//
//    if(n==0)return true;
//    if(i==v.size())return false;
//
//    if(n>=v[i]){
//        flag = fun(n-v[i], i);
//        if(flag == true)return true;
//        else return fun(n, ++i);
//    }
//    else{
//         flag2 = fun(n, ++i);
//        return flag2;
//    }
//    return false;
//}

//int isprime(long long int N){
//    if(N<2 || (!(N&1) && N!=2))
//        return 0;
//    for(long long int i=3; i*i<=N; i+=2){
//        if(!(N%i))
//            return 0;
//    }
//    return 1;
//}

//int binary(vector<int>&v,int target,int r,int l=0){
//
//    int mid;
//    mid = l+((r-l)/2);
//
//    if(l>r)return -1;
//
//    if(v[mid]==target)return mid;
//    else if(v[mid]>target){
//        r = mid-1;
//        return binary(v, target,r,l);
//    }
//    else{
//        l = mid+1;
//        return binary(v, target,r,l);
//    }
//
//    return -1;
//
//}

//int lcs(string s,string p){
//
//    vector<vector<int>>v(s.size()+1,vector<int>(p.size()+1));
//
//    for(int i=1; i<=s.size(); i++){
//        for(int j=1; j<=p.size(); j++){
//
//    if(s[i-1]==p[j-1]) v[i][j] = v[i-1][j-1]+1;
//
//    else v[i][j] = max(v[i-1][j], v[i][j-1]);
//
//  }
// }
//
//    return v[s.size()][p.size()];
//}
 
int main(){
  
    int a,b,c=0,n;
    string s,p;
    char ch;
    
    
    
    cin >>a >> b;
    
    a = ceil(double(a)/b);
    
    cout << a << endl;

    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int quick_pow(int n,int base)
{
    int ans=1;
    while(n)
    {
        if(n&1)
        {
            ans*=base;
            ans%=2019;
        }
        base*=base;
        base%=2019;
        n>>=1;
    }
    return ans;
}
int main()
{
    string str;
    //cout<<quick_pow(2017,2)<<endl;
    cin>>str;
    map<int,int>mp;
    long long int ans=0;
    int val=0;
    mp[0]=1;
    for(int i=0;i<str.size();++i)
    {
        val*=10;
        val+=str[i]-'0';
        val%=2019;
        int temp=val*quick_pow(str.size()-i,10)%2019;
        ++mp[temp];
        //cout<<temp<<endl;
    }
    map<int,int>::iterator it;
    for(it=mp.begin();it!=mp.end();++it)
    {
        ans+=(it->second-1)*(it->second)/2;
    }
    cout<<ans<<endl;
    return 0;
}


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

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

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

S_list = list(input())

def f(S_list):
  if S_list == []:
    print("YES")
    exit()
  elif "".join(S_list[0:11]) == "dreameraser":
    del S_list[0:11]
#    print(S_list)
    f(S_list)
  elif "".join(S_list[0:10]) == "dreamerase":
    del S_list[0:10]
#    print(S_list)
    f(S_list)
  elif "".join(S_list[0:7]) == "dreamer":
    del S_list[0:7]
#    print(S_list)
    f(S_list)
  elif "".join(S_list[0:6]) == "eraser":
    del S_list[0:6]
#    print(S_list)
    f(S_list)
  elif "".join(S_list[0:5]) == "dream" or "".join(S_list[0:5]) == "erase":
    del S_list[0:5]
#    print(S_list)
    f(S_list)
  else:
    print("NO")
    exit()

f(S_list)

Measured memory_bytes: 15772
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(b>=d){
    cout<<1<<endl;}
  else{
    cout<<0<<endl;}
  return 0;


}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
long long A,B,l,r,ll,rr;
int W1,W2=-1;
long long read(){
	long long ans=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=(ans<<1)+(ans<<3)+(c^48),c=getchar();
	return ans;
}
int main(){
	A=read(),B=read();
	if (A==B){printf("1");return 0;}
	for (register int i=60;i>=0;i--)
		if ((A&(1ll<<i))!=(B&(1ll<<i))){W1=i;break;}
	A&=((1ll<<(W1+1))-1),B&=((1ll<<(W1+1))-1);
	for (register int i=W1-1;i>=0;i--)
		if (B&(1ll<<i)){W2=i;break;}
	long long L1=A,R1=B|((1ll<<(W2+1))-1);
	long long L2=(1ll<<W1)|A,R2=(1ll<<(W1+1))-1;
	if (R1<L2) printf("%lld",R2-L2+1+R1-L1+1);
	else printf("%lld",R2-L1+1);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  double d = 0;
  vector<int> x(n), y(n);
  rep(i, n) cin >> x[i];
  rep(i, n) cin >> y[i];

  rep(i, 3) {
    d = 0;
    rep(j, n) {
      d += pow(abs(x[j] - y[j]), i + 1);
    }
    printf("%f\n", pow(d, 1. / double(i + 1)));
  }

  d = 0;
  rep(i, n) d = max(d, double(abs(x[i] - y[i])));
  printf("%f\n", d);  

  return 0;
}


Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int n;
  cin >> n;
  deque<ll> A{};
  REP(i, n) {
    ll a;
    cin >> a;
    A.push_back(a);
  }
  deque<ll> B{};
  bool tenti = false;
  REP(i, n) {
    if (tenti) {
      B.push_front(A[i]);
    } else {
      B.push_back(A[i]);
    }
    tenti = !tenti;
  }
  if (tenti) reverse(B.begin(), B.end());
  REP(i, n - 1) { cout << B[i] << " "; }
  cout << B[n - 1] << endl;
}

Measured memory_bytes: 5504
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    scan.close();
    
    int ans = c - (a - b);
   	if(ans < 0) ans = 0;
    
    System.out.println(ans);
   
  }
}

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

int main() {
  char a;
  cin >> a;
  if (a == 'A'){
    cout << "T" << endl;
  }
  if (a == 'T'){
    cout << "A" << endl;
  }
  if (a == 'C'){
    cout << "G" << endl;
  }
  if (a == 'G'){
    cout << "C" << endl;
  }
}

Measured memory_bytes: 256
S = input()
T = input()
assert len(S) == len(T)

def uniq(s):
    '''Return the list obtained from s by removing repeating chars.'''
    appeared = set()
    for c in s:
        if c not in appeared:
            appeared.add(c)
            yield c

def normalized(s):
    dic = {c: i for i, c in enumerate(uniq(s))}
    return [dic[c] for c in s]

print("Yes" if normalized(S) == normalized(T) else "No")

Measured memory_bytes: 6832
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    lli x;
    lli y;
    cin >> x >> y;
    int ans = 0;
    while (x <= y) {
        ans++;
        x *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        if (m >= 2 * n) {
            long c = n + (m - 2 * n) / 4;
            System.out.println(c);
        } else {
            System.out.println(m/2);
        }


    }

}

Measured memory_bytes: 20948
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Buttons
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b;
  scanf("%d%d", &a, &b);

  printf("%d\n", max(a + b, max(2 * a - 1, 2 * b - 1)));
  return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split()))
tmp_count = 0
ans = []
for i in range(N-1):
    if(h[i]>=h[i+1]):
        tmp_count+=1
    else:
        ans.append(tmp_count)
        tmp_count=0
ans.append(tmp_count)
print(max(ans))

Measured memory_bytes: 14252
object Main extends App {

  val n = scala.io.StdIn.readLine().toLong

  def solve(): Long = {
    val sqrtN = Math.floor(Math.sqrt(n)).toInt
    (1 to sqrtN).foldLeft(Int.MaxValue) { case (acc, a) =>
      if(n % a == 0) {
        val b = n / a
        val tmpMax = maxDigit(a, b)
        Math.min(acc, tmpMax)
      } else acc
    }
  }

  def maxDigit(a: Long, b: Long) = {
    Math.max(a.toString.length, b.toString.length)
  }

  println(solve)

}

Measured memory_bytes: 28364
from collections import deque

def bfs(maze, sy, sx):
    gy, gx = H - 1, W - 1
    q = deque()
    q.append((sy, sx))
    visited[sy][sx] = 1
    #print(sy, sx, gy, gx)
    now = 0
    while q:
      y, x = q.popleft()
      if (y, x) == (gy, gx):
        return visited[y][x]
      for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
        new_y, new_x = y + j, x + k #改行して条件文を続けるときにバックスラッシュ
        if (0 <= new_y <= H - 1) and (0 <= new_x <= W - 1):
          if maze[new_y][new_x] == "." and visited[new_y][new_x] > 10 ** 5:#まだ来たことない点だったという条件
            visited[new_y][new_x] = visited[y][x] + 1
            q.append((new_y, new_x))
    return 0

          
if __name__ == "__main__":
    H, W = map(int, input().split())
    maze = [[0] * W for i in range(H)]
    count = 0
    for i in range(H):
      s = str(input())
      for j in range(W):
        maze[i][j] = s[j]
        if s[j] == ".":
          count += 1
    visited = [[float("inf")] * W for j in range(H)]
    ans = bfs(maze, 0, 0)
    if ans == 0:
      print(-1)
    else:
      print(count - ans)


Measured memory_bytes: 40560
H ,W = map(int,input().split())
S = H*W
def ceil(i):
    if int(i) != i:
        return int(i)+1
    else:
        return int(i)

harfH1 = int(H/2)
harfH2 = ceil(H/2)
harfW1 = int(W/2)
harfW2 = ceil(W/2)
ans = 1000000000
for i in range(1,W):
    S1 = i*H
    S2 = (W-i) * harfH1 
    S3 = (W-i) * harfH2 
    diff = max(S1,S2,S3) - min(S1,S2,S3)
    ans = min(ans,diff)
for i in range(1,H):
    S1 = W*i
    S2 = harfW1 * (H-i)
    S3 = harfW2 * (H-i)
    diff = max(S1,S2,S3) - min(S1,S2,S3)
    ans = min(ans,diff)
if H % 3 == 0 or W % 3 == 0:
    ans = 0
else:
    ans = min(ans,W,H)
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  ll n,k;cin>>n>>k;
  ll ans=0;
  while(n>0){
    n=n/k;
    ans++;
  }
  cout<<ans;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define pi pair<int,int>
#define mod 1000000007
#define vectormax *max_element
#define vectormin *min_element
#define arraysize 1000000
#define setbit _builtin_popcountll
using namespace std;

ll ipow(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x ;
        n = n / 2;
        x = x * x;
    }
    return result;
}

int main() {
 int n;
 cin>>n;
 if(n==0)cout<<1<<endl;
 else cout<<0<<endl;
	  
   return 0;
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main(){
  double ans,nc=0,count=0;
  int sa,sv,answer=0,ansk;
  char c;
  while(cin>>sa>>c>>sv){
    answer += sa * sv;
    nc += sv;
    count++;
  }
  cout << answer << endl;
  ans = nc / count;
  ans +=0.5;
  ansk = ans;
  cout << ansk << endl;
  return 0;
}

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

namespace id_0360cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var vs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var a = vs[0];
            var b = vs[1];
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine(OverLapped(a, b, n));
            
        }
        static int OverLapped(int a, int b, int n)
        {
            foreach(var i in Enumerable.Range(0, n))
            {
                var vs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var s = vs[0];
                var f = vs[1];
                var isOverlapped = !(b <= s || f <= a);
                if (isOverlapped)
                {
                    return 1;
                }
            }
            return 0;
        }
    }
}



Measured memory_bytes: 9608