akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>


using namespace std;


int main()
{
    char map_to[26] = {0};
    char map_from[26] = {0};
    string S, T;

    bool sat = true;
    cin >> S >> T;
    for (long i = 0; i < static_cast<long>(S.length()); i++) {
        if (!(map_to[S[i]-'a'] == '\0' || map_to[S[i]-'a'] == T[i])) {
            sat = false;
            break;
        }
        if (!(map_from[T[i]-'a'] == '\0' || map_from[T[i]-'a'] == S[i])) {
            sat = false;
            break;
        }
        map_to[S[i]-'a'] = T[i];
        map_from[T[i]-'a'] = S[i];
    }
    if (sat)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

typedef long long ll;
ll a,b,c,d,e,f,g,ans;

int main(){
	cin>>a>>b>>c>>d>>e>>f>>g;
	ans=a/2*2+b+d/2*2+e/2*2;
	if(a&&d&&e)
		ans=max(ans,(a-1)/2*2+b+(d-1)/2*2+(e-1)/2*2+3);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  Hs = list(map(int, input().strip().split()))
  Hs[0] -= 1
  for i in range(n-1):
    if Hs[i] < Hs[i+1]:
      Hs[i+1] -= 1
    if Hs[i] > Hs[i+1]:
      print('No')
      return
  print('Yes')
      
  
if __name__=='__main__':
  main()



Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {

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

    String s = sc.nextLine();
    
    if ("Sunny".equals(s)) System.out.println("Cloudy");
    if ("Cloudy".equals(s)) System.out.println("Rainy");
    if ("Rainy".equals(s)) System.out.println("Sunny");
  }
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int n,d;
    cin>>n>>d;
    cout<<(n+2*d)/(2*d+1);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int n = N % 10;
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
    cout << "hon" << endl;
    return 0;
  }
  if (n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon" << endl;
    return 0;
  }
  cout << "bon" << endl;
  return 0;
}


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int F[N], A[N], I[N];

int P(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1LL * a * a % MOD) if (b & 1) res = 1LL * res * a % MOD;
	return res;
}
int C(int n, int r) { return r > n ? 0 : 1LL * I[r] * I[n - r] % MOD * F[n] % MOD; }

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	F[0] = 1;
	for (int i = 1; i < N; i++) F[i] = 1LL * i * F[i - 1] % MOD;
	I[N - 1] = P(F[N - 1], MOD - 2);
	for (int i = N - 2; i >= 0; i--) I[i] = 1LL * (i + 1) * I[i + 1] % MOD;

	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> A[i];
	sort(A, A + n);
	int ans = 0;
	for (int i = 0; i < n; i++) ans = (ans + 1LL * A[i] * C(i, k - 1) % MOD) % MOD;
	for (int i = 0; i < n; i++) ans = (ans - 1LL * A[i] * C(n - i - 1, k - 1) % MOD + MOD) % MOD;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1408
/*  ex7_3
    kento_titech*/
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int row,col,i,j,*check_row,*check_col;
    char **grid;
    scanf("%d %d",&row,&col);
    grid=(char**)malloc(sizeof(char*)*(row+1));//行に関して文字列配列を動的配列で割り当てる
    check_row=(int*)malloc(sizeof(int)*row);//チェック用の配列も動的配列で割り当てる
    check_col=(int*)malloc(sizeof(int)*col);
    if(grid==NULL){//エラー出力
        fprintf(stderr,"error\n");
        exit(1);
    }
    for(i=0;i<row;i++){
        grid[i]=(char*)malloc(sizeof(char)*(col+1));//列に関して文字列配列を動的配列で割り当てる
        if(grid[i]==NULL){//エラー出力
            fprintf(stderr,"error\n");
            exit(1);
        }
    }
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            scanf(" %c",&grid[i][j]);//row行col列の入力
        }
    }
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            if(grid[i][j]=='#'){//ある行にひとつでも黒色があればその行は消さない。列も同様
                check_row[i]=1;
                check_col[j]=1;
            }
        }
    }
    for(i=0;i<row;i++){
        if(check_row[i]==1){//ある行に黒色があれば列について確認、白色しかなければその行は出力しないで次の行に
            for(j=0;j<col;j++){
                if(check_col[j]==1){//列について黒色がある列のみ出力
                    printf("%c",grid[i][j]);
                }
            }printf("\n");
        }
    }
    for(i=0;i<row;i++){
        free(grid[i]);//列についてメモリ解放
    }
    free(grid);//行についてメモリ解放
    free(check_row);//チェック用配列についてメモリ解放
    free(check_col);

    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll Lpos[20][202020], Lsum[20][202020];
ll Rpos[20][202020], Rsum[20][202020];

int main(){
    ll n,k; cin >> n >> k;
    vl x(n); rep(i,n) cin >> x[i];
    rep(i,n){
        Lpos[0][i] = lower_bound(all(x), x[i] + k) - x.begin();
        Rpos[0][i] = upper_bound(all(x), x[i] - k) - x.begin() - 1;
		Lsum[0][i] = Rsum[0][i] = i;
    }
	Lpos[0][n] = n;
	rep(i,19){
		rep(j,n){
			Lpos[i+1][j] = Lpos[i][Lpos[i][j]];
			Lsum[i+1][j] = Lsum[i][j] + Lsum[i][Lpos[i][j]];
			if(Rpos[i][j] != -1) Rpos[i+1][j] = Rpos[i][Rpos[i][j]];
			else Rpos[i+1][j] = -1;
			Rsum[i+1][j] = Rsum[i][j];
			if(Rpos[i][j] >= 0){
				Rsum[i+1][j] += Rsum[i][Rpos[i][j]];
			}
		}
		Lpos[i+1][n] = n;
	}
	int q; cin >> q;
	while(q--){
		ll l,r; cin >> l >> r; l--; r--;
		ll pos = l;
		ll ls = 0, rs = 0;
		for(int i=19; i>=0; i--){
			if(Lpos[i][pos] <= r){
				ls += Lsum[i][pos];
				pos = Lpos[i][pos];
			}
		}
		ls += pos;
		pos = r;
		for(int i=19; i>=0; i--){
			if(Rpos[i][pos] >= l){
				rs += Rsum[i][pos] + (1<<i);
				pos = Rpos[i][pos];
			}
		}
		rs += pos + 1;
		cout << rs - ls << "\n";
	}
}

Measured memory_bytes: 130212
N = int(input())
L = input()

Li = L.split(' ')
Li = map((lambda x: int(x)), Li)
L = [i for i in Li]

if len(L) < 3:
    L = [0,0,0]

cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
           if L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[k] + L[j] > L[i]\
               and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                   cnt += 1
print(cnt)


Measured memory_bytes: 9028
using System;

public class hello
{
    public static string ns;
    public static int[] nv;

    public static void Main()
    {
        ns = "mcxi";
        nv = new int[] { 1000, 100, 10, 1 };

        var n = int.Parse(Console.ReadLine().Trim());
        var z = 0;
        while (z++ < n)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var s = getNum(line[0]);
            var t = getNum(line[1]);
            var ans = getAns(s + t);
            Console.WriteLine(ans);
        }
    }
    static string getAns(int n)
    {
        var ans = "";
        for (int i = 0; i < 4; i++)
        {
            var a = n / nv[i];
            if (a == 1) ans += ns[i];
            if (a > 1) ans += a.ToString() + ns[i].ToString();
            n -= a * nv[i];
        }
        return ans;
    }
    static int getNum(string s)
    {
        var ans = 0;
        for (int i = 0; i < 4; i++)
        {
            var p = s.IndexOf(ns[i]);
            if (p == 0) ans += nv[i];
            else if (p > 0)
            {
                int prep;
                if (!int.TryParse(s[p - 1].ToString(), out prep)) prep = 1;
                ans += prep * nv[i];
            }
        }
        return ans;
    }
}



Measured memory_bytes: 15880
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#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++)

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> data(N, vector<int>(3));
    rep(i, N) cin >> data.at(i).at(0) >> data.at(i).at(1) >> data.at(i).at(2);

    int now_t = 0, now_x = 0, now_y = 0, next_t = 0, next_x = 0, next_y = 0;

    rep2(i, -1, N - 1)
    {
        if (i != -1)
        {
            now_t = data.at(i).at(0);
            now_x = data.at(i).at(1);
            now_y = data.at(i).at(2);
        }
        next_t = data.at(i + 1).at(0);
        next_x = data.at(i + 1).at(1);
        next_y = data.at(i + 1).at(2);

        int dist = abs(next_x - now_x) + abs(next_y - now_y);
        if (dist > (next_t - now_t))
        {
            cout << "No" << endl;
            return 0;
        }
        else if ((next_t - now_t) % 2 != dist % 2)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 5760
# coding: utf-8

# In[1]:


d = int(input())


# In[2]:


if d == 25:
    print("Christmas")
elif d == 24:
    print("Christmas Eve")
elif d == 23:
    print("Christmas Eve Eve")
elif d == 22:
    print("Christmas Eve Eve Eve")
else:
    print(0)



Measured memory_bytes: 2940
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
// #define MOD ll(1e9) + 7
#define ll long long
const double PI = atan(1.0) * 4;
// const int N = 1e5 + 5 ;
// const ll INF = (int)1e9 ;
const int dx[4] = { -1, 0, 1, 0} ;
const int dy[4] = {0, -1, 0, 1} ;
// const ll INF = (ll)2e18 + 50;
const ll INF = 1e9 ;
const ll MOD = 1e9 + 7 ;


ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a % MOD ;
		a =  a * a % MOD ;
		e /= 2 ;
	}
	return res ;
}
vector<int> complement(const vector<int> &vec) {
	int n = vec.size() ;
	vector<bool> occur(n + 1 , true) ;
	vector<int> ans ;
	for (int i = 0 ; i < (int)vec.size() ; i++) {
		occur[vec[i]] = false ;
	}
	for (int i = 1 ; i <= n ; i++) {
		if (occur[i]) ans.push_back(i) ;
	}
	return ans ;
}

ll intlog(double base, double x) {
	return (ll)(log(x) / log(base));
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t ;
	// cin >> t;
	// while (t--) {
	int n ;
	cin >> n ;
	vector<ll> a(n) ;
	vector<ll> b(n) ;
	ll s = 0 ;
	for (int i = 0 ; i < n ; i++) {
		cin >> a[i] ;
		s ^= a[i] ;
	}
	// ll s = a[0] ;
	for (int i = 0 ; i < n ; i++) {
		b[i] = s ^ a[i] ;
		cout << b[i] << " " ;
	}
	cout << "\n";



	// }

	return 0;
}


Measured memory_bytes: 6372
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

inline int read () {
	int s = 0 , w = 1;
	char ch = getchar ();
	while ( ch > '9' || ch < '0' ) { if ( ch == '-' ) w = -1; ch = getchar ();}
	while ( ch >= '0' && ch <= '9' ) { s = s * 10 + ch - '0'; ch = getchar ();}
	return s * w;
}

const int N = 2e5 + 10;

int h , w , n;
int sr , sc;
char A[N] , B[N];
int fro[N][4][2];

int main ( void ) {
	h = read () , w = read () , n = read ();
	sr = read () , sc = read ();
	scanf ( "%s%s" , A + 1 , B + 1 );
	for ( int i = 1 ; i <= n ; i++ ) {
		for ( int j = 0 ; j < 4 ; j++ ) 
			fro[i][j][0] = fro[i - 1][j][0];
		if ( A[i] == 'L' )	fro[i][0][0]++;
		else if ( A[i] == 'R' ) fro[i][1][0]++;
		else if ( A[i] == 'U' ) fro[i][2][0]++;
		else if ( A[i] == 'D' ) fro[i][3][0]++;
	}
	for ( int i = 1 ; i <= n ; i++ ) {
		for ( int j = 0 ; j < 4 ; j++ ) 
			fro[i][j][1] = fro[i - 1][j][1];
		if ( B[i] == 'L' && sc - fro[i][0][1] + fro[i][1][0] > 1 ) fro[i][0][1]++;
		if ( B[i] == 'R' && sc + fro[i][1][1] - fro[i][0][0] < w ) fro[i][1][1]++;
		if ( B[i] == 'U' && sr - fro[i][2][1] + fro[i][3][0] > 1 ) fro[i][2][1]++;
		if ( B[i] == 'D' && sr + fro[i][3][1] - fro[i][2][0] < h ) fro[i][3][1]++;
		if ( fro[i][0][0] - sc >= fro[i - 1][1][1] ) {
			puts ( "NO" );
			return 0;
		} 
		if ( fro[i][1][0] - w - 1 + sc >= fro[i - 1][0][1] ) {
			puts ( "NO" );
			return 0;
		}
		if ( fro[i][2][0] - sr >= fro[i - 1][3][1] ) {
			puts ( "NO" );
			return 0;
		}
		if ( fro[i][3][0] - h - 1 + sr >= fro[i - 1][2][1] ) {
			puts ( "NO" );
			return 0;
		}
	}
	puts ( "YES" );
	return 0;
} 

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

int main() {
   vector<int> a(3);
   rep(i, 3) {
       cin >> a[i];
   }

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

   if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
       cout << "YES" << endl;
   } else {
       cout << "NO" << endl;
   }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  vector<int> a(26);
  for(int i=0;i<s.size();i++){
    a[s.at(i)-'a']++;
  }
  int sum=0;
  for(int i=0;i<26;i++){
    sum+=a[i]%2;
  }
  cout<<(sum==0?"Yes":"No")<<endl;
}


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

int n, s, b[105];
int main() {
	int i;
	cin >> n;
	for(i=1; i<n; i++) cin >> b[i];
	b[0] = b[n] = 1e9;
	for(i=1; i<=n; i++) s += min(b[i], b[i-1]);
	cout << s;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] count = new int['z'];
        for (int i : count) {
            i = 0;
        }
        while (sc.hasNext()) {
            String s = sc.next();
            s = s.toLowerCase();
            char[] c = s.toCharArray();
            for (char a : c) {
                count[a-1]++;
            }
        }
        for (int i = 'a'; i <= 'z'; i++) {
            System.out.println((char) i + " : " + count[i - 1]);
        }

    }
}


Measured memory_bytes: 26268
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    map<int, int> mp;
    rep(i, N){
        mp[A[i]]++;
    }
    vector<int> v;
    for(auto m: mp){
        v.push_back(m.second);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int ans = N;
    for(int i = 0; i < K; i++){
        if(v.size() <= i){
            cout << 0 << endl;
            return 0;
        }
        ans -= v[i];
    }
    cout << ans << endl;
    return 0;
}


// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 11516
# -*- coding:utf-8 -*-
c = [ list(input()) for _ in range(2) ] 
a = list(reversed(c[1]))
b = list(reversed(c[0]))
if ''.join(c[0]) == ''.join(a) and ''.join(c[1]) == ''.join(b):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
//prepared by dumb
#include<bits/stdc++.h>
using namespace std;
#define   ll long long int
#define   dl double
#define   llu unsigned long long int
#define   scll(x) scanf("%lld",&x)
#define   scld(x) scanf("%lf",&x)
#define   scull(x) scanf("%llu",&x)
#define   scch(x) scanf(" %c",&x)
#define   pb(x) push_back(x)
#define   pf(x) push_front(x)
#define   ppb() pop_back()
#define   ppf() pop_front()
#define   Pi acos(-1.0)
#define   INF 1000000000000000000
#define   mod 1000000007
#define   ff first
#define   ss second
#define   mpr make_pair
#define   debug(x) cout<<x<<'\n';
//sin((x*pi)/180.0)[x in degree]
//sin(x)[x in radian]
//asin(x)[radian]
//(asin(x)*180)/pi[degree]
//or(|)//and(&)//xor(^)//not(~)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ll a, b, c = 1, d, e, f = 0, g, h, i, j, k, l, o, p, q, r, s, t, u, v, w, x, y, z;
  ll cnt = 0, ans = 0, l1, l2, l3, c1 = 0, c2 = 0, c3 = 0, mx = 0, mn = 0;
  ll prevsum = 0, ans1 = 0, ans2 = 0, odd = 0, even = 0, hh, mm,id,n,m;
  string  str1, str2, str;
   scll(n);
   ll arr[n];
   for(i=0;i<n;i++)
    scll(arr[i]);
  sort(arr,arr+n,greater<ll>());
  c=id=0;
  for(i=0;i<n;i++)
  {
    if(i==0)
    {
      
    }
    else if(i==1){
      ans+=arr[id];
      id++;
    }
    else{

    ans+=arr[id];
    c++;
    if(c==2)
     {
      c=0;
      id++;
     }
  }
}
  cout<<ans;

   
  return 0;
}

Measured memory_bytes: 5212
n,k = (int(a) for a in input().split())
r,s,p = (int(a) for a in input().split())
T = list(input())
point = 0
for i in range(n) :
    if i < k :
        pass
    elif  T[i] == T[i-k] :
        T[i] = 0
a = T.count("r")
b = T.count("s")
c = T.count("p")
print(a*p + r*b + c*s)




Measured memory_bytes: 4084
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

int w,h;
int sx,sy;
int hn;
int map[15][15];
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};

int dfs(int y,int x,int p){
	//printf("%d %d %d %d\n",y,x,p,hn);
	bool ered = false;
	if(map[y][x]==2){
		if(p!=hn)return 0;
	}
	else if(map[y][x]==1){
		map[y][x]=0;
		p--;
		ered = true;
	}
	else return 0;
	
	int res=0;
	rep(i,4){
		reg(j,1,100){
			int tx = x + dx[i]*j,
				ty = y + dy[i]*j;
			switch(map[ty][tx]){
			case 0:
				break;
			case 1:
				res += dfs(ty,tx,p);
				goto nexti;
				break;
			case 2:
				if(p==0){
					res++;
					goto nexti;
				}
				else break;
			default:
				goto nexti;
				break;
			}
		}
nexti:;
	}
	if(ered)map[y][x]=1;
	return res;
}

int main(void){
	while(1){
		scanf("%d%d",&w,&h);
		if(w==0)break;
		memset(map,-1,sizeof(map));
		hn=0;
		reg(y,1,h){
			reg(x,1,w){
				scanf("%d",&map[y][x]);
				if(map[y][x]==1){
					hn++;
				}
				else if(map[y][x]==2){
					sy = y; sx = x;
				}
			}
		}
		printf("%d\n",dfs(sy,sx,hn));
	}
	return 0;
}

Measured memory_bytes: 1028
from collections import Counter
n = int(input())
vn = list(map(int, input().split()))
odd = []
even = []
for i in range(n):
    if i % 2 == 0:
        even.append(vn[i])
    else:
        odd.append(vn[i])
ans = len(even) + len(odd)
count_odd = Counter(odd).most_common()
count_even = Counter(even).most_common()
if count_odd[0][0] == count_even[0][0]:
    if len(set(even)) != 1 and len(set(odd)) != 1:
        even2 = count_even[1][1]
        odd2 = count_odd[1][1]
        ans -= max(even2 + count_odd[0][1], odd2 + count_even[0][1])
    elif len(set(even)) != 1 and len(set(odd)) == 1:
        ans -= count_odd[0][1] + count_even[1][1]
    elif len(set(even)) == 1 and len(set(odd)) != 1:
        ans -= count_even[0][1] + count_odd[1][1]
    else:
        ans -= max(count_even[0][1], count_odd[0][1])
else:
    ans -= count_odd[0][1] + count_even[0][1]
print(ans)


Measured memory_bytes: 21204
import java.util.Scanner;
import java.util.ArrayList;
public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int r = s.nextInt();
    int c = s.nextInt();
    int[][] table = new int[r][c];
    for (int i = 0; i < r; i++) {
      for (int j = 0; j < c; j++) {
        table[i][j] = s.nextInt();
      }
    }
    s.close();
    for (int i = 0; i < r; i++) {
      int sum = 0;
      for (int j = 0; j <= c; j++) {
        if (j < c) {
          System.out.print(table[i][j] + " ");
          sum += table[i][j];
        } else {
          System.out.println(sum);
        }
      }
    }
    int total = 0;
    for (int j = 0; j < c; j++) {
      int colSum = 0;
      for (int i = 0; i <= r; i++) {
        if (i < r) {
          colSum += table[i][j];
        } else {
          System.out.print(colSum + " ");
        }
      }
      total += colSum;
    }
    System.out.print(total + "\n");
  }
}



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

using namespace std;

typedef long long ll;
const int N=1e5+5;
int main()
{
    int a,b,c;
    ll k;
    scanf("%d %d %d %lld",&a,&b,&c,&k);
    if(k&1) printf("%d\n",b-a);
    else printf("%d\n",a-b);
    return 0;
}


Measured memory_bytes: 256
open System

let [|a; v|] = stdin.ReadLine().Split() |> Array.map int64
let [|b; w|] = stdin.ReadLine().Split() |> Array.map int64
let t = stdin.ReadLine() |> int64

if (v - w) * t  >= abs (a - b) then "YES"
else "NO"
|> printf "%s"

Measured memory_bytes: 29680
#include <bits/stdc++.h>
using namespace std;
#define ri register int
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		for(; c >= 'A' && c <= 'Z'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
const int N=1e3+5,M=2e5+5;
int rt,g[M],a[M],b[M],sta[2][N];
bool f[N][N],vis[N];
vector<pair<int,int> > v[N];
#define fi first
#define se second
inline void dfs0(ri x){
	if(f[rt][x]) return;
	f[rt][x]=1;
	for(auto o:v[x])
		dfs0(o.fi);
}
int cur;
inline void dfs(ri x){
	if(vis[x]==cur)
		return;
	vis[x]=cur;
	sta[cur][x]=rt;
	for(auto o:v[x])
		dfs(o.fi);
}
int main(){
	ri n,m,i,x;
	gi(n);gi(m);
	for(i=1;i<=m;++i)
		gi(a[i]),gi(b[i]),
		v[a[i]].push_back(make_pair(b[i],i));
	for(i=1;i<=n;++i)
		rt=i,
		dfs0(i);
	for(x=1;x<=n;++x){
		cur^=1;
		vis[x]=cur;
		for(auto o:v[x])
			rt=o.se,
			dfs(o.fi);
		reverse(v[x].begin(),v[x].end());
		cur^=1;
		vis[x]=cur;
		for(auto o:v[x])
			rt=o.se,
			dfs(o.fi);
		for(auto o:v[x])
			g[o.se]=sta[0][o.fi]!=sta[1][o.fi];
	}
	for(i=1;i<=m;++i)
		puts(f[b[i]][a[i]]^g[i]?"diff":"same");
	return 0;
}

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

using namespace std;

using edge_t = std::pair<int, int>;
struct vertex_t {
  std::vector<edge_t*> edges;
};

int solve(int vertexIdx, const std::vector<vertex_t>& vertices,
          const std::vector<edge_t>& edges,
          std::unordered_set<int> visitedVertexIdxes) {
  if (visitedVertexIdxes.count(vertexIdx) > 0) {
    return 0;
  }
  if (visitedVertexIdxes.size() == vertices.size() - 1) {
    return 1;
  }

  int ret = 0;
  visitedVertexIdxes.insert(vertexIdx);
  for (auto edge : vertices[vertexIdx].edges) {
    int const nextVertexIdx =
        edge->first == vertexIdx ? edge->second : edge->first;
    ret += solve(nextVertexIdx, vertices, edges, visitedVertexIdxes);
  }
  visitedVertexIdxes.erase(vertexIdx);
  return ret;
}

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<vertex_t> vertices(n, vertex_t());
  std::vector<edge_t> edges(m);
  for (auto& e : edges) {
    std::cin >> e.first >> e.second;
    e.first--;
    e.second--;
    vertices[e.first].edges.push_back(&e);
    vertices[e.second].edges.push_back(&e);
  }
  std::unordered_set<int> visitedVertexIdxes{};
  std::cout << solve(0, vertices, edges, visitedVertexIdxes) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
int main() {
    int a, b, c, d;
    int ans = 0;
 
    cin >> a >> b >> c >> d;
 
    if (a < c) {
        ans = min(b-c, d-c);
    } else {
        ans = min(d-a, b-a);
    }
 
    ans = max(0, ans);
    cout << ans << endl;
    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll n,A,B,C;
vll l;

ll ans=INF;
void rec(ll i,ll a,ll b,ll c, ll cost){
  if(i==n){
    if(!a||!b||!c) return;
    chmin(ans,abs(A-a)+abs(B-b)+abs(C-c)+cost);
    return;
  }
  rec(i+1,a,b,c,cost);
  rec(i+1,a+l[i],b,c,a==0?cost:cost+10);
  rec(i+1,a,b+l[i],c,b==0?cost:cost+10);
  rec(i+1,a,b,c+l[i],c==0?cost:cost+10);
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>A>>B>>C;
  l.resize(n);
  rep(i,n) cin>>l[i];
  rec(0,0,0,0,0);
  cout<<ans<<endl;
}

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

using namespace std;

template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}

template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}

template<class T>
vector<vector<T>> reads(size_t n, size_t m)
{
    vector<vector<T>> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(reads<T>(m));
    });
    return a;
}

int main()
{
    const auto c = reads<int>(3, 3);
    const int b[] = {
        c[0][0],
        c[0][1],
        c[0][2]};
    const int a[] = {
        c[0][0] - b[0],
        c[1][0] - b[0],
        c[2][0] - b[0]};
        
    for(int i = 0; i < 3; ++i)
    {
        for(int j = 0; j < 3; ++j)
        {
            if(a[i] + b[j] != c[i][j])
            {
                cout << "No\n";
                return 0;
            }
        }
    }

    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		// ??????A????????°?????????
		int line = in.nextInt();
		// ??????A????????°????????????B????????°?????????
		int line_column = in.nextInt();
		// ??????B????????°?????????
		int column = in.nextInt();

		// ??????A,B???????´??????????????????¨???
		int[][] matrixA = new int[line][line_column];
		int[][] matrixB = new int[line_column][column];

		// ??????A?????????????´?
		for(int i = 0; i < line; i++){

			for(int j = 0; j < line_column; j++){

				matrixA[i][j] = in.nextInt();

			}
		}

		// ??????B?????????????´?
		for(int j = 0; j < line_column; j++){

			for(int k = 0; k < column; k++){

				matrixB[j][k] = in.nextInt();

			}
		}

		// ??????A,B?????????????´??????????????????¨???
		long[][] ans = new long[line][column];

		// ??????A.B?????????????´?
		for(int i = 0; i < line; i++){

			for(int j = 0; j < line_column; j++){

				for(int k = 0; k < column; k++){

					ans[i][k] += matrixA[i][j] * matrixB[j][k];

				}
			}
		}

		// ??????A,B???????????????
		for(int i = 0; i < line; i++){

			for(int k = 0; k < column - 1; k++){

				System.out.print(ans[i][k] + " ");

			}

			System.out.println(ans[i][column - 1]);

		}
	}
}

Measured memory_bytes: 53828
import Data.List
main = interact $ unlines . map show' . missing_cards . map (read' . words) . tail . lines
 where
  read' [s,n] = (s, read n)
  show' (s,n) = s ++ " " ++ show n
missing_cards cards = [(s,n)| s<-["S","H","C","D"], n<-[1..13]] \\ cards

Measured memory_bytes: 4036
import sys
S = input()

for i in range(len(S)):
    if (i%2==0 and S[i] in ["R", "U", "D"]) or (i%2!=0 and S[i] in ["L", "U", "D"]):
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 8988
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    int n,k;
    cin >> n >> k;
    int i = 0;
    while(true){
        if(n < pow(k,i)){
            cout << i << endl;
            return  0;
        }else if(n == pow(k,i)){
            cout << i+1 << endl;
            return 0;
        }
        i++;
    }



    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(...) { printf("#  "); printf(__VA_ARGS__); puts(""); }
#define fi first
#define se second
#define endl "\n" 
using ll = long long;
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
using VI = vector <int>;
using VL = vector <ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; if (x >= mod) x -= mod; else if (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }
template <class T> inline void out(T s) { cout << s << "\n"; }
template <class T> inline void out(vector <T> &vec) { for (auto &it : vec) cout << it << " "; cout << endl; } 
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll qpow(ll base, ll n) { ll res = 1; while (n) { if (n & 1) res = res * base % mod; base = base * base % mod; n >>= 1; } return res; }
constexpr int N = 1e3 + 10;
int n;
vector <vector<int>> a;
set <pII> se; 
vector <int> vec, tvec; 
int gao() {
	tvec.clear(); 
	bool F = 0; 
	for (auto &u : vec) if (!a[u].empty()) {
		pII tmp = pII(u, a[u].back());
		if (tmp.fi > tmp.se) swap(tmp.fi, tmp.se);
		if (se.empty()) se.insert(tmp);
		else {
			auto pos = se.lower_bound(tmp);
			if (*pos == tmp) {
				se.erase(tmp);
				tvec.push_back(tmp.fi);
				tvec.push_back(tmp.se);
			    F = 1; 	
			} else se.insert(tmp);
		}
	}
	vec = tvec;
	for (auto &u : vec) a[u].pop_back();
	return F;
}
bool done() {
	for (int i = 1; i <= n; ++i)
		if (!a[i].empty())
			return 0;
	return 1;
}
void run() {
	a.clear(); a.resize(n + 1); 
	for (int i = 1; i <= n; ++i) {
		a[i].clear(); a[i].resize(n - 1);
		for (auto &it : a[i]) cin >> it;
		reverse(a[i].begin(), a[i].end());
	}
	se.clear();
	vec.clear();
	int res = 0;
   	for (int i = 1; i <= n; ++i) vec.push_back(i);	
	while (1) {
		if (!gao()) break; 
		++res;
	}
	if (not done()) res = -1;
	cout << res << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cout << fixed << setprecision(20);
	while (cin >> n) run();
	return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
     int a,b;
     cin>>a>>b;
     if(max(a,b)>8)
        cout<<":("<<endl;
     else
        cout<<"Yay!"<<endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a,b;
  cin >> a>>b;
 
  cout << a*a-b << endl;
  
}



Measured memory_bytes: 256
//Volume1-0127
import java.util.Scanner;

class Main {

    //declare
	private static final char[][] table = {{'a','f','k','p','u','z'},
		                                   {'b','g','l','q','v','.'},
		                                   {'c','h','m','r','w','?'},
		                                   {'d','i','n','s','x','!'},
		                                   {'e','j','o','t','y',' '}};

    public static void main(String[] arg){

    	int    x,y;
    	String ret;
    	char[] num;

        //input
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
        	ret = "";
        	num = sc.nextLine().toCharArray();
        	out: {
        		if(num.length%2!=0){ret = "NA"; break out;}
        		for(int i=0;i<num.length;i+=2){
        			if(!(Character.isDigit(num[i]) && Character.isDigit(num[i+1]))){
        				ret = "NA"; break out;
        			}
        			x = Character.digit(num[i],10)-1;
        			y = Character.digit(num[i+1],10)-1;
        			if(x < 0 || 5 < x || y < 0 || 4 < y){
        				ret = "NA"; break out;
        			}
        			ret += String.valueOf(table[y][x]);
        			}
        		}
        	System.out.println(ret);
        }
    }
}

Measured memory_bytes: 17464
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <limits>
#include <set>
using namespace std;
#define pinf = std::numeric_limits<int>::max()


void solve(){
    int n, m;
    cin >> n >> m;
    vector <int> C(n);
    vector <int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    C[0] = 0;
    C[1] = abs(h[1] - h[0]);
    for (int j = 2; j < n; ++j) {
        int k = 1;
        int tmp = int(1e9);
        while(k <= m && k <= j){
            tmp = min(C[j - k] + abs(h[j] - h[j - k]), tmp);
            k += 1;
        }
        C[j] = tmp;
    }
    cout << C[n - 1];
}

int main(){
    int t = 1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1024
/*
    Author : Ritesh Singh
*/
 
#include <bits/stdc++.h>
using namespace std;
#define lct long long int t;cin>>t;while(t--)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define el '\n'
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL)
const int mod = 1e9+7;
typedef long long ll;

int getValue(char c)
{
    return c - '0';
}

int32_t main()
{
    IOS;
    string s; cin>>s;
    ll ans = 0;
    rep(i,0,s.size())
        ans += getValue(s[i]), ans%=9;
    if(ans%9 == 0)
        cout << "Yes" <<endl;
    else
        cout << "No" <<endl; 

}




Measured memory_bytes: 3756
import pdb


def main():
    num = int(input())
    array = []
    tmp = input()
    tmp = tmp.split()
    for i in range(num):
        array.append(int(tmp[i]))
        
    ans = 1
    div = 0
    prev = 0
    count = 0
    #pdb.set_trace()
    for tmp in array:
        count += 1
        if count == 1:
            prev = tmp
            continue

        if div == 0:
            if prev < tmp:
                div = 1
            elif prev > tmp:
                div = -1
        else:
            if prev < tmp and div == -1:
                ans += 1
                div = 0
            elif prev > tmp and div == 1:
                ans += 1
                div = 0
                
        prev = tmp
        
    print(ans)

        
if __name__ == '__main__':
    main()


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	vector<char> ans;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '0' || s[i] == '1') ans.push_back(s[i]);
		else if (s[i] == 'B' && ans.size() > 0) ans.pop_back();
	}
	for (auto x: ans) cout << x;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();
		long A = scan.nextLong();
		long B = scan.nextLong();
		long count = 0;

		count = A*(N/(A+B));
		if(N%(A+B)>=A) {
			count = count + A;
		}else {
			count = count + N%(A+B);
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21972
t[9999][9999],j;main(p,W,a,b,c){
for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
		for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);c--)for(j=0;j<=W;j++)t[c-1][j]=(j<a)?t[c][j]:(t[c][j]>t[c][j-a]+b)?t[c][j]:(t[c][j-a]+b);for(j=0;t[0][j]-t[0][W];j++);}} 

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (int)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


int extend_gcd(int a, int b, int& x, int& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    int x1, y1;
    int d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

int rowNum[]={-1,0,0,1};
int colNum[]={0,-1,1,0};

int main()
{
	fastio
	int a,b,c,k,ans=0;
	cin>>a>>b>>c>>k;

	while(b<=a)
	{
		b=b*2;
		ans++;
	}

	while(c<=b)
	{
		c=c*2;
		ans++;
	}

	if(ans<=k)
		cout<<"Yes"<<endl;

	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 3688
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	double a,b,c,d,e,f,x,y;
	while(cin>>a>>b>>c>>d>>e>>f){
		y = (d*c - a*f)/(d*b - a*e);
		x = (c-b*y)/a;
	printf("%0.3f %0.3f\n",x+0.00000001,y+0.00000001);
	}
}

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

using namespace std;

int ans[1000][1000];

int main(){
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	memset(ans,0,sizeof(ans));
	for(int i=0;i<b;i++){
		for(int j=0;j<a;j++){
			ans[i][j]=1;
		}
	}
	for(int i=b;i<h;i++){
		for(int j=a;j<w;j++){
			ans[i][j]=1;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<ans[i][j];
		}
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,ans[10];
  cin>>a>>b;
  ans[a]=1;
  ans[b]=1;
  for(int i=1;i<=3;i++){
    if(ans[i]!=1)
      cout<<i<<endl;
  }
  return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<set>
#include<math.h>
using namespace std;

int N;
int M = pow(10, 9) + 7;
vector<map<string, int> > memo; // vector としてグローバルに宣言しておく

// 末尾 4 文字の検索
// ひっくり返しも込みで 'AGC' を含んでしまっていたら false を返す
bool top(string last4){
    string t;
    char tmp;
    int f;
    for(int i = 0; i < 4; i++){
        t = last4; // last4 で初期化
        if(i >= 1){ // ひっくり返す
            tmp = t[i];
            t[i] = t[i-1];
            t[i-1] = tmp;
        }
        f = t.find("AGC");
        if(f != -1) return false; 
    }
    return true;  
}

int dfs(int cur, string last3){
    int ret;
    string S = "ACGT";
    
    // 記録済みならそれを返す
    if(memo[cur].find(last3) != memo[cur].end())
        return memo[cur][last3];
    
    // 検索位置が最深部に到達したら終了
    if(cur == N)
        return 1;
    
    ret = 0;

    // 再帰の開始
    for(int i = 0; i < 4; i++){
        if(top(last3+S[i])) ret = (ret + dfs(cur + 1, last3.substr(1, 2) + S[i])) % M;
    }

    memo[cur][last3] = ret;
    
    return ret;
}

int main(){
    cin >> N;
    
    // 空の map を所定回数 push_back しておくことで長さを初期化できる
    // 初期化して memo の長さを N + 1 にしておく
    map<string, int> init;
    for(int i = 0; i < N + 1; i++) memo.push_back(init);

    cout << dfs(0, "TTT") << "\n";

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
  int n,a;
  vector<int> A;
  cin>>n;
  rep(i,n){
  	cin>>a;
  	A.push_back(a);
  }
  sort(all(A));
  rep(i,n-1){
  	if(A[i] < 0){
  		if(A[i+1] < 0){
  			A[i] *= -1;
  			A[i+1] *= -1;
  			i++;
  		}else{
  			if(A[i] + A[i+1] < 0){
  				A[i] *= -1;
  				A[i+1] *= -1;
  				break; 				
  			}else{
  				break;
  			}
  		}
  	}else{
  		break;
  	}
  }
  ll ans = 0;
  rep(i,n){
  	ans += A[i];
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(void)
{
  string s,t;
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  int startTime = H1 * 60 + M1;
  int endTime = H2 * 60 + M2 - K;

  int ans = endTime - startTime;
  cout << ans << endl;
}


Measured memory_bytes: 3592
N,W = list(map(int,input().split()))
WV = []
for i in range(N):
    WV.append(list(map(int,input().split())))

dp = [[0]*(W+1) for i in range(N)]

for j in range(W+1):
    if WV[0][0]>j:
        dp[0][j]=0
    else:
        dp[0][j]=WV[0][1]

for i in range(1,N):
    newW = WV[i][0]
    newV = WV[i][1]
    for j in range(1,W+1):
        if j-newW>=0:
            dp[i][j] = dp[i-1][j-newW]+newV
        dp[i][j] = max(dp[i-1][j],dp[i][j-1],dp[i][j])
#print(*dp,sep='\n')
print(dp[-1][-1])

Measured memory_bytes: 120684
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
using namespace std;
int main()
{
    string s; cin>>s;
    ll sum=0;
    for(ll i=0;i<s.size();i++) sum+=s[i]-'0';
    if(sum%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 3752
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a,x);l,r=0,length(a)+1;while r-l>1;m=(r+l)>>1;if a[m]<x;l=m;else;r=m;end;end;l;end

function main()
	s = readline() |> chomp
	l = length(s)
	top = Int[]
	btm = Int[0]
	if s[1]=='>'
		push!(top,1)
	else
		push!(btm,1)
	end
	for i in 1:l-1
		if s[i]=='<'&&s[i+1]=='>'
			push!(top,i+1)
		elseif s[i]=='>'&&s[i+1]=='<'
			push!(btm,i+1)
		end
	end
	if s[l]=='<'
		push!(top,l+1)
	else
		push!(btm,l+1)
	end
	push!(btm,l+2)
	x = 0
	for i in 1:length(top)
		p = bsearch(btm,top[i])
		y = max(top[i]-btm[p],btm[p+1]-top[i])
		z = min(top[i]-btm[p],btm[p+1]-top[i])
		x += y*(y+1)>>1+z*(z-1)>>1
	end
	println(x)
end

main()

Measured memory_bytes: 154132
S = input()

if S=='SUN':
  print(7)
  
if S=='MON':
  print(6)
if S=='TUE':
  print(5)
if S=='WED':
  print(4)
if S=='THU':
  print(3)
if S=='FRI':
  print(2)
if S=='SAT':
  print(1)

Measured memory_bytes: 3060