akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;

namespace ALDS1_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            if (string.IsNullOrEmpty(input)) return;
            int N = int.Parse(input);
            int[] list = new int[N];

            input = Console.ReadLine();
            string[] num = input.Split(' ');
            for (int i = 0; i < N; i++)
            {
                list[i] = int.Parse(num[i]);
            }
            string output = ArrayJoin(list);
            Console.WriteLine(output);

            insertionSort(list, N);

        }

        public static void insertionSort(int[] a, int N)
        {
            int tmp = 0;
            int j = 0;

            for (int i = 1; i < N;i++)
            {
                tmp = a[i];
                j = i - 1;
                while (j >= 0 && a[j] > tmp)
                {
                    a[j + 1] = a[j];
                    j--;
                    a[j + 1] = tmp;
                }

                string output = ArrayJoin(a);
                Console.WriteLine(output);

            }
        }

        private static string ArrayJoin(int[] arr)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < arr.Length; i++)
            {
                if (sb.Length > 0)
                {
                    sb.Append(" ");
                }
                sb.Append(arr[i]);
            }
            return sb.ToString();
        }

    }
}

Measured memory_bytes: 9368
#include<stdio.h>
class solution {
private:
	int n;
	int dp[100005];
	int ar[100005];
	int abs(int x) {
		return x < 0 ? -x : x;
	}
	int min(int a, int b) {
		if (a < b) return a;
		return b;
	}
	int serc(int x) {
		if (x == n - 1) return 0;
		if (dp[x] != -1) return dp[x];
		dp[x] = abs(ar[x] - ar[x + 1]) + serc(x + 1);
		if (x + 2 <= n - 1) {
			dp[x] = min(dp[x], abs(ar[x] - ar[x + 2]) + serc(x + 2));
		}
		return dp[x];
	}
public:
	solution() {
		scanf("%d", &n);
		for (int i = 0; i < n; i++) {
			scanf("%d", &ar[i]);
			dp[i] = -1;
		}
		printf("%d\n", serc(0));
	}
};

#ifndef L0C4L
int main() {
	solution();
	return 0;
}
#endif

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

using namespace std;

const int infI=1e9+5;
const long long infL=1e18;
const int MOD=1e9+7;
const int MAX=1e5+5;

#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define vl vector<vector<ll> >
#define vi vector<vector<int> >
#define eb emplace_back
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back();
#define se second
#define fi first

int n,k;
int a[505];

int main(){
    fastio;
    cin>>n>>k;
    ll sum=0;
    forn(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    vector<int> f;
    forn(i,1,sqrt(sum)){
        if(sum%i==0){
            f.pb(i);
            f.pb(sum/i);
        }
    }
    ll ans=0;
    forn(i,0,f.size()){
        int a1=f[i];
        ll total=0,used=0;
        multiset<int> v;
        forn(i,0,n){
            v.insert(a[i]%a1);
            total+=(a1-a[i]%a1);
        }
        for(auto itr=v.begin();itr!=v.end();++itr){
            used+=*itr;
            total-=(a1-*itr);
            if(used==total && used<=k){
                ans=max(ans,(ll)a1);
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a,q;
 int s,d,f,g,y = 0;
  cin >> s >> d;
  for (int i= 0;i<d;i++){
    cin >> f >> g;
    a.push_back(f);
        q.push_back(g);
  }
  for(int j =0;j<s;j++){
  y=0;
    for(int i=0;i<d;i++){
    if(j+1 == a.at(i))
      y += 1;
    if(j+1 == q.at(i))
      y += 1;
    }
    cout << y << endl;
  }
}
    

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

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var q = long.Parse(Console.ReadLine());

        var sum = a.Sum();

        var results = new List<long>();

        var histgram = new Dictionary<long, long>();
        for (int i = 0; i < a.Length; i++)
        {
            if (!histgram.ContainsKey(a[i])) histgram[a[i]] = 0;
            histgram[a[i]]++;
        }

        for (int i= 0; i < q; i++)
        {
            var bc = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var b = bc[0];
            var c = bc[1];

            if (!histgram.ContainsKey(b))
            {
                results.Add(sum);
                continue;
            }

            var dis = c - b;
            sum += dis * histgram[b];

            results.Add(sum);

            var kazu = histgram[b];
            histgram[b] = 0;
            if (!histgram.ContainsKey(c)) histgram[c] = kazu;
            else histgram[c] += kazu;
        }

        foreach (var item in results) Console.WriteLine(item);

    }
}



Measured memory_bytes: 50544
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    map<char, int> mp;
    mp['M'] = 0; mp['A'] = 1; mp['R'] = 2; mp['C'] = 3; mp['H'] = 4;

    int N;
    cin >> N;
    string S;
    vector<ll> cnt(5, 0);
    for (int i = 0; i < N; i++) {
        cin >> S;
        if (mp.count(S[0]) == 0) continue;
        cnt[mp[S[0]]]++;
    }
    ll ans = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = i + 1; j < 4; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += cnt[i] * cnt[j] * cnt[k];
            }
        }
    }
    cout << ans << '\n';
}


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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    int n=s.size()+1;
    int a[n];
    for(int i=0;i<n;++i) a[i]=0;
    for(int i=0;i<(n-1);++i)
    {
        if(s[i]=='<')
        {
            a[i+1]=a[i]+1;
        }
    }
    for(int i=(n-1);i>=0;--i)
    {
        if(s[i]=='>')
        {
            a[i]=max(a[i],a[i+1]+1);
        }
    }
    int sum=0;
    for(int i=0;i<n;++i) sum+=a[i];
    cout<<sum;
    return 0;
}


Measured memory_bytes: 7684
#include<stdio.h>
#define SIZE10 100000

typedef long long int ll;
typedef unsigned char u8;

int i = 0, j = 0;

struct student{
    int mem;
    int time;
};

int partition(struct student *num, int start, int end, int p);
void quicksort(struct student *num, int start, int end);


int partition(struct student *num, int start,int end, int p){
    i = start, j = end;
    struct student temp;
    while(i <= j){
        while(i <= end && num[i].mem <= p){
            i++;
        }
        while(j >= start && num[j].mem > p){
            j--;
        }

        if(i > j){
            break;
        }

        temp = num[i];
        num[i] = num[j];
        num[j] = temp;

    }
    return i;
}


void quicksort(struct student *num, int start, int end){
    if(start == end){
        return ;
    }
    int p = num[start].mem;
    int flg = 0;
    int base = start;
    int k = 0;
    while(base <= end){
        if(num[base].mem < p){
            flg = 1;
            p = num[base].mem;
            break;
        }else if(num[base].mem > p){
            flg = 1;
            break;
        }
        base++;
    }

    if(flg == 1){
        k = partition(num, start, end, p);
        quicksort(num, start, k-1);
        quicksort(num, k, end);
    }
}

int main(void){
    int N = 0;
    int A[SIZE10];
    struct student std[SIZE10];

    scanf("%d", &N);

    for(i = 0; i < N; i++){
        scanf("%d", &A[i]);
        std[i].mem = A[i];
        std[i].time = i ;
    }

    quicksort(std, 0, N-1);

    for(i = 0; i < N-1; i++){
        printf("%d ", std[i].time+1);
    }
    printf("%d", std[N-1].time+1);

    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <vector>
using namespace std;


int main() {
  long long N, D;
  cin >> N >> D;

  vector<long long> X(N), Y(N);
  for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];

  long long d2;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    d2 = X[i] * X[i] + Y[i] * Y[i];
    if (d2 <= D * D) ans++;
  }
  cout << ans << endl;

  return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    cout<<lcm(a,b)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
H = list(map(int, input().split()))

COUNTS = []
count = 0
for i in range(n - 1):
    if H[i + 1] <= H[i]:
        count += 1
    else:
        COUNTS.append(count)
        count = 0
COUNTS.append(count)

answer = max(COUNTS)
print(answer)


Measured memory_bytes: 14224
n=int(input())
array=list(map(int,input().split()))
ans=1
if 0 in array:
  ans=0
else:
  for i in range(n):
    if ans>10**18:
      break
    else:
      ans=ans*array[i]
if ans>10**18:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 21668
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;
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; }

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


ll n, k;
ll h[110000];
ll dp[110000];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < 110000; i++) dp[i] = inf;

    dp[0] = 0;
    for(int i = 0; i < n; i++){
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }

    cout << dp[n-1] << endl;
    return 0;
}

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

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    vector<int> B(N);
    rep(i, N) cin >> A[i] >> B[i];
    vector<int> dp(H + 1, 100000007);

    rep(n, N) {
        int a = A[n];
        int b = B[n];
        rep(h, H + 1) {
            int tmpmin = b * ((h + a - 1) / a);
            dp[h]     = min(dp[h], dp[h - a] + b);
            dp[h]     = min(dp[h], tmpmin);
        }
    }
    cout << dp[H] << endl;
}

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

using namespace std;

typedef unsigned long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k, a, b;
  cin >> k >> a >> b;
  ll cur = 1;
  if (b > a && b - a > 2) {
    if (k >= abs(a - cur) + 2) {
      k -= abs(a - cur);
      cur = b;
      k -= 2;
      if (k > 0) {
        ll y = k / 2;
        cur += (y * b);
        cur -= (y * a);
        cur += (k % 2);
      }
    } else {
      cur += k;
    }
  } else {
    cur += k;
  }
  cout << cur << '\n';
  return 0;
}


Measured memory_bytes: 256
import bisect
import itertools
a,b,q = map(int,input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
INF = float("inf")
for x_ in x:
  ind_s = bisect.bisect_left(s,x_)
  ind_t = bisect.bisect_left(t,x_)
  s_l = s[ind_s-1] if ind_s > 0 else -INF
  s_r = s[ind_s] if ind_s < a else INF
  t_l = t[ind_t-1] if ind_t > 0 else -INF
  t_r = t[ind_t] if ind_t < b else INF
  ans = INF
  for s_ in [s_l,s_r]:
    for t_ in [t_l,t_r]:
      if abs(s_-x_)>abs(t_-x_):
        sub1,sub2 = t_,s_
      else:
        sub1,sub2 = s_,t_
      ans = min(ans,abs(sub1-x_)+abs(sub1-sub2))
  print(ans)
  
        
    

Measured memory_bytes: 16164
#include<iostream>
#include<cmath>
#define MAX 1000000

using namespace std;

bool prime[MAX+1];
int T[MAX];

void eratos( int n ){
    for ( int i = 0; i < n; i++ ) prime[i] = false;
    for ( int i = 3; i <= n; i += 2 ) prime[i] = true;
    prime[2] = true;
    for ( int i = 3, limit = (int)sqrt(n); i <= limit; i += 2 ) {
	if ( !prime[i] ) continue;
	for ( int j = i * i, k = i * 2; j <= n; j += k ) prime[j] = false;
    }
}

void initialize(){
    eratos( MAX );
    for ( int i = 0; i < MAX; i++ ){
	T[i] = T[i - 1];
	if ( prime[i] ) T[i]++;
    }
}

main(){
    initialize();
    int n;
    while ( cin >> n ) cout << T[n] << endl;
}

Measured memory_bytes: 0
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String str;
		str = br.readLine();
		for(int i=0;i<str.length(); i++){
			System.out.print(str.charAt(i));
			if(i==3){
				System.out.print(" ");
			}
		}
		System.out.println();
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(){
	int N,house[101];
	cin>>N;
	REP(i,N) cin>>house[i];

	SORT(house,N);

	printf("%d\n",house[N-1]-house[0]);

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,id,k;
typedef struct{
	int key;
	int parent;//???
	int lch;//????????????id
	int rch;//????????????id
}NODE;
NODE node[251];

int main(){
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >>node[i].key;
		if(i/2>0){
			node[i].parent=i/2;
		}else{
			node[i].parent=-1;
		}
		if(2*i<=n){
			node[i].lch=2*i;
		}else{
			node[i].lch=-1;
		}
		if(2*i+1<=n){
			node[i].rch=2*i+1;
		}else{
			node[i].rch=-1;
		}
	}
	
	for(int i=1;i<=n;i++){
		cout <<"node " <<i<<": ";
		cout <<"key = "<<node[i].key<<", ";
		if(node[i].parent!=-1)
			cout <<"parent key = "<<node[node[i].parent].key<<", ";
		if(node[i].lch!=-1)
			cout <<"left key = "<<node[node[i].lch].key<<", ";
		if(node[i].rch!=-1)
			cout <<"right key = "<<node[node[i].rch].key<<", ";
		cout << endl;
	}

}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

//B

void solve() {

}

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  vector<ll> vec_x, vec_y;
  vec_x.pb(a);
  REP(x,-10,11) if( a <= a + x && a + x <= b ) vec_x.pb(a+x);
  vec_x.pb(b);
  REP(x,-10,11) if( a <= b + x && b + x <= b ) vec_x.pb(b+x);

  vec_y.pb(c);
  REP(x,-10,11) if( c <= c + x && c + x <= d ) vec_y.pb(c+x);
  vec_y.pb(d);
  REP(x,-10,11) if( c <= d + x && d + x <= d ) vec_y.pb(d+x);
  
  ll maxi = b * d;
  rep(i,(int)vec_x.size()) {
    rep(j,(int)vec_y.size()) {
      maxi = max(maxi,vec_x[i]*vec_y[j]);
    }
  }
  
  cout << maxi << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n) {
        int ans = 0;
        vector<string> v(n);
        string s;
        for (int i = 0; i < n; ++i) {
            string t;
            cin >> t;
            s += t;
            v[i] = t;
        }
        sort(s.begin(), s.end());
        s.erase(unique(s.begin(), s.end()), s.end());
        vector<int> isreading(10, 0);
        vector<int> perm(10), val(10);
        for (int i = 0; i < n; ++i) {
            int vv = 1;
            for (int j = (int)v[i].size()-1; j >= 0; --j) {
                for (int k = 0; k < s.size(); ++k) {
                    if(v[i][j] == s[k]){
                        if(i == n-1) val[k] += vv;
                        else val[k] -= vv;
                        if(j == 0 && v[i].size() != 1) isreading[k] = 1;
                        break;
                    }
                }
                vv *= 10;
            }
        }
        iota(perm.begin(),perm.end(), 0);
        do {
            int sum = 0;
            for (int i = 0; i < 10; ++i) {
                if(perm[i] != 0) sum += perm[i]*val[i];
                else if(isreading[i]) sum = -INF<int>;
            }
            if(sum == 0) {
                ans++;
            }
        }while(next_permutation(perm.begin(),perm.end()));
        for (int i = 2; i <= 10-(int)s.size(); ++i) {
            ans /= i;
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3204
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception{
		Scanner scanner = new Scanner(System.in);
		int input1 = Integer.parseInt(scanner.next());
		int input2 = Integer.parseInt(scanner.next());
		int input3 = Integer.parseInt(scanner.next());
		int input4 = Integer.parseInt(scanner.next());
		int input5 = Integer.parseInt(scanner.next());
		
		if(input1 ==0) {
			System.out.println("1");
		}else if(input2 == 0) {
			System.out.println("2");
		}else if(input3 == 0) {
			System.out.println("3");
		}else if(input4 == 0) {
			System.out.println("4");
		}else if(input5 == 0) {
			System.out.println("5");
		}
		scanner.close();
	}
}


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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    vector<vector<int> > lis(s.size()+2, vector<int>(2, 0));
    REP(i, 0, s.size()){
        if(s[i] == '.'){
            lis[i+1][0] = lis[i][0]+1;
            lis[i+1][1] = lis[i][1];
        }else{
            lis[i+1][0] = lis[i][0];
            lis[i+1][1] = lis[i][1]+1;
        }
    }
    lis[s.size()+1] = lis[s.size()];
    int ans = 1e9;
    REP(i, 0, s.size()+1){
        int mid = lis[i][1] + (lis[s.size()+1][0] - lis[i][0]);
        ans = min(ans, mid);
    }
    cout << ans << endl;
}

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

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

  //ここから
  int animals;
  int legs;
  std::cin >> animals >> legs;

  if (legs % 2 == 0 && animals * 2 <= legs && animals * 4 >= legs)
    std::cout << "Yes";
  else
    std::cout << "No";
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007,INF=1001001001;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


//#define int ll

int n,t,x=0,mina,cnt=1;
int a[100010];

signed main(){
    cin>>n>>t;
    rep(i,0,n){
        cin>>a[i];
    }
    mina=a[0];
    
    rep(i,1,n){
        if(mina<a[i]){
            if(x==a[i]-mina)cnt++;
            x=max(x,a[i]-mina);
        }
        mina=min(mina,a[i]);
    }
    
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    unsigned long long int n,m;
    cin>>n>>m;
    if(m/2<=n){
        cout<<m/2;
    }
    else{
        unsigned long long int result=n;
        m-=2*n;
        result+=m/4;
        cout<<result;
    }
}

Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
const ll maxn = 1e5 + 10;
ll a[maxn];
ll n, k;
ll check(ll p) {
	ll i = 0;
	ll temp = 0, nk = k-1;
	for (i = 0; i < n; i++) {
		if (temp + a[i] <= p) {
			temp += a[i];
		}
		else if(nk>0&&a[i]<=p){
			temp = a[i];
			nk--;
		}
		else {
			return i;
		}
	}
	return i+1;
}
int main() {
//	freopen("input.txt", "r", stdin);
	scanf("%lld%lld", &n, &k);
	for (ll i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}
	ll l = 0, r = 1e9;
	while (l < r -1) {
		ll m =(r+l)/2;
		if (check(m) >= n) {
			r = m;
		}
		else {
			l = m;
		}
	}
	printf("%lld\n", r);
	return 0;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
//long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

void solve(string str, int cnt, int ns, int nn){
    if(cnt< nn){
        rep(i,ns){
            char c = 'a'+i;
            solve(str+c, cnt+1, ns,nn);
        }
        char d = 'a'+ns;
        solve(str+d, cnt+1, ns+1,nn);

    }else{
        cout << str << endl; 
    }
    
} 


int main(){
    int N;
    cin >> N;
    //char s='a'+1;
    //string st="";
    //st += s;
    //for(int i=1;i<(1 << (N))){
      //  st += s;
    //}
    solve("a",1,1,N);
    //cout << st << endl;
}


Measured memory_bytes: 1536
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,x;cin>>n>>x;
    ll ans=0;
    int a;cin>>a;
    if(a>x){
        ans+=a-x;
        a=x;
    }
    int prev=a;
    rep(i,n-1){
        cin>>a;
        if(a+prev>x){
            ans+=a+prev-x;
            prev=x-prev;
        }
        else prev=a;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
long long int inf = 1e18;

int main() {

  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  vector<long long int> b(n, 0);
  b[0] = a[0];
  for(int i=1; i<n; i++){
    b[i] = a[i];
    b[i] += b[i-1];
  }

  long long int ans = inf;
  for(int i=0; i<n-1; i++){
    long long int x = b[i];
    long long int y = b[n-1] - b[i];
    ans = min(abs(x-y), ans);
  }
  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 2560
import typing


class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        if self.parent_or_size[a] < 0:
            return a

        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))


def main() -> None:
    # https://atcoder.jp/contests/practice2/tasks/practice2_a
    import sys

    n, q = map(int, sys.stdin.readline().split())
    dsu = DSU(n)

    for _ in range(q):
        t, u, v = map(int, sys.stdin.readline().split())
        if t == 0:
            dsu.merge(u, v)
        if t == 1:
            if dsu.same(u, v):
                print(1)
            else:
                print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13192
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[100001];
int dfs(int l,int r,int suml,int sumr)
{
	if(l>r)return 0;
	int ans=1e18;
	for(int i=l;i<=r;i++)
		ans=min(ans,dfs(l,i-1,suml+sumr,sumr)+dfs(i+1,r,suml,suml+sumr)+a[i]*(suml+sumr));
	return ans;
}
signed main()
{
	int n;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	printf("%lld",dfs(2,n-1,1,1)+a[1]+a[n]);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>

#define rep(i, n) for (int i = 0; i < n; i++) 
#define rrep(i, n) for(int i = n-1; i>=0; i--)
#define range(i, n, m) for (int i = n; i < m; i++) 
#define rrange(i, n, m) for (int i = n - 1; i => m; i--) 
#define MOD 1000000007
#define MAX 20000000000

typedef long long int ll;
typedef unsigned long long int ull;


using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


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

	string S;
	cin >> S;

	ll c1, c2;
	c1 = c2 = 0;

	rep(i, S.size()) {
		if (i % 2 == 0) {
			if (S[i] != '0') c1++;
			if (S[i] != '1') c2++;
		}
		else{
			if (S[i] != '1') c1++;
			if (S[i] != '0') c2++;
		}
	}

	cout << min(c1, c2) << endl;


	
	return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {	
	static Map<Integer,List<Integer>> map;
	static int[] H;
	static int max = -1;
	private static void solve(){
		//Implement solution here.
		int N = ni();
		int M = ni();
		H = na(N);
		map = new HashMap<Integer, List<Integer>>();
		for(int i = 0; i < M; i++) addPath(ni(),ni());
		int result = 0;
		for(int i = 1; i <= N; i++) {
			if(!map.containsKey(i)) {
				result++;
			} else {
				boolean ok = true;
				for(int j = 0; j < map.get(i).size(); j++) {
					if(H[i - 1] <= H[map.get(i).get(j) - 1]) {
						ok = false;
						break;
					}
				}
				//if(ok)System.out.println(i + " " + H[i - 1] + " " + map.get(i));
				if(ok)result++;
			}			
		}
		System.out.println(result);
	}
	
	private static void addPath(int A, int B){
		if(!map.containsKey(A)) map.put(A, new ArrayList<Integer>());
		map.get(A).add(B);
		if(!map.containsKey(B)) map.put(B, new ArrayList<Integer>());
		map.get(B).add(A);
	}
	
	private static void rec() {
		
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 63000
import fractions
def gcdlist(a):
    ans = a[0]
    for i in range(1, len(a)):
        ans = fractions.gcd(ans, a[i])
    return ans

n,y=map(int,input().split())
x=list(map(int,input().split()))
x.append(y)
if y==1:
    print(abs(x[0]-1))
    exit()

l=[]
for i in range(n):
    l.append(abs(x[i+1]-x[i]))
print(gcdlist(l)) 




Measured memory_bytes: 90492
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element



//---------- 最大公約数 ----------
int gcd(int x, int y)
{
	int r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}



//----------最小公倍数----------
int lcm(int x, int y)
{
	return (x / gcd(x, y) * y);
}



signed main()
{
	int A, B;
	cin >> A >> B;
	cout << lcm(A, B) << endl;
}




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


int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N){
      cin >> A[i];
  }
  ll SUM = 0;//A[i]全ての和
  rep(i,N){
      SUM += A[i];
  }

  vector<ll> sum(N);//sum[i]はAのi番目までの和
  sum[0] = A[0];
  for(int i = 1;i<N-1;i++){
    sum[i] = sum[i-1] + A[i];
  }
  /*for(int i = 0;i<N-1;i++){
      cout << sum[i] << endl;
  }*/

  ll ans = 1000000000000;
  for(int i = 0;i<N-1;i++){
      ans = min(ans,abs(sum[i]-(SUM-sum[i])));
  }
  //cout << SUM << endl;
  cout << ans << endl;

}

Measured memory_bytes: 3328
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author koneko096
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    BBiteEating solver = new BBiteEating();
    solver.solve(1, in, out);
    out.close();
  }

  static class BBiteEating {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt(), l = in.nextInt();
      int L = l, R = l + n - 1;
      if (L <= 0 && 0 <= R) {
        out.println(sum(L, R));
      } else if (Math.abs(R) < Math.abs(L)) {
        out.println(sum(L, R - 1));
      } else if (Math.abs(L) < Math.abs(R)) {
        out.println(sum(L + 1, R));
      }
    }

    private int sum(int l, int r) {
      int n = r - l + 1;
      return n * (l + r) / 2;
    }

  }


  static class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

  }
}



Measured memory_bytes: 22740
n = int(input())
judges = [input() for s in range(n)]

ac = wa = tle = re = 0
for judge in judges:
  if (judge == "AC"):
    ac += 1
  elif (judge == "WA"):
    wa += 1
  elif (judge == "TLE"):
    tle += 1
  elif (judge == "RE"):
    re += 1

print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)

Measured memory_bytes: 16000
n, *a = $stdin.read.split.map(&:to_i)

h = Hash.new { 0 }

a.each do |x|
  h[x - 1] += 1
  h[x] += 1
  h[x + 1] += 1
end

freq = 0
h.each_value do |v|
  freq = v if freq < v
end

puts freq


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

int main(){
    int n, minv, maxv;
    cin >> n;
    int r[n];
    cin >> r[0];
    minv = r[0];
    maxv = -1000000000;
    for(int i=1; i<n; i++){
        cin >> r[i];
        maxv = max(r[i]-minv, maxv);
        minv = min(r[i], minv);
    }

    cout << maxv << endl; 
}


Measured memory_bytes: 3868
import java.util.Scanner;
import java.util.stream.Stream;

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

        int[] nums = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int a = nums[0];
        int b = nums[1];
        int t = nums[2];

        int cnt = t / a;
        System.out.println(cnt * b);
    }
}


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

int main(){
    long long int n,a,b;
    cin>>n>>a>>b;
    
    long long int t=n/(a+b);
    long long int ans,m=n%(a+b);

    if(m>=a){m=a;}
    
    ans=a*t+m;
    cout<<ans<<endl;
    }


Measured memory_bytes: 256
H = list(map(int, input().split()))
N = H[0]
M = H[1]
C = [0]*N
A = 0
W = [0]*N
w = 0
for i in range(M):
    X = input().split()
    if (C[int(X[0])-1]==0):
        if (X[1]=="AC"):
            C[int(X[0])-1]=1
            A += 1
        else:
            W[int(X[0])-1]+= 1

for i in range(N):
    if(C[i]==1):
        w+=W[i]
print(str(A)+" "+str(w))


Measured memory_bytes: 4724
#define  _CRT_SECURE_NO_WARNiINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <cassert>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define cycle_per_sec 2806192512
int main() {
	int n;
	cin >> n;
	vector<int> as;
	REP(i, n) {
		int a;
		cin >> a;
		as.push_back(a);
	}
	long long ans = n-1;
	for (int nowa = 0; nowa < 2; ++nowa) {
		vector<pair<int,int>> hogea;
		long long now_cnt = 0;
		for (int q = 0; q < as.size(); ++q) {
			hogea.push_back(make_pair(as[q], q));
		}
		sort(hogea.begin(), hogea.end());
		now_cnt = 1;
		for (int i = 1; i < hogea.size(); ++i) {
			if (hogea[i].second > hogea[i - 1].second) {
				now_cnt++;
				ans = min(ans, n - now_cnt);
			}
			else {
				now_cnt = 1;
			}
		}
		for (int q = 0; q < as.size(); ++q) {
			as[q] = n - as[q] + 1;
		}
		reverse(as.begin(), as.end());
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4692
#include <iostream>
#include <string.h>
using namespace std;
int main() {
	int K, N, l, i=0, tmp=0;
  	cin >> K >> N;
  	int  a[N-1], b[N-1];
  	//cout << "K=" << K << "N=" << N << endl;
    while(cin>>l){
        a[i] = l;
      	//cout << a[i] << endl;
        i++;
    }
  	for(i=0; i<N-1; i++){
      b[i] = a[i+1] - a[i];/*隣の家との距離をb[]に格納*/
      //cout << b[i] << endl;
    }
  	b[N-1] = K - a[N-1] + a[0];
	for(i=0; i<N; i++){
      if(b[i] >= tmp) tmp = b[i];
      //cout << "tmp" << tmp << endl;
    }
  	cout << K - tmp << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define MAX 1000001

void _main(){
    int out=0;
    int n; cin >> n;
    string s; cin >> s;
    for(int bi =0 ; bi < 1000 ; bi++){
        string ba = to_string(bi);
        while(ba.size()<3) ba.insert(0,"0");
        int flag=0;
        int bfiter=0;
        for(auto a: ba){
            auto iter = find(s.begin()+bfiter,s.end(),a);
            if(iter==s.end()) break;
            bfiter = iter-s.begin()+1;
            flag++;
        }
        if(flag==3) {
            out++;
        }
    }
    cout << out << endl;
    return;
}
int main() {
    cout << fixed << setprecision(10);
    _main();
    return 0;
}
    

Measured memory_bytes: 3244
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
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; }

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

int main(){
    string s; cin >> s;
    map<char, int> m;
    rep(i, s.size()){
        m[s[i]]++;
    }

    auto begin = m.begin(), end=m.end();
    int temp;
    bool flag=true;
    for(auto iter =  begin; iter != end; iter++){
        temp = iter->second;
        if(temp%2!=0){
            flag = false;
        }
    }

    if(flag){
        out("Yes");
    }
    else{
        out("No");
        }
}

Measured memory_bytes: 3592
A, B, C, X, Y = map(int, input().split())
s1 = A * X + B * Y
s2 = A * (X - min(X, Y)) + B * (Y - min(X, Y)) + C * 2 * min(X, Y)
s3 = C * 2 * max(X, Y)
print(min(s1, s2, s3))

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
	
	int H,W;
	int i,j;
	while(1)
	{
		scanf( "%d %d",&H, &W );
		
		if( H == 0 && W == 0 )
		{
			break;
		}
		
		for( i=0; i<H; i++ )
		{
			for( j=0; j<W; j++)
			{
				if(i>0&&i<H-1&&j>0&&j<W-1)
				{
					printf(".");
				}
				else{
					printf( "#" );
				}
			}
			printf( "\n" );
		}
		
		printf( "\n" );
	}
	
	return 0;
}


Measured memory_bytes: 2032
#include<iostream>
using namespace std;
int main(){
	int n,m,l;

	cin >> n >> m >> l;

	int A[n][m],B[m][l];
	long con[n][l];

	for(int i=0; i<n; i++){
		for(int k=0; k<l; k++){
			con[i][k] = 0;
		}
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> A[i][j];
		}
	}
	for(int j=0; j<m; j++){
		for(int k=0; k<l; k++){
			cin >> B[j][k];
		}
	}

	for(int i=0; i<n; i++){
		for(int k=0; k<l; k++){
			for(int j=0; j<m; j++){
				con[i][k] += A[i][j]*B[j][k];
			}

		}
	}

	for(int i=0; i<n; i++){
		for(int k=0; k<l; k++){
			if(k>0) cout << " ";
			cout << con[i][k];
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1312
// C.

#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>

using namespace std;

typedef pair<int, int> II;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	map<int, int> m;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		m[a] += 1;
	}
	int ans = 0;
	for (auto kv : m) {
		if (kv.first > kv.second) {
			ans += kv.second;
		} else if (kv.first < kv.second) {
			ans += kv.second - kv.first;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4736
S = STDIN.gets.chomp.split('')

arr = []

S.each_cons(3) {|str| arr.push(str.join('').to_i) }

mindiff = 10000
minnum = nil
arr.each do |i|
  diff = (753 - i).abs
  if diff < mindiff
    mindiff = diff
    minnum = i
  end
end

puts mindiff


Measured memory_bytes: 1788
/*
	Nishant Singh
	nishant.ns19
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 

// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********

// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// ******** Using PBDS ********

using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;

// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********

inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}

inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}

inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}

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

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

ll modinv(ll n)
{
	return modexp(n,mod-2);
}

// ******** GLOBAL VARIABLES ********

//ll n;
// ******** GLOBAL VARIABLES ********

void solve(){
	ll n,k;
	cin>>n>>k;
	ll p=abs(n-(k*(n/k)));
	ll q=abs(p-k);

	cout<<min(p,q);
}  
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

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

int ssort(int *A, int N) {
  auto cnt = 0;
  for (int i = 0; i < N; i++) {
    auto mini = i;
    for (int j = i + 1; j < N; j++) {
      if (A[mini] > A[j]) mini = j;
    }
    if (mini != i) {
      int temp;
      temp = A[i];
      A[i] = A[mini];
      A[mini] = temp;
      cnt++;
    }
  }
  return cnt;
}

int main(void) {
  int N, A[100];
  
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  
  auto cnt = ssort(A, N);
  
  for (int i = 0; i < N; i++) {
    if (i != 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << cnt << endl;
  
  return 0;
}

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

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> pur(N);
    for(auto &x:pur){
        cin>>x;
    }

    int minm=*min_element(pur.begin(),pur.end());

    int ans=pur[0];


    for(int i=1;i<N;++i){
        if(pur[i-1]>pur[i]){

        }else{
            ans+=(pur[i]-minm)-(pur[i-1]-minm);
        }
    }




    cout<<ans<<endl;

}

Measured memory_bytes: 256
# /Users/yusukeumemura/python/蟻本/p66_分割数.py と蟻本p66 を参考にした

# SのS//3分割
# ただし、数列なので組み合わせだけではなく順序も区別

S = int(input())
mod = 10 ** 9 + 7

# dp[i][j] = jのi分割の総数
dp = [[0] * (S + 1) for i in range(S // 3 + 1)]

dp[0][0] = 1
for i in range(1, S // 3 + 1):
    for j in range(S + 1):
        if j == 0 or j == 1 or j == 2:
            dp[i][j] = 0
        elif j == 3 or j == 4 or j == 5:
            dp[i][j] = 1
        else:
            dp[i][j] = (dp[i][j - 1] + dp[i - 1][j - 3]) % mod
        # print(i, j, dp[i][j])

ans = dp[S//3][S]
print(ans)


Measured memory_bytes: 60948