akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define pb push_back
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define INF 300000000000001
#define ll_max 9000000000000000000
#define PI 3.14159265358979323846L
#define fill(a, n, x) for(int i = 0; i < n; i++) a[i] = x;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long int ll;
typedef long double ld;
typedef vector<pair<ll,ll> > vll;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
ll mod = 1000000007;
const ll N = 300001;
const ll M = log2(N);

struct point
{
    ll x, y;
};

struct node
{
    ll t, p, d, i;
};

void debug(stringstream &s) {}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cerr << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    if(n & 1) return fast_exp(x, n - 1) * x % mod;
    else
    {
        ll ans = fast_exp(x, n / 2);
        return ans * ans % mod;
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    int _ = 1;
    //cin >> _;
    int test = 0;
    while(_--)
    {
        test++;
        ll n, m, x = 0, y = 0, k, ans = 0, a, b, c;
        cin >> a >> b >> c >> k;
        if(a >= b)
        {
            while(a >= b)
            {
                b = 2* b;
                ans++;
            }
        }
        while(b >= c)
        {
            c = 2* c;
            ans++;
        }
        if(ans <= k) cout << "Yes\n";
        else cout << "No\n";
        //cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
  int x,y;
  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    if(x > y){
      cout<<y<<" "<<x<<"\n";
    }else{
      cout<<x<<" "<<y<<"\n";
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

int main(){
    string s;
    cin>>s;
    int n=(int)s.size();
    int ans=n;
    string pr=to_string(s[0]);
    for(int i=1;i<n;){
        if(to_string(s[i])==pr){
            ans--;
            if(i<n-1) pr=s.substr(i,2);
            i+=2;
        }else{
            pr=to_string(s[i]);
            i++;
        }
    }
    out(ans);
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(auto &&i : s){
		i=(i-'A'+n)%26+'A';
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
K  = int(input())
li = list(map(int,input().split()))	
ans = []
for i in range(N):
    if abs(li[i]-0)>=abs(li[i]-K):
        ans.append(2*abs(li[i]-K))
    elif abs(li[i]-0)<abs(li[i]-K):
        ans.append(2*li[i])
print(sum(ans))

Measured memory_bytes: 3064
INF = 10 ** 7
n, m = gets.split.map(&:to_i)
edges = []
m.times { edges << gets.split.map(&:to_i) }
memo = Array.new(n) { Array.new(n, INF) }
# 初期化　既にいる場所へ行くコストは 0
n.times { |i| memo[i][i] = 0 }
edges.each do |f, t, w|
  f -= 1
  t -= 1
  memo[f][t] = w
  memo[t][f] = w
end

# ワーシャルフロイド法 Warshall–Floyd Algorithm
# 参照渡しで若干高速化
(0...n).each do |via|
  (0...n).each do |from|
    memo_from = memo[from]
    (0...n).each do |to|
      via_dist = memo_from[via] + memo[via][to]
      memo_from[to] = via_dist if memo_from[to] > via_dist
    end
  end
end

# 最短距離でない edge をカウント
puts edges.count { |f, t, w| memo[f - 1][t - 1] != w }


Measured memory_bytes: 2172
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define N 4
#define N2 16
using namespace std;

vector<int> move_list[N2];
int dist[N2][N2];

class Game{
public:
  char board[N2];
  char w;
  vector<char> route;
  char mnh;

  bool operator < (const Game &other) const{
    return route.size()+mnh > other.route.size()+other.mnh;
  }
};
Game start;

vector<char> search(){
  priority_queue<Game> q;
  q.push(start);
  
  while(!q.empty()){
    Game g=q.top();q.pop();
    if(g.mnh==0) return g.route;

    for(int move:move_list[g.w]){
      if(g.route.size()>0 && g.route.back()==-move) continue;
      Game h=g;
      int to=h.w+move;
      h.mnh -= dist[to][h.board[to]-1];
      h.mnh += dist[h.w][h.board[to]-1];
      swap(h.board[h.w],h.board[to]);
      h.w = to;
      h.route.push_back(move);
      q.push(h); 
    }
  }
}

int solve(){
  vector<char> route=search();
  return route.size();
}

void initialize(){
  for(int i=0;i<N2;i++){
    if(i%N<N-1) move_list[i].push_back(1);
    if(i%N>0  ) move_list[i].push_back(-1);
    if(i/N<N-1) move_list[i].push_back(N);
    if(i/N>0  ) move_list[i].push_back(-N);
  }

  //i=board,j=piece-1
  for(int i=0;i<N2;i++){
    for(int j=0;j<N2;j++){
      dist[i][j] = abs(j%N-i%N) + abs(j/N-i/N);
    }
  }

  start.mnh=0;
  for(int i=0;i<N2;i++){
    if(i==start.w) continue;
    start.mnh += dist[i][start.board[i]-1];
  }
}
 
int main(){
  int tmp;
  for(int i=0;i<N2;i++){
    cin>>tmp;
    if(tmp==0){
      start.board[i]=N2;
      start.w=i;
    }else{
      start.board[i]=tmp;
    }
  }
  initialize();
  cout<<solve()<<endl;
}


Measured memory_bytes: 199000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	vector<int> zip;
	int num = 0;
	char tmp = s[0];
	if (tmp == '0')
		zip.push_back(0);
	for (int i = 0; i < n; i++) {
		if (s[i] == tmp)
			num++;
		else {
			zip.push_back(num);
			tmp = s[i];
			num = 1;
		}
	}
	zip.push_back(num);
	if (zip.size() % 2 == 0)
		zip.push_back(0);
	if (zip.size() / 2 <= k) {
		cout << n << endl;
		return 0;
	}
	else {
		int acc = accumulate(zip.begin(), zip.begin() + k * 2 + 1, 0), ans = acc;
		for (int i = 0; i < zip.size() - k * 2 - 1; ++++i) {
			acc -= zip[i] + zip[i + 1];
			acc += zip[i + 2 * k + 1];
			if (i + 2 * k + 2 < zip.size())
				acc += zip[i + 2 * k + 2];
			ans = max(ans, acc);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1020
# coding: utf-8
# Your code here!
s = input()
odd = 'RUD'
even = 'LUD'
ans = 'Yes'
for i in range(len(s)):
    c = s[i]
    if (i+1) % 2 != 0:
        if c == 'L':
            ans = 'No'
    else:
        if c == 'R':
            ans = 'No'
print(ans)

Measured memory_bytes: 39796
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

main(){
    ll a,b,c,d,ans=0;
    cin>>a>>b>>c>>d;
    ll x=b/c-a/c;
    if(a%c==0)x++;
    ll y=b/d-a/d;
    if(a%d==0)y++;
    ll k=c*d/GCD(c,d);
    ll z=b/k-a/k;
    if(a%k==0)z++;
    cout<<b-a+1-(x+y-z)<<endl;
    
}




Measured memory_bytes: 256
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n=int(input())
a=[int(input()) for _ in range(n)]

bad=(a[0]!=0)
for i in range(n-1):
    if a[i]+1<a[i+1]:
        bad=True

if bad: print(-1)
else:
    # calculate answer
    ans=[0]*n
    for i in range(n):
        ans[i-a[i]]=a[i]
    print(sum(ans))


Measured memory_bytes: 51292
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#define maxn 2010
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define IL inline
#define ss system
using namespace std;

int up[maxn][maxn], down[maxn][maxn], lef[maxn][maxn], rig[maxn][maxn], n, m;
char s[maxn][maxn];
template <class T> void read(T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch))
    fl |= ch == '-', ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> s[i] + 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      up[i][j] = (up[i - 1][j] + 1) * (s[i][j] == '.');
      lef[i][j] = (lef[i][j - 1] + 1) * (s[i][j] == '.');
    }
  }
  for (int i = n; i; i--) {
    for (int j = m; j; j--) {
      down[i][j] = (down[i + 1][j] + 1) * (s[i][j] == '.');
      rig[i][j] = (rig[i][j + 1] + 1) * (s[i][j] == '.');
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      ans = max(ans, up[i][j] + down[i][j] + lef[i][j] + rig[i][j] - 3);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 67200
import math

N, D = map(int, input().split())

point = []
cnt = 0

for _ in range(N):
    point.append(list(map(int, input().split())))

def calc_dist(x, y):
    dist = 0
    for xx, yy in zip(x, y):
        dist += ((xx - yy) ** 2)
    return math.sqrt(dist)

for i in range(N):
    for j in range(i+1, N):
        dist = calc_dist(point[i], point[j])

        if int(dist) == dist:
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>

int calc_da(int i) {
    int ans=0;
    while(10*i/10) {
        ans += i%10;
        i /= 10;
    }

    return ans;
}

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

    int i, min=100001, sum;
    for(i=N-1; i>0; i--) {
        sum = calc_da(i) + calc_da(N-i);
        if(min>sum) {
            min = sum;
        }
    }

    printf("%d\n", min);

    return 0;

}

Measured memory_bytes: 128
n = list(map(int, input().split()))
a =[]
c = 1
b = []

for i in range(1, n[0]+1):
    b.append(i)

for j in range(1, n[1]+1):
    a.append(j)

for k in range(b[-1]):
    if b[-1] == a[-1]:
        print(c)
        break
    else:
        a[-1] += 1
        c += 1

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#include<string.h>

int main(){
    int A,B;
    scanf("%d %d",&A,&B);
    if(B%A==0) printf("%d",B+A);
    else printf("%d",B-A);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    REP(i,b+1){
        if(i*a%b == c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+8;
int x[maxn],y[maxn],t[maxn];

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        memset(t,0,sizeof(t));
        memset(x,0,sizeof(x));
        memset(y,0,sizeof(y));
        for(int i = 1;i<=n;i++)
        {
            scanf("%d%d%d",&t[i],&x[i],&y[i]);
        }
        bool ans = true;
        int last=t[1];
        for(int i=1;i<=n;i++)
        {
            last=t[i]-t[i-1];
            int temp=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
            //cout<<last<<' '<<temp<<endl;
            if(last<temp){ans=false;break;}
            if((last&1)!=(temp&1))
            {
                ans=false;
                break;
            }

        }
        if(ans)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007
 
ll n,m;

int main()
{

    Fast;
    
    cin>>n>>m;
    
    if(m>=n)
        cout<<"Yes";
    else
        cout<<"No";    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
#include<string.h>
#include<string>
int main(){
	string v,s;
	int i,j=0,n,g=0;
	cin>>v>>n;
	for(i=0;i<n;i++){
		cin>>s; s=(s+s);
		if(s.find(v)!=-1){
			g++;
		}
	}
	printf("%d\n",g);
	return 0;
}



Measured memory_bytes: 3260
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
t=gi
if t==1
  puts 'Hello World'
else
  a=gi
  b=gi
  puts a+b
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;

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

  vector<int> p(n);
  for(int i=0; i<n; i++){
    cin >> p[i];
  }

  sort(p.begin(), p.end());
  int sum=0;
  for(int i=0; i<k; i++){
    sum += p[i];
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vl a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    priority_queue<pair<ll, int>> pq;
    for (int i = 0; i < n; ++i) {
        pq.emplace(b[i], i);
    }
    ll ret = 0;
    while (!pq.empty()) {
        auto p = pq.top();
        pq.pop();
        ll val  = p.first;
        int idx = p.second;
        int l   = idx == 0 ? n - 1 : idx - 1;
        int r   = idx == n - 1 ? 0 : idx + 1;
        ll op   = (val - a[idx]) / (b[l] + b[r]);
        val -= op * (b[l] + b[r]);
        b[idx] -= op * (b[l] + b[r]);
        ret += op;
        if (val != a[idx]) {
            if (op == 0) {
                cout << -1 << "\n";
                return 0;
            }
            pq.emplace(val, idx);
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 9328
#include <stdio.h>
int main(void) {
  int a[10];
  int i, sum;
  for(i = 0;i < 10; i++){
    scanf("%d",&a[i]);
  }
  sum = 0;
  for(i = 0;i < 10;i++){
    sum += a[i];
  }

printf("%d\n",sum);

return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<stack>
#include<vector>
#include<string>
#include<algorithm>

struct node {
	int num;
	std::vector<int> child;
};

int recurcive(node nodes[],int d[100], int f[100], int n, int count) {
	d[n] = count++;
	for (size_t i = 0; i < nodes[n].child.size(); i++) {
		if (d[nodes[n].child[i]] == 0) {
			count = recurcive(nodes, d, f, nodes[n].child[i], count);
		} else {
			nodes[n].child.erase(std::find(nodes[n].child.begin(), nodes[n].child.end(), nodes[n].child[i]));
			i--;
		}
	}
	f[n] = count++;

	return count;
}

int main() {
	int node_num;
	node nodes[100];
	std::cin >> node_num;

	for (int i = 0; i < node_num; i++) {
		int n, num;
		std::cin >> n >> num;
		for (int j = 0; j < num; j++) {
			int val;
			std::cin >> val;
			nodes[n - 1].child.push_back(val - 1);
		}
	}

	std::stack<int> st, st2;
	std::vector<int> gone;
	int d[100], f[100];
	int count = 1;

	for (int i = 0; i < 100; i++)
		d[i] = f[i] = 0;

	for (int i = 0; i < node_num; i++) {
		if (d[i] == 0) {
			count = recurcive(nodes, d, f, i, count);
		}
	}

	for (int i = 0; i < node_num; i++) {
		std::cout << i + 1 << " " << d[i] << " " << f[i] << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1228
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int l = scanner.nextInt(), r = 0;
			while ((1 << (r + 1)) <= l) {
				r++;
			}
			int n = r + 1, count = 2 * r;
			StringBuilder sb = new StringBuilder();
			for (int i = r; i >= 1; i--) {
				// System.out.println("l=" + l + ", r=" + r + ", i=" + i);
				if ((l - (1 << (i - 1))) >= (1 << r)) {
					l -= 1 << (i - 1);
					sb.append(i + " " + n + " " + l).append("\n");
					count++;
				}
			}
			System.out.println(n + " " + count);
			IntStream.rangeClosed(1, r).forEach(i -> {
				System.out.println(i + " " + (i + 1) + " 0");
				System.out.println(i + " " + (i + 1) + " " + (1 << (i - 1)));
			});
			System.out.print(sb.toString());
		}
	}
}


Measured memory_bytes: 41536
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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



  cin >> s;
  ll b = 0, r = 0;
  rep(i, s.length()) s[i] == '0' ? b++ : r++;
  cout << min(b, r) * 2 << endl;


  return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll x;

int solve() {
    int res = 0;
    ll c = 100;
    while (c < x) {
        c += c / 100;
        res++;
    }
    return res;
}

void input() {
    cin >> x;
}

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

    input();
    cout << solve() << endl;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);

  int n, X, Y; cin >> n >> X >> Y;
  vector<int> a(n);
  for(int &x : a) cin >> x;

  vector<vector<long long>> f(n + 1, vector<long long>(n + 2, 1e18));

  f[0][0] = 0;
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j <= n; ++j) {
      if(j > 0) f[i][j] = min(f[i][j], f[i][j - 1]);

      if(a[i] > j) {
        f[i + 1][a[i]] = min(f[i + 1][a[i]], f[i][j]);
        f[i + 1][j] = min(f[i + 1][j], f[i][j] + X);
      }
      else {
        f[i + 1][j] = min(f[i + 1][j], f[i][j] + Y);
      }
    }
  }

  cout << *min_element(f[n].begin(), f[n].end()) << endl;

  return 0;
}


Measured memory_bytes: 195968
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        int D = sc.nextInt();
        int[][] A = new int[H][W];
        for (int r = 0; r < H; ++r) {
            for (int c = 0; c < W; ++c) {
                A[r][c] = sc.nextInt() - 1;
            }
        }
        int Q = sc.nextInt();
        int[] L = new int[Q];
        int[] R = new int[Q];
        for (int i = 0; i < Q; ++i) {
            L[i] = sc.nextInt() - 1;
            R[i] = sc.nextInt() - 1;
        }

        System.out.println(solve(A, D, L, R));

        sc.close();
    }

    static String solve(int[][] A, int D, int[] L, int[] R) {
        int H = A.length;
        int W = A[0].length;

        Point[] points = new Point[H * W];
        for (int r = 0; r < H; ++r) {
            for (int c = 0; c < W; ++c) {
                points[A[r][c]] = new Point(r, c);
            }
        }

        @SuppressWarnings("unchecked")
        List<Integer>[] prefixSumLists = new List[D];
        for (int i = 0; i < prefixSumLists.length; ++i) {
            prefixSumLists[i] = new ArrayList<>();
            int prefixSum = 0;
            for (int j = i; j < points.length; j += D) {
                prefixSum += computeDistance(points, j - D, j);
                prefixSumLists[i].add(prefixSum);
            }
        }

        return IntStream.range(0, L.length).mapToObj(i -> {
            int m = L[i] % D;
            int indexL = L[i] / D;
            int indexR = R[i] / D;

            return String.valueOf(prefixSumLists[m].get(indexR) - prefixSumLists[m].get(indexL));
        }).collect(Collectors.joining("\n"));
    }

    static int computeDistance(Point[] points, int index1, int index2) {
        if (index1 < 0) {
            return 0;
        }

        return Math.abs(points[index1].r - points[index2].r) + Math.abs(points[index1].c - points[index2].c);
    }
}

class Point {
    int r;
    int c;

    Point(int r, int c) {
        this.r = r;
        this.c = c;
    }
}

Measured memory_bytes: 94204
macro_rules! scan {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(usize);
    let s = n.to_string();
    let bytes = s.as_bytes();
    if (bytes[0] == bytes[1] && bytes[1] == bytes[2])
        || (bytes[1] == bytes[2] && bytes[2] == bytes[3])
    {
        println!("Yes")
    } else {
        println!("No")
    }
}


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


int main() {
    string s,t;
    cin >> s >> t;
    if (s.size()+1!=t.size()) {
        cout << "No" << endl;
    }
    else {
        bool check=true;
        for (int i=0;i<s.size();i++) {
            if (s[i]!=t[i]) {
                check=false;
            }
        }
        if (check) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main() {
  const long double PI = 3.141592653589793238462643383279502884;
  long double r;
  cin >> r;
  cout << r * 2 * PI << endl;

  // TODO
  return 0;
}

Measured memory_bytes: 3796
from sys import stdin
input = stdin.readline
def BFS(K,path,N):
  """リストのリスト道順path,頂点の個数Nが与えられたとき, 頂点Kから各頂点までの距離をlistで返す"""
  import queue
  dist=[-1]*N
  dist[K]=0
  que=queue.Queue()
  que.put(K)
  while que.qsize():
    label=que.get()
    for i,c in path[label]:
      if dist[i]==-1:
        dist[i]=dist[label]+c
        que.put(i)
  return dist
 
N=int(input())
path=[ [] for i in range(N)]
for i in range(N-1):
  a,b,c=map(int,input().split())
  path[a-1]+=[(b-1,c)]
  path[b-1]+=[(a-1,c)]
Q,K=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(Q)]
distance=BFS(K-1,path,N)
for i in range(Q):
  print(distance[xy[i][0]-1]+distance[xy[i][1]-1])

Measured memory_bytes: 68680
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  long long a,b,c;
  cin >> a >> b >> c;
  if(a+b+1>=c) {
    cout << b+c << endl;
  }
  else{
    cout << b+a+b+1 << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[38]:


N = int(input())


# In[39]:


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


# In[41]:


mydict = {}
for i in range(1,N+1):
    mylist = factorization(i)
    for x in mylist:
        if x[0] in mydict.keys():
            mydict[x[0]] += x[1]
        else:
            mydict[x[0]] = x[1]
ans = 1
for j,y in mydict.items():
    if j > 1:
        ans *= y+1
print(ans%(10**9+7))


# In[ ]:






Measured memory_bytes: 9356
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  _int64 x,i,sum;
  scanf("%lld",&x);
  for (i=1;;i++)
  {
    sum=(i+1)*i/2;
    if (sum>=x)
    {
      printf("%lld\n",i);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}

inline void solve(void){
  int N,M;
  in(N);
  vector<int>D(N);
  rep(i,N)in(D[i]);
  in(M);
  vector<int>T(M);
  rep(i,M)in(T[i]);
  sort(all(D));
  sort(all(T));
  int i=0,j=0;
  for(;;){
    if(D[i]==T[j])i++,j++;
    else i++;
    if(i==N||j==M)break;
  }
  out(j==M?"YES":"NO");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int n, k, num=1, i, ct=0, var=0, ans=0;
  cin >> n >> k;
  int a[n], b[n];
  for(i=0; i<n; i++)
    cin >> a[i];
  sort(a, a+n);
  for(i=0; i<n-1; i++)
    if(a[i]!=a[i+1]) num++;
  if(num<=k){
    cout << 0;
    return 0;
  }
  for(i=1; i<n; i++){
    if(a[i-1]!=a[i]){ct++;
      b[var]=ct;
      var++;
      ct=0;
    }
    else{ct++;}

  }
  ct++;
  b[var]=ct;
  sort(b, b+var+1);
  for(i=0; i<num-k; i++)
    ans+=b[i];
  cout << ans;
  return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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

#define MAX 100005
#define INF 1001001001

int popcount(int n) {
  int res = 0;
  while(n) { res+=n&1; n>>=1; }
  return res;
}
int f(int n) {
  int res = 0;
  while(n) {
    n = n%popcount(n);
    res++;
  }
  return res;
}
int main(int, char**)
{
  int n;
  cin >> n;

  string x;
  cin >> x;

  int onecnt = 0;
  rep(i,n) if (x[i]=='1') onecnt++;
  reverse(x.begin(), x.end());
  int mod1 = onecnt+1;
  int mod2 = onecnt-1;
  int msk1 = 1, msk2 = 1;
  int base1 = 0, base2 = 0;
  rep(i,n) {
    if (x[i]=='1') {
      base1 = (base1+msk1)%mod1;
      if (mod2>0) base2 = (base2+msk2)%mod2;
    }
    msk1 = (msk1<<1)%mod1;
    if (mod2>0)msk2 = (msk2<<1)%mod2;
  }
  msk1 = msk2 = 1;
  vector<int> ans;
  rep(i,n) {
    if (x[i]=='0') {
      ans.push_back(1+f((base1+msk1)%mod1));
    } else {
      if (mod2>0)
        ans.push_back(1+f((base2-msk2+mod2)%mod2));
      else
        ans.push_back(0);
    }
    msk1 = (msk1<<1)%mod1;
    if (mod2>0)msk2 = (msk2<<1)%mod2;
  }
  reverse(ans.begin(),ans.end());
  rep(i,n) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 4472
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int n; cin >> n;
    vector <int> p(n), q(n);
    loop(i, n)
        cin >> p[i];
    loop(i, n)
        cin >> q[i];
    vector <int> perm;
    loop1(i, n)
        perm.pb(i);
    int c1, c2, cnt = 0;
    do {
        if (p == perm)
            c1 = cnt;
        if (q == perm)
            c2 = cnt;
        ++cnt;
    } while (next_permutation(all(perm)));
    cout << abs(c1 - c2);
}

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


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pii;
#define MAX_V 100010
struct edge{
	int from,to,cost;
};
struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    bool findSet(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
bool operator < (const edge &a,const edge &b){
	return a.cost<b.cost;
}
vector<edge>G;
int V,E;
void kruskal(){
	int sum=0;
	sort(all(G));
	UnionFind uf(V);
	rep(i,G.size()){
		edge e=G[i];
		if(!uf.findSet(e.from,e.to)){
			sum+=e.cost;
			uf.unionSet(e.from,e.to);
		}
	}
	cout<<sum<<endl;
}
int main(){
	cin>>V>>E;
	while(E--){
		int a,b,c;
		cin>>a>>b>>c;
		edge t={a,b,c};
		G.pb(t);
	}
	kruskal();
}

Measured memory_bytes: 2724
/**
 *    author:  tourist
 *    created: 23.09.2017 14:52:20       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, m, k; cin >> n >> m >> k; for (int a = 0; a <= n; a++) for (int b = 0; b <= m; b++) if (a * b + (n - a) * (m - b) == k) { cout << "Yes" << endl; return 0; } cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = pow(10,9)+7;
/*template*/


int main()
{
  ll N,X,Y;cin>>N>>X>>Y;
  ll a[N-1];
  for(ll i=0;i<N-1;i++){
    a[i]=0;
  }
  for(ll i=0;i<N;i++){
    for(ll j=i+1;j<N;j++){
      ll k=j-i;
      ll x=i-X+1;
      ll y=j-Y+1;
      if(x<0)x=-x;
      if(y<0)y=-y;
      chmin(k,x+y+1);
      a[k-1]++;
    }
  }
  for(ll i=0;i<N-1;i++){
    cout<<a[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int a,b,c,x,ans=0;
  cin >> a >> b >> c >> x;
  for(int i=0; i<=a; i++) {
    for(int j=0; j<=b; j++) {
      for(int k=0; k<=c; k++) {
        if(500*i+100*j+50*k==x) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please



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


	int N;
	cin >> N;

	ll kotae = 0;

	rep1(i, N) {
		ll k = N / i;

		kotae += k * (k + 1) / 2 * i;
	}

	co(kotae);

	Would you please return 0;
}

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

vector<char> tv, dv;
int n, q;
string s;

int mv(int p){
    if(p >= n) return n;
    if(p < 0) return -1;
    for(int i = 0; i < q; i++){
        char t = tv[i], d = dv[i];
        if(s[p] == t){
            if(d == 'L'){
                if(p == 0) return -1;
                p--;
            }else{
                if(p == n - 1) return n;
                p++;
            }
        }
    }
    return p;
}

int main(){
    char t, d;
    cin >> n >> q;
    cin >> s;
    for(int i = 0; i < q; i++){
        cin >> t >> d;
        tv.push_back(t);
        dv.push_back(d);
    }
    int safe_l, safe_r, mid;
    int l = -1, r = n;
    while(1){
        mid = l + (r - l) / 2;
        if(mv(mid) == -1 && mv(mid+1) == -1){
            l = mid + 1;
        }
        else if(mv(mid) != -1 && mv(mid+1) != -1){
            r = mid;
        }
        else break;
    }
    safe_l = mid + 1;
    l = -1, r = n;
    while(1){
        mid = l + (r - l) / 2;
        if(mv(mid) == n && mv(mid+1) == n){
            r = mid;
        }
        else if(mv(mid) != n && mv(mid+1) != n){
            l = mid + 1;
        }
        else break;
    }
    safe_r = mid + 1;
    cout << (safe_r - safe_l) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#define MAX 100010
using namespace std;
int stones[MAX];
int dp[MAX];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&stones[i]);
	}
	
	dp[0]=0;
	dp[1]=abs(stones[1]-stones[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(stones[i]-stones[i-1]), dp[i-2]+abs(stones[i]-stones[i-2]));
	}
	printf("%d",dp[n-1]);
	return 0;
} 

Measured memory_bytes: 1024
import math
import itertools

n = int(input())
listA = []
total = 0
num = math.factorial(n)

for i in range(n):
    listA.append(list(map(int,input().split())))

listB = list(itertools.permutations(listA, n))

for i in range(len(listB)):
    for j in range(n-1):
        tmp = (listB[i][j][0] - listB[i][j+1][0])**2 + (listB[i][j][1] - listB[i][j+1][1])**2
        total += math.sqrt(tmp)
        
print(total/num)


Measured memory_bytes: 8052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int num=Integer.parseInt(reader.readLine());
        System.out.println(num*num*num);
	}
}

Measured memory_bytes: 24224
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
KMAX = (N - 1) * (N - 2) // 2


def solve():
    if K > KMAX:
        return None
    edges = []
    for i in range(1, N):
        edges.append((1, i + 1))
    if K == KMAX:
        return edges
    cnt = KMAX
    for i in range(1, N):
        for j in range(i + 1, N):
            edges.append((i + 1, j + 1))
            cnt -= 1
            if cnt == K:
                return edges
    raise ValueError()


if __name__ == "__main__":
    r = solve()
    if r is None:
        print(-1)
    else:
        print(len(r))
        for u, v in r:
            print(u, v)


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
int main() {
 	int n;
 	cin >> n;
 	if(n > 81) {
 	 	cout << "No" << endl;
 	}
 	else {
 	 	for(int i = 1; i <= 9; ++i) {
 	 	 	if(n % i == 0 && n / i <= 9) {
 	 	 		cout << "Yes" << endl;
 	 	 		return 0; 	
 	 	 	}
 	 	}
 	 	cout << "No" << endl;
 	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, m, ex, ey;
short dp[N][N][N][N], s1[N][N], s2[N][N];
char s[N][N];
inline void up(short& x, short y) { x = (x < y ? y : x); }
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i][j] == 'E') ex = i, ey = j;
            s1[i][j] = s1[i][j - 1] + (s[i][j] == 'o');
            s2[i][j] = s2[i - 1][j] + (s[i][j] == 'o');
        }
    }
    int I = ex - 1, J = n - ex, K = ey - 1, L = m - ey;
    for (int i = 0; i <= I; i++)
        for (int j = 0; j <= J; j++)
            for (int k = 0; k <= K; k++)
                for (int l = 0; l <= L; l++) {
                    int L = max(ey - k, l + 1), R = min(ey + l, m - k);
                    if (L <= R) {
                        up(dp[i + 1][j][k][l], dp[i][j][k][l] + (ex - i - 1 >= j + 1? s1[ex - i - 1][R] - s1[ex - i - 1][L - 1]: 0));
                        up(dp[i][j + 1][k][l], dp[i][j][k][l] + (ex + j + 1 <= n - i? s1[ex + j + 1][R] - s1[ex + j + 1][L - 1] : 0));
                    }
                    L = max(ex - i, j + 1), R = min(ex + j, n - i);
                    if (L <= R) {
                        up(dp[i][j][k + 1][l], dp[i][j][k][l] + (ey - k - 1 >= l + 1? s2[R][ey - k - 1] - s2[L - 1][ey - k - 1] : 0));
                        up(dp[i][j][k][l + 1], dp[i][j][k][l] + (ey + l + 1 <= m - k? s2[R][ey + l + 1] - s2[L - 1][ey + l + 1] : 0));
                    }
                }
    printf("%d", dp[I][J][K][L]);
    return 0;
}

Measured memory_bytes: 209280
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <cassert>
#define SIZE 1000005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char S[SIZE],T[SIZE];

int gcd(int x,int y)
{
	if(x==0) return y;
	return gcd(y%x,x);
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	scanf("%s",&S);
	scanf("%s",&T);
	int g=gcd(n,m);
	for(int i=0;i<g;i++)
	{
		if(S[i*n/g]!=T[i*m/g])
		{
			puts("-1");
			return 0;
		}
	}
	ll ret=(ll) n*(ll) m/(ll) g;
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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


struct edge{
    int to, cost;
    edge(int To, int Cost): to(To), cost(Cost){};
};


long long prim(std::vector<std::vector<edge>>& G){
    int V(G.size());
    long long res(0);
    //std::pair<int, int> first: 距離　second: 頂点
    std::priority_queue<std::pair<int, int>,
                        std::vector<std::pair<int, int>>,
                        std::greater<std::pair<int, int>>> que;
    std::vector<int> d(V, INF);
    d[0] = 0;
    que.push({0, 0});

    while(!que.empty()){
        std::pair<int, int> p = que.top(); que.pop();
        int v(p.second);
        if(d[v] < p.first) continue;
        d[v] = 0;
        res += p.first;
        for(edge &e : G[v]){
            if(d[e.to] > e.cost){
                d[e.to] = e.cost;
                que.push({d[e.to], e.to});
            }
        }
    }
    return res;
}

int main(){
    int V, E; std::cin >> V >> E;
    std::vector<std::vector<edge>> G(V);
    {
        int s, t, w; 
        for(int i(0); i < E; ++i){
            std::cin >> s >> t >> w;
            G[s].emplace_back(t, w);
            G[t].emplace_back(s, w);
        }
    }
    std::cout << prim(G) << std::endl;
    return 0;
}



Measured memory_bytes: 6108
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        String str0 = sc.next();
        int max = 0;
        for(int i = 0; i < num; i++){
        	String str1 = str0.substring(0,i);
            String str2 = str0.substring(i);
            int count = 0;
            ArrayList<String> list = new ArrayList<>();
            for(int x = 0; x < i; x++){
            	if(str2.contains(str1.substring(x, x + 1)) && list.contains(str1.substring(x, x + 1)) == false){
                	list.add(str1.substring(x, x + 1));
                    count++;
                }
                if(max < count){
                	max = count;
                }
            }
        }
        System.out.println(max); 
    }
}

Measured memory_bytes: 36664