akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var a = IO.RSInt;
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0) WriteLine(i + 1);
            }
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 28312
#include <iostream>

int main(){
  int r, d, x2000;
  std::cin >> r >> d >> x2000;
  int current = x2000;
  for(int i=0; i<10; ++i){
    current = r*current - d;
    std::cout << current << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
# Problem D - Dice in Line

# input
N, K = map(int, input().split())
p_list = list(map(int, input().split()))

# initialization
kitai_list = [0]*N
for i in range(N):
    p = p_list[i]
    p_sum = (1 + p)*p / 2
    p_ave = p_sum / p
    kitai_list[i] = p_ave
max_score = -1

# count
tmp = 0
for i in range(N):
    if i-K<0:
        tmp += kitai_list[i]
        max_score = max(max_score, tmp)
    else:
        tmp -= kitai_list[i-K]
        tmp += kitai_list[i]
        max_score = max(max_score, tmp)

# output
print(max_score)


Measured memory_bytes: 71792
n, m = gets.split.map(&:to_i)
cards = gets.split.map(&:to_i).sort
replace = m.times.map{|i| gets.split.map(&:to_i)}.sort_by{|count, value| value}
replace.size.times.reverse_each.drop(1).each{|i| replace[i][0] += replace[i + 1][0]}
replace.unshift([n, 0])

sum = 0
current_rep = replace.pop
cards.each_with_index{|value, index|
    if index + 1 > current_rep[0]
        current_rep = replace.pop
    end
    sum += [value, current_rep[1]].max
}
puts sum


Measured memory_bytes: 21032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;

int main(){
  int s;
  cin >> s;
  map<int, bool> mp;
  mp[s] = true;
  int cnt = 1;
  while(1){
    cnt++;
    if(s % 2) s = 3*s + 1;
    else s = s / 2;
    if(mp.count(s) && mp[s]) break;
    else mp[s] = true;
  }
  cout << cnt << endl;
}
    

Measured memory_bytes: 3628
#include <stdio.h>

int main( void )
{
    int price = 700;
    char topping[ 4 ];
    scanf("%s", topping);
    for( int i = 0; i < 3; i++ )
        if( topping[i] == 'o' ) 
            price += 100;
    
    printf("%d\n", price);
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;

int main()
{
    int n; cin >> n;
    vi a(n);
    vll s(n);
    rep(i, n) {
        cin >> a[i];
        s[i] = a[i] + (i==0?0:s[i-1]);
    }

    ll ans[2] = {0, 0};
    ll change[2] = {0, 0};
    rep(i, n) {
        rep(j, 2) {
            ll a = ((i+j)%2==1) ? -1 : 1;
            ll sum = s[i]+change[j];
            if (sum == 0) {
                change[j] += a;
                ans[j] += 1;
            } else if ((sum < 0 && (i+j)%2==0) || (sum > 0 && (i+j)%2==1)){
                change[j] += a - sum;
                ans[j] += abs(a - sum);
            }
        }
    }
    
    cout << min(ans[0], ans[1]) << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;


int main()
{
	fast;
	ll n;
	cin >> n;
	ll ans = n / 2 + (n % 2);
	cout << ans << endl;

	return 0;
}


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

int main()
{
	ll h,w,k;
	cin >> h >> w >> k;
	vector<string> s(h);
	for(int i = 0;i<h;i++)cin >> s[i];

	int ans = 0;
	for(int bit = 0;bit < (1<<h);bit++)
	{
		for(int bit2 = 0;bit2 <(1<<w);bit2++)
		{
			int cnt = 0;
			for(int i = 0;i<h;i++)
			{
				for(int j = 0;j<w;j++)
				{
					if(bit>>i&1||bit2>>j&1)continue;
					if(s[i][j]=='#')cnt++;
				}
			}
			if(cnt==k)ans++;

		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3628
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys


def solve(l,k):
  for i in range(5):
    for j in range(5):
      if abs(l[i]-l[j] > k):
        return False
  return True


l = []
for _ in range(5):
  l.append(int(input()))
k = int(input())
if solve(l,k):
  print("Yay!")
else:
  print(":(")



Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>

int main(){
	int a,b,c,k;
	std::cin>>a>>b>>c>>k;
	int max=(a>b?(a>c?a:c):(b>c?b:c));
	int tot=a+b+c-max;

	for(int x=0;x<k;x++){
		max*=2;
	}
	std::cout<<tot+max<<std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <functional>
using namespace std;

template<typename Monoid, typename OpMonoid = Monoid>
class LazySegmentTree{
private:
    using F = function<Monoid(Monoid, Monoid)>;
    using G = function<Monoid(Monoid,OpMonoid)>;
    using H = function<OpMonoid(OpMonoid,OpMonoid)>;
    using P = function<OpMonoid(OpMonoid,int)>;
    int sz;
    vector<Monoid> data;
    vector<OpMonoid> lazy;
    const F func;
    const G op;
    const H mergeOp;
    const P multmergeOp;
    const Monoid e;
    const OpMonoid op_e;
public:
    LazySegmentTree(int n, const F f, const G g, const H h, const P p,
    const Monoid &e, const OpMonoid op_e)
    :func(f), op(g), mergeOp(h), multmergeOp(p), e(e), op_e(op_e){
        sz = 1;
        while(sz<n) sz <<= 1;
        data.assign(2*sz,e);
        lazy.assign(2*sz,op_e);
    }
    //初期化
    void set(int k, const Monoid &x){
        data[k+sz] = x;
    }
    //前計算
    void build(){
        for(int k=sz-1;k>0;k--){
            data[k] = func(data[2*k],data[2*k+1]);
        }
    }
    //kの子に長さlenの遅延を伝搬
    void propagate(int k, int len){
        if(lazy[k]!=op_e){
            if(k<sz){
                //遅延を下の段に伝搬、結果を分割する
                lazy[2*k] = mergeOp(lazy[2*k],lazy[k]);
                lazy[2*k+1] = mergeOp(lazy[2*k+1],lazy[k]);
            }
            data[k] = op(data[k],multmergeOp(lazy[k],len));
            lazy[k] = op_e;
        }
    }
    //更新
    Monoid update(int a, int b, const OpMonoid &x, int k, int l, int r){
        propagate(k,r-l);
        if(r<=a || b<=l) return data[k];
        else if(a<=l && r<=b){
            lazy[k] = mergeOp(lazy[k],x);
            propagate(k,r-l);
            return data[k];
        }else{
            return data[k] = func(update(a,b,x,2*k,l,(l+r)>>1),update(a,b,x,2*k+1,(l+r)>>1,r));
        }
    }
    Monoid update(int a, int b, const OpMonoid &x){
        return update(a,b,x,1,0,sz);
    }
    //クエリ回答
    Monoid query(int a, int b, int k, int l, int r){
        propagate(k,r-l);
        if(r<=a || b<=l){
            return e;
        }else if(a<=l && r<=b){
            return data[k];
        }else{
            return func(query(a,b,2*k,l,(l+r)>>1),query(a,b,2*k+1,(l+r)>>1,r));
        }
    }
    Monoid query(int a, int b){
        return query(a,b,1,0,sz);
    }
    Monoid operator[](const int &k){
        return query(k,k+1);
    }
};

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

int main(){
    int N,Q;
    cin >> N >> Q;
    auto func = [](P a, P b){return P(a.first+b.first,a.second+b.second);};
    auto op = [](P a, ll b){return P(a.second*b,a.second);};
    auto merge = [](ll a, ll b){return b!=INT_MAX? b:a;};
    auto multmergeop = [](ll a, int b){return a;};
    LazySegmentTree<P,ll>
    seg(N,func,op,merge,multmergeop,P(0,0),INT_MAX);
    for(int i=0;i<N;i++) seg.set(i,P(0,1));
    seg.build();
    for(int i=0;i<Q;i++){
        ll c,s,t,x;
        cin >> c;
        if(c==0){
            cin >> s >> t >> x;
            seg.update(s,t+1,x);
        }else{
            cin >> s >> t;
            cout << seg.query(s,t+1).first << endl;
        }
    }
}


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

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

using namespace std;
using lint = long long;

int main(void)
{
    int X;
    cin >> X;
    while(X >= 100){
        int Y = X % 100;
        if(Y >= 5) X -= 105;
        else if(Y == 4) X -= 104;
        else if(Y == 3) X -= 103;
        else if(Y == 2) X -= 102;
        else if(Y == 1) X -= 101;
        
        if(Y == 0) X = 0;
    }
    if(X != 0){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s=input()[::-1]
T=["dream","dreamer","erase","eraser"]
l,n=0,len(s)

while l!=n:
    flag=0
    for i in T:
        word=i[::-1]
        if s[l:l+len(word)]==word:
            l +=len(word)
            flag=1
    if flag==0:print("NO");exit()
print("YES")

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

int main() {

  int N;
  cin >> N;

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

  sort(A.begin(), A.end());
  
  cout << A[N - 1] - A[0] << endl;

}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	struct Point
	{
		public readonly int x, y;
		public Point(int[] a) : this(a[0], a[1]) { }
		public Point(int a, int b) { x = a; y = b; }
	}
	void Solve()
	{
		var N = F;
		var a = new Point[N];
		var b = new Point[N];
		for (var i = 0; i < N; i++) a[i] = new Point(G);
		for (var i = 0; i < N; i++) b[i] = new Point(G);
		var g = new Dinic(2 * N + 2);
		for (var i = 0; i < N; i++) for (var j = 0; j < N; j++) if (a[i].x < b[j].x && a[i].y < b[j].y) g.AddEdge(i + 1, j + N + 1, 1);
		for (var i = 0; i < N; i++) { g.AddEdge(0, i + 1, 1); g.AddEdge(i + N + 1, 2 * N + 1, 1); }
		Console.WriteLine(g.MaxFlow(0, 2 * N + 1));
	}
}
class Dinic
{
	public const long INF = 4011686018427387913L;
	class Edge
	{
		public readonly int To;
		public long Capacity;
		public Edge Reverse;
		public Edge(int t, long c, Edge r)
		{
			To = t;
			Capacity = c;
			Reverse = r;
		}
	}
	public Dinic(int v)
	{
		V = v;
		level = new int[V];
		es = new List<Edge>[v];
		for (var i = 0; i < V; i++) es[i] = new List<Edge>();
	}
	readonly int V;
	int[] iter;
	readonly int[] level;
	readonly List<Edge>[] es;
	public void AddEdge(int f, int t, long c)
	{
		var e1 = new Edge(t, c, null);
		var e2 = new Edge(f, 0, e1);
		e1.Reverse = e2;
		es[f].Add(e1);
		es[t].Add(e2);
	}
	long DFS(int v, int t, long f)
	{
		if (v == t) return f;
		for (; iter[v] < es[v].Count; iter[v]++)
		{
			var e = es[v][iter[v]];
			if (level[v] >= level[e.To] || e.Capacity <= 0) continue;
			var g = DFS(e.To, t, Min(e.Capacity, f));
			if (g > 0)
			{
				e.Capacity -= g;
				e.Reverse.Capacity += g;
				return g;
			}
		}
		return 0;
	}
	void BFS(int s)
	{
		for (var i = 0; i < V; i++) level[i] = -1;
		var queue = new Queue<int>();
		level[s] = 0;
		queue.Enqueue(s);
		while (queue.Count > 0)
		{
			var v = queue.Dequeue();
			foreach (var e in es[v])
				if (e.Capacity > 0 && level[e.To] < 0)
				{
					level[e.To] = level[v] + 1;
					queue.Enqueue(e.To);
				}
		}
	}
	public long MaxFlow(int s, int t)
	{
		var flow = 0L;
		while (true)
		{
			BFS(s);
			if (level[t] < 0) return flow;
			iter = new int[V];
			while (true)
			{
				var f = DFS(s, t, INF);
				if (f <= 0) break;
				flow += f;
			}
		}
	}
}

Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << " "
#define dumpL(x) cout << #x << " : " << x << '\n'
#define LINE cout << "line : " << __LINE__ << " "
#define LINEL cout << "line : " << __LINE__ << '\n'
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << " "
#define dumpVL(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) 
#define dumpL(x) 
#define LINE 
#define LINEL 
#define dumpV(v) 
#define dumpVL(v) 
#define STOP assert(false)
#endif
#define mp make_pair
 
namespace std {
template<class S, class T>
ostream &operator <<(ostream& out, const pair<S, T>& a) {
    out << '(' << a.fi << ", " << a.se << ')';
    return out;
}
}

struct Edge {
    int from, to, id;
};
const int MAX_N = 51;
const int MAX_M = 21;

vector<Edge> es[MAX_N];

bool getPath(int cur, int par, int g, vi& path) {
    dump(cur); dumpVL(path);
    if(cur == g) return true;
    for(auto&& e: es[cur]) {
        if(e.to == par) continue;
        path.pb(e.id);
        if(getPath(e.to, cur, g, path)) return true;
        path.pop_back();
    }
    return false;
}

int main(){
    int n;
    cin >> n;
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        es[a].push_back(Edge{a, b, i});
        es[b].push_back(Edge{b, a, i});
    }
    int m;
    cin >> m;
    vector<ll> x(m);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        dump(a); dumpL(b);
        vi path;
        getPath(a, -1, b, path);
        for(auto&& v : path) x[i] |= 1LL<<v;
        dumpVL(path);
    }
    ll ans = 0LL;
    rep(mask, 1<<m) {
        int cnt = 0;
        ll tmp = 0LL;
        rep(i, m) if(mask&(1<<i)) {
            cnt++;
            tmp |= x[i];
        }
        ll k = 0LL;
        rep(i, n) if(tmp&(1LL<<i)) ++k;
        ll num = (1LL<<(n-1-k));
        if(cnt&1) ans -= num;
        else ans += num;
        dump(bitset<4>(mask)); dump(bitset<4>(tmp)); dump(k); dumpL(num);
    } 
    cout << ans << endl;
    return 0;
}

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

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

int main(){
    int h, n;
    cin >> h >> n;
    vector<int> a, b;
    rep(i, n){
        int A, B;
        cin >> A >> B;
        a.push_back(A);
        b.push_back(B);
    }

    vector<int> dp(h+1, 0);
    dp[0] = 0;

    rep2(i, 1, h+1){
        int mincos=INT32_MAX;
        rep(j, n){
            if(i<=a[j]){
                mincos = min(mincos, b[j]);
            }else{
                mincos = min(mincos, dp[i-a[j]] + b[j]);
            }
        }
        dp[i] = mincos;
    }

    cout << dp[h] << endl;
    return 0;
}

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

using namespace std;

int dirs[4][2]={{-1, 0}, {0, 1}, {1, 0}, {0, -1}};

int main()
{
    //freopen("inp.in", "r", stdin);
    //freopen("outp.out", "w", stdout);
    //ios::sync_with_stdio(false);
    int n;
    scanf("%d", &n);
    vector<char> v(n);
    for(int i=0; i<n; i++)
    {
        scanf(" %c", &v[i]);
    }
    vector<int> nb_change(n, 0);
    for(int i=0; i<n; i++)
    {
        if(i>0) nb_change[i]=nb_change[i-1];
        if(v[i]=='W') nb_change[i]++;
    }
    vector<int> second(n, 0);
    for(int i=n-1; i>=0; i--)
    {
        if(i+1<n) second[i]=second[i+1];
        if(v[i]=='E') second[i]++;
    }
    int ans=n+1;
    for(int i=0; i<n; i++)
    {
        int nieuw=0;
        if(i-1 >= 0) nieuw += nb_change[i-1];
        if(i+1<n) nieuw += second[i+1];
        ans=min(ans, nieuw);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#include <deque>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
#define ls rt << 1
#define rs rt << 1 | 1
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
int work()
{
  int x ;
  scanf("%d" , &x) ;
  x /= 100 ;
  if(x < 6) puts("8") ;
  else if(x < 8) puts("7") ;
  else if(x < 10) puts("6") ;
  else if(x < 12) puts("5") ;
  else if(x < 14) puts("4") ;
  else if(x < 16) puts("3") ;
  else if(x < 18) puts("2") ;
  else puts("1") ;
  return 0 ;
}
int main()
{

  work() ;
  return 0 ;
}
/*
*/


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N;
    cin >> N;
    vector<int> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    int a = 0;
    int sum = 0;
    vector<int> X(N+1);
    for ( int i = 0; i < N; i++ ) {
        X[i] = abs(A[i]-a);
        sum += abs(A[i]-a);
        a = A[i];
    }
    X[N] = abs(A[N-1]);
    sum += abs(A[N-1]);

    for ( int i = 0; i < N; i++ ) {
        int b = abs( ( i == 0 ? 0 : A[i-1] ) - ( i == N-1 ? 0 : A[i+1] ) );
        cout << sum - X[i] - X[i+1] + b << endl;
    }


    return 0;
}

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

int main() {
  int inputVal;
  cin >> inputVal;
  
  int hitCount = 0;
  for( int i=0; i<3; i++ )
  {
  	if( inputVal % 10 == 1 )
    {
    	hitCount++;
    }
    inputVal /= 10;
  }
  
  cout << hitCount << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>

using namespace std;

int main(){
    vector<string> da(3);
    for(int i=0;i<3;i++){
        cin >> da[i];
    }
    queue<char> a,b,c;
    vector<queue<char>> q={a,b,c};
    for(int i=0;i<3;i++){
        for(int j=0;j<da[i].size();j++){
            q[i].push(da[i][j]);
        }
    }
    int no=0;
    while(!q[no].empty()){
        char x=q[no].front();
        q[no].pop();
        no=x-'a';
    }
    char ans='A'+no;
    cout << ans << endl;
}

Measured memory_bytes: 256
#関数リスト
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def ruiseki(mydata):
    res = [0]*(len(mydata)+1)
    for i in range(len(mydata)):
        res[i+1] = res[i] + mydata[i]
    return res

n, k , m = MI()
a = ruiseki(LI())
b = ruiseki(LI())
a = a
b = b

result = 0
index = k
for i, ii in enumerate(a):
    if ii > m:
        break
    while b[index] + ii > m:
        index -= 1
    result = max(result, i+index)
print(result)

Measured memory_bytes: 113496
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
    }
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
            fn parse(s: &str) -> ($($t),*) {
                let mut tokens = s.split_whitespace();
                let t = ($($t::parse(tokens.next().unwrap())),*);
                t
            }
        }
    }
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let s : String = read();
    let mut cnt = 0;
    for c in s.chars() {
        if c == '1' {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}

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

using namespace std;

template< typename Semigroup >
struct DisjointSparseTable {
  using F = function< Semigroup(Semigroup, Semigroup) >;
  const F &f;
  vector< vector< Semigroup > > st;

  DisjointSparseTable(const vector< Semigroup > &v, const F &f) : f(f) {

    int b = 0;
    while((1 << b) <= v.size()) ++b;
    st.resize(b, vector< Semigroup >(v.size(), Semigroup()));
    for(int i = 0; i < v.size(); i++) st[0][i] = v[i];
    for(int i = 1; i < b; i++) {
      int shift = 1 << i;
      for(int j = 0; j < v.size(); j += shift << 1) {
        int t = min(j + shift, (int) v.size());
        st[i][t - 1] = v[t - 1];
        for(int k = t - 2; k >= j; k--) st[i][k] = f(v[k], st[i][k + 1]);
        if(v.size() <= t) break;
        st[i][t] = v[t];
        int r = min(t + shift, (int) v.size());
        for(int k = t + 1; k < r; k++) st[i][k] = f(st[i][k - 1], v[k]);
      }
    }
  }

  Semigroup query(int l, int r) {
    if(l >= --r) return st[0][l];
    int p = 31 - __builtin_clz(l ^ r);
    return f(st[p][l], st[p][r]);
  }
};

vector< bool > get_prime(int n) {
  vector< bool > prime(n + 1, true);

  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;

  for(int i = 2; i * i <= n; i++) {
    if(prime[i]) {
      for(int j = i + i; j <= n; j += i) prime[j] = false;
    }
  }

  return (prime);
}

int main() {
  auto table = get_prime(100001);

  int Q;
  cin >> Q;
  vector< int > v(100001);
  for(int i = 1; i < 100001; i += 2) {
    if(table[i] && table[(i + 1) / 2]) v[i]++;
  }
  DisjointSparseTable< int > beet(v, [&](int a, int b) { return a + b; });
  for(int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << beet.query(l, r + 1) << endl;
  }
}

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

const int inf = int (1e9) + 7;
const long long INF = 1e18;
const double eps = 1e-9;

using namespace std;
const int maxn = int(1e5) + 10;
int x[maxn], l[maxn];


inline bool check(int robotId, vector<int>& res){
	int last = res[res.size() - 1];
	if(x[last] + l[last] <= x[robotId] - l[robotId]){
		return true;
	}
	return false;
}

int main(){
	#ifdef nurik
	freopen ("in", "r", stdin);
	#endif

	ios_base::sync_with_stdio(0);

	int n;
	vector<pair<int, int>> pos;

	cin >> n;

	for(int i=1; i<=n; ++i){
		cin >> x[i] >> l[i];
		pos.push_back({x[i] + l[i], i});
	}

	sort(pos.begin(), pos.end());

	vector<int> res;
	for(auto i: pos){
		if(res.empty() || check(i.second, res)){
			res.push_back(i.second);
		}
	}

	cout << res.size();

	return 0;
}


Measured memory_bytes: 2676
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7


def power(x, y, z):
    if y == 0:
        return 1
    a = power(x, y // 2, z)
    a = (a * a) % z
    if y % 2 == 1:
        a = (a * x) % z
    return a


def choose(n, r, z):
    x = 1
    y = 1

    for i in range(min(r, n - r)):
        x = (x * (n - i)) % z
        y = (y * (i + 1)) % z

    y = power(y, z - 2, z)
    return (x * y) % z


ans = power(2, n, mod) - 1 - choose(n, a, mod) - choose(n, b, mod)
ans %= mod

print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>	
using namespace std;
int main() {
    int x[3],k;
    vector<vector<long>> a;
    a.assign(3,vector<long>());
    vector<long> answer;
    for (int i=0;i<3;i++){
        scanf("%d",&x[i]);
    }
    scanf("%d",&k);
    answer.reserve(k*2);
    for (int i=0;i<3;i++){
        a[i].reserve(x[i]);
        for (int j=0;j<x[i];j++){
            long tmp;
            scanf("%ld",&tmp);
            a[i].push_back(tmp);
        }
    }
    sort(a.begin(),a.end(),[](vector<long> v1, vector<long>v2) -> int { return ( v1.size() < v2.size() ); } );
    for (int i=0;i<3;i++){
        sort(a[i].begin(),a[i].end(),greater<long>());
    }
    int i0,i1,i2;
    long min = __LONG_MAX__;
    i0 = i1 = i2 = 0;
    while (i0 < a[0].size() ){
        long tmp = a[0][i0] + a[1][i1] + a[2][i2];
        if (answer.size() < k ) {
            if (tmp < min) {
                min = tmp;
            }
            answer.push_back(tmp);
            i2 ++;
        } else if (min < tmp ) {
            swap(*(min_element(answer.begin(),answer.end())),tmp);
            min = *(min_element(answer.begin(),answer.end()));
            i2 ++;
        } else {
            i2 = 0;
            i1 ++;
        }
        if (i2>=a[2].size()) {
            i2 = 0;
            i1 ++;
        }
        if (i1>=a[1].size()) {
            i1 = 0;
            i0 ++;
        }
    }
    sort(answer.begin(),answer.end(),greater<long>());
    for (int i=0;i<answer.size();i++){
        printf("%ld\n",answer[i]);
    }
}

Measured memory_bytes: 384
t = [int(input()) for i in range(5)] 
ugly = []
small = 10

total = 0
for i in t:
    remainder = i % 10
    if remainder != 0:
        ugly.append(i)
        if remainder < small:
            small = remainder
    else:
        total += i

last = True
for i in ugly:
    re = i % 10
    if re == small and last:
        total += i
        last = False
    else:
        total += i + 10 - re

print(total)

Measured memory_bytes: 3064
#include<iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

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


	if (N % 2 == 0)
	{
		cout << N/2*N/2 << endl;

		return 0;
	}
	else
	{
		cout << N/2 * (N/2+1) << endl;

		return 0;
	}

	


	


}



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

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define _shwv(v) for (auto _t1 : v) cerr << _t1 << " "; cerr << endl;
#define dbg(x) cerr << #x << ": " << (x) << endl;
#define dbgv(v) cerr << #v << ": "; _shwv(v);
#define dbgm(m) cerr << #m << ":" << endl; for (auto _t2 : m) { _shwv(_t2); }

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

template<typename T> inline void prt(T x) { cout << x << endl; }
template<typename T> inline void getv(T& v) { for (auto& t : v) cin >> t; }
template<typename T> inline int siz(T& x) { return x.size(); }
template<typename T> inline ll pow2(T n) { return 1ll << n; }
template<typename T, typename U> inline int bit(T x, U n) { return x >> n & 1; }
template<typename T, typename U>
inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }


int main() {
    while (true) {
        int n, m; cin >> n >> m;
        if (n == 0 && m == 0) break;
        vi c(m); getv(c);
        vi x(n); getv(x);
        vvi dp(n + 1, vi(256, INF));
        dp[0][128] = 0;
        rep(i, n) {
            rep(j, 256) {
                if (dp[i][j] == INF) continue;
                rep(k, m) {
                    int t = j + c[k];
                    if (t < 0) t = 0;
                    if (t > 255) t = 255;
                    umin(dp[i + 1][t], dp[i][j] + pow(x[i] - t, 2));
                }
            }
        }
        int ans = INF;
        rep(i, 256) umin(ans, dp[n][i]);
        prt(ans);
    }

    return 0;
}



Measured memory_bytes: 23696
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
//#define ordered_set         tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
/*

    order_of_key (k) : Number of items strictly smaller than k .
    find_by_order(k) : K-th element in a set (counting from zero).

*/
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 3e18;

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
signed main()
{
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        vi a(n);
        cin>>a;
        int ans=0;
        for(auto it:a)ans^=it;
        for(int i=0;i<n;i++)
        {
            cout<<(ans^a[i])<<" ";
        }
        cout<<endl;
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||

|| A year from now you may wish you had started today ||
*/



Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  vector<int> C(n);
  rep(i, n) {
    cin >> C[i];
    C[i]--;
  }
  vector<pair<int, int>> p(q);
  vector<int> id(q);
  rep(i, q) {
    cin >> p[i].first >> p[i].second;
    p[i].first--; p[i].second--;
    id[i] = i;
  }
  sort(all(id), [&](int i, int j) {
    return p[i].second < p[j].second;
  });
  vector<int> prev(n, -1);
  BinaryIndexedTree<int> bit(n);
  int j = 0;
  vector<int> ans(q);
  rep(i, n) {
    if(prev[C[i]] != -1) {
      bit.add(prev[C[i]], -1);
    }
    bit.add(i, 1);
    prev[C[i]] = i;
    while(j < q && p[id[j]].second == i) {
      ans[id[j]] = bit.sum(p[id[j]].second) - bit.sum(p[id[j]].first-1);
      j++;
    }
  }
  rep(i, q) cout << ans[i] << endk;
  return 0;
}


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

#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define endl "\n"

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep(i,n)      for(i = 0; i < n; i++)
#define repit(it,type)  for(auto it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

int main()
{
    IOS
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n,i,cnt=0;
    string s;

    cin>>n>>s;

    int l = 0,r = n-1;

    while(l < r)
    {
    	if(s[l]=='W' && s[r]=='R')
    	{
    		swap(s[l],s[r]);
    		l++,r--;
    		cnt++;
    	}
    	else if(s[l]=='W')
    		r--;
    	else
    		l++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3732
import java.util.Scanner;
import java.util.HashSet;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			int n = scan.nextInt();
			boolean[] isPrime = new boolean[n + 1];
			for (int i = 2; i <= n; i++) {
				isPrime[i] = true;
			}
			for (int i = 2; i <= n; i++) {
				if (!isPrime[i]) continue;
				for (int j = i * 2; j <= n; j += i) {
					isPrime[j] = false;
				}
			}
			int count = 0;
			for (int i = 2; i <= n; i++) {
				if (isPrime[i]) count++;
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 36148
import sys
N = int(input())
moji = "abcdefghijklmnopqrstuvwxyz"

if N == 1 :
  print("a")
  sys.exit()

num = 1
keta = 0

while num <= N :
  keta += 1
  pre_num = num
  num = num * 26 + 1
  
N = N - pre_num
ans_list = [0] * keta

for i in reversed(range(keta)):
  num = 26**i
  shou = N // num
  
  
  if shou == 0:
    next
  else:
    ans_list[keta - i - 1] += shou
    N = N % num

ans =""
for i in ans_list :
  ans = ans + moji[i]
  
print(ans)

Measured memory_bytes: 9048
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''


def main():
    N = int(input())
    A = list(map(int, input().split()))

    AA = set(A)
    if len(AA) == len(A):
        print("YES")
    else:
        print("NO")
        


if __name__ == '__main__':
    main()


Measured memory_bytes: 26808
<?php
/*プログラムのイメージ
--入力-----
5
3 8 7 5 5
-----------
2*3=a+b
2*8=b+c
2*7=c+d
2*5=d+e
2*5=e+a

2*3=a+(2*8-c)
2*3=a+(2*8-(2*7-d))
2*3=a+(2*8-(2*7-(2*5-e)))
2*3=a+(2*8-(2*7-(2*5-(2*5-a))))
a+a=(2*3)-(2*8-(2*7-(2*5-(2*5))))
2a=(2*3)-(2*8)+(2*7)-(2*5)+(2*5)
2a=6-16+14
a=2

e=(2*5)-a
e=8

d=(2*5)-e
d=2

c=(2*7)-d
c=12

b=(2*8)-c
b=4
*/
fscanf(STDIN,"%d",$N);
$lowA = fgets(STDIN);
$arrayA = explode(" ",$lowA);
$result = [];

//初期値設定
for($i=0;$i<$N;$i++){
  ${"mount".$i} = 0;
}

//ダム1に溜まった水計算
for($i=0;$i<$N;$i++){
  if($i%2===0){
    $mount0 += $arrayA[$i];
  }else{
    $mount0 -= $arrayA[$i];
  }
}
//最後のダムに溜まった水計算
${"mount".($N-1)} = 2*$arrayA[$N-1]-$mount0;
//上記以外のダムに溜まった水計算
for($i=$N-2;$i>0;$i--){
  ${"mount".($i)} = 2*$arrayA[$i]-${"mount".($i+1)};
}

for($i=0;$i<$N;$i++){
  $result[] = ${"mount".($i)};
}

echo implode(" ",$result);

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

int main() {
    double x1, x2, y1, y2;
    double dst;
    
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    
    dst = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
    dst = sqrt(dst);
    
    printf("%f\n", dst);
    return 0;
}



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String str = sc.next();
		
		if(str.substring(0, n/2).equals(str.substring(n/2))) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22740
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;

int main()
{
	ll x, y, i, ans;
	scanf("%lld %lld",&x, &y);
	for(ll i = 1; x <= y; i++)
	{
		x *= 2;
		ans = i;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 200010
char s1[N],s2[N];
int a[30],b[30];
int main()
{
    int i,j,k;
    scanf("%s%s",s1,s2);
    k=strlen(s1);
    for(i=0;i<k;i++)
    {
        j=s1[i]-'a';
        a[j]++;
    }
    k=strlen(s2);
    for(i=0;i<k;i++)
    {
        j=s2[i]-'a';
        b[j]++;
    }
    sort(a,a+30);
    sort(b,b+30);
    for(i=0;i<30;i++)
    if(a[i]!=b[i])
    {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
#ABC145 A

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

r = I()
print(r**2)

Measured memory_bytes: 38384
#include <iostream>
#include <math.h>
#include<iomanip>
#include <string>
using namespace std;

int main() {
    int N;
    cin >> N;
    int A[100];

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

    bool flag=1;
    int i = 0, x = 0;
    while(flag){
        flag = 0;
        for (int j=N-1;j>=i+1;j--){
            if (A[j]<A[j-1]){
                int v = A[j];
                A[j] = A[j-1];
                A[j-1] = v;
                flag = 1;
                x++;
            }
        }
        i++;
    }
    for (int k=0;k<N-1;k++){
        if (k == (N-1)) {
            break;
        }
        else {
            cout << A[k] << " ";
        }
    }
    cout << A[N-1] << endl;
    cout << x << endl;

//    for (int k=0;k<N-1;k++){
//        cout << A[k] << " ";
//    }
//    cout << A[N-1] << endl;
}

Measured memory_bytes: 3064
import java.util.*;
public class Main{
	static int count = 0 ;
	public static void main(String args[]){
		Scanner sc =new Scanner(System.in);
		int n = sc.nextInt();
		int[] nums  =new int[n];
		for(int i=0;i<n;i++){
			nums[i] = sc.nextInt();
		}
		bubbleSort(nums);
		for(int i=0;i<nums.length;i++){
			if(i>0) System.out.print(" ");
			System.out.print(nums[i]);
		}
		System.out.println();
		System.out.println(count);
	}
	public static void bubbleSort(int[] A){
		int N = A.length;
		for(int i=0;i<N;i++){
			for(int j=1;j<N-i;j++){
				if(A[j]<A[j-1]){
					count++;
					int t = A[j];
					A[j] = A[j-1];
					A[j-1] = t; 
				}
			}
		}
	}
}

Measured memory_bytes: 26252
Node,Path = map(int,input().split())
ad_mat = [[float('inf')]*Node for _ in range(Node)]
path_ls = [[0,0,0] for _ in range(Path)]
for i in range(Path):
    a,b,c = map(int,input().split())
    ad_mat[a-1][b-1] = c
    ad_mat[b-1][a-1] = c
    path_ls[i] = a-1,b-1,c
for i in range(Node):
    ad_mat[i][i] = 0

for stop in range(Node):
    for start in range(Node):
        for end in range(Node):
            ad_mat[start][end] = min(ad_mat[start][end],ad_mat[start][stop]+ad_mat[stop][end])

ans = 0
for a,b,cost in path_ls:
    if cost > ad_mat[a][b]:
        ans += 1
print(ans)

Measured memory_bytes: 74908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n,k;
	string s;
	cin>>n>>k>>s;
	ll lc=0,rc=0,num=0;
	for(int i=0;i<n;i++){
			if(s[i]=='L'){
				lc++;
				if(rc)num+=rc-1;
				rc=0;
			}else {
				rc++;
				if(lc)num+=lc-1;
				lc=0;
			}
	}
	if(s[n-1]=='L'&&lc)num+=lc-1;
	if(s[n-1]=='R'&&rc)num+=rc-1;
	cout<<min(n-1,num+2*k);
	return 0;
}


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

using namespace std;

int main()
{   char tmp[3] ;
    string s ;
    cin>> s ;
    int n = s.size() ;
    if (n==2){
        cout<<s ;
    } else
     {
        string tmp  ;
        while (n--){
            tmp.push_back(s[n]) ;
        }
        cout<<tmp ;
     }
    return 0;
}


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

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

int main(){
    string s;
    cin >> s;
    int N = 0, S = 0, E = 0, W = 0;
    for(auto c: s){
        if(c == 'N') N = 1;
        if(c == 'S') S = 1;
        if(c == 'E') E = 1;
        if(c == 'W') W = 1;
    }
    puts(N^S || E^W ? "No" : "Yes");
}

Measured memory_bytes: 256
N, M = map(int,input().split())
p = list(map(lambda x:int(x)-1,input().split()))
xy = [list(map(lambda x:int(x)-1,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n)] #親
        self.rank = [1]*n #深さ
        self.size = [1]*n #size[i]:=iを根とするグループのサイズ
    
    def find(self,x):
        if self.par[x] == x:
            return x
        else:
            return self.find(self.par[x])
            
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
                self.size[y] += self.size[x]
            else:
                self.par[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
                    
    def same(self,x,y):
        return self.find(x) == self.find(y)
        
    def group_size(self,x):
        return self.size[self.find(x)]

uf = UnionFind(N)
ans = 0
for x, y in xy:
    uf.unite(x,y)
for i in range(N):
    if uf.same(i,p[i]):
        ans += 1
print(ans)
    


Measured memory_bytes: 136940