akhauriyash/Code-Regression huggingface dataset:
// Problem : D - Xor Sum 4
// Contest : AtCoder - AtCoder Beginner Contest 147
// URL : https://atcoder.jp/contests/abc147/tasks/abc147_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
void solve()
{
    ll n;
    cin>>n;
    ll pw[61];
    pw[0]=1;
    for(ll i=1;i<=60;i++)
    {
    	pw[i]=(2*pw[i-1])%MOD;
    }
    vector<ll> a(n);
    rep(i,0,n)
    	cin>>a[i];
    ll ans=0;
    for(ll i=0;i<=60;i++)
    {
    	ll s=0;
    	for(ll j=0;j<n;j++)
    	{
    		if(a[j]&1)
    			s++;
    		a[j]=a[j]/2;
    	}
    	ans=(ans+(((s*(n-s))%MOD)*pw[i])%MOD)%MOD;
    }
    cout<<ans;
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<int(n);i++)
using namespace std;
const ll pa=1000000007;

inline int max(int a, int b) {//最大
	if (a > b) return a;
	return b;
}
inline int min(int a, int b) {//最小
	if (a < b) return a;
	return b;
}

ll mod(ll a) {
	return a % pa;
}

ll gcd(ll a, ll b) {
	ll r = a % b;
	if (r == 0) return b;
	gcd(b, r);
}
 
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

void swap(ll &a, ll &b) {
	ll tmp = a;
	a = b;
	b = tmp;

}

ll n, k;
ll ans = 0;

int main() {
	cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ans += a[i];
	}
	sort(a.begin(),a.end());
	
	int i = n - 1;
	int p = 1;
	while (p <= k && i>=0) {
		ans -= a[i];
		i--;
		p++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String odd = sc.next();
        String even = sc.next();
        final int N = odd.length();
        final int M = even.length();
        final int L = Math.min(N, M);
        
        String ans = "";
        for (int i = 0; i < L; i++) {
            ans += odd.charAt(i);
            ans += even.charAt(i);
        }
        if (N < M) {
            ans += even.charAt(M - 1);
        } else if (N > M) {
            ans += odd.charAt(N - 1);
        }
            
        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 21588
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int cnt = 0;
    int ans = 0;
    String s = sc.next();
    String[] m = s.split("");
    for (int i = 0; i < 3; i++) {
      if (("o").equals(m[i]))
        cnt++;
    }
    ans = 700 + 100 * cnt;
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	int l = A + B;
	int r = C + D;
	string ret;
	if(l > r)
		ret = "Left";
	else if(l == r)
		ret = "Balanced";
	else
		ret = "Right";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[57],n,m;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=n;i>n-m;i--) a[0]+=a[i];
	cout<<a[0]<<endl; 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector> //可変長配列
#include <queue> //キュー
#include <unordered_map> //ハッシュ連想配列
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    for(;;){
        int n,m; cin>>n>>m;
        bool cont = true;
        if(n==0&&m==0) break;
        int taro[100],hanako[100],tarosum=0,hanakosum=0;
        for(int i = 0; i < n; i++){
            cin>>taro[i];
            tarosum+=taro[i];
        }
        for(int i = 0; i < m; i++){
            cin>>hanako[i];
            hanakosum+=hanako[i];
        }
        int ansa=0,ansb=0,ansum=INFTY;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                if((tarosum-taro[i]+hanako[j])==(hanakosum-hanako[j]+taro[i])){
                    if(taro[i]+hanako[j]<ansum){
                        ansa = taro[i];
                        ansb = hanako[j];
                        ansum = taro[i]+hanako[j];
                    }
                }
            }
        }
        if(ansum==INFTY) cout<<"-1"<<endl;
        else cout<<ansa<<" "<<ansb<<endl;
    }
    return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    long long ans = n;
    int tmp = 0;
    int l = 0;
    for(int r=0; r<n; r++) {
        while(tmp & a[r]) {
            tmp -= a[l];
            l++;
        }
        ans += r - l;
        tmp += a[r];
    }
    cout << ans << endl;

    return 0;
}

// EOF


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int a[10]={};
bool ok(int n){
  while(n){
  if(a[n%10]==0){
    n /= 10;
  }
  else return false;
  }
  return true;
}
int main(void){
  int n, k;

  int d;
  cin >> n >> k;
  for(int i=0; i<k; i++){
    cin >> d;
    a[d]=1;
  }
  while(!ok(n)){
    n++;
  }
  cout << n << endl;
  return 0;
}


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

int main() {
	
	char check[1000000] = "";
	long N;
	int len = 0;
	long ans = 0;

	scanf("%ld", &N);
	

	for (int i = 1; i <= N; i++) {
		sprintf(check, "%d", i);
		len = strlen(check);
		if (len % 2 != 0) {
			ans += 1;
		}
	}

	printf("%ld", ans);

	return 0;
}



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

namespace ConsoleApp1
{
    static class CWelcometoAtCoder
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');
            var n = int.Parse(inputs[0]);
            var m = int.Parse(inputs[1]);
            var acs = new Dictionary<int, int>();
            var was = new Dictionary<int, int>();
            int acCount = 0;
            int waCount = 0;

            for (int i = 0; i < m; i++)
            {
                var answer = Console.ReadLine().Split(' ');
                var number = int.Parse(answer[0]);
                var acOrwa = answer[1];

                if (acOrwa == "AC")
                {
                    if (!acs.ContainsKey(number))
                    {
                        acs.Add(number, 1);
                        acCount++;
                        waCount += was.ContainsKey(number) ? was[number] : 0;
                        was.Remove(number);
                    }                    
                }
                else
                {
                    if (!was.ContainsKey(number))
                    {
                        was.Add(number, 1);
                    }
                    else
                    {
                        was[number]++;
                    }                    
                }
            }
            
            Console.WriteLine($"{acCount} {waCount}");
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 20296
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #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 REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,q,qi,l,r;
string s;
char c;

signed main(){
    cin >> n >> s >> q;
    set<int> idx[26];
    REP(i,n) idx[s[i]-'a'].insert(i);
    vector<char> sc(all(s));

    REP(_,q){
        cin >> qi;
        if (qi == 1){
            cin >> l >> c;
            l--;
            idx[sc[l]-'a'].erase(l);
            idx[c-'a'].insert(l);
            sc[l] = c;
        } else {
            int ret = 0;
            cin >> l >> r;
            l--;
            REP(i,26) {
                auto itl = idx[i].lower_bound(l);
                auto itr = idx[i].lower_bound(r);
                ret += itl != itr;
            }
            cout << ret << endl;
        }
    }
}

Measured memory_bytes: 24708
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

int main() {
  string S;
  cin >> S;
  const int N = S.size();

  auto f = [](string s) {
    int n = s.size();
    for (int i = 0; i < (int)(n); ++i) if (s[i] != s[n - 1 - i]) return false;
    return true;
  };

  if (f(S) && f(S.substr(0, (N - 1) / 2)) && f(S.substr((N + 3) / 2 - 1))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vector<vi> g(n);
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vi df(n,-1),ds(n,-1);
  queue<int> q;
  q.push(0);
  df[0]=0;
  while(q.size()){
    int p=q.front();
    q.pop();
    rep(i,g[p].size()){
      int next=g[p][i];
      if(df[next]==-1){
	df[next]=df[p]+1;
	q.push(next);
      }
    }
  }
  q.push(n-1);
  ds[n-1]=0;
  while(q.size()){
    int p=q.front();
    q.pop();
    rep(i,g[p].size()){
      int next=g[p][i];
      if(ds[next]==-1){
        ds[next]=ds[p]+1;
        q.push(next);
      } 
    }
  }
  int f=0,s=0;
  rep(i,n)
    if(ds[i]<df[i])s++;
    else f++;
  if(s<f)cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;
}


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

int main()
{
string a,b;
int flag=0,c;

cin>>a>>b;
int length=a.length();
for(int i=0;i<length;i++)
{
  if(a[i]==b[i])
  {
    flag++;
  }
}
c=length-flag;
cout<<c<<endl;
return 0;
}


Measured memory_bytes: 3920
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n = input_int()
    MOD = (10 ** 9) + 7

    if n == 1:
        print(0)
    # elif n == 2:
    #     print(2)
    else:
        print(((10 ** n) - (9 ** n) - (9 ** n) + (8 ** n)) % MOD)

if __name__ == "__main__":
    main()


Measured memory_bytes: 10840
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func main() {
	defer write.Flush()

	a := make([][]int, 3)
	for i := range a {
		a[i] = make([]int, 3)
	}

	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			fmt.Fscan(read, &a[i][j])
		}
	}

	var n int
	fmt.Fscan(read, &n)

	for i := 0; i < n; i++ {
		var b int
		fmt.Fscan(read, &b)
		for i := range a {
			for j := range a[i] {
				if a[i][j] == b {
					a[i][j] = -1
				}
			}
		}
	}

	ans := "No"
	for i := 0; i < 3; i++ {
		if a[i][0] == a[i][1] && a[i][0] == a[i][2] {
			ans = "Yes"
		}
		if a[0][i] == a[1][i] && a[0][i] == a[2][i] {
			ans = "Yes"
		}
	}

	if a[0][0] == a[1][1] && a[0][0] == a[2][2] {
		ans = "Yes"
	}
	if a[0][2] == a[1][1] && a[0][2] == a[2][0] {
		ans = "Yes"
	}
	fmt.Fprintln(write, ans)
}


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

map<ll,ll> p;
queue<ll> q;

void prime(ll n){
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)q.push(i);
        while(n%i==0){
            p[i]++;
            n/=i;
        }
    }
    if(n!=1){
        p[n]=1;
        q.push(n);
    }
    return;
}

int main(){
    ll n;cin>>n;
    prime(n);
    ll ans=0;
    while(q.size()){
        auto a=p[q.front()];q.pop();
        rep(i,50){
            if(a<i*(i+1)/2){
                ans+=i-1;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    try(Scanner sc = new Scanner(System.in)) {
      int A = sc.nextInt();
      int B = sc.nextInt();
      int c1 = A + (int)Math.abs(B);
      int c2 = A * B;
      int c = c1 < c2 ? c2 : c1;
      System.out.println(c);
    }
  }
}

Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int N = 18;
const int INF = 1e18 + 239;

pair<int, int> conq(pair<int, int> a, pair<int, int> b) {
	if (a.first < b.first) swap(a, b);
	return make_pair(a.first, max(a.second, b.first));
}

int a[1 << N];
pair<int, int> mn[1 << N];

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

	int n;
	cin >> n;
	for (int i = 0; i < (1 << n); i++) {
		cin >> a[i];
		mn[i] = {a[i], -INF};
	}
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j < (1 << n); j++) {
			if ((j >> i) & 1) {
				mn[j] = conq(mn[j], mn[j ^ (1 << i)]);
			}
		}
	}
	int c = 0;
	for (int i = 0; i < (1 << n); i++) {
		c = max(c, mn[i].first + mn[i].second);
		if (i > 0) cout << c << '\n';
	}
}


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

using namespace std;

int main(){
	int n;cin>>n;
	string s;cin>>s;
	bool puede = false;
	if(n%2 == 0){
		string s1 = s.substr(0, n/2);
		string s2 = s.substr(n/2,n/2);
		if(s1 == s2){
			puede = true;
		}
	}
	if(puede){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s; cin >> s;
  bool b = true;
  for(int i=1; i<4; i++){
    if(s[i] == s[i-1]){
      b = false;
      break;
    }
  }
  if(b)cout << "Good" << endl;
  else cout << "Bad" << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
W = [list(map(int, input().split())) for _ in range(M)]
W.sort()
C = [0 for i in range(N-1)]
r = W[0][1]-1
for i in range(1, M):
    r = min(W[i][1]-1, r)
    if r <= W[i][0]-1:
        C[W[i-1][0]-1] = 1
        r = W[i][1]-1
C[W[-1][0]-1] = 1
print(sum(C))

Measured memory_bytes: 28696
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> as;

int twos(int a) {
    int cnt = 0;
    while (a % 2 == 0) {
        cnt++;
        a /= 2;
    }
    return cnt;
}

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

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        cnt += twos(as[i]);
    }

    cout << cnt << endl;

    return 0;
}


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

using namespace std;
#define N 200

int main()
{
	int n, k;
	int d[N];
	int a[N][N];
	int cnt[N] = {};
	int flag = 0;

	cin >> n >> k;
	for (int i = 0; i < k; i++){
		cin >> d[i];
				for(int j = 0; j < d[i]; j++){
			cin >> a[i][j];
			cnt [a[i][j]]++;
		}
	}
	for(int i =1; i<=n; i++){
		if(cnt[i] == 0){
			flag++;
		}
	}
	cout << flag;
		return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

ll mod = 1;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

class combination{
public:
    vector<mint> fact,inv,finv;
    combination(int N){
        fact = inv = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        inv[0] = inv[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
            inv[i] = (mint) mod - inv[mod%i]*(mod/i);
            finv[i] = finv[i-1]*inv[i];
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N >> mod;
    combination C(N);
    mint ans = 0;
    vec<mint> pow2(N*N+1,1);
    for(int i=1;i<=N*N;i++) pow2[i] = pow2[i-1]*2;
    for(int r=0;r<=N;r++){
        int b = N-r;
        mint now = 0;
        for(int j=0;j<=r;j++){
            mint p = ((mint) 1)-((mint) 2).pow(j-r+mod-1);
            mint val = p.pow(b);
            val *= pow2[r*b-b*j]*((mint) mod-1).pow(j)*C.comb(r,j);
            now += val;
        }
        now *= pow2[r*(r-1)/2+b*(b-1)/2]*C.comb(N,r);
        ans += now;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 34040
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b,c,f=0;
 cin>>a>>b>>c;

for(int i=1;i<=a;i++)
 if((b*i+c)%a==0){f=1;break;}
 if(f)cout<<"YES"<<endl;
 else cout<<"NO"<<endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long t,n,i,j,k,x;
    string s;
    cin>>s;
    n=0;
    for(auto x:s)
        n=(n+x-'0')%9;
    if(n%9==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
  return 0;
}


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

int main(){
	int N;
	long long K;
	cin >> N >> K;
	int A[N];
	for(int i=0;i<N;i++){
		cin >> A[i];
		A[i]--;
	}
	int G[N];
	for(int i=0;i<N;i++){
		G[i] = 0;
	}
	G[0]++;
	int st = -1;
	long long cnt = 0;
	int now = 0;
	while(K > 0){
		now = A[now];
		K--;
		G[now]++;
		if(G[now] == 2){
			if(st == -1){
				st = now;
			}
			else{
				cnt++;
			}
		}
		else if(G[now] == 3 && now == st){
			cnt++;
			K %= cnt;
		}
		// cout << now<< ":" << K << endl;
		// cout << cnt << endl;
	}
	cout << now + 1 << endl;
}

Measured memory_bytes: 5192
main = putStrLn =<< solver <$> getLine <*> getLine
 
solver :: String -> String -> String
solver s' t = h (fmap (zipWith g s') (filter (and . (zipWith f s')) ts))
 where
    ts = fmap ((\l x -> (replicate x '?') ++ t ++ (replicate (l - x) '?')) n) [0..n]
    n = (length s') - (length t)
    f a b = (a == '?') || (a == b) || (b == '?')
    g a b = if (a == '?') then (if (b == '?') then 'a' else b) else a
    h [] = "UNRESTORABLE"
    h a = minimum a

Measured memory_bytes: 892
S = input()

dict_S = {}

for s in S:
  if s not in dict_S:
    dict_S[s] = 1
  else:
    dict_S[s] += 1

    
if len(dict_S) == 2:
  for v in dict_S.values():
    if v == 2:
      continue
    else:
      print('No')
      break
    
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;

vector<int > bok[11];
int n, k;
int memo[11][2001];
int rui[11][2001];

int check(int j, int w)
{
	return rui[j][w]+w*(w-1);
}
int dp(int j,int w)
{
	if (j == 11)return 0;
	if (w >= k)return 0;
	if (memo[j][w] != -1)return memo[j][w];
	int ans = 0;
	for (int i = 0; i <= min((int)bok[j].size(),k-w); i++)
	{
		ans = max(ans, dp(j + 1, w + i) + check(j, i));
	}
	return memo[j][w] = ans;
}


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

	for (int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		bok[y].push_back(x);
	}
	memset(memo, -1, sizeof(memo));
	for (int i = 1; i < 11; i++)
	{
		sort(bok[i].begin(), bok[i].end());
		reverse(bok[i].begin(), bok[i].end());
		rui[i][0] = 0;
		for (int s = 1; s <= bok[i].size(); s++)
		{
			rui[i][s] = rui[i][s - 1] + bok[i][s - 1];
		}
	}
	cout << dp(1, 0) << endl;

}

Measured memory_bytes: 1372
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int[] ant = new int[5];
 		ant[0] = sc.nextInt();
		ant[1] = sc.nextInt();
		ant[2] = sc.nextInt();
		ant[3] = sc.nextInt();
		ant[4] = sc.nextInt();
		int k = sc.nextInt();
		int cnt = 0;
		
		for(int l = 0; l < ant.length; l++) {
			for(int n = 0; n < ant.length; n++) {
				if(ant[l] > ant[n]) {
					if(ant[l] - ant[n] > k) {
						cnt++;
					}
				}
				else {
					if(ant[n] - ant[l] > k) {
						cnt++;
					}
				}
			}
		}
		// 出力
		if(cnt == 0) {
			System.out.println("Yay!");
		}
		else {
			System.out.println(":(");
		}
	}
}

Measured memory_bytes: 23508
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define YORN(f) puts((f)?"YES":"NO")
ll n;
//ld ;
//string s;

int main() {
    bool tflg = true;
    cin >> n;
    priority_queue<ll> a;
    for(ll i=0;i<n;i++){
        ll atemp;
        cin >> atemp;
        a.push(atemp);
    }
    ll ptemp = 0;
    for(ll j=0;j<n&&tflg;j++){
        if(a.top() == ptemp){
            tflg = false;
        }else{
            ptemp = a.top();
            a.pop();
        }
    }
    YORN(tflg);
    return 0;
}

Measured memory_bytes: 2420
n = int(input())
l = list(map(int, input().split()))

ll = []
for i in l :
  if i%2 == 0:
    ll.append(i)

cnt = 0
for i in ll:
  if i%3 == 0 or i%5 == 0:
    cnt += 1 

if cnt != len(ll):
  print('DENIED')
else:
  print('APPROVED')

Measured memory_bytes: 9184
public class Main {
    public static void main(String args[]) {
        java.util.Scanner sc = new java.util.Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        int h[] = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        java.util.Arrays.sort(h);
        long ans = 0;
        for (int i = 0; i < Math.max(0, n - k); i++) {
            ans += h[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 63988
#include <bits/stdc++.h>
using namespace std;
unsigned gcd(unsigned a,unsigned b){
  while(1){
    if(a<b) swap(a,b);
    if(!b) break;
    a%=b;
  }
  return a;
}

int main(){
	int W,H,C;
	cin >> W>>H>>C;
	int t = gcd(W,H);
	
	cout << W*H*C/t/t << endl;
	return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)

using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif


std::mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int a, int b) {
    return uniform_int_distribution<int>(a, b)(rng);
}

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

const ll INF = (ll)(8e18);
const ll MOD = (ll)(1e9 + 7);
const ll HMOD = (ll)4222234727;
const ll Hashprime = (ll)31;

const int maxn = 100100;

std::vector<pii> g[maxn];
int ans[maxn];

void dfs(int v, int par, bool parity){
   ans[v] = parity;
   for(auto i : g[v]){
       if(i.first != par){
          if(i.second){
             dfs(i.first, v, parity ^ 1);
          }else{
             dfs(i.first, v, parity);
          }
       }
   }
}

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    while(t--){
       int n; cin >> n;
       for(int i = 1; i < n; i++){
          int u,v,w; cin >> u >> v >> w;
          g[u].push_back({v, (w % 2 != 0)});
          g[v].push_back({u, (w % 2 != 0)});
       }
       dfs(1, -1, 0);
       for(int i = 1; i <= n; i++) cout << ans[i] << '\n';
    }
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "c" "comp.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g


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

const int N = 2e5 + 10;

int n, m, f[N];

struct edge {
	int u, v, w;
}e[N << 1];

int find(int x) {
	if (f[x] == x) return x;
	return f[x] = find(f[x]);
}

bool cmp(edge a, edge b) {
	return a.w < b.w;
}

int main() {
	scanf("%d%d", &n, &m);
	int cnt = 0;
	for (int i = 1; i <= m; ++i) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		e[++cnt] = (edge) { a, b, 0 };
	}
	for (int i = 1; i <= n; ++i) {
		e[++cnt] = (edge) { n + 1, i, 1 };
	}
	++n;
	for (int i = 1; i <= n; ++i) f[i] = i;
	int ans = 0;
	sort(e + 1, e + cnt + 1, cmp);
	for (int i = 1; i <= cnt; ++i) {
		int x = find(e[i].u), y = find(e[i].v);
		if (x != y) {
			ans += e[i].w;
			f[y] = x;
		}
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define int int64_t
#define double long double
#define rep(i, N) for(int i=0; i<N; i++)
#define repr(i, N) for(int i=N-1; i>=0; --i)
#define all(v) v.begin(),v.end()
using namespace std;
using vec = vector<int>;
int sum(int n){
    int ans = 0;
    for(int i = 1;i <= n;i++)
    {
        ans += i;
    }
    return ans;
}
signed main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int len;
    int ans = 0;
    int cmp = 0;
    string s;
    cin >> s;
    len = s.size();
    len++;
    vec d(len);
    d[0] = 1;
    d[len-1] = 1;
    for(int i = 1; i < len-1; i++)    
     {
        if(s[i] != s[i - 1])         
        {
            d[i] = 1;
            if(s[i] == '>')             
            {
                cmp = d[i - 1];
                ans += sum(d[i - 1]);
            }
            else            
            {
                ans += sum(d[i - 1]);
                ans -= min(cmp,d[i - 1]);
            }
        }
        else
        {
            d[i] = d[i - 1] + 1;
        }
    }
    ans += sum(d[len - 2]);
    if(s[len - 2] == '>')    ans -= min(d[len - 2],cmp);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a[4][4];
    bool b[4][4]={};
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
		    cin>>a[i][j];	
		}
	}
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		long long x;
		cin>>x;
		for(int j=1;j<=3;j++)
	    {
		    for(int k=1;k<=3;k++)
		    {
		        if(x==a[j][k])
				{
					b[j][k]=true;
				}	
		    }
	    }	
	}
	for(int i=1;i<=3;i++)
	{
		if(b[i][1]&&b[i][2]&&b[i][3])
		{
			cout<<"Yes";
			return 0;
	    }
	    if(b[3][i]&&b[1][i]&&b[2][i])
		{
			cout<<"Yes";
			return 0;
	    }
	}
	if(b[1][1]&&b[2][2]&&b[3][3])
	{
		cout<<"Yes";
		return 0;
	 } 
	if(b[1][3]&&b[2][2]==1&&b[3][1])
	{
	    cout<<"Yes";
		return 0;
	}  
	cout<<"No"; 
	return 0;
}                     

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int h,m,s,S;
    scanf("%d",&S);
    
    s=S%60;
    m=S/60%60;
    h=S/3600;
    
    printf("%d:%d:%d\n", h, m, s);
    
    
    return 0;
}



Measured memory_bytes: 2100
using System;
using System.Linq;
using System.Collections.Generic;
class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        
        var aPlus1 = a.Select(e =>e + 1);
        var aMinus1 = a.Select(e => e - 1);
        var allA = a.Concat(aPlus1.Concat(aMinus1));
        var group = allA.GroupBy(e => e).Select(e => new { e.Key, Count = e.Count() });        
        var ans = group.OrderByDescending(e => e.Count).First();


        Console.WriteLine(ans.Count);
    }
    
}

Measured memory_bytes: 36844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
void read(int& x){ scanf("%d",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back

int main()
{
    int n, x=0, y=0;
    read(n);
    for(;n--;){
		int a; read(a);
		((a%2)?x:y)++;
    }
    if(x&1) puts("NO");
    else puts("YES");
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define present(i, c) ((c).find(i) != (c).end())

#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define fora(i, a, b) for(int i = (a); i < (b); i++)
#define ford(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define watch(x) TRACE(cerr << #x" = " << x << endl)
#define watch_all(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)
	
#define INF 0x3F3F3F3F

//=========================

int H[100001];
int dp[100001];

void run_test() {
	int N, K; cin >> N >> K;
    for0(i, N) cin >> H[i];
    ini(dp, 0x3f);
    dp[0] = 0;
    for0(i, N)
        for1(k, K)
            if(i+k < N) 
                dp[i+k] = min(dp[i+k], dp[i] + abs(H[i+k]-H[i]));
    cout << dp[N-1] << endl;
}

//=========================

ifstream infile;
clock_t start__;
void open_func();
void close_func();

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	open_func();
	//int t; cin >> t; while(t--) run_test();
	run_test();
	close_func();
	return 0;	
}

void open_func() {
	//infile = ifstream("input.in"); if(infile.good()) cin.rdbuf(infile.rdbuf());
	start__ = clock();
	cerr << "---" << endl;
}

void close_func() {
	clock_t elapsed = clock()-start__;
	cerr << "---" << endl << "(time " << fixed << setprecision(2) << elapsed * (1.0/CLOCKS_PER_SEC) << "s)" << endl;	
	//if(infile.good()) infile.close();
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    long l, r;
    long ans = 0;

    while (n--) {
        cin >> l >> r;

        ans += r - l + 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma region def
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

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

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
using pint = pair<int, int>;
const int INF = 1e9;
const long long llINF = 1e18;
#pragma endregion

int main () {
    string s; cin >> s;
    for (int i = 0; i < s.length(); i++) {
        s[i] = 'x';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)

	trees := make([]tree, n+1)
	trees[0].parent = -1
	for i := 0; i < n-1; i++ {
		uvw := getIntList(scanner)
		u := uvw[0]
		v := uvw[1]
		w := uvw[2] % 2

		update(u, v, w, trees)
		trees[v].parent = u
		trees[v].w = w
	}
	for i := 1; i <= n; i++ {
		fmt.Println(chokudai(i, trees))
	}
}

type tree struct {
	parent int
	w      int
}

func update(u int, v int, w int, trees []tree) {
	p := trees[v].parent
	if p == 0 {
		return
	}
	w ^= trees[v].w
	update(u, p, w, trees)
	trees[p].parent = u
	trees[p].w = w

}
func chokudai(i int, trees []tree) int {
	if trees[i].parent == 0 {
		return trees[i].w
	}
	w := (trees[i].w + chokudai(trees[i].parent, trees)) % 2
	trees[i].w = w
	trees[i].parent = 0
	return w
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int n, m;
ll x[1111], y[1111], z[1111];
ll val[1111];

int main() {
   cin >> n >> m;
   rep (i, n) cin >> x[i] >> y[i] >> z[i];

   ll ans = -1e18;
   rep (mask, 8) {
      int a = (mask & 1) ? -1 : 1;
      int b = (mask & 2) ? -1 : 1;
      int c = (mask & 4) ? -1 : 1;
      rep (i, n) {
         val[i] = a * x[i] + b * y[i] + c * z[i];
      }
      sort(val, val+n, greater<ll>());
      ll cur = 0;
      rep (i, m) cur += val[i];
      ans = max(ans, cur);
   }
   cout << ans << endl;

   return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;

const ll INF = (1LL<<60);

int main(){

    ll n; cin >> n;
    vll h(n);
    rep(i, n) cin >> h[i];

    ll m = 0;
    ll cnt = 0;
    rep(i, n-1){
        if(h[i]>=h[i+1]) cnt++;
        else cnt = 0;
        m = max(m, cnt);
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define re(n) for (int i = 0; i < (n); ++i)
#define rej(n) for (int j = 0; j < (n); ++j)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <pair <int, int>> vii;

const ld PI = acos((ld)-1);

int main() {
    #ifndef LOCALDEBUG
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #endif  // LOCALDEBUG
    int n;
    cin >> n;
    vi b(n);
    re(n-1) cin >> b[i];
    int ans = 0;
    ans += b[0];
    b[n-1] = INT32_MAX;
    re(n-1)
        ans += min(b[i], b[i + 1]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
a=int(input())
sum=0
s=''

if a!=0:
    while(a!=1):
        if a%(-2)==-1:
            s=s+'1'
            a=a-1
            a=a/-2
        else:
            s = s + '0'
            a=a/-2
    s=s+'1'
    for i in range(len(s)):
        print(s[len(s)-1-i],end='')
    print()
else:
    print(0)


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

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m, d, cnt = 0;
    cin >> m >> d;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= d; j++) {
            int t1 = j / 10;
            int t2 = j % 10;
            if (t1 >= 2 && t2 >= 2 && i == t1 * t2)
                cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


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

int cnt;

void countSet(int n, int k, int s) {
    if (k == 1 && s == n) {
        cnt++;
    } else if (s > n) {
        for (int i = n - 1; i > 0; --i) {
            countSet(i, k - 1, s - n);
        }
    }
}

int main()
{
    int n, k, s;
    while (cin >> n >> k >> s, n) {
        cnt = 0;
        if (k == 1 && s <= n) {
            cnt = 1;
        } else {
            for (int i = n; i * k > s; --i) {
                countSet(i, k, s);
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t;
    string s;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    b=n/2;
    a=b-1;
    ll ans=arr[b]-arr[a];
    cout<<ans;
}

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

using namespace std;

const int nxx=1e5+5;
vector<pair<long long,long long>> v(101);
long long dp[101][nxx];
int n,k;

long long ans(int i,int k){
    if(i==n||k==0){
        return 0;
    }
	if(v[i].first>k) return ans(i+1,k);
	if(dp[i][k]!=-1) return dp[i][k];
	else{
	    long long value=max(ans(i+1,k),ans(i+1,k-v[i].first)+v[i].second);
	    return dp[i][k]=value;
	}
}

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

    for(int i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
    }
	memset(dp,-1,sizeof(dp));
    cout<<ans(0,k);
    
}

Measured memory_bytes: 82520
//#include <bits\stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#define ll long long
#define y1 bad_fdsaf
#ifdef Stetsyk
#define files freopen("input.txt", "r", stdin);
#else
#define files
#endif
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

int main(){
    files;
    string s;
    cin >> s;
    if(s.size() >= 4  && s.substr(0, 4) == "YAKI"){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Node[] list;
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int m= Integer.parseInt(sc.next());
        String s;
        int reg=0;
        int flag=1;
        list=new Node[m];
        for(int i=0;i<m;i++) list[i] = new Node();
        
        for(int i=0;i<m;i++){
        	s=sc.next();
        	if(s.equals("insert")){
        		list[i].number=Integer.parseInt(sc.next());
        		if(flag==1){
        			reg=i;
        			flag=0;
        		}else{
        			insert(list[reg],list,i);
        		}
        	}else if(s.equals("print")){
        		naka(list,list[reg]);
        		System.out.print("\n");
        		mae(list,list[reg]);
        		System.out.print("\n");
            }
        }
    }
    static void insert(Node node,Node[] list,int i){
        if(list[i].number>node.number){
            if(node.right==null){
            	node.right=list[i];
            }else{
            	insert(node.right,list,i);
            }
        }else {
        	if(node.left==null){
        		node.left=list[i];
        	}else{
        		insert(node.left,list,i);
        	}
        }
    }
    static void mae(Node[] list, Node node){
    	System.out.print(" ");
    	System.out.print(node.number);
    	if(node.left!=null){
    		mae(list,node.left);
    	}
    	if(node.right!=null){
    		mae(list,node.right);
    	}
    }
    static void naka(Node[] list, Node node){
    	if(node.left!=null){
    		naka(list,node.left);
    	}
    	System.out.print(" ");
    	System.out.print(node.number);
    	if(node.right!=null){
    		naka(list,node.right);
    	}
    }
}

class Node{
	int number;
	Node left;
	Node right;
	Node(){
		number=-1;
		left=null;
		right=null;
	}
}


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

int main(){
  int a[11]={};
  
  while(1)
    {
      cin >> a[0];
      if(a[0]==0)break;
      
  for(int i =1;i < 10;i++)
    {
      cin >> a[i];
    }
  for(int j =1;j < 11;j++)
    {
      a[0] -= a[j];
    }
  cout << a[0] << endl;
    }
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int A = 0, B = 0, C = 0;
  for(int i = 0; i < 3; i++){
  	if(S.at(i) == 'a'){
    	A++;
    }else if(S.at(i) == 'b'){
    	B++;
    }else if(S.at(i) == 'c'){
    	C++;
    }
  }
  if(A == 1 && B == 1 && C == 1){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256