akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Stack;

public class Main {
    private static final Reader reader = new Reader();

    public static void main(String[] args) throws Exception{
        long n = reader.readLong();
        Stack<Character> stack = new Stack<>();
        while(n>0){
            n--;
            int dig = (int)(n%26);
            stack.add((char)('a'+dig));
            n/=26;
        }
        StringBuffer sb = new StringBuffer();
        while(!stack.isEmpty())
            sb.append(stack.pop());
        System.out.println(sb.toString());
    }


    private static class Reader{
        private final BufferedReader br;
        public Reader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public int readInt() throws Exception{
            return Integer.parseInt(br.readLine());
        }
        public long readLong() throws Exception {
            return Long.parseLong(br.readLine());
        }
        public double readDouble() throws Exception {
            return Double.parseDouble(br.readLine());
        }
        public String readLine() throws Exception{
            return br.readLine();
        }
        public int[] readIntArray() throws Exception{
            String[] tokens = br.readLine().split(" ");
            int[] nums = new int[tokens.length];
            for(int i=0;i<tokens.length;i++){
                nums[i] = Integer.parseInt(tokens[i]);
            }
            return nums;
        }
        public long[] readLongArray() throws Exception{
            String[] tokens = br.readLine().split(" ");
            long[] nums = new long[tokens.length];
            for(int i=0;i<tokens.length;i++){
                nums[i] = Long.parseLong(tokens[i]);
            }
            return nums;
        }
        public double[] readDoubleArray() throws Exception {
            String[] tokens = br.readLine().split(" ");
            double[] nums = new double[tokens.length];
            for(int i=0;i<tokens.length;i++){
                nums[i] = Double.parseDouble(tokens[i]);
            }
            return nums;
        }
        public String[] readWords() throws Exception {
            return br.readLine().split(" ");
        }
    }
}

Measured memory_bytes: 25412
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, m;
string s[105];
ll d[105][105][2];

int main()
{
    cin>>n>>m;
    for(ll i = 1; i <= n; i++)
    {
        cin>>s[i];
        s[i] = ' ' + s[i];
    }
    for(ll i = 0; i <= n; i++)
    {
        for(ll j = 0; j <= m; j++)
        {
            d[i][j][0] = d[i][j][1] = 4e18;
        }
    }
    d[0][1][0] = 0;
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= m; j++)
        {
            if(s[i][j] == '#') d[i][j][1] = min(min(d[i - 1][j][0] + 1, d[i - 1][j][1]), min(d[i][j - 1][0] + 1, d[i][j - 1][1]));
            else d[i][j][0] = min(min(d[i - 1][j][1], d[i - 1][j][0]), min(d[i][j - 1][1], d[i][j - 1][0]));
        }
    }
    cout<<min(d[n][m][0], d[n][m][1])<<endl;
    return 0;
}


Measured memory_bytes: 384
import itertools
from functools import reduce


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


k = int(input())
ans = 0
for abc in itertools.product([i for i in range(1, k+1)], repeat=3):
    ans += reduce(gcd, abc)

print(ans)


Measured memory_bytes: 75968
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin>>S;
  int Ncount=0;
  int Wcount=0;
  int Scount=0;
  int Ecount=0;
  bool Z=true;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='N'){
      Ncount++;
    }
    if(S.at(i)=='W'){
      Wcount++;
    }
    if(S.at(i)=='S'){
      Scount++;
    }
    if(S.at(i)=='E'){
      Ecount++;
    }
  }
  if(Ncount>0){
    if(Scount==0){
      Z=false;
    }
  }if(Wcount>0){
    if(Ecount==0){
      Z=false;
    }
  }
  if(Scount>0){
    if(Ncount==0){
      Z=false;
    }
  }
  if(Ecount>0){
    if(Wcount==0){
      Z=false;
    }
  }
  if(Z){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll A, B;
	ll tillA, tillB;

	cin >> A >> B;

	if (A % 2 == 0) tillA = 0;
	else tillA = A - 1;

	if ((B + 1) % 2 == 0) tillB = 0;
	else tillB = B;

	if (((A) / 2) % 2 != 0) tillA = tillA ^ 1;

	if (((B + 1) / 2) % 2 != 0) tillB = tillB ^ 1;

	cout << (tillB ^ tillA) << endl;

	return 0;
}


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

typedef long long LL;

int main()
{
    string S;
    cin >> S;
    LL N = S.length();
    LL counter = 0, result = 0;
    for (LL i = 0; i < N; ++i)
    {
        if (S[i] == 'B')
            counter++;
        else if (S[i] == 'W')
            result += counter;
    }

    cout << result;
    return 0;
}


Measured memory_bytes: 640
L = int(input())

t = L
c = 0
zf = []
endd = []

tc = 1
while t>0:
    g = t%2
    c+= g
    zf.append(g)
    t//=2
    tc*=2
    endd.append(t*tc)
while len(zf)<20:
    zf.append(0)
 

lastd = False
if L >= 2**19:
    lastd = True
en = 36+c
if lastd:
    en+=1
print(20, en  )

x = 1
t = L
for i in range(1,20):
    if zf[i-1] == 1:
        print(i, 20, endd[i-1])
    if (i!=19 or lastd):
        print(i, i+1, 0)
        print(i, i+1, x) 
    x*=2
    
        


Measured memory_bytes: 3064
//#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 1; i <= n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define END(s)          {cout<<s; return 0;}
#define CON(s)          {cout<<s; continue;}
#define BRE(s)          {cout<<s; break;}
#define pb              push_back
#define All(a)          a.begin(), a.end()  //with A in CAPITAL!!!
#define sz(a)           (int)a.size()
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool Read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool Write(int x){
	if(x >= 10) Write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

int n;
double p[3030];
double dp[3030][3030];
double ans = 0.0000000000;

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n;
	rep(i, n) cin >> p[i];
	memset(dp, 0.0000000000, sizeof(dp));
	dp[0][0] = 1.0000000000;
	rep(i, n){
		for(int j = 0; j <= i; j++){
			if(j) dp[i][j] += dp[i - 1][j - 1] * p[i];
			dp[i][j] += dp[i - 1][j] * (1 - p[i]);
		}
	}
	for(int j = n/2 + 1; j <= n; j++){
		ans += dp[n][j];
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 72064
#include<bits/stdc++.h>
 using namespace std;
bool istrue(int *arr,int n){
	int cnt=0;
	for(int i=0;i<n;i++){
       if(arr[i]%2==0)
       	cnt++;
	}
	if(cnt==n)
		return true;
	else
		return false;
}
 int main(){
 	int n;
 	cin>>n;
 	int arr[n];
 	for(int i=0;i<n;i++){
 		cin>>arr[i];
 	}
 	int ans=0;
  while(istrue(arr,n)){
  	for(int i=0;i<n;i++){
  		arr[i]=arr[i]/2;
  	}
  	ans++;
  }
cout<<ans<<"\n";
  return 0; 	
 }

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

using namespace std;

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int arr[100003];

int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);
	int n; scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &arr[i]);
	sort(arr, arr+n, greater<int>());
	int x = 0, mx = -1;
	for(int i = 1; i < n; i++)
	{
		if(min(arr[0]-arr[i],arr[i]) > mx)
		{
			x = arr[i];
			mx = min(arr[0]-arr[i],arr[i]);
		}
	}
	printf("%d %d\n", arr[0], x	);
}





Measured memory_bytes: 640
#include <cstdio>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a == 1){
        a = 14;
    }
    if(b == 1){
        b = 14;
    }
    if(a > b){
        printf("Alice\n");
    }else if(a < b){
        printf("Bob\n");
    }else{
        printf("Draw\n");
    }

    return 0;
}


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

int a[222222];
int main() {
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        scanf("%d", a + i + 1), (a[i + 1] += a[i] - 1) %= k;
    map<int, int> m;
    long r = 0;
    for(int i = 0; i <= n; i++) {
        r += m[a[i]]++;
        if(i - k + 1 >= 0)
            m[a[i - k + 1]]--;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 10368
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void main() {
    char a;
    scan(a);
    writeln('a' <= a && a <= 'z' ? 'a' : 'A');
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 2668
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdio>

const double EPSILON = 1e-10;

inline bool equals(double a, double b) {
    return std::fabs(a - b) < EPSILON;
}

struct Point {
    double x;
    double y;

    bool operator < (const Point& p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point& p) const {
        return equals(x, p.x) && equals(y, p.y);
    }
};

Point operator + (const Point& p1, const Point& p2) {
    return Point{p1.x + p2.x, p1.y + p2.y};
}

Point operator - (const Point& p1, const Point& p2) {
    return Point{p1.x - p2.x, p1.y - p2.y};
}

Point operator * (const Point& p1, double k) {
    return Point{p1.x * k, p1.y * k};
}

struct Segment {
    Point p1, p2;
};

struct Circle {
    Point center;
    double radius;
};

using Vector = Point;
using Line = Segment;
using Polygon = std::vector<Point>;


double norm(const Vector& p) {
    return p.x * p.x + p.y * p.y;
}

double abs(const Vector& p) {
    return std::sqrt(norm(p));
}

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}

Vector projection(const Segment& s, const Point p) {
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / norm(base);
    using namespace std;
    // cerr << "p: " << p.x << ", " << p.y;
    // cerr << " dot: " << dot(p - s.p1, base);
    // cerr << " norm: " << norm(base) << endl;
    return s.p1 + base * r;
}

int main() {
    using namespace std;

    Point p1, p2;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    Segment s{p1, p2};

    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        double x, y;
        cin >> x >> y;
        auto p = projection(s, Point{x, y});
        cout << setprecision(20) << p.x << " " << p.y << endl;
    }

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll sumofketa(ll a,ll b){
    string s=to_string(a),t=to_string(b);
    return max(s.size(),t.size());
}

int main(void)
{
    ll a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    ll ans1=100*a,ans2=0;
    double tmp=0;
    rep(i,31)rep(j,31){
        rep(k,101)rep(l,101){
            double w = 100 * (a*i + b*j), s = c*k + d*l;
            if(w==0) continue;
            if(w + s > f) break;
            if(s > e * (a*i + b*j)) break;
            if(s / (w + s) > tmp){
                tmp = s / (w + s);
                ans1 = w + s;
                ans2 = s;
            }
        }
    }
    cout << ans1 << " " << ans2 <<endl;
    return 0;
}

Measured memory_bytes: 3608
D,G=map(int,input().split())
# bit全探索で、全問解く問題の組み合わせをすべて試す
 
scores=[None]*D
for i in range(D):
  p,c=map(int,input().split())
  # 一問の得点、問題数、ボーナス、全てといたときの得点
  scores[i]=[(i+1)*100,p,c,((i+1)*100)*p+c]
 
# あとあとのために点数高い順に並べる
scores=sorted(scores,key=lambda x:x[0])[::-1]
 
# 全問とく組み合わせに対して、最小の問題数
ans=D*100
for i in range(2**D):
  total=0
  solve=0
  for j in range(D):
    if (i>>j)&1:
      # 全問とく問題のボーナスを足していく
      total+=scores[j][3]
      solve+=scores[j][1]
  if total>=G:
    if ans>solve:
      ans=solve
    continue
  rest=G-total
  for j in range(D):
    if (i>>j)&1==0:
      point=scores[j][0]
      num=scores[j][1]-1 # 全問とかないので1減らす
      if point*num<rest:
        rest-=point*num
        solve+=num
      else:
        solve+=(rest//point+(rest%point>0))
        rest=0
    if rest<=0 and ans>solve:
      ans=solve
  
print(ans)

Measured memory_bytes: 9240
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n, y;
    cin >> n >> y;
    bool f = false;
    REP(i, n+1) {
        REP(j, n+1-i) {
            if(10000*i+5000*j+1000*(n-i-j) == y) {
                cout << i << " " << j << " " << n-i-j << endl;
                f = true;
                break;
            }
        }
        if(f) break;
    }
    if(!f) cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
    int a, b, c, d;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);

    printf("%d\n", ((a < b) ? a : b) + ((c < d) ? c : d));
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <cstdlib>


namespace vector {
  template<typename T, size_t dcap = 16ULL>
  class vec {
    size_t sz;
    size_t cap;
    T* a;
  public:
    vec() : sz(0), cap(dcap) {
      a = (T*)std::malloc(sizeof(T) * cap);
    }
    vec(size_t n) : sz(n), cap(dcap) {
      while (cap < sz) cap <<= 1;
      a = (T*)std::malloc(sizeof(T) * cap);
    }
    vec(size_t n, T v) : sz(n), cap(dcap) {
      while (cap < sz) cap <<= 1;
      a = (T*)std::malloc(sizeof(T) * cap);
      for (size_t i = 0; i < sz; i++) {
        a[i] = v;
      }
    }
    T& operator[](size_t i) {
      return a[i];
    }
    size_t size() const {
      return sz;
    }
    void output(std::ostream& out, char delim = ' ') const {
      for (size_t i = 0; i < sz; i++) {
        if (i) out << delim;
        out << a[i];
      }
    }
    friend std::ostream& operator<<(std::ostream& out, const vec& v) {
      v.output(out);
      return out;
    }
    void input(std::istream& in) {
      for (size_t i = 0; i < sz; i++) {
        in >> a[i];
      }
    }
    friend std::istream& operator>>(std::istream& in, vec& v) {
      v.input(in);
      return in;
    }
    ~vec() {
      std::free(a);
    }
  };
}

namespace algorithm {
  template<typename T>
  void insertion_sort(vector::vec<T>& v, bool verbose = false) {
    for (int i = 0, n = v.size(); i < n; i++) {
      int x = v[i], j;
      for (j = i - 1; j >= 0 && v[j] > x; j--) {
        v[j + 1] = v[j];
      }
      v[j + 1] = x;
      if (verbose) std::cout << v << std::endl;
    }
  }
  template<typename T>
  size_t bubble_sort(vector::vec<T>& v) {
    size_t cnt = 0;
    int n = v.size();
    for (int i = 0; i < n - 1; i++) {
      for (int j = n - 1; j > i; j--) {
        if (v[j] < v[j - 1]) {
          T t = v[j - 1];
          v[j - 1] = v[j];
          v[j] = t;
          cnt++;
        }
      }
    }
    return cnt;
  }
}

int main() {
  using namespace vector;
  using namespace algorithm;

  int N;
  std::cin >> N;

  vec<int> A(N);
  std::cin >> A;

  size_t cnt = bubble_sort(A);
  std::cout << A << std::endl << cnt << std::endl;
  
  return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <algorithm>

using namespace std;

int bt[1<<18], n, sz=1;

void maketree(int l, int r) {
	if(l+1==r) return;
	for(int i=l;i<r;i+=2) {
		bt[i/2]=max(bt[i],bt[i+1]);
	}
	maketree(l/2,r/2);
}

int f(int l, int r, int s) {
	if(l>=r) return l==r?max(s,bt[l]):s;
	if(l%2==0 && r%2) return f(l/2,r/2,s);
	else if(l%2==0 && r%2==0) return f(l/2,r/2-1,max(s,bt[r]));
	else if(l%2 && r%2) return f(l/2+1,r/2,max(s,bt[l]));
	else return f(l/2+1,r/2-1,max(s,max(bt[l],bt[r])));
}

int main() {
	int t;
	scanf("%d %d",&n,&t);
	while(sz<n) sz*=2;
	for(int i=sz;i<sz+n;i++)
		scanf("%d",&bt[i]);
	maketree(sz,sz*2);
	int res=0, mx=0;
	for(int i=0;i<n;i++) {
		int u=bt[sz+i], v=f(sz+i+1,sz+n-1,0);
		if(u>=v) continue;
		if(mx==v-u) res++;
		else if(mx<v-u) {
			mx=v-u; res=1;
		}
	}
	printf("%d",res);
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n, m;
	cin >> n >> m;
	if (m == 0) {
		return cout << (n == 1 ? 0 : pow(10,n-1)) << endl,0;
	}
	vector<ll>s(m), c(m);
	rep(i, m)cin >> s[i] >> c[i];
	for (ll ans = (n == 1 ? 0 : pow(10,n-1)); ans <= 999;ans++) {
		string tmpS = to_string(ans);
		bool flag = true;
		for (ll i = 0; i < m; i++) {
			if (tmpS[s[i] - 1] != '0' + c[i])flag = false;
		}
		if (flag == true)return cout << ans << endl,0;
	}
	cout << -1 << endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vl a(3 * n);
    for (int i = 0; i < 3 * n; ++i) {
        cin >> a[i];
    }
    priority_queue<ll, vl, greater<ll>> pq1;
    priority_queue<ll> pq2;
    deque<ll> frontSum;
    deque<ll> backSum;
    frontSum.push_back(0);
    backSum.push_back(0);
    for (int i = 0; i < n; ++i) {
        pq1.push(a[i]);
        frontSum.front() += a[i];
    }
    for (int i = 3 * n - 1; i >= 2 * n; --i) {
        pq2.push(a[i]);
        backSum.front() += a[i];
    }
    for (int i = n; i < 2 * n; ++i) {
        ll currSum = frontSum.back();
        pq1.push(a[i]);
        ll mini = pq1.top();
        pq1.pop();
        frontSum.push_back(currSum + a[i] - mini);
    }
    for (int i = 2 * n - 1; i >= n; --i) {
        ll currSum = backSum.front();
        pq2.push(a[i]);
        ll maxi = pq2.top();
        pq2.pop();
        backSum.push_front(currSum + a[i] - maxi);
    }
    ll ret = -INF;
    for (int i = 0; i <= n; ++i) {
        chmax(ret, frontSum[i] - backSum[i]);
    }
    cout << ret << "\n";

    return 0;
}

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

int main() {
	int n; cin >> n;
	vector<vector<int>>  a(2, vector<int>(n));
	rep(i, 0, 2) rep(j, 0, n) cin >> a[i][j];

	int ans = 0;
	rep(i, 0, n) {
		int ame = 0;
		rep(j, 0, i + 1) {
			ame += a[0][j];
		}
		rep(j, i, n) {
			ame += a[1][j];
		}
		ans = max(ans, ame);
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from sys import stdin

def f(n,m):
     a = [int(x) for x in stdin.readline().split()]
     min_a = min(a)
     a = [(1,i) for i in a]
     b_c = [tuple(map(int,x.split())) for x in stdin.readlines()]
     a += b_c
     a.sort(key=lambda x:x[1])
     ans = 0
     while True:
          if n>a[-1][0]:
               ans += a[-1][0]*a[-1][1]
               n -= a[-1][0]
               a.pop()
          else:
               ans += a[-1][1]*n
               break
     print(ans)

n,m = [int(x) for x in stdin.readline().split()]
f(n,m)

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

using namespace std;
typedef long long ll;
typedef long double ld;

int n;
int main()
{ 
    ios_base::sync_with_stdio(0); cin.tie(0);

    vector<int>v[4];

    v[1] = {2, 4, 5, 7, 9};
    v[2] = {0, 1, 6, 8};
    v[3] = {3};
    vector<string> sol= {"", "hon", "pon", "bon"};
    cin >> n;
    n = n %10;
    for(int i = 1; i <= 3; i++)
    {
        for(int j : v[i]){
            if(j == n){
                cout << sol[i];
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3636
n,m = map(int,input().split())
g = [[] for _ in range(n)] 
 
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)
 
from collections import deque
 
def bfs(u):
    queue = deque([u])
    d = [None] * n 
    d[u] = 0 
    l = [[] for _ in range(n)] 
    dic = {}
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                queue.append(i)
                l[i].append(v)
                dic[i] = v
    return d,l,dic
d,l,dic = bfs(0)
if None in d:
    print("No")
else:
    print("Yes")
    l.remove(l[0])
    [print(i[0]+1) for i in l]

Measured memory_bytes: 50996
#include <stdio.h>
 
int main(){
  int a, b, c;
  while(scanf("%d%d%d", &a, &b, &c) && (a != -1 || b != -1 || c != -1)){
    if(a < 0 || b < 0) puts("F");
    else if(a + b >= 80) puts("A");
    else if(a + b >= 65) puts("B");
    else if(a + b >= 50 || c >= 50) puts("C");
    else if(a + b >= 30) puts("D");
    else puts("F");
  }
  return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <iterator>
#include <list>
#include <unordered_map>
#include <string>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
	int k, s, ans = 0;
	cin >> k >> s;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if (0 <= z && z <= k) {
				ans++;
			}
		}
	}
	cout << ans;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


void Main()
{
    int n;cin>>n;

    vector<pair<LL,int>> a(n);


    REP(i,n){
        cin>>a[i].first;
        a[i].second = i;
    }

    SORT_DESC(a);

    vector<vector<LL>> happy(n+100);
    REP(i,n+100){
        happy[i].resize(n+100);
    }

    REP(i,n){
        //dump(i)
        REP(left,i+1){
            int right = i-left;
            //dump(left)
            //dump(right)

            LL d0 = a[i].first*abs(a[i].second - (n-1-right));

            happy[i+1][left] = max(happy[i+1][left], happy[i][left] + d0);

            LL d1 = a[i].first*abs(a[i].second - left);
            happy[i+1][left+1] = max(happy[i+1][left+1], happy[i][left] + d1);
        }
    }

    /*
    REP(i,n){
        REP(j,i+1){
            cerr<<happy[i][j] << " ";
        }
        cerr<<endl;
    }
    */

    LL result = 0;
    REP(i,n+1){
        result = max(result, happy[n][i]);
    }
    cout<<result<<endl;


    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n,a,b;cin>>n>>a>>b;
    ll res;
    if((b-a) % 2 == 0){
        res = min(n-a,b-1);
        res = min(res,(b-a)/2);
    }
    else res = min(a-1+1,n-b+1) + (b-a-1)/2;
    out(res);
}


Measured memory_bytes: 256
N = int(input())
reds = [tuple(map(int, input().strip().split())) for _ in range(N)]
blues = [tuple(map(int, input().strip().split())) for _ in range(N)]
redset = set()
for b in sorted(blues, key=lambda x: x[0]):
  for r in sorted(reds, key=lambda x: -x[1]):
    if r not in redset and b[0] > r[0] and b[1] > r[1]:
      redset.add(r)
      break
print(len(redset))


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

  string s1, s2;

  cin >> s1 >> s2;

  ll sum = 0;
  FOR(i, 0, 3){
    if(s1.at(i) == s2.at(i)){
      sum++;
    }
  }

  cout << sum << endl;

}


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

using namespace std;
#define int long long
#define maxn 666666
int n,m;
int arr[maxn];
signed main(){
	int s=0;int w=0;
	cin>>n>>m;for(int i=1;i<=n;i++) cin>>arr[i],s+=arr[i];
	for(int i=1;i<=n;i++){
		if(4*m*arr[i]>=s){
			w++;
		}
	}
	if(w>=m) cout<<"Yes";else cout<<"No";
	return 0;
}

/*
3
1 3 4
6 7 9
1 1 2 3

*/

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long a, b, c, d;
    scan(a, b, c, d);
    max(a * c, b * c, a * d, b * d).writeln();
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
#define MAX 1000000
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n, ll k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modpow(ll a, ll n, ll mod = MOD) {
    ll res = 1;
    while(n > 0) {
        if(n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    ll n, m;
    cin >> n >> m;
    COMinit();
    ll ans = 0;
    for(ll k = 0; k <= n; k++) {
        ll sub = COM(n, k) % MOD;
        sub = sub * COM(m, k) % MOD;
        sub = sub * fac[k] % MOD;
        ll tmp = COM(m - k, n - k) * fac[n - k] % MOD;
        tmp = tmp * tmp % MOD;
        sub = sub * tmp % MOD;
        if(k % 2) {
            ans -= sub;
        } else {
            ans += sub;
        }
        ans = (ans + MOD) % MOD;
    }
    cout << ans << endl;
}

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

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

  int N;
  cin >> N;
  vector<int> A(N);
  int min = 999999999;
  int mini = 0;
  int count = 0;
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (abs(A.at(i)) < min) {
      min = abs(A.at(i));
    }
    if (A.at(i) < 0) {
      count++;
    }
    sum += abs(A.at(i));
  }
  if (count % 2 == 1) {
    sum -= 2 * abs(min);
  }
  cout << sum << endl;
}

Measured memory_bytes: 640
class abc_158:
    
    def __init__(self):
        pass
    
    def A(self):
        S=input()
        if "BA" in S or "AB" in S:print("Yes")
        else:print("No")
    
    def B(self):
        NAB=list(map(int,input().split()))
        
        if NAB[0]<=NAB[1]:ans=NAB[0]
        elif NAB[0]<=NAB[1]+NAB[2]:ans=NAB[1]
        else:
            tail = NAB[0]%(NAB[1]+NAB[2]) if NAB[0]%(NAB[1]+NAB[2])<NAB[1] else NAB[1]
            ans=(int(NAB[0]/(NAB[1]+NAB[2]))*NAB[1])+tail
            
        print(int(ans))
            
    def C(self):
        AB=list(map(int,input().split()))
        ans=-1
        
        #A<B<100
        for i in range(1,1001):
            if AB[0]==int(i*0.08) and AB[1]==int(i*0.1):
                ans=i
                break
            else:continue
        print(ans)
            
    def D(self):
        pass
        
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_158()
    obj.B()

Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
const int MAX=50;
//ここまでテンプレ
int main(){
	int N,M;
	cin>>N>>M;
	//辺の情報
	vll s,t,c;
	//最短距離
	vll dist;
	//最短距離を初期化する
	//すべてにINFを入れたあと、始点のみ0に
	for(int i=0;i<N;i++){
		dist.pb(INFLL);
	}
	dist[0]=0;
	for(int i=0;i<M;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		x--,y--;
		s.pb(x);
		t.pb(y);
		c.pb(-z);
	}
	//最短距離の更新をN-1回する
	for(int loop=0;loop<N-1;loop++){
		for(int i=0;i<M;i++){
			if(dist[s[i]]==INFLL)
				continue;
			if(dist[t[i]]>dist[s[i]]+c[i]){
				dist[t[i]]=dist[s[i]]+c[i];
			}
		}
	}
	ll ans=dist[N-1];
	//負の閉路を検出するための配列
	vector<bool> negative;
	for(int i=0;i<N;i++){
		negative.pb(0);
	}
	//最短距離の更新をN回繰り返す
	//ここで更新されるということは閉路があるということだから
	//更新された頂点のnegativeをtrueに
	for(int loop=0;loop<N;loop++){
		for(int i=0;i<M;i++){
			if(dist[s[i]]==INFLL)
				continue;
			if(dist[t[i]]>dist[s[i]]+c[i]){
				dist[t[i]]=dist[s[i]]+c[i];
				negative[t[i]]=1;
			}
			if(negative[s[i]]==1){
				negative[t[i]]=1;
			}
		}
	}
	if(negative[N-1])
		cout<<"inf"<<endl;
	else
		cout<<-ans<<endl;
	return 0;
}

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

#define rin(i,a,b) for(int i=(a);i<=(b);++i)
#define irin(i,a,b) for(int i=(a);i>=(b);--i)
#define trav(i,a) for(int i=head[a];i;i=e[i].nxt)
#define Size(a) (int)a.size()
#define pb push_back
#define mkpr std::make_pair
#define fi first
#define se second
#define lowbit(a) ((a)&(-(a)))
typedef long long LL;

using std::cerr;
using std::endl;

inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=200005;

int n;
LL ans;
char s[MAXN];
std::vector<int> a;

void solve(){
	int cnt=0;
	rin(i,0,Size(a)-1){
		if(a[i]==1)++cnt;
		else ans+=cnt;
	}
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	rin(i,1,n){
		if(s[i]=='A')a.pb(1);
		else if(s[i]=='B'&&s[i+1]=='C')a.pb(0);
		else if(s[i]=='C'&&s[i-1]=='B')continue;
		else{solve();a.clear();}
	}
	solve();
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1528
s = gets.chomp.split("")
k = gets.chomp.to_i

substr = []
1.upto(s.length) do |n|
  break if n > k
  a = []
  s.each_cons(n) do |ss|
    a << ss.join("")
  end
  a.uniq!
  substr += a
end
substr.sort!

puts substr[k-1]

Measured memory_bytes: 7036
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repb(i,n) for(ll i=(n-1);i>=0;i--)
#define all(a) a.begin(),a.end()
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void d(){
    ll n; cin >> n;
    string s; cin >> s;
    ll c = 0;
    ll cc = 0;
    rep(i,n){
        if(s[i]=='('){
            c++;
        }else{
            if(c>0) c--;
        }
    }
    repb(i,n){
        if(s[i]==')'){
            cc++;
        }else{
            if(cc>0)cc--;
        }
    }
    rep(i,c){
        s+=')';
    }
    rep(i,cc){
        s= '('+s;
    }
    cout << s << endl;
}

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

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  
  int n = s.size();
  
  vector<int> a(26,0);
  
  REP(i,n){
    REP(j,26){
      if(j + 'a' == s[i]){
        a[j]++;
      }
    }
  }
  
  bool can = true;
  REP(i,26) {
    if(a[i] % 2 != 0){
      can = false;
    }
  }
  
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;



}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
using namespace std;

constexpr int N = 20;
constexpr int MAX_L = 1000000;
constexpr int K = 13;
vector<tuple<int, int, int> > solve(int l) {
    vector<int> e(K + 1);
    e[0] = 1;
    REP (k, K) e[k + 1] = 3 * e[k];
    assert (e[K - 1] < MAX_L and MAX_L < e[K]);

    assert (l <= MAX_L);
    vector<int> trits;
    for (int acc = l; acc; acc /= 3) {
        trits.push_back(acc % 3);
    }

    vector<tuple<int, int, int> > edges;
    REP (k, (int)trits.size() - 1) {
        edges.emplace_back(N - k - 2, N - k - 1, 0);
        edges.emplace_back(N - k - 2, N - k - 1, e[k]);
        edges.emplace_back(N - k - 2, N - k - 1, 2 * e[k]);
    }
    int acc = 0;
    REP_R (k, trits.size()) {
        if (trits[k] == 1) {
            edges.emplace_back(0, N - k - 1, acc);
        } else if (trits[k] == 2) {
            edges.emplace_back(0, N - k - 1, acc);
            edges.emplace_back(0, N - k - 1, acc + e[k]);
        }
        acc += trits[k] * e[k];
    }

    array<bitset<MAX_L>, N> dp = {};
    dp[0][0] = true;
    REP (i, N - 1) {
        for (auto edge : edges) {
            int u, v, w; tie(u, v, w) = edge;
            if (u != i) continue;
            assert (dp[u].count() == (dp[u] << w).count());
            assert ((dp[v] & (dp[u] << w)).none());
            dp[v] |= dp[u] << w;
        }
    }
    assert (dp[N - 1].count() == l and (dp[N - 1] >> l).none());
    assert (edges.size() <= 60);
    return edges;
}

int main() {
    int l; cin >> l;
    auto edges = solve(l);
    cout << N << ' ' << edges.size() << endl;
    for (auto edge : edges) {
        int u, v, w; tie(u, v, w) = edge;
        cout << u + 1 << ' ' << v + 1 << ' ' << w << endl;
    }
    return 0;
}


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

namespace ABC117
{
    class Points
    {
        public int min, max;
    }

    class C
    {
        static void Main(string[] args)
        {
            List<int> a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            int N = a[0], M = a[1];
            List<int> X = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            X.Sort();

            List<long> d = new List<long>();
            for (int i = 0; i < X.Count - 1; i++)
            {
                d.Add(X[i + 1] - X[i]);
            }

            d.Sort();

            int numt = Math.Max(M - N, 0);
            long sum = d.Take(numt).Sum();
            Console.WriteLine(sum);
        }

    }
}


Measured memory_bytes: 20960
//be name khoda
#include<bits/stdc++.h>

typedef long long ll;
typedef long double ld;

using namespace std;

const ll INF = 1e18;
const ll maxn = 5e3+10;
const ll mod = 1e9+7;

ll n , m , k;
ll dp[maxn][maxn], a[maxn];

int main()
{
    cin>> n;
    for(ll i = 1; i <= n; i++) cin>>  a[i];

    for(ll t = 1; t <= n; t++)
        for(ll l = 1; l+t-1 <= n; l++)
        {
            ll r = l+t-1;
            if(t == 1){
                dp[l][r] = a[l];
                continue;
            }

            dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
        }
    cout<< dp[1][n];
}










Measured memory_bytes: 118400
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;


signed main(){
    int ans = max_int * -1;
    int mini;
    cin >> n >> mini;
    n--;
    REP(i,n){
        int t;
        cin >> t;
        ans = max(ans,t-mini);
        mini = min(mini,t);
    }
    print(ans);
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}





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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W,D,Q;
int A[303][303];
int dist[90909];

int DD[90909];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>D;
	FOR(y,H) FOR(x,W) {
		cin>>A[y][x];
		DD[A[y][x]]=y*300+x;
	}
	for(i=1;i<=H*W;i++) {
		if(i+D>H*W) break;
		int cy=DD[i+D]/300;
		int cx=DD[i+D]%300;
		y=DD[i]/300;
		x=DD[i]%300;
		dist[i+D]=dist[i]+abs(y-cy)+abs(x-cx);
	}
	
	cin>>Q;
	int L,R;
	FOR(i,Q) {
		cin>>L>>R;
		cout<<dist[R]-dist[L]<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    String ans = "No";

    for(int i = 0; i <= T.length(); i++){
      if(S.equals(T)){
        ans = "Yes";
        break;
      }
      S = S.substring(S.length() - 1) + S.substring(0, S.length() - 1); //endIndexで指定したインデックスの文字は切り出しに含まれないことに注意
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21460
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
using namespace std;

int n;
int a,b;
int aa,bb;
int ares,bres;
int main(void){
	scanf("%d",&n);
	scanf("%d%d",&a,&b);
	scanf("%d%d",&aa,&bb);
	ares=a/aa;
	if(a%aa>0)ares++;
	bres=b/bb;
	if(b%bb>0)bres++;
	ares=n-ares;
	bres=n-bres;
	printf("%d\n",min(ares,bres));
	return 0;
}

Measured memory_bytes: 1188
a,b,k=map(int,input().split())
a_list=list(range(1,a+1))
b_list=list(range(1,b+1))
a1=[]
b1=[]
for i in a_list:
    if a%i==0:
        a1.append(i)
for i in b_list:
    if b%i==0:
        b1.append(i)
a_b=set(a1)&set(b1)
a_blist=list(a_b)
a_blist.sort()
print(a_blist[-k])

Measured memory_bytes: 3064