akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> A, std::vector<long long> B) {
  priority_queue<pair<ll, ll>> a;
  ll cur = A[0];
  ll count = 1;
  FOR(i, 1, N) {
    if (cur != A[i]) {
      a.emplace(count, cur);
      cur = A[i];
      count = 1;
    } else {
      count++;
    }
  }
  a.emplace(count, cur);
  priority_queue<pair<ll, ll>> b;
  cur = B[0];
  count = 1;
  FOR(i, 1, N) {
    if (cur != B[i]) {
      b.emplace(count, cur);
      cur = B[i];
      count = 1;
    } else {
      count++;
    }
  }
  b.emplace(count, cur);
  vector<pair<ll, ll>> ans;
  REP(i, N) {
    auto x = a.top();
    a.pop();
    auto y = b.top();
    b.pop();
    if (x.first == 1 && y.first == 1) {
      a.emplace(x);
      b.emplace(y);
      break;
    }
    if (x.second == y.second) {
      if (b.empty()) {
        cout << NO << endl;
        return;
      }
      auto z = b.top();
      b.pop();
      swap(y, z);
      b.push(z);
    }
    ans.emplace_back(x.second, y.second);
    if (x.first > 1) {
      a.emplace(x.first - 1, x.second);
    }
    if (y.first > 1) {
      b.emplace(y.first - 1, y.second);
    }
  }
  vector<ll> c;
  vector<ll> d;
  while (!a.empty()) {
    auto x = a.top();
    a.pop();
    c.push_back(x.second);
    auto y = b.top();
    b.pop();
    d.push_back(y.second);
  }
  sort(ALL(c));
  sort(ALL(d));
  REP(j, c.size()) {
    bool ok = true;
    REP(i, c.size()) {
      if (c[i] == d[i]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      REP(i, c.size()) {
        ans.emplace_back(c[i], d[i]);
      }
      sort(ALL(ans));
      cout << YES << endl;
      REP(i, N) {
        cout << ans[i].second << " ";
      }
      cout << endl;
      return;
    }
    rotate(c.begin(), c.begin() + 1, c.end());
  }
  cout << NO << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  std::vector<long long> B(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &B[i]);
  }
  solve(N, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 23632
N,K = map(int,input().split())
li = list(map(int,input().split()))
d = {}
total = []
for i in li:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1
#print(d)
sorted_d = sorted(d.values())
#print(sorted_d)
s = len(d) - K
for i in sorted_d[:s]:
  total.append(i)
print(sum(total))

Measured memory_bytes: 33148
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		
		int ans = n.charAt(0) - '0' + 9 * (n.length() - 1) - (n.matches(".9*") ? 0 : 1);
				
		System.out.println(ans);
	}	
}


Measured memory_bytes: 21972
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	int N;
	int[]a;
	void solve(){
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		a=new int[3*N];
		PriorityQueue<Integer> p=new PriorityQueue();
		PriorityQueue<Integer> q=new PriorityQueue(Comparator.reverseOrder());
		
		for(int i=0;i<3*N;i++){
			a[i]=Integer.parseInt(sc.next());
		}
		long[]max=new long[N+1];
		long[]min=new long[N+1];
		long sump=0;
		long sumq=0;
		//初期化
		for(int j=0;j<N;j++){
			p.add(a[j]);
			q.add(a[2*N+j]);
			sump+=a[j];
			sumq+=a[2*N+j];
		}
		
		max[0]=sump;
		min[N]=sumq;
		
		for(int i=1;i<=N;i++){
			p.add(a[N-1+i]);
			sump+=a[N-1+i];
			sump-=p.poll();
			max[i]=sump;
		}
		
		for(int i=1;i<=N;i++){
			q.add(a[2*N-i]);
			sumq+=a[2*N-i];
			sumq-=q.poll();
			min[N-i]=sumq;
		}
		
		long Max=-Long.MAX_VALUE/2;
		for(int i=0;i<=N;i++){
			Max=Math.max(Max, max[i]-min[i]);
		}
		System.out.println(Max);
	}
}


Measured memory_bytes: 65124
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define each(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

int main(){
	int n;
	int s = 0;
	cin >> n;
	rep(i, n){
		char a; int c;
		cin >> a >> c;
		if(a =='(') s += c;
		else s -= c;
		if(s < 0){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << (s == 0 ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
ll N, K;
llvec A, F;

bool chk(ll tot){
  ll cnt=0;
  rep(i, N){
    if(A[i]*F[i]<=tot){
      continue;
    }else{
      cnt += A[i] - tot/F[i];
    }
  }
  return cnt<=K;
}

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> N >> K;
  A = llvec(N);
  F = llvec(N);
  rep(i, N)cin >> A[i];
  rep(i, N)cin >> F[i];

  sort(ALL(A));
  sort(ALL(F), [](ll a, ll b){return a>b;});

  ll l=-1, r=1e12;
  while(r-l>1){
    ll m=(r+l)/2;
    if(chk(m)){
      r = m;
    }else{
      l=m;
    }
  }
  cout << r;
  
  return 0;
}


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

using namespace std;
using ll =long long;
using db = double;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 998244353;
const ll INF = 1LL << 60;

//ここから書き始める

int main()
{
	cout << setprecision(10);
	ll n ; cin >> n ;
	ll POW;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];

	if(a[0]!=0){
		cout << 0 << endl;
		return 0;
	}
	SORT(a);
	ll ans = 1;

	vector<ll> x(n,0);
	rep(i,n){
		x[a[i]] ++;
	}

//	for(auto neko :x){
//		cout << neko <<" ";
//	}

	if(x[0] != 1){
		cout << 0 << endl;
		return 0 ;
	}else{
		For(i,0,n){
			if(i==0){continue;}
			if(x[i] == 0 ){//0だったらそれよりあとに1以上が出てこないければok
				For(j,i+1,n){
					if(x[j]>=1){
						cout << 0 << endl;
						return 0;
					}
				}
				cout << ans%mod<< endl;
				return 0;
			}else{
				POW = 1;
				rep(k,x[i]){
					POW *=x[i-1];
					POW %=mod;
				}
				ans *= POW;
				ans %= mod;
			}
		}
	}
	cout << ans%mod << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<int64_t> X(N), dp(N);
    rep (i, 0, N) cin >> X[i];

    int64_t mean = accumulate(X.begin(), X.end(), 0ll);
    mean /= N;
    dp.resize(mean+1);

    rrep (i, 1, mean+1) {
        int64_t cnt = 0;
        rep (j, 0, N) {
            cnt += pow(X[j] - i, 2);
        }
        dp[i-1] = cnt;
    }

    int64_t ans = *min_element(dp.begin(), dp.end());
    cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = []
b = []
n.times do |i|
  a[i], b[i] = gets.chomp.split.map(&:to_i)
end

ind = (0...n).to_a.sort_by { |i| a[i] + b[i] }.reverse
ans = 0
n.times do |i|
  if (i % 2).zero?
    ans += a[ind[i]]
  else
    ans -= b[ind[i]]
  end
end
p ans


Measured memory_bytes: 7408
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s, t;
	cin >> s >> t;

	vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1));

	for (int i = 1, s_len = (int)s.length(); i <= s_len; i++) {
		for (int j = 1, t_len = (int)t.length(); j <= t_len; j++) {

			dp[i][j] = max(dp[i][j], dp[i][j - 1]);
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);

			if (s[i - 1] == t[j - 1] && dp[i][j] < dp[i - 1][j - 1] + 1) dp[i][j] = dp[i - 1][j - 1] + 1;
		}
	}
	
	string ans = "";
	int x = (int)s.length(), y = (int)t.length();
	while (x > 0 && y > 0) {

		if (dp[x][y] == dp[x - 1][y]) x--;
		else if (dp[x][y] == dp[x][y - 1]) y--;
		else {
			ans.push_back(s[x - 1]);
			x--, y--;
		}
	}

	reverse(ans.begin(), ans.end());
	cout << ans << "\n";

	return 0;

}

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

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int n = int.Parse(In[0]);
            int k = int.Parse(In[1]);
            string[] In2 = Console.ReadLine().Split(' ');
            int[] V = new int[n];
            for (int i = 0; i < n; i++)
            {
                V[i] = int.Parse(In2[i]);
            }
            int max = 0;
            for(int l = 0; l <= k; l++)
            {
                for(int r=0; r <= k - l; r++)
                {
                    if (l + r > n) continue;
                    int d = k - l - r;//戻す
                    int now = 0;
                    var L = new List<int>();
                    for(int i = 0; i <= l - 1;i++)
                    {
                        now += V[i];
                        L.Add(V[i]);
                    }
                    for (int i = n-r; i <= n - 1; i++)
                    {
                        now += V[i];
                        L.Add(V[i]);
                    }
                    L.Sort();
                    for(int i = 0; i <= d - 1;i++)
                    {
                        if (i >= L.Count) break;//<-多分これ抜けてた
                        if (L[i] > 0) break;//<-ｋ回「以下」
                        now -= L[i];
                    }
                    max = (int)Math.Max(max, now);
                }
            }
            Console.WriteLine(max);
        }
    }
}

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

int main (){
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) cin >> d.at(i);
    
    vector<int>num(110);
    for (int i = 0; i < N; i++){
        num.at(d.at(i)) = 1;
    }

    int ans = 0;
    for(int i = 1; i < 101; i++){
        if (num.at(i) == 1) ans++;
    }
    cout << ans << endl;
}

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

struct Edge {
	int src, dst;
	Edge(int f, int t) {
		src = f;
		dst = t;
	}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

void bfs(int v,const Graph &g,vector<int> &memo){
    queue<int>q;
    memo[v]=1;
    //cout<<v<<" "<<memo[v]<<endl;
    q.push(v);
    while(!q.empty()){
        int u=q.front();q.pop();
        //cout<<u<<endl;
        for(auto e:g[u]){
            //cout<<"T"<<endl;
            // cout<<e.src<<e.dst<<endl;
            //cout<<e.dst<<" "<<memo[e.dst]<<endl;
            if(!memo[e.dst]){
                //cout<<e.dst<<endl;
                q.push(e.dst);
                memo[e.dst]=memo[e.src]+1;
            }
        }
    }
    return;
}

int main(){
    int n;
    cin >> n;
    Graph g(n);
    for (int i = 0; i<n-1; ++i) {
        int s, t; cin >> s >> t;
        --s;
        --t;
        //cout<<s<<t<<endl;
        g[s].emplace_back(s, t);
        g[t].emplace_back(t, s);
    }
    vector<int>fenec_dist(n,0);
    fenec_dist[0]=1;
    vector<int>snuke_dist(n,0);
    snuke_dist[n-1]=1;
    bfs(0,g,fenec_dist);
    bfs(n-1,g,snuke_dist);
    int f=0;
    for(int i=0;i<n;++i){
        //cout<<fenec_dist[i]<<endl;
        if(fenec_dist[i]<=snuke_dist[i])f++;
    }
    int s=n-f;
    //cout<<s<<endl;
    if(f<=s)cout<<"Snuke"<<endl;
    else cout<<"Fennec"<<endl;
}

Measured memory_bytes: 7040
// Problem : B - Multiple of 9
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ff         first
#define ss         second
#define endl       '\n'
#define pb         push_back
#define int        long long
#define vi         vector<int>
#define mii        map<int, int>
#define pii        pair<int, int>
#define all(x)     (x).begin(), (x).end()
#define fill(a,b)  memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define px(a)      for(auto x: a) cout<<x<<" "; cout<<'\n';
#define pxy(a,n)   rep(i,0,n) {px(a[i])};
/*_________________________________________________________*/

const long long MOD=1e9+7,N=1e5+5;
int solve()
{
	string s;
	cin>>s;
	int ans=0;
	int n=s.length();
	rep(i,0,n){
		ans+=s[i]-'0';
		ans%=9;
	}
	//px(a);
	return (ans%9==0);
}
int32_t main()
{	
	std::ios::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1; 
	//cin>>t;
	while(t--) 
	//solve();
	//cout<<solve()<<endl;
	cout<<(solve()?"Yes":"No")<<endl;
}

Measured memory_bytes: 3748
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  s = readline()

  n = length(s)
  ans = 0
  for b in 0:1<<(n - 1) - 1
    sx = String[]
    i = 1
    for j in 1:n - 1
      if b & 1<<(j - 1) != 0
        push!(sx, s[i:j])
        i = j + 1
      end
    end
    push!(sx, s[i:end])
    # println(sx)
    ans += map(parseInt, sx) |> sum
  end
  println(ans)
end

main()


Measured memory_bytes: 168448
#include<bits/stdc++.h>
 
#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
 
int main(){
    int a,b,x;
    cin >> x >> a >> b;
    x -= a;
    cout << x % b << endl;
}

Measured memory_bytes: 256
<?php
list($n, $m) = explode(" ",trim(fgets(STDIN)));
$box = array_fill(0,$n+1,array(1,0));
$box[1][1] = 1;
$count = 1;
for ( $i=0; $i<$m; $i++ ) {
	list($src, $dst) = explode(" ",trim(fgets(STDIN)));
	$box[$dst][0]++;
	--$box[$src][0];
	if ( $box[$src][1] ) {
		if ( !$box[$dst][1] ) {
			$box[$dst][1] = 1;
			$count++;
		}
		if ( $box[$src][0] <= 0 ) {
			$box[$src][1] = 0;
			$count--;
		}
	}
}
echo $count.PHP_EOL;


Measured memory_bytes: 42744
#このコード
# aabbccdd
# ababcdcd
# をYesと通すのだが....

from collections import Counter
 
S = list(input())
T = list(input())
 
cs = sorted(Counter(S).values())
ct = sorted(Counter(T).values())
 
if cs == ct:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 6960
public class Main {
    public static void main(String[] args) {

        java.util.Scanner sc = new java.util.Scanner(System.in);
        StringBuilder str = new StringBuilder(sc.nextLine());
        int q = Integer.parseInt(sc.nextLine());

        for (int i = 0; i < q; i ++) {
            String[] command = sc.nextLine().split(" ");
            int a = Integer.parseInt(command[1]);
            int b = Integer.parseInt(command[2]) + 1;

            if (command[0].equals("print")) { System.out.println(str.substring(a, b)); }
            if (command[0].equals("reverse")) {
                StringBuilder br = new StringBuilder(str.substring(a, b));
                br.reverse();
                str.replace(a, b, br.toString());
            }
            if (command[0].equals("replace")) { str.replace(a, b, command[3]); }
        }
    }
}

Measured memory_bytes: 28256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n>>m;
	if(n==m){
		cout << "Yes" << endl;

	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

ll A, B, C;

int main(void){
	cin >> A >> B >> C;
	int cnt = 0;
	while(1){
		if(A % 2 || B % 2 || C % 2)break;
		if(cnt >= 1000000){
			printf("-1\n");
			return 0;
		}
		ll tA = B / 2 + C / 2;
		ll tB = A / 2 + C / 2;
		ll tC = A / 2 + B / 2;
		A = tA;
		B = tB;
		C = tC;
		cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 256
a,b = [int(i) for i in input().split()]

step = 2
towers = [1]
i = 1
while True:
    towers.append(towers[i-1] + step)
    
    if towers[i] >= 499500:
        break
    i += 1
    step += 1


depth = towers[(b-a)-1] - b
print(depth)



Measured memory_bytes: 3060
local function lower_bound(ary, x)
  if(x <= ary[1]) then return 1 end
  local num = #ary
  if(ary[num] < x) then return num + 1 end
  local min, max = 1, num
  while(1 < max - min) do
    local mid = (min + max) // 2
    if(ary[mid] < x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end
local function getComb(n, k)
  local ret = 1
  for i = 1, k do
    ret = ret * (n + 1 - i)
    ret = ret // i
  end
  return ret
end
local n, a, b = io.read("*n", "*n", "*n")
local t = {}
for i = 1, n do t[i] = io.read("*n") end
table.sort(t)
local sum = 0
for i = 1, a do
  sum = sum + t[n + 1 - i]
end
print(string.format("%.8f", sum / a))
local minval = t[n + 1 - a]
local minvalcount = 0
local usecount = 0
for i = 1, n do
  if(t[i] == minval) then
    minvalcount = minvalcount + 1
    if(n + 1 - a <= i) then
      usecount = usecount + 1
    end
  end
end
if minval ~= t[n] then
  print(string.format("%d", getComb(minvalcount, usecount)))
else
  local ret = 0
  for i = a, b do
    ret = ret + getComb(minvalcount, i)
  end
  print(string.format("%d",ret))
end


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

int main(){
  int N,ans;
  cin>>N;
  for(int i = 0; i<8;i++){
    if(N<pow(2,i)){
      ans=pow(2,i-1);
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import string
from collections import Counter


# least common char count
def lccc(c, cnts):
    m = 51 # s <= 50
    for cc in cnts:
        if (not c in cc):
            return 0
        if (cc[c] < m):
            m = cc[c]
    return m


def main():
    counter = dict()

    n = int(input())
    cnts = [Counter(list(input())) for i in range(n)]
    for c in list(string.ascii_lowercase):
        counter[c] = lccc(c, cnts)

    print("".join([k * counter[k] for k in sorted(counter.keys())]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3768
N, K = map(int, input().split())
A = list(map(int, input().split()))

lst = [0]
lst_append = lst.append
for a in A:
    lst_append(lst[-1] + max(0, a))

tmp = sum(A[:K])
ans = lst[N] - lst[K] + max(0, tmp)
for i in range(K, N):
    tmp += A[i] - A[i - K]
    next_ = (lst[N] - lst[i + 1]) + max(0, tmp) + lst[i - K + 1] - lst[0]

    ans = max(ans, next_)

print (ans)

Measured memory_bytes: 14504
let ans, n, xss = Scanf.(scanf "%d %d" @@ fun n d -> ref 0, n, Array.(init n @@ fun _ -> init d @@ fun _ -> scanf " %d" (+) 0))
let rec f n i = if i * i >= n then i * i = n else f n (i + 1)
let g a b = let s = ref 0 in Array.iteri (fun i x -> s := !s + (x - b.(i)) * (x - b.(i))) a; !s
let _ = for i = 0 to n - 1 do for j = i + 1 to n - 1 do if f (g xss.(i) xss.(j)) 0 then incr ans done done; Printf.printf "%d\n" !ans

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef pair<int,int> P;
const int INF = 1000000000;

long long int f(int n){
	if(n<=1)return 1;
	return f(n-1)*n;
}

int main(){
	char s[50];
	static int x[30];
	int um=0,om=0,lm=0;
	long long int result;
	scanf("%s",s);
	rep(i,strlen(s)){
		x[s[i]-'a']++;
	}
	rep(i,26){
		if(x[i]>0)um+=x[i];
		if(x[i]%2==1)om++;
	}
	if(um%2==0&&om>0){
		result=0;
	}else if(um%2==1&&om!=1){
		result = 0;
	}else{
		
		//printf("%d",lm);
		rep(i,26)if(x[i]>0){
			/*if(x[i]%2==0){
				x[i]/=2;
			}else if(x[i]%2==1){
				x[i]/=2;
			}*/
			x[i]/=2;
			lm += x[i];
		}
		
		//printf("%d",lm);
		//if(om==1)lm--;
		//printf("%d",lm);
		result = f(lm);
		rep(i,26)if(x[i]>0){
			result /= f(x[i]);
		}
	}
	printf("%lld\n",result);
	return 0;
}

Measured memory_bytes: 968
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
#define ll long long 
#define il inline
const int maxn=1000010;
ll a; int ans;
ll prime[maxn];
int notprime[maxn];
int tot;
int times[maxn];
int main(){
    cin>>a;
    notprime[1]=1;
    for (int i=2;i<=1000000;++i){
        if (!notprime[i]){
            prime[++tot]=i;
        }
        for (int j=1;j<=tot&&i*prime[j]<=1000000;++j){
            notprime[i*prime[j]]=1;
            if (!(i%prime[j])) break;
        }
    }
    for (int i=1;i<=tot;++i){
        while (a%prime[i]==0){
            a/=prime[i]; times[i]++;
        }
    }
    for (int i=1;i<=tot;++i){
        int j=1;
        while (j*(j+1)/2<=times[i]) ++j;
        ans+=j-1;
    }
    if (a!=1) ++ans;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 8164
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        long[] sums = new long[n + 1];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            sums[arr[i]]++;
        }
        long ans = 0;
        for (int i = 0; i <= n; i++) {
            ans += sums[i] * (sums[i] - 1) / 2;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            long x = sums[arr[i]];
            long tmp = ans - x * (x - 1) / 2 + (x - 1) * (x - 2) / 2;
            sb.append(tmp).append("\n");
        }
        System.out.print(sb);
    }
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL n;
    cin >> n;
    vector<LL> div = Div(n);
    int l, r;
    l = 0;
    r = div.size() - 1;
    LL res = LINF;
    while(l <= r) {
        div[l]--;
        if(l != r) div[r]--;
        res = min(res, div[r] + div[l]);
        ++l; --r;

    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 384
from collections import deque
inf=float("inf")


def BFS():
    D=[[inf for _ in range(W)] for _ in range(H)]
    queue=deque()
    queue.append([Cx-1,Cy-1,0])
    D[Cx-1][Cy-1]=0

    while len(queue)>0:
        x,y,cnt=queue.popleft()
        for i,j in [[1,0],[0,1],[-1,0],[0,-1]]:
            X,Y=x+i,y+j
            if 0<=X<H and 0<=Y<W:
                if S[X][Y]=="." and D[X][Y]>cnt:
                    D[X][Y]=cnt
                    queue.appendleft([X,Y,cnt])
        for X in range(max(0,x-2),min(H,x+3)):
            for Y in range(max(0,y-2),min(W,y+3)):
                if S[X][Y]=="." and D[X][Y]>cnt+1:
                    D[X][Y]=cnt+1
                    queue.append([X,Y,cnt+1])

    return D[Dx-1][Dy-1]


H,W=map(int,input().split())
Cx,Cy=map(int,input().split())
Dx,Dy=map(int,input().split())
S=[list(input()) for _ in range(H)]

ans=BFS()
print(ans if ans!=inf else -1)

Measured memory_bytes: 164920
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
tmp_x = X
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if X == (500*i+100*j+50*k):
        cnt+=1
        break
print(cnt)

Measured memory_bytes: 3060
N=int(input())
s_ts=[]
for i in range(N):
    inp=input().split()
    s_ts.append((str(inp[0]),int(inp[1])))

X=str(input())

S=0
is_passed=False
for s_t in s_ts:
    s=s_t[0]
    t=s_t[1]

    if is_passed:
        S+=t
    
    if s == X:
        is_passed=True

print(S)



Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000





int main(){
	
	long long N,X,D;
	cin>>N>>X>>D;
	if(D==0){
		if(X!=0)cout<<N+1<<endl;
		else cout<<1<<endl;
		return 0;
	}
	vector<long long> A(N);
	A[0] = X;
	for(int i=1;i<N;i++){
		A[i] = A[i-1] + D;
	}
	if(D<0){
		D*=-1;
		reverse(A.begin(),A.end());
	}
	
	vector<long long> S(N+1,0);
	
	for(int i=0;i<N;i++){
		S[i+1] += S[i];
		S[i+1] += A[i];
	}
	
	vector<pair<long long,long long>> P;
	
	for(int i=0;i<=N;i++){
		long long l = S[i];
		long long r = S[N] - S[N-i];
		P.emplace_back(l,r);
	}
	
	
	map<int,vector<pair<long long,long long>>> mp;
	for(int i=0;i<P.size();i++){
		long long a = P[i].first;
		a %= D;
		//cout<<a<<endl;
		if(a<0)a+=D;
		mp[a].push_back(P[i]);
	}
	vector<pair<long long,long long>> P2;
	for(auto &a:mp){
		sort(a.second.begin(),a.second.end());
		for(int i=0;i<a.second.size();i++){
			if(i==0){
				P2.push_back(a.second[i]);
			}
			else{
				if(P2.back().second >= a.second[i].first){
					P2.back().second = max(P2.back().second,a.second[i].second);
				}
				else{
					P2.push_back(a.second[i]);
				}
			}
		}
	}
	

	
	long long ans = 0;
	for(int i=0;i<P2.size();i++){
		//cout<<P2[i].first<<','<<P2[i].second<<endl;
		long long a = P2[i].second - P2[i].first;
		a /= D;
		ans += a+1;
	}
	
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 37356
#include<stdio.h>
#include<string.h>
int main(void)
{
	char S[200001],T[200001];
	int len,cnt,i;
	cnt=0;
	scanf("%s %s",S,T);
	len=strlen(S);
	for(i=0;i<len;i++){
		if(S[i]!=T[i]){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}
		
		

Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
	ll a,b,c,d;
	while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d))
	{
		ll gcd=__gcd(c,d);
		ll lcm=c*d/gcd;
		ll n=b/c-(a-1)/c;
		ll m=b/d-(a-1)/d;
		ll num=n+m-(b/lcm-(a-1)/lcm);
		printf("%lld\n",b-a+1-num);
	}
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,k;
    cin>>n>>k;
    int l[n];
    rep(i,n){
        cin>>l[i];
        l[i]=-l[i];
    }
    sort(l,l+n);
    int ans=0;
    for(int i=0;i<k;i++){
        ans-=l[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;
double pai = 3.141592653589793;

signed main(){
	int N,K;
	cin>>N>>K;
	vector<int> a(N); for(auto& e:a)cin >> e;
	vector<int> f(N); for(auto& e:f)cin >> e;
	sort(ALL(a));
	sort(ALL(f));
	reverse(ALL(f));
	auto ff =[&](int x)->bool{
		int k = K;
		REP(i,N){
			int t = x / f[i];
			k-=max(a[i]-t,0ll);
		}
		return k>=0;
	};
	int l = -1, r = 1e18 + 1;
	while(r - l > 1){
		int c = (l + r) / 2;
		if(ff(c)) r = c;
		else l = c;
	}cout << r << endl;
}

Measured memory_bytes: 3328
k = int(input())
line = input()

m = []
sums = []
for n in range(k):
    m.append(int(line.split()[n]))

dif = []
for t in range(k-1):
    s1 = sum(m[:(t+1)])
    s2 = sum(m[(t+1):])
    dif.append(abs(s1-s2))
    
dif.sort()
print(dif[0])


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() { 
    int n, c; cin >> n >> c;
    vector<int> S(n), T(n), C(n);
    vector<int> plus(200010), minus(200010);
    rep(i, n){
        cin >> S[i] >> T[i] >> C[i];
        int a = (S[i]-0.5)*2, b = T[i]*2;
        plus[a]++; minus[b]++;
    }
    int mx = 0, cnt = 0;
    rep(i, 200000){
        cnt -= minus[i];
        cnt += plus[i];
        chmax(mx, cnt);
    }
    cout << min(mx, c) << ln;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int N, M, K;
map<P, ld> memo;
ld dp(int n, int m) {
	if (n > m * M || n < m) return 0;
	if (memo.count( P(n, m) ) > 0) return memo[P(n, m)];
	if (m == 1) return 1.0/M;
	ld res = 0;
	REP(i, M) {
		res += dp(n-i-1, m-1) / M;
	}
	memo[P(n, m)] = res;
	return res;
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	while ( cin >> N >> M >> K, N || M || K ) {
		memo.clear();
		ld ans = 0;
		FOR(i, N, N*M+1) {
			int b = max(1LL, i-K);
			ans += (ld)b * dp(i, N);
		}
		cout << fixed << setprecision(10) << ans << endl;
	}
}

Measured memory_bytes: 3188
s = input()
t = len(s)


if t % 2 == 0 :  # 偶数文字
    ans = t // 2
    th = t // 2
    if s[th-1] == s[th] :
        ans += 1 
        b = s[th]
        l = th - 1 - 1
        r = th + 1
        while l >= 0 and r <= t-1 and s[l] == b and s[r] == b :
            ans += 1
            l -= 1
            r += 1
else :  # 奇数文字
    ans = t // 2 + 1
    th = t // 2
    
    b = s[th]
    l = th - 1
    r = th + 1
    while l >= 0 and r <= t-1 and s[l] == b and s[r] == b :
        ans += 1
        l -= 1
        r += 1
        
print(ans)


Measured memory_bytes: 3316
a,b,c,k=map(int, input().split())
""" a:1
    b:0
    c:-1
"""
sum_max=0
minus=0
if(a+b>=k):
    if(a>=k):
        sum_max=k
    else:
        sum_max=a
else:
    minus=k-(a+b)
    sum_max=a-minus




print(sum_max)


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

int main()
{
    int x;
    scanf("%d",&x);
    
    int total = 0;
    total += (x/500) * 1000;
    x -= (x/500) * 500;
    total += (x/5) * 5;
    
    printf("%d", total);
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    string s,a,b,c;
    s="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    cin>>a>>b>>c;
    cout<<s[a[0]-'a']<<s[b[0]-'a']<<s[c[0]-'a']<<endl;
    return 0;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  string S;
  cin >> S;
  if(S.at(B - 1) == 'A') {
    S.at(B - 1) = 'a';
  }
  if(S.at(B - 1) == 'B') {
    S.at(B - 1) = 'b';
  }  
  if(S.at(B - 1) == 'C') {
    S.at(B - 1) = 'c';
  }
  cout << S << endl;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
   SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD SYSIN.
   01 INDATA  PIC X(5000).
WORKING-STORAGE SECTION.
01 ln         PIC X(5000).
01 maxlen     PIC 9(10) VALUE 100 COMP.
01 cur        PIC 9(10) VALUE 1 COMP.
01 i          PIC 9(10) VALUE 1 COMP.
01 j          PIC 9(10) COMP.
01 len        PIC 9(10) COMP.
01 ans        PIC 9(10) VALUE ZERO.
01 zs         PIC Z(9)9.
01 N          PIC 9(10).
01 K          PIC 9(10).
01 p1.
   03 p11 OCCURS 1000 DEPENDING ON N.
      05 p    PIC S9(10).

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO N K.
  OPEN INPUT SYSIN.
  READ SYSIN INTO INDATA.
  CLOSE SYSIN.
  MOVE INDATA TO ln.
  MOVE N TO maxlen.
  PERFORM maxlen TIMES
    PERFORM VARYING j FROM cur BY 1 UNTIL ln(j:1) = SPACE
    END-PERFORM
    COMPUTE len = j - cur
    MOVE ln(cur:len) TO p(i)
    COMPUTE cur = j + 1
    ADD 1 TO i
  END-PERFORM.
  SORT p11 ON ASCENDING p.
  PERFORM VARYING i FROM 1 BY 1 UNTIL K < i
    ADD p(i) TO ans
  END-PERFORM.
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


Measured memory_bytes: 3908
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int d = scanner.nextInt();
        int n = scanner.nextInt();
        if (n == 100) {
            n++;
        }
        System.out.println((int)Math.pow(100, d) * n);
    }
}

Measured memory_bytes: 21840
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N;
vector<pi> G[1024];
int p[1024], d[1024];

int del_leaf()
{
  queue<int>Q;
  int ret = 0;
  rep(i, N){
    if(G[i].size() != 1) continue;
    ret += G[i][0].second;
    Q.push(i);
  }
  while(!Q.empty()){
    int from = Q.front(); Q.pop();
    int to = G[from][0].first;
    G[from].erase(G[from].begin());
    G[to].erase(find(G[to].begin(), G[to].end(), pi(from, G[from][0].second)));
  }
  return ret;
}

pi dfs(int n, int prev)
{
  pi res = pi(0, n);
  for(int i=0;i<G[n].size();i++){
    if(G[n][i].first == prev) continue;
    pi tmp = dfs(G[n][i].first, n);
    if(res.first < tmp.first + G[n][i].second){
      res = pi(tmp.first+G[n][i].second, tmp.second);
    }
  }
  return res;
}

int compute_r()
{
  rep(i, N){
    if(G[i].size()){
      pi a = dfs(i, -1);
      pi b = dfs(a.second, -1);
      //      cout << i << " " << a.second << " " << b.second << endl;    
      return b.first;
    }
  }
  return 0;
}

int main()
{
  // input
  while(cin >> N, N){
    rep(i, 1024) G[i].clear();
    int res = 0, sum = 0;
    rep(i, N-1) cin >> p[i];
    rep(i, N-1){
      cin >> d[i];
      sum += d[i];
    }
    rep(i, N-1){
      int s = i+1, t = p[i]-1;
      G[s].push_back(pi(t, d[i]));
      G[t].push_back(pi(s, d[i]));
    }
    

    // delete leaf
    int w_leaf =  del_leaf();
    res += w_leaf;
    sum -= w_leaf;
    // ??¨?????????????±???????
    int r = compute_r();
    res += r*2;
    sum -= r;
    res += sum*3;
    //    cout << w_leaf << " " << r << " " << sum << endl;
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;

int		main(void){
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes\n";
	else
		cout << "No\n";
}


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

int main() {
  int K, S;
  cin >> K >> S;
  
  int count = 0;
  
  for (int x = 0; x <= K; x++){
    for (int y = 0; y <= K; y++){
      if (S - x - y >= 0 && S - x - y <= K) count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 3680
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

void f(int n) {
    if (n % 10 == 7 || (n / 10) % 10 == 7 || (n / 100) % 10 == 7) cout << "Yes" <<endl;
    else cout << "No" << endl;
}
int main() {
    int R;
    cin >> R;
    cout << 2 * M_PI * R <<endl;
   
    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>							
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;

void solve() {
	string s;
	cin >> s;
	int n = s.length();
	int cnt = 0;
	for(int i = 0; i < n / 2; ++i) {
		if(s[i] != s[n - i - 1]) cnt++;
		}
		cout << cnt << endl;
}


int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}
 
 
 



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=1000;i++){
        int A=floor(i*0.08);
        int B=floor(i*0.1);
        if(A==a && B==b){
            //cout<<A<<" "<<B<<endl;
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  
  double x1,y1,x2,y2;
  double ans;
  
  scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
  
  ans=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
  
  printf("%lf\n",sqrt(ans));

  return 0;
}
  



Measured memory_bytes: 2104
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
//~ #pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));


using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(0)cout
#endif

const int maxn = (1e6)+7;
const int maxk = 20;
const int inf = (1e9)+7;
const LL LLinf = ((LL)1e18)+7LL;
const LD eps = 1e-9;
const LL mod = 1e9+7;

// ***************************** CODE ***************************** //

string tab;
int n, q;
char lit[maxn], str[maxn];

int gdzie(int x)
{
  for(int i = 1;i <= q;i++)
  {
    if(lit[i] == tab[x])
    {
      if(str[i] == 'L')
        x--;
      else
        x++;
    }
    if(x == 0)
      return 0;
    if(x == n + 1)
      return n + 1;
  }
  return x;
}

int main()
{
	_upgrade
  cin>>n>>q;
  cin>>tab;
  tab = "$" + tab;
  for(int i = 1;i <= q;i++)
    cin>>lit[i]>>str[i];
  int l = 0;
  int p = n + 1;
  while(l + 1 < p)
  {
    int sr = (l + p) / 2;
    if(gdzie(sr) == 0)
      l = sr;
    else
      p = sr;
  }
  int pref = l;
  l = 0;
  p = n + 1;
  //cerr<<pref<<" ";
  while(l + 1 < p)
  {
    int sr = (l + p) / 2;
    if(gdzie(sr) == n + 1)
      p = sr;
    else
      l = sr;
  }
//  cerr<<gdzie(n)<<" "<<n<<endl;
//  cerr<<p<<" ";
  pref += n + 1 - p;
  cout<<n - min(n, pref);
	return 0;
}


Measured memory_bytes: 976
#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;
typedef vector<int> vec;
typedef vector<vec> mat;
vec G[200001];
int V,color[200001];
bool dfs(int v,int c){
    color[v]=c;
    rep(i,G[v].size()){
        if(color[G[v][i]]==c) return false;
        if(color[G[v][i]]==0&&!dfs(G[v][i],-c)) return false;
    }
    return true;
}
int main(){
    ll n,m,a,b;
    cin>>n>>m;
    rep(i,m) cin>>a>>b,G[a].push_back(b),G[b].push_back(a);
    if(!dfs(1,1)) cout<<n*(n-1)/2-m;
    else{
        ll k=0,s=0;
        rep(i,n){
            if(color[i+1]==1) k++;
            else s++;
        }
        cout<<s*k-m;
    }
}

Measured memory_bytes: 8832
import java.util.Arrays;
import java.util.Scanner;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = Integer.parseInt(stdin.nextLine());
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = stdin.nextLine();
        }

        long ans = Arrays.stream(s)
                          .map(str -> new String(str.chars().sorted().toArray(), 0, str.length()))
                          .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))
                          .values()
                          .stream()
                          .collect(Collectors.summingLong(v -> v * (v - 1) / 2L));
        System.out.println(ans);
    }
}


Measured memory_bytes: 138580