akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

struct D { int t; bool ex; int p; };

int main()
{
	int n;
	while (cin >> n, n)
	{
		vector<D> v;
		REP(i, n)
		{
			int mon, day, h, m; char io; int p;
			scanf("%d/%d %d:%d", &mon, &day, &h, &m);
			cin >> io >> p;
			int t = m + h * 60 + day * 1440 + mon * 1440 * 31;
			v.emplace_back(D{ t,(io=='I'),p });
		}
		vector<bool> f(1000);
		vi ans(1000);
		int t = v[0].t;
		f[v[0].p] = v[0].ex;
		FOR(i, 1, n)
		{
			int res = v[i].t - t;
			FOR(j, 1, 1000)
			{
				if (f[0]&&f[j]) ans[j] += res;
			}
			t = v[i].t;
			f[v[i].p] = v[i].ex;
		}
		cout << *max_element(ALL(ans)) << endl;
	}
	return 0;
}

Measured memory_bytes: 3212
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
#define mx 100000
char ar[mx+2];
int main(){

    int n,m;
    I2(n,m);
    scanf("%s", ar+1);
    pair<int,int> a[n+2];
    a[1] = mk(ar[1]-'0', 1);
        pair<int,int>br[n+2];
    br[1] = mk(1,1);

    int sz = 1;
    for(int i=2;i<=n;i++){
        if(ar[i]==ar[i-1]){a[sz].y++;
            br[sz].y=i;
        }
        else{ a[++sz] = mk(ar[i]-'0', 1);
        br[sz] = mk(i,i);
        }
    }
    int cum[sz+2];
    SET(cum);
    for(int i=1;i<=sz;i++){
        cum[i] = cum[i-1];
        if(a[i].x==0)cum[i]++;
    }
    if(sz==0){
        cout<<n<<endl;
        return 0;
    }

    int res=0;
    for(int i=1;i<=sz;i++){
        int lo = i,hi = sz;
        while(lo<=hi){
            int mid = (lo+hi)/2;
            int x = cum[mid]-cum[i-1];
            if(x<=m){
                res = max(res, br[mid].y-br[i].x+1);
                lo = mid+1;
            }
            else hi = mid-1;
        }

    }
    cout<<res<<endl;



    return 0;
}

Measured memory_bytes: 2304
def main():
    n  = int(input())
    students = list(map(int,input().split()))
    number = [i for i in range(1,n+1)]
    students_number = []
    for i in range(n):
        students_number.append([students[i]] + [number[i]])
    sorted_students_number = sorted(students_number,key = lambda x:x[0])
    ans = [i[1] for i in sorted_students_number]
    print(*ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 25156
#include<bits/stdc++.h>
using namespace std;
#define rep (i,n) for (int i = 0; i < (n); i++)
using ll = long long;
template <typename T, typename U>
using P = pair<T,U>;
template <typename T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    if(A > B || A != B && N == 1){
        cout << 0 << endl;
        return 0;
    }

    ll mini = A*(N-1) + B;
    ll maxi = B*(N-1) + A;
    ll ans = maxi - mini + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

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

    int n;
    while (cin >> n)
    {
        if (n == 0)
            break;
        int cnt = 0;
        for (int i = 1; i <= n; ++i)
        {
            int t = i;
            while (t % 5 == 0)
            {
                t /= 5;
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3172
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
    int a;
    char buf[30];
    fgets(buf, sizeof(buf),stdin);
    a=atoi(buf);
    if(a<=10&&a>=1){
        a=a+a*a+a*a*a;
        printf("%d\n",a);
    }
}

Measured memory_bytes: 1708
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <cctype>
#define pb push_back
#define endl '\n'
#define ll long long
#define PI acos(-1)
#define RUN_FAST ios::sync_with_stdio(false);
#define sz 8000000
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    int r, g, b, k, i;
    bool flag;
    cin >> r >> g >> b >> k;
    for (i=0; i<k; i++) {
        if (g>r && b>g) break;

        if (r>=g) g*=2;
        else if (g>=b) b*=2;
    }
    if (g>r && b>g) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3648
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    vector<int>vec(202);
    int x,n;
    cin>>x>>n;
    map<int,int>mm;
    for(int i=0;i<n;i++){
        int w;
        cin>>w;
        mm[w]=1;
    }
    vec.pb(-1);
    vec.pb(0);
    for(int i=1;i<=198;i++){
        if(mm[i]==1)continue;
        vec.pb(i);
    }
    int ans,diff=200;
    for(int i=0;i<(int)vec.size();i++){
        if(abs(x-vec[i])<diff){
            diff=abs(x-vec[i]);
            ans=vec[i];
        }
    }
    cout << ans << endl;
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  cout << N * (N-1) / 2 << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> field(H);
  for (int y = 0; y < H; ++y) cin >> field[y];

  int sx, sy;
  int ans = 0;
  for (int h = 0; h < H; ++h) {
    int max_moves = 0;
    for (int w = 0; w < W; ++w) {
      sx = h;
      sy = w;
      if (field[sx][sy] == '#') continue;
      vector<vector<int>> dist(H, vector<int>(W, -1));
      dist.at(sx).at(sy) = 0;
      queue<pair<int, int>> que;
      que.push(make_pair(sx, sy));

      while (!que.empty()) {
        pair<int, int> current_pos = que.front();
        int x = current_pos.first;
        int y = current_pos.second;
        que.pop();
        for (int direction = 0; direction < 4; ++direction) {
          int next_x = x + dx[direction];
          int next_y = y + dy[direction];
          if (next_x < 0 || next_x >= H || next_y < 0 || next_y >= W) continue;
          if (field[next_x][next_y] == '#') continue;

          if (dist[next_x][next_y] == -1) {
            que.push(make_pair(next_x, next_y));
            dist.at(next_x).at(next_y) = dist.at(x).at(y) + 1;
          }
        }
      }

      for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W; ++w) {
          max_moves = max(max_moves, dist.at(h).at(w));
        }
      }
    }
    ans = max(ans, max_moves);
  }

  printf("%d", ans);
  return 0;
}



Measured memory_bytes: 256
N, X, Y = [int(i) for i in input().split()]
li = [0]*(N-1)
for i in range(1, N+1):
    for j in range(i+1, N+1):
        k = 0
        if(i<X and j<X):
            k = j-i
        if(i<X and X<=j<=Y):
            k = min(j-i, X-i+1+Y-j)
        if(i<X and Y<j):
            k = X-i+1+j-Y
        if(X<=i<=Y and X<=j<=Y):
            k = min(j-i, i-X+1+Y-j)
        if(X<=i<=Y and Y<j):
            k = min(j-i, i-X+1+j-Y)
        if(Y<i and Y<j):
            k = j-i
        li[k-1] += 1

for i in li:
    print(i)


Measured memory_bytes: 3444
#include <stdio.h>
#include <vector>
#include <utility>

int selection_sort(std::vector<int>& arr)
{
  using std::swap;
  int swap_num = 0;
  for (int i = 0; i < arr.size() - 1; i++) {
    int minv = i;
    for (int j = i + 1; j < arr.size(); j++) {
      if (arr[minv] > arr[j]) {
        minv = j;
      }
    }
    if (i != minv) {
      swap(arr[i], arr[minv]);
      swap_num++;
    }
  }
  return swap_num;
}

int main()
{
  int N;
  std::vector<int> arr;

  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    int temp;
    scanf("%d", &temp);
    arr.push_back(temp);
  }

  int n = selection_sort(arr);

  for (int i = 0; i < arr.size(); i++) {
    if (i == arr.size() - 1) {
      printf("%d\n", arr[i]);
    }
    else {
      printf("%d ", arr[i]);
    }
  }
  printf("%d\n", n);

  return 0;
}



Measured memory_bytes: 2760
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#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)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const ll MOD = (ll)1000000007;//10^9+7
const ll INF2 = (ll)100000000000000000;//10^18


int main() {
    string s;
    cin>>s;

    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
    }
    for(int i=0;i<s.size()-2;i++){
        if(s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<"-1 -1"<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  int digit = 5;
  int n=0;
  vector<int> x(digit);
  for(int i=0;i<B-A+1;i++){
  	for(int k=0;k<digit;k++){
      x.at(k) = (A+i)%((int)pow(10,5-k))/(int)pow(10,5-k-1);
    }
    if(x.at(0) == x.at(4) && x.at(1) == x.at(3)){
      n++;
    }
  }
  cout << n;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			
			String s = sc.next();
			
			int len = s.length();
			int cnt = 0;
			int max = 0;
			char[] sChars = s.toCharArray();
			
			for(int i=0;i<len;i++) {
				if(sChars[i]=='R') {
					cnt=cnt+1;
					if(max<cnt) {
						max=cnt;
					}
				}else {
					cnt=0;
				}
			}
			
			System.out.println(max);
	}	
}

Measured memory_bytes: 35728
#include<bits/stdc++.h>
#define ll long long
#define For(i,x,y) for(int i=x;i<=y;i++)
#define Rep(i,x,y) for(int i=x;i>=y;i--)
#define Forn(i,x,y) for(int i=x;i<y;i++)
#define oo 1000000
#define zyy 1000000007
#define M 100
#define N 200005
using namespace std;
inline int read(){int x=0,f=0;char ch=getchar();for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-48;return f?-x:x;}
inline void write(ll x){if(x<10) putchar(x+48);else write(x/10),putchar(x%10+48);}
inline void writeln(ll x){if(x<0) putchar('-'),x=-x;write(x);putchar('\n');}
int n,a[N],ans;
int main(){
	n=read();For(i,1,n) a[i]=read(),ans+=a[i];
	sort(a+1,a+1+n);
	if(ans%10!=0) return writeln(ans),0;
	For(i,1,n) if(a[i]%10!=0){
		ans-=a[i];
		return writeln(ans),0;
	}
	puts("0");
	return 0;
}

Measured memory_bytes: 256
N=input()

l=len(N)

if(l==1):
  a=int(N[0])
elif(l==2):
  a=int(N[1])
elif(l==3):
  a=int(N[2])

if(a==2 or a==4 or a==5 or a==7 or a==9):
  print("hon")
elif(a==0 or a==1 or a==6 or a==8):
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9232
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
ll dp[N][15] = {1};
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s;
    cin >> s;
    ll n = s.size();
    for (ll i = 0; i < n; i++)
        if (s[i] == '?')
            for (ll j = 0; j < 13; j++)
                for (ll k = 0; k < 10; k++)
                    dp[i + 1][(j * 10 + k) % 13] = (dp[i + 1][(j * 10 + k) % 13] + dp[i][j]) % M;
        else
            for (ll j = 0; j < 13; j++)
                dp[i + 1][(j * 10 + s[i] - '0') % 13] = (dp[i + 1][(j * 10 + s[i] - '0') % 13] + dp[i][j]) % M;
    cout << dp[n][5];
    return 0;
}

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

int main(){

  char c[10];
  int st[100];
  int top=0;

  while(scanf("%s",c)!=EOF){

    if(strcmp(c,"+")==0){
      st[top-2]=st[top-2]+st[top-1];
      top--;
      //    printf("+ ");

    }else if(strcmp(c,"-")==0){
      st[top-2]=st[top-2]-st[top-1];
      top--;
      //    printf("- ");

    }else if(strcmp(c,"*")==0){
      st[top-2]=st[top-2]*st[top-1];
      top--;;
      //    printf("* ");

    }else{
      st[top]=atoi(c);
      //     printf("%d ",st[top]);
      top++;

    }

  }

  printf("%d\n",st[top-1]);


  return 0;
}

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

void printv(vector<ll> v){
	for(int i = 0; i < v.size(); i++){
		printf("%lld ", v[i]);
	}
	printf("\n");
}

int main(void){
	const ll M = 1000000007;
	ll n, ans = 0, temp = 0;
	cin >> n;
	vector<ll> a(n), v;
	for(ll i = 0; i < n; i++) cin >> a[i];
	for(ll i = n-1; i > 0; i--){
		temp += a[i];
		temp %= M;
		v.push_back(temp);
	}
	for(ll i = 0; i < n-1; i++){
		ans += a[i] * v[n-2-i];
		ans %= M;
	}
	//printv(a);
	//printv(v);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6852
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,n,s) for(int i=(int)(s);i<(int)(n);++i)
#define RREP(i,n,s) for(int i=(int)(s);i>=(int)(n);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

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

    int c[111111] = {};
    c[0] = 0;
    REP2(i, n+1, 1) {
        c[i] = c[i-1]+1;
        for(int j = 6; j <= i; j*=6) {
            c[i] = min(c[i], c[i-j]+1);
        }
        for(int j = 9; j <= i; j*=9) {
            c[i] = min(c[i], c[i-j]+1);
        }
    }

    cout << c[n] << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define nn 65536*4
#define lf double
int bel[nn];
set<int> s;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x;scanf("%d",&x);
		s.insert(i);bel[x]=i;
	}
	s.insert(0);s.insert(n+1);
	ll ans=0;
	for(int i=n;i>=1;i--)
	{
		s.erase(bel[i]);
		set<int>::iterator it=s.lower_bound(bel[i]);
		int r=*it,l=*(--it);
		ans=ans+1ll*i*(r-bel[i])*(bel[i]-l);
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 10368
def solve():
    N, *h = map(int, open(0).read().split())
    h += [h[-1]]
    
    dp = [10 ** 10] * (N + 1)
    dp[0] = 0
    for i in range(N - 1):
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
        dp[i + 2] = dp[i] + abs(h[i] - h[i + 2])
    print(dp[N - 1])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 57872
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main(string[] args)
        {
            var c = Scanner.scanint;
            var b = Scanner.scanint;
            var a = Scanner.rescanint(c[0]);

            var res = 0;
            for(var i = 0; i < c[0]; i++)
            {
                var sum = 0;
                for(var j = 0; j < c[1]; j++)
                {
                    sum += a[i][j] * b[j];
                }
                sum += c[2];
                if (sum > 0) res++;
            }
            Console.WriteLine(res);
        }
    }

    public class Scanner
    {
        public static string[] scan => Console.ReadLine().Split(' ');
        public static int[] scanint => Array.ConvertAll(scan, int.Parse);
        public static long[] scanlong => Array.ConvertAll(scan, long.Parse);
        public static string[][] rescan(int n) => Enumerable.Repeat(0, n).Select(_ => scan).ToArray();
        public static int[][] rescanint(int n) => Enumerable.Repeat(0, n).Select(_ => scanint).ToArray();
        public static long[][] rescanlong(int n) => Enumerable.Repeat(0, n).Select(_ => scanlong).ToArray();

    }

    public class Ex
    {
        public static int[] subarr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; }
    }
}


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

int main() {
  int A,B;
  cin >> A >> B;
  int coincount=0;
  coincount+=max(A,B);
  if (A>=B){
    A--;
  } else {
    B--;
  }
  coincount+=max(A,B);
  cout << coincount << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

void dfs(ll a, const vvll &e, vb &ald, vll &t){
    ald[a] = true;
    t.emplace_back(a);
    for(auto x: e[a]){
        if(!ald[x]){dfs(x, e, ald, t);}
    }
    return;
}

int main(){
    ll N, M; cin >> N >> M;
    vll p(N+1);
    rep(i, 1, N+1){
        cin >> p[i];
    }
    vvll e(N+1, vll(0));
    rep(i, 0, M){
        ll a, b; cin >> a >> b;
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }
    vb ald(N+1, false);
    ll c = 0;
    rep(i, 1, N+1){
        if(!ald[i]){
            vll t(0);
            dfs(i, e, ald, t);
            vll s(0);
            for(auto x: t){
                s.emplace_back(p[x]);
            }
            sort(s.begin(),s.end());
            for(auto x: t){
                if(upper_bound(all(s), x) != lower_bound(all(s),x)){
                    c++;
                }
            }
        }
    }
    prt(c);
}

Measured memory_bytes: 13940
#pragma GCC optimize(3)

#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int cys=998244353;
int n;
string a;
map<string,ll> d;
char s[105];

ll mod(ll x){return x>=cys?x-cys:x;}

ll dp(string a){
	int m=a.length();
	if(!m) return 1;
	if(d.count(a)) return d[a];
	d[a]=(a[0]-'0'+1)*dp(a.substr(1));
	for(int i=1;i<=(m+1)/2;i++){
		string x=a.substr(0,i);
		for(int j=2;j*i<=m;j++){
			string y=a.substr(i*(j-1),i);
			for(int k=0;k<i;k++) chkmin(x[k],y[k]);
			d[a]=mod(d[a]+dp(x)*dp(a.substr(i*j))%cys);
		}
	}
	return d[a];
}

int main(){
	cin>>a;
	printf("%lld\n",dp(a));
	return 0;
}

Measured memory_bytes: 5632
/**
     *    author:  shashank_hire
    **/
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define ld long double
#define MOD 1000000007

vector<ll> dp(2e5, -1);
vector<vector<ll>> g(2e5);
ll f(ll i)
{
    if(dp[i] != -1)
        return dp[i];
    if(g[i].size() == 0)
        return 0;
    ll ma=0;
    for(auto n: g[i])
        ma = max(ma, f(n));
    return dp[i] = 1 + ma;
}

int main()
{
    IOS;
    ll n, m, i, x, y, ma;
    cin>>n>>m;
    
    while(m--)
    {
        cin>>x>>y;
        g[x-1].push_back(y-1);
    }
    for(i=0, ma=0;i<n;i++)
        ma = max(ma, f(i));
    cout<<ma<<"\n";
    
    return 0;
}

Measured memory_bytes: 11648
import java.util.Scanner;
import java.util.Arrays;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
    int As[]=new int[N-1];
    int Bs[]=new int[N];
    for (int i=0;i<N-1 ;i++ ) {
      As[i]=sc.nextInt();
    }
    for (int i=0;i<N;i++ ) {
      Bs[i]=0;
    }
    for (int i=0;i<N-1;i++ ) {

      Bs[As[i]-1]++;

    }

    for (int i=0;i<N;i++) {
      System.out.println(Bs[i]);
    }


  }
}


Measured memory_bytes: 63164
n = int(input())
a = [int(input()) for _ in range(n)]
first = 0
second = 0
index = 0
for i in range(n):
    if a[i] > first:
        index = i
        second = first
        first = a[i]
    elif a[i] > second:
        second = a[i]

for i in range(n):
    if i == index:
        print(second)
    else:
        print(first)


Measured memory_bytes: 12532
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    double L;
    double X, Y, Z;
    ll ans;

    cin >> L;

    X = L / 3.0;
    Y = L / 3.0;
    Z = L - X - Y;
    cout << fixed << setprecision(10) << X * Y * Z << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int count = 0;

    for (int i=a; i<=b; i++)
    {
        if (i%10 == i/10000 && i%100/10 == (i%10000/1000))
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3604
#include<algorithm>
#include<cstdio>
#define mxn 1000010
#define LL long long
using namespace std;
const int mod=1e9+7;
int n,id,sl,fh,ans,a[mxn],d[mxn],l[mxn],dp[mxn],col[mxn],cir[mxn],tot[mxn];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
//	freopen("dayinf.in","r",stdin);
//	freopen("dayinf.out","w",stdout);
	n=rd();int x;ans=1;
	for(int i=1;i<=n;++i) a[i]=rd();
	for(int i=1;i<=n;++i)
	{
		d[a[i]]++;
		x=i;for(;!col[x];col[x]=i,x=a[x]);
		if(col[x]==i) for(++id;!cir[x];cir[x]=id,x=a[x]);
	}
	for(int i=1;i<=n;++i)
		if((cir[i]&&d[i]>2)||(!cir[i]&&d[i]>1))
			return puts("0"),0;
	for(int c,i=1;i<=n;++i)
		if(!d[i])
		{
			for(c=0,x=i;!cir[x];++c,x=a[x]);
			l[x]=c;
		}
	for(int ln,st,ed,cnt,i=1;i<=n;++i)
		if(cir[i])
		{
			st=ed=cnt=0;
			for(x=i;cir[x];cir[x]=0,x=a[x])
			{
				cnt++;
				if(l[x])
				{
					if(!st) st=ed=cnt,ln=l[x];
					else ans=1ll*ans*((l[x]<cnt-ed)+(l[x]<=cnt-ed))%mod,ed=cnt;
				}
			}
			if(st) ans=1ll*ans*((ln<cnt+st-ed)+(ln<=cnt+st-ed))%mod;
			else tot[cnt]++;
		}
	dp[0]=1;
	for(int i=1;i<=n;++i)
		if(tot[i])
		{
			for(int j=1;j<=tot[i];++j)
			{
				dp[j]=1ll*dp[j-1]*((i>1&&(i&1))+1)%mod;
				if(j>1) dp[j]=(dp[j]+1ll*i*(j-1)%mod*dp[j-2])%mod;
			}
			ans=1ll*ans*dp[tot[i]]%mod;
		}
	printf("%d\n",ans);
	fclose(stdin);fclose(stdout);
	return 0;
}

Measured memory_bytes: 16512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string str;
    cin >> str;
    string ans = "";
    rep(i, 0, 3) ans += str[i];
    cout << ans << endl;
}


Measured memory_bytes: 3656
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;





signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b,k;
	cin >> a >> b >> k;
	int a2 = max(0LL, a - k);
	k= max(0LL, k-a);
	int b2 = max(0LL, b - k);
	cout << a2 << " " << b2 << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        k: i64, a: i64, b: i64,
    }
    puts!("{}\n", if (a - 1) / k < b / k { "OK" } else { "NG" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2240
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    int n, a[10] = {}, b = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i], b += a[i];
    sort(a, a + n);
    if (a[n - 1] + a[n - 1] >= b) cout << "No";
    else cout << "Yes";
}


Measured memory_bytes: 256
import java.util.*;

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

		int n = sc.nextInt();
		int tblData[] = new int[n];
		
		//?????????????´?
		for(int i = 0; i < n; i++) {
			tblData[i] = sc.nextInt();
		}
		
		//??´???(??????)
		int tmp;
		int k = n - 1;
		while(k > 0) {
			int i = 0;
			while(i < k) {
				if(tblData[i] > tblData[i+1]) {
					tmp = tblData[i];
					tblData[i] = tblData[i+1];
					tblData[i+1] = tmp;
				}
				i++;
			}
			k--;
		}
		
		long sum = 0L;
		for(int i = 0; i < n; i++) {
			sum = sum + tblData[i];
		}
		
		System.out.println(tblData[0] + " " + tblData[n-1] + " " + sum);
	}
}

Measured memory_bytes: 43052
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int a,b; cin>>a>>b;
    if(b%a==0)
        cout<<a+b<<endl;
    else
        cout<<b-a<<endl;
}


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

namespace Volume1 {
	public class Program {
		public static void Main() {
			int d, w, h;
			while (true) {
				int[] dwh = Console.ReadLine()
					.Split()
					.Select(int.Parse)
					.ToArray();
				d = dwh[0]; w = dwh[1]; h = dwh[2];
				if (d == 0 && w == 0 && h == 0) break;
				Cheese c = new Cheese(d, w, h);

				int n = int.Parse(Console.ReadLine());
				int ssd = c.GetSquareOfShortestDiagonal();
				for(int i = 0; i < n; i++) {
					int r = int.Parse(Console.ReadLine());
					if (ssd < 4 * r * r) Console.WriteLine("OK");
					else Console.WriteLine("NA");
				}
			}
		}
	}

	public class Cheese {
		int d;
		int w;
		int h;

		public Cheese(int d, int w, int h) {
			this.d = d;
			this.w = w;
			this.h = h;
		}

		public int GetSquareOfShortestDiagonal() {
			bool _d = false, _w = false, _h = false;
			if (d < w) _d = true; else _w = true;
			if (d < h) _d = true; else _h = true;
			if (w < h) _w = true; else _h = true;
			return (_d ? d * d : 0) + (_w ? w * w : 0) + (_h ? h * h : 0);
		}
	}
}



Measured memory_bytes: 9268
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 15;
int n, s[N], m, k, a, p[N];

int main() {
	ios_base::sync_with_stdio(false);	
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		cin >> k;
		for(int j = 1; j <= k; j++) {
			cin >> a;
			a--;
			s[i] |= (1 << a);
		}
	}

	for(int i = 1; i <= m; i++) 
		cin >> p[i];

	int ans = 0;
	for(int msk = 0; msk < (1 << n); msk++) {
		int cnt = 0;
		for(int i = 1; i <= m; i++)
			if(__builtin_popcount(msk & s[i]) % 2 == p[i])
				cnt++;
		if(cnt == m) ans++;
	}
	cout << ans << '\n';
}	


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

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

char A[1000001];

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


	int N = getint();

	rep(i, N) A[getint()]++;

	if (A[1]) {
		if (A[1] == 1) co(1);
		else co(0);
		return 0;
	}
	if (A[2]) {
		int kotae = (A[2] == 1);
		for (int i = 3; i <= 500000; i += 2) {
			if (A[i]) {
				kotae += (A[i] == 1);
				for (int j = i + i; j <= 1000000; j += i) {
					A[j] = 0;
				}
			}
		}
		for (int i = 500001; i <= 1000000; i += 2) kotae += (A[i] == 1);
		co(kotae);
		return 0;
	}

	int kotae = 0;
	for (int i = 2; i <= 500000; i++) {
		if (A[i]) {
			kotae += (A[i] == 1);
			for (int j = i + i; j <= 1000000; j += i) {
				A[j] = 0;
			}
		}
	}
	for (int i = 500001; i <= 1000000; i++) kotae += (A[i] == 1);
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 4752
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  rep(i,N) cin >> A.at(i);
  rep(i,N) cin >> B.at(i);
  rep(i,N-1) cin >> C.at(i);
  int manzokudo = 0;
  rep(i,N){
    manzokudo = manzokudo + B.at(A.at(i)-1);
    if(i < N-1 && A.at(i) + 1 == A.at(i+1)){
      manzokudo += C.at(A.at(i)-1);
    }
  }
  cout << manzokudo <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string w;
    cin >> w;
    map<char,int>mp;
    REP(i,w.length()){
        mp[w[i]]++;
    }
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if(itr->second%2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

//vector <long long> v;

stack <char> s;

long long int  x[1000000], y, pot[30], czy=0, w, n, m;
//char s;

int main()
{
    long long int a, b, c, d, k, i, j, q, t, p;

//    q=1;
//    scanf("%lld", &q);
//    for(t=0; t<q; t++)
    {
        scanf("%lld", &n);

        w=0;

        for(i=0; i<n; i++)
        {
            scanf("%lld", &x[i]);
            w=w^x[i];
        }


        for(i=0; i<n; i++)
        {
            printf("%lld ", w^x[i]);
        }
    }

    return(0);
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

const int N = 1e6;

set<int> primes;

void generate() {
  vector<bool> sieve(N+1, false);
  sieve[0] = sieve[1] = true;
  for (int i=2; 1LL*i*i<=1LL*N; i++) {
    if (!sieve[i]) {
      for (int j=i*i; j<=N; j+=i) {
	sieve[j] = true;
      }
    }
  }
  for (int i=0; i<=N; i++) {
    if (!sieve[i]) {
      primes.insert(i);
    }
  }
}

bool isprime(int x) {
  return primes.count(x);
}

template<typename T>
map<T, T> prime_factors(T x) {
  map<T, T> mp;
  for (T i=2; 1LL*i*i <= 1LL*x; i++) {
    while (x%i == 0) {
      mp[i]++;
      x = x / i;
    }
  }
  if (x > 1) {
    mp[x]++;
  }
  return mp;
}

void testlib() {
  assert(!isprime(6));
  assert(isprime(7));
  assert(isprime(97));

  map<int,int> res = prime_factors(84);
  map<int,int> expected;
  expected[2] = 2;
  expected[3] = 1;
  expected[7] = 1;
  assert(res == expected);
}


ll a , b;

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

  generate();
  cin>>a>>b;

  ll g = __gcd(a, b);

  if (g == 1) out(1);

  map<ll,ll> mp = prime_factors(g);

  ll ans = mp.size();
  ans++;

  out(ans);

  

  return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <stdlib.h>

int main() {
  long long a,b,c,k;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &k);

  if(k<=a){
    printf("%lld", k);
  }
  else if(k>a && k<=(a+b)){
    printf("%lld", a);
  }
  else{
    printf("%lld", a-(k-a-b));
  }
  return 0;
}


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

using namespace std;

map<string, int> m;
map<string, int>::iterator it;

int main()
{
  ios_base::sync_with_stdio(false);
  int q;
  cin >> q;
  while(q--) {
    int a, x;
    string s;
    cin >> a;
    if (a == 0) {
      cin >> s >> x;
      m[s] = x;
    }
    else if (a == 1) {
      cin >> s;
      cout << m[s] << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 25944
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
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); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    s[k-1] -= 'A' - 'a';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define A 1000 
 
main(){
 int i,j,k,n,a[A];
 
 scanf("%d",&n);
 for(i=0;i<n;i++)scanf("%d",&a[i]);
 
 for(i=0;i<n;i++){
   j=i;
   while(j>0 && a[j]<a[j-1]){
     k=a[j-1];
     a[j-1]=a[j];
     a[j]=k;
     j--;
   }
  for(j=0;j<n;j++){
    printf("%d",a[j]);
    if(j!=n-1)printf(" ");
  }
  printf("\n");
 }
  return 0;
}


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

int main(){
    ll A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    vector<ll> w, s;
    map<ll, ll> fw, fs;
    
    for(ll i = 0; i <= F/(100*A); i++){
        for(ll j = 0; j <= F/(100*B); j++){
            ll x = 100*(A*i + B*j);
            if(x <= F){
                if(fw.count(x) == 0){
                    w.push_back(x);
                    fw[x]++;
                }
            }
        }    
    }

    for(ll i = 0; i <= F/C; i++){
        for(ll j = 0; j <= F/D; j++){
            ll x = (C*i + D*j);
            if(x <= F){
                if(fs.count(x) == 0){
                    s.push_back(x);
                    fs[x]++;
                }
            }
        }    
    }
    
    cerr << w.size() << " " << s.size() << endl;

    pair<ll, ll> ans = {100*A,0};
    double mx = 0;
    rep(i, 0, w.size()){
        rep(j, 0, s.size()){
            if(w[i]+s[j] == 0) continue;
            if((w[i]/100)*E < s[j] || w[i]+s[j] > F) continue;
            double ratio = (double)s[j]/(double)(w[i]+s[j]);
            if(ratio > mx){
                mx = ratio;
                ans = {w[i]+s[j], s[j]};
            }
        }
    }

    cout << ans.first << " " << ans.second << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define N 100

int main(){
  int M[N][N];
  int n,u,k,v;
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2108
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

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

	vector<int> apple(N);
	for (int i = 0; i < N; i++) {
		apple.at(i) = i + L;
	}

	int sum = 0, Min = 101;
	for (int i = 0; i < N; i++) {
		sum += apple.at(i);
		if (apple.at(i) == 0) {
			Min = 0;
		}
		if (abs(apple.at(i)) <= abs(Min)) {
			Min = apple.at(i);
		}
	}

	cout << sum - Min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
     
    int main(){
          int n;
          double t , a , dif = 0;
          cin >> n >> t >> a;
          int ans = 1;
          double f;
          cin >> f;
          f = t - f*0.006;
          dif = abs(f - a);
          for(int i = 2; i <= n; i++){
                                 double d;
                                 cin >> d;
                                 d = t - d*0.006;
                                 d = abs(d - a);
                                 if(d <= dif){
                                           ans = i; 
                                           dif = d;
                                 }
          }
         cout << ans << endl;
    }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int main(){
    long long n,ans,p=0,MOD=1000000007;
    string s[2];
    bool flag = false;
    cin >> n >> s[0] >> s[1];
    if(s[0][p]==s[1][p]){
        ans=3;
        p++;
    }
    else{
        ans = 6;
        p+=2;
        flag = true;
    }
    while(p<n){
        if(s[0][p]==s[1][p]){
            if(!flag){
                ans*=2;
                ans%=MOD;
            }
            flag = false;
            p++;
        }
        else{
            if(!flag){
                ans*=2;
            }
            else{
                ans*=3;
            }
            ans%=MOD;
            flag = true;
            p+=2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256