akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<map>
#include<cstdlib>
#include<stack>
#include<algorithm>
#include<set>
#include<cmath>
#include<vector>
using namespace std;
struct nod
{
	long long pay;
	long long num;
}a[100005];
bool cmp(nod c,nod d)
{
	if(c.pay==d.pay)return c.num>d.num;
	return c.pay<d.pay;
}
int main()
{
	#ifdef local
	freopen("1.txt","r",stdin);
	#endif
	int n,i,m;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&a[i].pay,&a[i].num);
	}
	sort(a,a+n,cmp);
	long long sum=0;
	for(i=0;i<n&&m;i++)
	{
		if(m<a[i].num)
		{
			sum+=a[i].pay*m;
			m=0;
		}
		else m-=a[i].num,sum+=a[i].num*a[i].pay;
	}
	printf("%lld",sum);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define loop(i, sta, end, inc) for(int i = sta; i <= end; i += inc)
#define itr(it, l)             for(auto it = l.begin(); it != l.end(); it ++)
#define in(a, b, c)            assert( b <= a && a <= c)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define what_is(x) cerr<<#x<<" ="<<x<<" ";
#define error(args...)  { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define LINT_MAX  9223372036854775807
#define LINT_MIN -9223372036854775808
#define EPS 1e-9
#define MOD 1000000007
#define mod 998244353
#define DEBUG 1
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define range 200010
#ifndef LOCAL
#pragma GCC optimize ("Ofast")
#define endl '\n'
#endif

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
void err(istream_iterator<string> it) { cerr<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    if(DEBUG == 0)return;
	cerr << *it << " = " << a <<" ";
	err(++it, args...);
}


int main(){

//	freopen("test.txt","r",stdin);
	ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	map<string,int> mp;
	
	int n;cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		if(mp.find(s)!=mp.end())mp[s]++;
		else mp[s]=1;
	}
	auto it = mp.begin();
	long long ans=0;
	while(it!=mp.end()){
		int x=it->second;

		ans+=(1LL*x*(x-1))/2;
		it++;
	}
	cout<<ans<<endl;

	
	
	
    return 0;
}


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

int main()
{
  int num;
  int head;
  int tail;

  cin >> num;

  tail= num%10;
  head= num/100;

  if(head==tail){
  cout << "Yes" << endl;
  }else{
  cout << "No"  << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int main(){
	int h,w;
	int num[256];
	memset(num,0,sizeof num);
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++){
		string c;
		cin>>c;
		for(int j=0;j<w;j++)num[c[j]]++;
	}
	int id='a';
	for(int i=1;i<=h/2;i++){
		for(int j=1;j<=w/2;j++){
			while(num[id]<4&&id<='z') id++;
			if(id>'z'){
				cout<<"No\n";
				return 0;
			}
			num[id]-=4;
		}
	}
	id='a';
	if(h%2){
		for(int i=1;i<=w/2;i++){
			while(num[id]<2&&id<='z') id++;
			if(id>'z'){
				cout<<"No\n";
				return 0;
			}
			num[id]-=2;
		}
	}
	id='a';
	if(w%2){
		for(int i=1;i<=h/2;i++){
			while(num[id]<2&&id<='z') id++;
			if(id>'z'){
				cout<<"No\n";
				return 0;
			}
			num[id]-=2;
		}
	}
	cout<<"Yes\n";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    int n = s.size();
    if(s[0] == s[n - 1]) n--;
    if(n % 2 == 0) cout << "Second" << endl;
    else cout << "First" << endl;
    return 0;
}

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

template <int MOD>
class Modular {
public:
    Modular(long long v=0) {
        value = v % MOD;
        if (value < 0)
            value += MOD;
    }

    Modular(long long a, long long b) : value(0) {
        *this += a;
        *this /= b;
    }

    Modular& operator+=(Modular const& b) {
        value += b.value;
        if (value >= MOD)
            value -= MOD;
        return *this;
    }

    Modular& operator-=(Modular const& b) {
        value -= b.value;
        if (value < 0)
            value += MOD;
        return *this;
    }

    Modular& operator*=(Modular const& b) {
        value = (long long)value * b.value % MOD;
        return *this;
    }

    friend Modular power(Modular a, long long e) {
        Modular res = 1;
        while (e) {
            if (e & 1)
                res *= a;
            a *= a;
            e >>= 1;
        }
        return res;
    }

    friend Modular inverse(Modular a) {
        return power(a, MOD - 2);
    }

    Modular& operator/=(Modular const& b) {
        return *this *= inverse(b);
    }

    friend Modular operator+(Modular a, Modular const b) {
        return a += b;
    }

    friend Modular operator-(Modular a, Modular const b) {
        return a -= b;
    }

    friend Modular operator-(Modular const a) {
        return 0 - a;
    }

    friend Modular operator*(Modular a, Modular const b) {
        return a *= b;
    }

    friend Modular operator/(Modular a, Modular const b) {
        return a /= b;
    }

    friend std::ostream& operator<<(std::ostream &os, Modular const& a) {
        return os << a.value;
    }

    friend bool operator==(Modular const& a, Modular const& b) {
        return a.value == b.value;
    }

    friend bool operator!=(Modular const& a, Modular const& b) {
        return a.value != b.value;
    }

    int value;
    static const int MOD_value = MOD;
};

using ModInt = Modular<1'000'000'007>;

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

    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    for (auto& x : a)
        for (auto& y : x)
            cin >> y;
    
    vector<vector<ModInt>> dp(n+1, vector<ModInt>(1 << n, 0));
    dp[0][0] = 1;

    for (int i = 1; i <= n; i++) {
        for (int mask = 0; mask < (1 << n); mask++) {
            int last_bit = -1;
            int cnt = 0;
            for (int j = 0; j < n; j++) {
                if (mask & (1 << j)) {
                    last_bit = j;
                    cnt++;
                }
            }
            if (cnt != i) {
                continue;
            }

            for (int j = 0; j < n; j++) {
                if (mask & (1 << j) && mask && a[i-1][j]) {
                    dp[i][mask] += dp[i-1][mask ^ (1 << j)];
                }
            }
        }
    }

    cout << accumulate(dp.back().begin(), dp.back().end(), ModInt(0)) << '\n';
}


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

void print_list(list<int> v) {
  cout << v.front(); v.pop_front();
  while (!v.empty()) {
    cout << " " << v.front();
    v.pop_front();
  }
  cout << endl;
}

int main() {
  // cin.ignore(numeric_limits<streamsize>::max(),'\n');
  list<int> dl;
  int N;
  scanf("%d\n", &N);
  rep(i, N) {
    char cmd[20];
    int num;
    scanf("%s", cmd);
    auto dlbegin = dl.begin();
    int len = strlen(cmd);
    if (len < 10) {
      int num;
      scanf("%d\n", &num);
      if (cmd[0] == 'i') { // insert
        dl.push_front(num);
      } else { // delete
        auto it = find(dlbegin, dl.end(), num);
        if (it != dl.end()) {
          dl.erase(it);
        }
      }
    } else if (len == 11) { // DeleteFirst
      dl.pop_front();
    } else { // DeleteLast
      dl.pop_back();
    }
  }

  print_list(dl);
}


Measured memory_bytes: 34420
import math
 
N, M = map(int,input().split())
 
if M == 0:
    if N == 1:
        print(0)
    else:
        print(10**(N-1))
else:
    s = list()
    c = list()
 
    for i in range(M):
        s_val, c_val = map(int, input().split())
        s.append(s_val)
        c.append(c_val)
 
    ans = 1000
    for i in range(int(10**(N)-1), int(10**(N-1)-1),-1):
        keta=list()
        for j in range(N):
            keta.append((math.floor(i/(10**j))%10))
        counter = 0
        
        for k in range(M):
 
            if keta[N-s[k]] == c[k]:
                counter += 1
            if counter == M:
                ans = i
 
    if N == 1 and M == 1 and c[0] == 0:
        print(0)
 
    elif ans == 1000:
        print(-1)
    else:
        print(ans)

Measured memory_bytes: 3064
public class Hello{
    public static void Main(){
        for(int i=1;i<10;i++) x1_9(i);
    }
    public static void x1_9(int x){
        for(int i=1;i<10;i++) System.Console.WriteLine(x + "x" + i + "=" + (x*i));
    }
}



Measured memory_bytes: 9032
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()




using namespace std;

int main(){
  ll h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;

  ll t1 = m1 + 60 * h1;
  ll t2 = m2 + 60 * h2;

  ll t = t2 - t1;

  ll ans = t - k;

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3636
n, k = map(int, input().split())
cnt = 0
MOD = 1000000007
for i in range(k, n+2):
    left = i*(i-1)//2
    right = i*(2*n-i+1)//2
    add = right - left + 1
    cnt = (cnt+add)%MOD
print(cnt)

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve(){
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	
	int n;
	cin >> n;



	cout << n * (n + 1) / 2 << endl;
}


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


	solve();
	system("PAUSE");
	return 0;
}

Measured memory_bytes: 504
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

std::string s;

int main(){
    std::cin >> s;
    long ans = 0;
    for(int i = 0; i < s.length() - 1; i++){
        if(s[i] != s[i+1]){
            ans++;
        }
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long int
#define pp pair<int,int>
#define endl "\n"
#define PI 3.14159265
int MAXN = 5000001;
const int mod=1000000007;
const int INF =INT_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
   // cin>>t;
    while(t--)
    {
       string s;
       cin>>s;
       int n=s.length();
       if(s[n-1]=='s')s+="es";
       else s+='s';
       cout<<s<<endl;





    }
    return 0;
}


Measured memory_bytes: 3624
N = int(input())
Data = list(map(int,input().split()))
dic = {}
for d in Data:
    if not d in dic.keys():
        dic[d] = 0
    dic[d]+=1

allsum = 0
for d in dic.values():
    allsum += d*(d-1)//2
for d in Data:
    n = dic[d]
    ans = allsum - n*(n-1)//2
    if n > 1:
        ans += (n-1)*(n-2)//2
    print(ans)


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

int main() {
    int n;cin>>n;
    int l[n];rep(i,n)cin>>l[i];
    sort(l,l+n);
    
    int ans = 0;
    rep(i,n)rep(j,i)rep(k,j){
        if(l[i]>l[j] && l[j]>l[k] && l[j]+l[k]>l[i])++ans;
    }
    cout<<ans<<endl;
	return 0;
}

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

// 1s = 10 ^ 8 loop

int main() {
  int N;
  cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;
  } else {
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
ans = 0

def judge753(x):
    counter = [False for _ in range(10)]
    while x > 0:
        a = x % 10
        counter[a] = True
        x //= 10

    for j, c in enumerate(counter):
        if j in (3, 5, 7):
            if not c:
                return False
        else:
            if c:
                return False
    
    return True


def dfs(x=0):
    if x > N:
        return
    global ans
    if judge753(x):
        ans += 1
    dfs(10 * x + 3)
    dfs(10 * x + 5)
    dfs(10 * x + 7)

dfs()
print(ans)

Measured memory_bytes: 3064
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]
def same(x,y):
    return find(x) == find(y)
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y
    size[y] = size[x] + size[y]
    size[x] = 0

N,M = map(int,input().split())
par = [ i for i in range(N+1)]
size = [1 for _ in range(N+1)]
for _ in range(M):
    a,b = map(int,input().split())
    unite(a,b)
A = size.count(0)
print(N-A-1)

Measured memory_bytes: 13868
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=1e9;
const long double eps=1e-9;
const int maxdig=20;
int dig[maxdig];
inline ll read(){
	ll x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int i;ll n;
	n=read();
	int cnt=0,sum=0,ans=0;
	while(n){
		dig[++cnt]=n%10;
		n/=10;
	}
	for(i=cnt;i>=1;i--)sum+=dig[i];
	ans=9*(cnt-1)+dig[cnt]-1;
	printf("%d\n",max(ans,sum));
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a + b >= c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}




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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

bool comp1(pl a, pl b){
    if(a.second==b.second)return a.first>b.first;
    return a.second<b.second;
}

bool comp2(pl a, pl b){
    return a.first>b.first;
}

int main(){

    int n;
    cin>>n;

    vc<vc<pl>> lr(2);

    rep(i,n){
        string t; 
        cin>>t;
        int l=0,r=0;
        rep(j,t.length()){
            if(t[j]=='(')l++;
            else{
                if(l)l--;
                else r++;
            }
        }
        if(l-r>0)lr[0].emplace_back(l,r);
        else lr[1].emplace_back(l,r);
    }

    sort(all(lr[0]),comp1);
    sort(all(lr[1]),comp2);
    // rep(i,2)rep(j,lr[i].size())cerr<<"( = "<<lr[i][j].first<<"  ) = "<<lr[i][j].second<<"\n";
    ll ans=0;

    rep(i,2){
        rep(j,lr[i].size()){
            if(ans-lr[i][j].second<0){
                cout<<"No\n";
                return 0;
            }
            ans+=lr[i][j].first-lr[i][j].second;
        }
    }

    if(ans==0)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

Measured memory_bytes: 18988
import collections
import itertools
t = []
while True:
    try:
        k=int(input())
        t.append(k)
    except EOFError:
        break
counter = collections.Counter(t)
mode_v=counter.most_common()[0][-1]
it = itertools.takewhile(lambda kv:kv[-1]==mode_v,counter.most_common())
m=(k for k,v in it)
[print(i) for i in m]




Measured memory_bytes: 6020
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,p,n) for(ll i=n-1;i>=p;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define trav(it,a) for(auto it=a.begin();it!=a.end();++it)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll  x;
  cin>>x;
  ll c=x/500;
  ll s=c*1000;
  x=x-(c*500);
  c=x/5;
  s=s+(c*5);
  cout<<s;
  return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n; cin >>n;
  vector<ll> a(n+1);
  vector<ll> b(n);
  ll ans=0;
  rep(i,n+1) cin >>a[i];
  rep(i,n) cin >>b[i];
  rep(i,n){
    if(a[i]>=b[i]) ans+=b[i];
    else{
      if(a[i+1]+a[i]>=b[i]) {
        ans+=b[i];
        a[i+1]=a[i+1]+a[i]-b[i];
      }else{
        ans+=a[i+1]+a[i];
        a[i+1]=0;
      }
    }
  }
  
  cout <<ans<<endl;
}

Measured memory_bytes: 1792
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	ll a,b,c,d;cin>>a>>b>>c>>d;
	ll turn =0;
	while(1)
	{
		if(turn ==0) c-=b;
		else         a-=d;
		if(a<=0 || c<=0 ) break;
		turn^=1;
	}

	if(turn==0) cout<<"Yes\n";
	else cout<<"No\n";


	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
	int n,a[10000],i,max,sum,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	max=a[0];
	for(i=0;i<n;i++)
{
	if(a[i]>max) 
	{
	max=a[i];
	j=i;	
	}
}
sum=0;
for(i=0;i<j;i++)
{
	sum=sum+a[i];
}
for(i=j+1;i<n;i++)
{
	sum=sum+a[i];
}
printf("%d\n",sum+max/2);	
} 

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

void cookie(int *p1,int *p2){
	if(*p1 % 2)	--(*p1);
	*p1 /= 2;
	*p2 += *p1;
	return;
}

int main(int argc, char const *argv[])
{	
	int a,b,k;
	scanf("%d%d%d",&a,&b,&k);
	for (int i = 1; i <= k; ++i)
	{
		if(i % 2)	cookie(&a,&b);
		else cookie(&b,&a);
	}
	printf("%d %d\n",a,b);
}

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

int main(){
    vector<int> v(5);
    for(int i = 0; i < 5; i++){
        int a; cin >> v[i];
    }
    int k; cin >> k;
    sort(v.begin(), v.end());
    int d = v[4] - v[0];
    cout << (d > k ? ":(" : "Yay!") << endl;
}

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

#define mod 1000000007

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

    int rootN = sqrt(N);

    // (a, b, c) は区間[a, b] の要素iが i*c <= N かつ i*(c+1) > N を満たすことを示す
    // cはいらないので(a, b)だけ保存
    // b = N/c, aは一個前のbに+1
    vector<pair<int, int>> element;
    element.reserve(2*rootN+2);

    for (int i = 1; i <= rootN; ++i) {
        element.push_back(make_pair(i, i));
    }
    int last = rootN;
    // i = c で回す
    for (int i = N / (rootN+1); i > 0; --i) {
        int b = N / i;
        element.push_back(make_pair(last+1, b));
        last = b;
    }

    // i番目の数はelement[i]が右端に来る場合の数
    vector<ll>ans(element.size(), 0);
    ans[0] = 1; // 0回目, 右には[1, N]の任意の数が来る

    // K回の更新で答えが出る
    for (int i = 0; i < K; ++i) {
        vector<ll>temp(element.size());
        ll c_sum = 0;
        for (int j = 0; j < element.size(); ++j) {
            int rev = element.size()-1-j;
            c_sum = (c_sum + ans[j]) % mod;
            temp[rev] = c_sum * (element[rev].second - element[rev].first + 1) % mod;
        }
        ans.swap(temp);
    }

    ll sum = 0;
    for (int i = 0; i < ans.size(); ++i) {
        sum = (sum + ans[i]) % mod;
    }
    cout << sum;
    return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m; cin>>n >>m;
  priority_queue<long long> a;
  for(int i=0;i<n;i++){
    long long A; cin>>A;
    a.push(A);
  }

  while(m>0){
    long long A;
    A=a.top();
    a.pop();
    A/=2;
    a.push(A);
    m--;
  }

  long long sum=0;
  for(int i=0;i<n;i++){
    long long A=a.top();
    a.pop();
    sum+=A;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s;
    int t;
    REP(i,7){
        if(A[i]==s) t= i;
    }
    cout << 7-t << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  
 int a,b,c;

 cin>> a >> b >> c;
 

 if (a==b)
    cout<< c; 
 
 else if (a==c)
     cout<< b; 
 else 
    cout<< a;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
template<class T> void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

int main(void) {
	string S, T;
	cin >> S >> T;

	vector<vector<int> > dp(S.size() + 1, vector<int>(T.size() + 1));

	for (int t = 1; t <= T.size(); t++) {
		for (int s = 1; s <= S.size(); s++) {
			if (S[s - 1] == T[t - 1]) {
				dp[s][t] = dp[s - 1][t - 1] + 1;
			}
			else {
				dp[s][t] = max(dp[s][t - 1], dp[s - 1][t]);
			}
		}
	}

	string ans = "";
	int s = S.size();
	int t = T.size();
	while (s > 0 && t > 0) {
		if (dp[s][t] == dp[s - 1][t]) {
			s--;
		}
		else if (dp[s][t] == dp[s][t - 1]) {
			t--;
		}
		else {
			ans.push_back(S[s - 1]);
			s--;
			t--;
		}
	}
	reverse(ans.begin(), ans.end());

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 35584
s = input()
now = 0
n = len(s)
prev = ""
x = {"eraser", "dreamer", "dream", "erase"}
y = {"ase", "aser"}
ds = [7, 6, 5, 4, 3]
ans = "YES"
while now < n:
    q = 1
    for i in ds:
        index = now + i
        if index > n:
            continue
        w = s[now:index]
        if w in x:
            now += i
            prev = w
            q = 0
            break
        elif prev == "dreamer" and w in y:
            now += i
            prev = w
            q = 0
            break
    if q:
        ans = "NO"
        break
print(ans)






Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
int rooms[5][4][11];
void pp(){
    for(int i=1;i<=4;i++){
        for(int j=1;j<=3;j++)
            for(int k=1;k<=10;k++){
                cout<<' '<<rooms[i][j][k];
                if(k==10) cout<<'\n';
            }
        if(i!=4)
            printf("####################\n");
    }
}

int main()
{   
    memset(rooms,0,sizeof(rooms));
    int n,b,f,r,v;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>b>>f>>r>>v;
        rooms[b][f][r] += v;
    }
    pp();

}


Measured memory_bytes: 3080
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    if N == 1:
        print(1)
        return
    A.sort()
    if A[0] == 1 and not A[1] == 1:
        print(1)
        return
    arr = [0] * (A[-1] + 1) # 1-indexed
    for a in A:
        arr[a] += 1

    count = 0
    for i in range(0, len(arr)):
        if arr[i] == 0:
            continue
        elif arr[i] == 1:
            count += 1
        j = 2
        while i * j <= A[-1]:
            arr[i * j] = 0
            j += 1
    print(count)


    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 102660
#include <iostream>
#include <algorithm>
#include <map>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;


int main(void) {
    int n, i;
    ll a[200003] = {};
    map<ll, ll> m;

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

    for (i = 1; i <= n; i++) {
        a[i] += a[i - 1];
    }

    for (i = 0; i <= n; i++) {
        m[a[i]]++;
    }

    map <ll, ll>::iterator ite;
    ll ans = 0;
    for (ite = m.begin(); ite != m.end(); ite++) {
        ans += ite->second * (ite->second - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<string>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
using namespace std;

int main(void){
  int n, in;
  cin>>n;
  cin>>in;
  int ma = in, mi = in;
  rep(i,n-1){
    cin>>in;
    ma = max(ma, in);
    mi = min(mi, in);
  }
  cout<<ma - mi<<endl;
}

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

int main(){
    long long N, K, gcd_ab;
    long long count = 0;
    string temp;
    bool chohuku;
    vector<string> S;

    cin >> N;
    count = N;

    rep(i,N){
        cin >> temp;
        S.push_back(temp);
   //     cout << S[i];
    }
    //sort(S.begin(),S.end());
std::sort(S.begin(), S.end() );
    
    rep(i,N-1){
   //     cout << S[i];
        if(S[i] == S[i+1]){
            count--;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 11544
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        //値を取得
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int b = 1;  //整数
        int p = 2;  //掛ける回数
        
        //Xが1の場合、条件に合致するのは1のみなのでここで終了
        if (b == X){
            System.out.println(1);
            return;
        }
        
        int max = 4;    //1の次に小さいべき乗数
        for (b = 2; b <= X; ++b){
            for (p = 2; p <= X; ++p){
                int expo = (int) Math.pow(b,p);   //べき乗数
                if(expo > X) {  //べき乗数の値がXを超えたらループを抜ける
                    break;
                }
                max = Math.max(expo, max);	//求めたべき乗数と4のうち、大きい方を代入
            }
        }
        
        //出力
        System.out.println(max);
    }
}

Measured memory_bytes: 35956
//
// Created on 2020/07/11.
//


#include <iostream> // cout, endl, cin
#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 <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int bit_count(int i){
    //数字iを二進数表記にした際の1の数を調べる
    return __builtin_popcount(i);
}

int solve(int i){
    if(i == 0) return 0;
    return solve(i%bit_count(i))+1;
}

int main() {

    int n;
    cin>>n;
    string s;
    cin>>s;
    int x0_cnt = 0;
    vector<int>x(n);
    for (int j = 0; j < n; ++j) {
        x[j] = s[j] - '0';
        x0_cnt += x[j];
    }
    reverse(all(x));
    vector<int>ans(n);

    for (int b = 0;b < 2; ++b) {
        int pc;
        if(b == 0) pc = x0_cnt + 1;
        else  pc = x0_cnt - 1;
        if(pc <= 0) continue;
        ll x0_mod = 0;
        int r = 1;
        for (int j = 0; j < n; ++j) {
            x0_mod = (x0_mod + (r * x[j]))% pc;
            r = (r * 2) % pc;
        }
        r = 1;
        for (int k = 0; k < n; ++k) {
            if(x[k] == b){
                ll now;
                if(b==0){
                    now = (x0_mod + r) % pc;
                }else{
                    now = (x0_mod - r)% pc;
                    if(now < 0)now += pc;
                }
                ans[k] = solve(now) + 1;
            }
            r = (r * 2) % pc;
        }
    }
    reverse(all(ans));
    for (int i = 0; i < n; ++i) {
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int count = 0;
		for (int i = 1; i <= N; i++) {
			if (i % 2 != 0) {
				count++;
			}
		}
		double ans = (double) count / N;
		System.out.println(String.format("%.6f", ans));
		in.close();
	}
}

Measured memory_bytes: 22864
import itertools
n = int(input())

a = []

for i in range(1, 10):
    a += list(itertools.product('357', repeat=i))

cnt = 0
for s in a:
    if int("".join(s)) > n:
        continue

    if s.count('3') > 0 and s.count('5') > 0 and s.count('7') > 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 7156
# 200216 B

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

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 != 0 and A[i] % 5 != 0:
            print("DENIED")
            exit()

print("APPROVED")

Measured memory_bytes: 3060
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	int max_num = max(A, max(B, C));
	int other = A + B + C - max_num;

	for(int i = 0; i < K; ++i){
		max_num = max_num * 2;
	}

	cout << other + max_num << endl;

	return 0;
}

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

int main(){
	int N;
	scanf("%d",&N);
	int num = N;

	if(N >= 64){
		printf("64\n");
	}
	else if(N >= 32){
		printf("32\n");
	}
	else if(N >= 16){
		printf("16\n");
	}
	else if(N >= 8){
		printf("8\n");
	}
	else if(N >= 4){
		printf("4\n");
	}
	else if(N >= 2){
		printf("2\n");
	}
	else{
		printf("1\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
typedef long long ll;

using namespace std;

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

    string t[4] = {"dream", "dreamer", "erase", "eraser"};

    int si = s.size();
    bool can = true;
    while (si != 0){
	bool can2 = false;
	for (int i = 0; i < 4; i++){
	    if (si < t[i].size()) continue;
	    string sub = s.substr(si-t[i].size(), t[i].size());
	    if (sub == t[i]){
		can2 = true;
		si -= t[i].size();
		break;
	    }
	}
	if (!can2){
	    can = false;
	    break;
	}
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

int main()
{
	float ax,ay,bx,by,cx,cy,dx,dy;
	double katamuki[2];
	short n;
	cin>>n;
	
	for(int i=1;i<=n;i++){
		cin>>ax>>ay>>bx>>by>>cx>>cy>>dx>>dy;
		katamuki[0]=(by-ay)/(bx-ax);
		katamuki[1]=(dy-cy)/(dx-cx);
		cout<<((katamuki[0]==katamuki[1])?"YES":"NO")<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3076
let (sx,sy,tx,ty) = Scanf.scanf "%d %d %d %d" (fun a b c d -> (a,b,c,d) )

let rec firstx x y tx ty list =
  if (x < tx) then firstx (x+1) y tx ty ('R'::list) else
    if (x > tx) then firstx (x-1) y tx ty ('L'::list) else list

let rec firsty x y tx ty list =
  if (y < ty) then firsty x (y+1) tx ty ('U'::list) else
    if (y > ty) then firsty x (y-1) tx ty ('D'::list) else list

let rec secondx x y tx ty list =
  if (x < (tx+1)) then firstx (x+1) y tx ty ('R'::list) else
    if (x > (tx+1)) then firstx (x-1) y tx ty ('L'::list) else list

let rec secondy x y tx ty list =
  if (y < ty) then firsty x (y+1) tx ty ('U'::list) else
    if (y > ty) then firsty x (y-1) tx ty ('D'::list) else list
      
let rec listinv = function
  | [] -> []
  | a :: rest ->
     match a with
     | 'R' -> 'L' :: listinv rest
     | 'L' -> 'R' :: listinv rest
     | 'U' -> 'D' :: listinv rest
     | 'D' -> 'U' :: listinv rest
      
let list1 = firstx sx sy tx ty [] 
let list2 = firsty sx sy tx ty []
let list12 = list1 @ list2 
let list12' = listinv list12
let list3 = 'D' :: (firstx sx sy tx ty []) @ ['R'] 
let list4 = 'U' :: (firsty sx sy tx ty []) @ ['L'] 
let list34 = list3 @ list4
let list34' = listinv list34
let anslist = list12 @ list12' @ list34 @ list34'

let rec list_to_string : char list -> string = fun cl ->
   String.concat "" @@ List.map (String.make 1) cl

let ans = list_to_string anslist
  
let () = Printf.printf "%s\n" ans


Measured memory_bytes: 2432
import sys
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

comb = Combination(10**5 + 5)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    pre_idx = 0
    idx = 0
    appeared = [-1] * (N + 1)
    for i, a in enumerate(A):
        if appeared[a] == -1:
            appeared[a] = i
        else:
            pre_idx, idx = appeared[a], i
            break

    """
    dpする前に計算量を見積もる癖はつけた方が良さそう。
    TLEした後に引き返せる時間が残っていない。。。

    問題が「同じ表現を含まない」のネガティブなので、全体から
    表現が被るケースを除くべきでした。
    同じ表現になるのは、２回出てくる数をaとして、aが２回出てくるまでの範囲を見た時に
    aを一回選びかつ2つのaの間の数を全く選ばない時。
    """

    for k in range(1, N + 2):
        if k == 1:
            print(N)
            continue
        rem = (N + 1) - (idx - pre_idx + 1)
        if rem < k - 1:
            print(comb(N + 1, k))
        else:
            print((comb(N + 1, k) - comb(rem, k - 1)) % mod)





if __name__ == "__main__":
    main()


Measured memory_bytes: 91992
const main = (inputs) => {
  var fristArray = inputs[0].split(" ");
  var N = fristArray[0]*1;  //人数
  var K = fristArray[1]*1;  //ポイント
  var Q = fristArray[2]*1;  //正解数
  inputs.shift();
  var ans = [];

  for(var i=0; i < N; i++){
    ans.push(Q * -1);
  }

  for(var j=0; j < inputs.length; j++){
    ans[inputs[j]-1] = ans[inputs[j]-1] + 1;
  }

  for(var k=0; k < N; k++){
    if(ans[k]+K > 0){
      console.log('Yes');
    }
    else {
      console.log('No');
    }
  }
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));

Measured memory_bytes: 33152
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));

    double x = (double)a[n-1]/2.0;
    vector<pair<double, ll>> p(n);
    rep(i, n) {
        p[i] = make_pair(abs((double)a[i] - x), i);
    }
    sort(all(p));

    cout << a[n-1] << " " << a[p[0].second] << endl;
    re0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main()
{
int x1,x2,x3,x4,x5;
cin>>x1>>x2>>x3>>x4>>x5;
if(x1==0)
{
    cout<<"1";
}
else if(x2==0)
{
    cout<<"2";
}
else if(x3==0)
{
    cout<<"3";
}
else if(x4==0)
{
    cout<<"4";
}
else
{
    cout<<"5";
}
return 0;
}


Measured memory_bytes: 3620
w = list(input())

w.sort()

cnt = 1

for i in range(len(w)-1):
    if w[i] != w[i+1]:
        if cnt % 2 == 1:
            print('No')
            exit()
        else:
            cnt = 1
    else:
        cnt += 1

if cnt % 2 == 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int N, K;
    cin >> N >> K;
    unsigned long long ans = 0;
    unsigned long long a = 0, b = 0;
    rep2(i, 1, N + 1)
    {
        if (i % K == 0)
            a++;
        if (i % K == K / 2)
            b++;
    }
    if (K % 2)
    {
        ans = a * a * a;
    }
    else
    {
        ans = b * b * b + a * a * a;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

vector<int> f(int nbit, int b) {
    if (nbit == 1) {
        return vector<int>{ 0, 1 };
    }
    int x = ((b ^ (b - 1)) + 1) >> 1;
    int overx = ((1 << nbit) - 1) ^ (x | (x - 1));
    int c = (b & (x - 1)) | ((b & overx) >> 1);
    int m = 1;

    vector<int> p = f(nbit - 1, m);
    vector<int> q = f(nbit - 1, c ^ m);
    for (int& a : p) {
        a = (a & (x - 1)) | ((a & (overx >> 1)) << 1);
    }
    for (int a : q) {
        a ^= m;
        a = (a & (x - 1)) | ((a & (overx >> 1)) << 1) | x;
        p.push_back(a);
    }
    return p;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    int C = A ^ B;
    int M = 0;
    rep(i, N) M += C >> i & 1;
    if (M % 2 == 0) {
        write("NO");
        return 0;
    }

    write("YES");
    vector<int> ans = f(N, C);
    rep(i, 1 << N) cout << (ans[i] ^ A) << (i == (1 << N) - 1 ? '\n' : ' ');
}

Measured memory_bytes: 1648
#include<stdio.h>

int main(void)
{

	int i, sum;
	char num[1001];

	for(;;){
		scanf("%s", &num);
		if(num[0]=='0') break;

		int len = strlen(num);
		sum = 0;
		for(i = 0; i < len; i++){
			sum += num[i] - '0';
		}

		printf("%d\n", sum);
	}
	return 0;
}


Measured memory_bytes: 2044
#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;
int n;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  double ans = 0;
  cin>>n;
  for (int i=0; i<n; i++) {
    double x; cin>>x;
    ans += (1.0/x);
  }
  ans = 1.0 / ans;
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
using namespace std;

int main(){
  int S,W,ans=0;
  cin>>S>>W;
  
  if(S<=W) cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;
}

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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,int>>
#define pb push_back
#define mod 1000000007

using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

int n;
ll k;
ll g[55][55];

ll res[55][55];
bool first;

void mulm(int flag) {
    ll tt[n + 1][n + 1];
    if (flag) {
        if (!first) {
            first = true;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    res[i][j] = g[i][j];
                }
            }
            return;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                ll temp = 0;
                for (int p = 1; p <= n; p++) {
                    temp += (res[i][p] * g[p][j]) % mod;
                    temp %= mod;
                }
                tt[i][j] = temp;
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                res[i][j] = tt[i][j];
            }
        }
    } else {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                ll temp = 0;
                for (int p = 1; p <= n; p++) {
                    temp += (g[i][p] * g[p][j]) % mod;
                    temp %= mod;
                }
                tt[i][j] = temp;
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                g[i][j] = tt[i][j];
            }
        }
    }
}

void matrix_power() {
    while (k > 0) {
        if (k & 1) mulm(1);
        k = k >> 1;
        mulm(0);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cin >> k;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) cin >> g[i][j];
    }
    matrix_power();
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            ans += res[i][j];
        }
    }
    cout << ans % mod;
    return 0;
}

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

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

Measured memory_bytes: 384