akhauriyash/Code-Regression huggingface dataset:
#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)-1;i>=(a);i--)
#define all(a) (a).begine(),(a).end()
#define MOD 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main(){
   
    int h,w,a,b;
    cin >> h >> w >> a >> b;

    int f=0;
    rep(i,h){
        rep(j,w){
            cout << (i<b^j<a);
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] left = new int[n + 1];
        int[] right = new int[n + 1];
        left[0] = 0;
        right[n] = 0;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            left[i + 1] = gcd(left[i], a[i]);
        }
        for (int i = n - 1; i >= 0; i--) {
            right[i] = gcd(right[i + 1], a[i]);
        }
        for (int i = 0; i < n; i++) {
            int m = gcd(left[i], right[i + 1]);
            if (ans < m)
                ans = m;
        }
        System.out.println(ans);
    }

    static int gcd(int x, int y) {
        if (y > x)
            return gcd(y, x);
        if (y == 0)
            return x;
        else
            return gcd(y, x % y);
    }
}


Measured memory_bytes: 63156
N = int(input())
A = list(map(int, input().split()))


A_minus = [a for a in A if a < 0]
A_abs = [abs(a) for a in A]

if len(A_minus) % 2 == 0:
    print(sum(A_abs))
else:
    print(sum(A_abs) - 2 * min(A_abs))

Measured memory_bytes: 14284
N,M = map(int,input().split())
H = list(map(int,input().split()))

x = [True] * N

for _ in range(M):
	a,b = map(int,input().split())
	if H[a - 1] >= H[b - 1]:
		x[b - 1] = False
	if H[b - 1] >= H[a - 1]:
		x[a - 1] = False
print(len([i for i in x if i == True]))

Measured memory_bytes: 20052
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int a,b,c,x;
    cin >> a >> b >> c;
    if(a==b&&b==c) x=1;
    else if(a!=b&&b!=c&&c!=a) x=3;
    else x=2;
    cout << x << endl;
}


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

int main(){
  int N, K, i;
  long long int min, max, ans = 0;
  cin >> N >> K;
  int h[N];
  for(i=0; i<N; i++){
    cin >> h[i];
  }
  sort(h, h+N);
  for(i=0; i<N; i++){
    if(i+K-1 <= N-1){
      min = h[i]; max = h[i+K-1];
      if(i==0) ans = max - min;
      if(ans > max-min) ans = max - min;
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N=100010;
const LL LINF=1ll<<60;
int n,m;
int cost[N];
int h[N],tot;
struct Edge{
	int v,next;
}e[N*2];
struct Node{
	int u,t;
}p[N];
inline LL min(LL x,LL y){
	return x<y?x:y;
}
inline LL max(LL x,LL y){
	return x>y?x:y;
}
void addEdge(int u,int v){
	e[++tot]=(Edge){v,h[u]}; h[u]=tot;
	e[++tot]=(Edge){u,h[v]}; h[v]=tot;
}
void readData(){
	scanf("%d%d",&n,&m);
	int a,b;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		cost[i]=b;
		p[i]=(Node){i,max(a-b,0)};
	}
	int u,v;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		addEdge(u,v);
	}
}
int bel[N];
bool active[N];
LL f[N],sum[N];
bool cmpThreshold(const Node &x,const Node &y){
	return x.t<y.t;
}
int find(int x){
	return bel[x]==x?x:(bel[x]=find(bel[x]));
}
void solve(){
	sort(p+1,p+1+n,cmpThreshold);
	for(int i=1;i<=n;i++) bel[i]=i;
	for(int ii=1;ii<=n;ii++){
		int u=p[ii].u;
		active[u]=true;
		sum[u]=cost[u];
		f[u]=LINF;
		bool haveSon=false;
		for(int i=h[u],v;i;i=e[i].next){
			v=find(e[i].v);
			if(v!=u&&active[v]){
				active[v]=false;
				haveSon=true;
				bel[v]=u;
				sum[u]+=sum[v];
				f[u]=min(f[u],max(f[v],p[ii].t-sum[v]));
			}
		}
		if(!haveSon)
			f[u]=p[ii].t;
	}
	int last=p[n].u;
	printf("%lld\n",sum[last]+f[last]);
}
int main(){
	readData();
	solve();
	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> ans;
    for(int d = 1; d <= min(a, b); d++) {
        if(a % d == 0 and b % d == 0) {
            ans.push_back(d);
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		int D = stdIn.nextInt();
		
		if (D == 25)
			System.out.println("Christmas");
		else if (D == 24)
			System.out.println("Christmas Eve");
		else if (D == 23)
			System.out.println("Christmas Eve Eve");
		else if (D == 22)
			System.out.println("Christmas Eve Eve Eve");
				
	}

}


Measured memory_bytes: 21076
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		FastScanner sc=new FastScanner();
		int n=sc.nextInt();
		int a[]=sc.readArray(n);
		Arrays.sort(a);
		int min=Integer.MAX_VALUE;
	//	int j=n-1;
		long ans=0;
		ArrayList<Integer> al=new ArrayList<Integer>();
		al.add(a[n-1]);
		for(int i=n-2;i>=0;i--)
		for(int j=0;j<2;j++) al.add(a[i]);
		
		for(int i=0;i<n-1;i++)
		ans+=al.get(i);
		
		//ans-= al.get(n-1);
	
	     
	

	System.out.println(ans);
		
		
		
	}
		static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}
}


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

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;



int main()
{
    int x,y;
    cin>>x>>y;
    if(4*x<y||y<2*x)
    {
        cout<<"No";
        return 0;
    }
    if(y%2==0&&2*x==y)
    {
        cout<<"Yes";
        return 0;
    }
    if(y%4==0&&4*x==y)
    {
        cout<<"Yes";
        return 0;
    }
    
    if(y%2!=0)
    {
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
return 0;
}

Measured memory_bytes: 3624
#python 3.7.1
s = list(input())
s = [int(i) for i in s]
n = 0
r = 0
b = 0
for i in s:
	if s[n] == 0:
		r += 1
	elif s[n] == 1:
		b += 1
	n += 1
print(min(r,b) * 2)

Measured memory_bytes: 4652
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    cin >> n;
    for(int i =0; i<n; i++) cin >> R[i];
    int maxv = -2000000000;
    int minv = R[0];
    for(int i =1; i<n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3884
#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
#define mod 1000000007
#define MN 1000000
ll f[MN+5],n;
int main(){
    ll sum=0;
    scanf("%d",&n);
    f[1]=n; f[2]=(n*n)%mod;
    for(int i=3;i<=n;i++){
        sum=(sum+f[i-3])%mod;
        f[i]=(sum+f[i-1]+(n-1)*(n-1)%mod+n-i+2)%mod;
    }
    cout<<f[n]; 
    return 0;  
}

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


using namespace std;

#define int long long
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define ff first 
#define ss second 
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpii;
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    vi h(n),dp(n,1e9);
    cin >> h;
    dp[0]= 0;
    for(int i = 0; i < n; ++i){
        for(int j = 1; j <= k; ++j){
            if(i + j < n){
                dp[i + j] = min(dp[i+j],dp[i] + abs(h[i] - h[i+j]));
            }
        }
    }
    
    cout << dp[n-1];
}

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

using namespace std;


void solve() {
    int x, y;
    cin >> x >> y;
    int r = (x*3+y)/2;
    cout << r;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#!/usr/bin/python
 
input_data = list(map(int,input().split()))
 
neko = input_data[0]
neko_inu = input_data[1]
d = input_data[2]
 
if neko > d:
    print("NO")
elif neko+neko_inu < d:
    print("NO")
else:
    print("YES")

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

int main()
{
    char a,b;
   // freopen("inp.txt","r",stdin);
   cin>>a>>b;
    if(a=='H')
    {
        if(b=='H')
        {
            cout<<"H ";
        }
        else
            cout<<"D ";
    }
    else
    {
        if(b=='H')
        {
            cout<<"D ";
        }
        else
            cout<<"H ";

    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;cin>>H>>W;
  char X[H+2][W+2];string x="Yes";
  for(int i=0;i<H+2;i++){X[i][0]='.';X[i][W+1]='.';}
  for(int i=0;i<W+2;i++){X[0][i]='.';X[H+1][i]='.';}
  for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)cin>>X[i][j];
  for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)
    if(X[i][j]=='#'&&X[i-1][j]=='.'&&X[i+1][j]=='.'
       &&X[i][j-1]=='.'&&X[i][j+1]=='.')x="No";
  cout<<x<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int comp_count(const int &left, const int & right) {
	if (left + 1 < right) {
		return (right - left) + comp_count(left, (left + right) / 2) + comp_count((left + right) / 2, right);
	}
	else {
		return 0;
	}
}
int main() {
	int n;
	std::cin >> n;
	std::vector<int> vector(n);
	for (auto &v : vector) {
		std::cin >> v;
	}
	sort(vector.begin(), vector.end());
	std::cout << vector.at(0);
	for (auto i = 1; i < n; ++i) {
		std::cout << " " << vector.at(i);
	}
	std::cout << std::endl << comp_count(0, n) << std::endl;
	return 0;
}

Measured memory_bytes: 4608
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

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


Measured memory_bytes: 3632
/*input
1
9
10
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
int v[105],t[105],n,a[20005],res[20005];

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,p,x,y;
	cin>>n;
	long double ans=0;
	for(int i=0;i<n;++i){
		cin>>t[i];
	}
	for(int i=0;i<n;++i){
		cin>>v[i];
	}
	int last=0;
	for(int i=0;i<n;last+=t[i++])
		for(int j=0;j<t[i];++j)
			a[last+j]=v[i];

	for(int i=1;i<last;++i)
		res[i]=min({1+res[i-1],a[i],a[i-1]});

	for(int i=last;--i;)
		res[i]=min({res[i],1+res[i+1],a[i]});
	//for(int i=0;i<=last;++i) cout<<i<<" : "<<res[i]<<'\n';
	for(int i=1;i<=last;++i){
		ans+=((double)(res[i-1]+res[i]))/2;
		if(res[i-1]==res[i] && res[i]<a[i-1])
			ans+=0.25;
	}
	cout<<fixed<<setprecision(9)<<ans;
}

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

#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  solve();
  return 0;
}

void solve() {
  int d, g;
  std::cin >> d >> g;
  std::vector<int> p(d), c(d);
  REP(i, d) {
    std::cin >> p.at(i) >> c.at(i);
  }

  int min_num = 100000;
  REP(i, (1 << d)) {
    std::bitset<10> b(i);
    int score = 0;
    int num = 0;

    // Total score of completed problem sets and the number of problems
    REP(j, d) {
      if (b.test(j)) {
        score += 100 * (j+1) * p.at(j) + c.at(j);
        num += p.at(j);
      }
    }

    // Calculate the problem needs to be solved
    if (g > score) {
      // Find the problem set with the highest points from incomplete problem sets
      int h_score;
      int h_num;
      for (int j = d-1; j >= 0; j--) {
        if (!b.test(j)) {
          h_score = 100 * (j + 1);
          h_num = p.at(j);
          break;
        }
      }
      if (g - score > (h_num - 1) * h_score) {
        continue;
      }
      num += (g - score + h_score - 1) / h_score;
    }

    // update min
    if (num < min_num) {
      min_num = num;
    }
  }
  cout(min_num);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#define int long long
using namespace std;
int n;
signed main()
{
    cin >> n;
    int a[n + 2], total[n + 2];
    total[0] = 0;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 1; i < n; i++)
    {
        total[i] = total[i - 1] + abs(a[i] - a[i - 1]);
        if (i > 1)
            total[i] = min(total[i], total[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << total[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    string s;
    cin>>s;
    REP(i,s.size()){
        cout<<"x";
    }
    cout<<endl;
    return 0;
}

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

int main()
{
	string s;
	int q;
	cin >> s >> q;
	vector<tuple<int, int, char>> query(q);
	for (int i = 0; i < q; i++) {
		int t_in;
		cin >> t_in;
		int f_in = 0;
		char c_in = ' ';
		if (t_in == 2) {
			cin >> f_in >> c_in;
		}
		query.at(i) = make_tuple(t_in, f_in, c_in);
	}

	bool dir = true;
	deque<char> d;
	for (auto c : s) {
		d.push_back(c);
	}

	for (auto query_ele : query) {
		int t = get<0>(query_ele);
		int f = get<1>(query_ele);
		char c = get<2>(query_ele);

		if (t == 1) {
			dir = !dir;
		}
		if (t == 2) {
			if (dir == true) {
				if (f == 1) {
					d.push_front(c);
				} else {
					d.push_back(c);
				}
			} else {
				if (f == 1) {
					d.push_back(c);
				} else {
					d.push_front(c);
				}
			}
		}
	}

	if (dir == true) {
		while (d.size() != 0) {
			cout << d.front();
			d.pop_front();
		}
	} else {
		while (d.size() != 0) {
			cout << d.back();
			d.pop_back();
		}
	}
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 n;
  cin >> n;
  vi data(n);
  rep(i,n) cin >> data[i];
  vi same(n);
  rep(i,n) same[i] = data[i];
  sort(all(same));
  reverse(all(same));
  in6 est = same[0], er = same[1];
  rep(i,n) {
    if(data[i] == est) cout << er;
    else cout << est;
    hinata;
  }
}

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

int main() {
  int N;
  cin >> N;
  string s[N];
  for(int i=0;i<N;i++){
    cin >> s[i];
  }
  int M;
  cin >> M;
  string t[M];
  for(int i=0;i<M;i++){
    cin >> t[i];
  }
  vector<int> score(N+M,0);
  string str[N+M];
  int k=0;
  bool flag=false;
  for(int i=0;i<N;i++){
    str[k]=s[i];
    flag=false;
    for(int j=0;j<k;j++){
      if(str[j]==str[k]){
        score.at(j)++;
        break;
      }
      if(j+1==k){
        flag=true;
      }
    }
    if(k==0||flag==true){
      score.at(k)++;
      k++;
      continue;
    }
  }
  for(int i=0;i<M;i++){
    str[k]=t[i];
    flag=false;
    for(int j=0;j<k;j++){
      if(str[j]==str[k]){
        score.at(j)--;
        break;
      }
      if(j+1==k){
        flag=true;
      }
    }
    if(k==0||flag==true){
      score.at(k)--;
      k++;
      continue;
    }
  }
  int tmp=0;
  for(int i=0;i<k;i++){
    if(tmp<score.at(i)){
      tmp=score.at(i);
    }
  }
  cout << tmp << endl;
}


Measured memory_bytes: 256
'use strict'

function Main(input) {
  const S = input.split("")
  for(let i=0; i<S.length-1; i++) {
    if(S[i] === S[i+1]) {
      console.log("Bad")
      return
    }
  }
  console.log("Good")

}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())

Measured memory_bytes: 21064
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string S; cin >> S;
    int ans = 0;
    rep(i, 10) {
        rep(j, 10) {
            rep(k, 10) {
                bool exist[3] = {};
                rep(t, n) {
                    if(!exist[0] && S[t] == i + '0') exist[0] = true;
                    else if (exist[0] && !exist[1] && S[t] == j + '0') exist[1] = true;
                    else if (exist[0] && exist[1] && !exist[2] && S[t] == k + '0') exist[2] = true;
                    if(exist[0] && exist[1] && exist[2]) {
                        //cout << i << " " << j << " " << k << endl;
                        ans++; break;
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

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

		String s = sc.next();

		int count = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '1') {
				count++;
			}
		}

		System.out.println(count);

		sc.close();
	}
}



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

using namespace std;

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

    for (int a = 1; a < 10000; a++) {
        double P8 = a * 0.08;
        double P10 = a * 0.1;

        double P8_ = floor(P8);
        double P10_ = floor(P10);


        if(P8_ == A){
            if(P10_ == B){
                cout << a << endl;
                return 0;
            }
        }

    }

    cout << "-1" << endl;


    return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

const long long unsigned int mod = 1000000007;
bool contain( char* a, char* b, int al, int bl ){
    if( al > bl ) return false;

    long long unsigned int t = 1;
    for( int i = 0; i < al; i++ ) t *= mod;

    long long unsigned int ah = 0, bh = 0;
    for( int i = 0; i < al; i++ ) ah = ah * mod + a[i];
    for( int i = 0; i < al; i++ ) bh = bh * mod + b[i];

    for( int i = 0; i + al <= bl; i++ ){
        if( ah == bh ) return true;
        if( i+al < bl ) bh = bh * mod + b[i+al] - b[i] * t;
    }
    return false;

}
    int N;

int main() {

    Scd(N);
    char s[114514];
    Scs(s);

    int streak = 0;
    int ans = 0;

    int sr = N/2+1;
    int sl = 0;

    bool ok = true;
    while( sr - sl > 1 ){
        int sc = ( sr+sl ) / 2;
        ok = false;
        Rep(l1,N-sc*2+1){
            if( contain( s+l1, s+l1+sc, sc, N-l1-sc ) ){
                ok = true;
            }
        }
        if( ok ) sl = sc;
        else sr = sc;
    }

    printf ("%d\n", sl );

    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
 
#define int long long 
#define pb push_back
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define fr first
#define sc second
#define bst ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;

using namespace std;

const int N = 5e5 + 10, mod = 1e9 + 7, inf = 1e18 + 7, logn = 23;
const double pi = acos(-1);

int dp[N], w[N], c[N], n, W;


void solve() {
	//soln
	cin >> n >> W;
	for(int i = 1; i <= n; i++) {
		cin >> w[i] >> c[i];
		for(int j = W; j >= 1; j--) {
			
			if(j >= w[i]) {
				dp[j] = max(dp[j], dp[j - w[i]] + c[i]);
			}
		}
	}
	cout << dp[W] << endl;
}
main() {
	bst;
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
}


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

const ll mod = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  map<int, ll> p;
  for (int i = 2; i <= n; i++) {
    int ix = i;
    int px = 2;
    while (px*px <= ix) {
      if (ix % px == 0) {
          ll cnt = 0;
          while (ix % px == 0) ix /= px, cnt++;
          p[px] += cnt;
      }
      px++;
    }
    if (ix > 1) p[ix] += 1;
  }
  ll ans = 1;
  for (auto &i : p) {
    ans = (ans * ((i.second + 1) % mod)) % mod;
  }
  cout << ans << endl;
  return 0;
}


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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  lli n, nn;
  cin>>n;
  if(n<=4 || (n%2)) {
    cout<<0<<endl;
    return 0;
  }
  lli ans1 = 0, ans2 = 0;
  lli p = 5;
  nn = n;
  n = n / 2;
  rep(i,1,100) {
    if(n/p == 0) break;
    ans1 += (n/p);
    lli pp = p;
    p = p * 5;
    if(pp != p/5) break;
  }
  p = 2;
  rep(i,1,100) {
    if(n/p == 0) break;
    ans2 += (n/p);
    lli pp = p;
    p = p * 5;
    if(pp != p/5) break;
  }
  lli s1 = 0, s2 = 0;
  n = nn;
  p = 5;
  rep(i,1,100) {
    if(n/p == 0) break;
    s1 += (n/p);
    lli pp = p;
    p = p * 5;
    if(pp != p/5) break;
  }
  p = 2;
  rep(i,1,100) {
    if(n/p == 0) break;
    s2 += (n/p);
    lli pp = p;
    p = p * 2;
    if(pp != p/2) break;
  }
  if(n%2 == 0) {
    cout<<min(ans1, ans2+n/2)<<endl;
  }
  else {
    debug(ans1, ans2, s1, s2);
    ans1 = s1 - ans1;
    ans2 = s2 - (ans2+n/2);
    cout<<min(ans1, ans2)<<endl;
  }
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int n,m,a,b;
    cin>>n>>m;
    std::deque<int> deq(n+1,0);
    for (int i=0;i<m;i++) {
        cin>>a>>b;
        deq[a]+=1;
        deq[b]+=1;
    }
    for (int j=1;j<n+1;j++) {
        cout<<deq[j]<<endl;
    }
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
	let n: usize = read();
	let mut v: Vec<usize> = vec![0; 100001];
	let mut temp: usize;
	let mut sum: usize = 0;
	for _ in 0..n {
		temp = read();
		sum += temp;
		v[temp] += 1;
	}
	let q: usize = read();
	let mut b: usize;
	let mut c: usize;
	let mut w: Vec<usize> = Vec::new();
	for _ in 0..q {
		b = read();
		c = read();
		sum -= b * v[b];
		sum += c * v[b];
		v[c] += v[b];
		v[b] = 0;
		w.push(sum);
	}
	for i in &w {
		println!("{}", i);
	}
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 3724
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
int a[300010];
int main()
{
    int n,k,indx;
    scanf("%d%d",&k,&n);
    indx=n;
    if(k%2==0)
    {
        a[1]=k/2;
        for(int i=2;i<=n;i++)
            a[i]=k;
    }
    else
    {
        int temp=n/2;
        for(int i=1;i<=n;i++)
            a[i]=(k+1)/2;
        while(temp--)
        {
            if(a[indx]==1)
                a[indx--]--;
 
            else
            {
                a[indx]--;
                while(indx<n)
                    a[++indx]=k;
            }
        }
    }
    for(int i=1;i<=indx-1;i++)
       cout<<a[i]<<" ";
    cout<<a[indx]<<endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
    int A,B;
    cin>>A>>B;
    cout<<max(A+B,max(A*B,A-B))<<endl;
}

Measured memory_bytes: 764
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
l,r = map(int,input().split())

temp = 2019*2019
if r-l+1 >=2019:
    temp = 0
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            temp = min((i*j)%2019,temp)

ans = temp
print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 2940
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

int main(){
  int H, W, N;
  while(cin >> H >> W >> N && (H|W|N)){
    string s;
    char c[1000][1000];
    cin >> s;
    REP(i, H) REP(j, W) cin >> c[i][j];
    int sx, sy, gx, gy;
    REP(i, H) REP(j, W) if(c[i][j] == 'S') {
      sx = j, sy = i;
      c[i][j] = '.';
    }
    REP(i, H) REP(j, W) if(c[i][j] == 'G') {
      gx = j, gy = i;
      c[i][j] = '.';
    }

    vector<int> d(N + 1);
    REP(i, N){
      d[i + 1] = (d[i] + (s[i] == 'L' ? -1 : +1) + 4) % 4;
    }
    vector<int> indexes[4];
    REP(i, N + 1) indexes[d[i]].push_back(i);
    REP(i, 4) indexes[i].push_back(INF);

    bool used[1000][1000] = {};
    typedef pair<int, int> P;
    typedef pair<int, P> S;
    priority_queue<S, vector<S>, greater<S> > que;
    que.push(S(0, P(sx, sy)));

    bool ans = false;
    while(!que.empty()){
      S s = que.top(); que.pop();
      int x = s.second.first, y = s.second.second;
      int k = s.first;
      if(x == gx && y == gy){
        ans = true;
        break;
      }
      if(used[y][x]) continue;
      used[y][x] = true;
      REP(r, 4){
        int nk = *lower_bound(indexes[r].begin(), indexes[r].end(), k);
        if(nk == INF) continue;
        int nx = x + dx[r];
        int ny = y + dy[r];
        if(!valid(nx, ny, W, H)) continue;
        if(used[ny][nx]) continue;
        if(c[ny][nx] == '#') continue;
        que.push(S(nk, P(nx, ny)));
      }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4028
N = int(input())
H_list = list(map(int, input().split()))
H_length = len(H_list)
ans_count = 0

for h_i in range(H_length):
    j_list = [j for j in range(h_i)]
    j_list = sorted(j_list, reverse=True)
    i_e = H_list[h_i]
    if len(j_list)==0:
        ans_count = ans_count + 1
        continue
    is_higher = True
    for h_j in j_list:
        if i_e<H_list[h_j]:
            is_higher = False
    if is_higher:
        ans_count = ans_count + 1

print(ans_count)


Measured memory_bytes: 38420
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
const int MAX = 1e5;
const int INF = 1e8;
int K;
int d[MAX];

int bfs() {
	deque<int> deq;
		rep(i, K) d[i] = INF;
	deq.push_front(1);
	d[1] = 1;

		while (true) {
			int p = deq.front();
			deq.pop_front();

			if (p == 0)break;

			int pt = (10 * p) % K;
			if (d[pt] >d[p]) {
				deq.push_front(pt);
				d[pt] = d[p];
			}

			int pp = (p + 1) % K;
			if (d[pp] >d[p]+1) {
				deq.push_back(pp);
				d[pp] = d[p] + 1;
			}
		}
	return d[0];
}

int main() {
	cin >> K;

	int res = bfs();
	cout << res;
}

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

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

  //int A[2][N];
  vector<vector<int> > A(2, vector<int>(N));
 
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) { 
      cin >> A[i][j];
    }
  }
  vector<vector<int> > dp(2, vector<int>(10000, 0));

  for(int i=0; i<2; i++){
    for(int j=0; j<N; j++){
      if(i==0){
        if(j!=0){
          dp[i][j] = dp[i][j-1]+A[i][j];
        }else{
          dp[0][0] = A[0][0];
        }
      }else if(j==0){
        dp[i][j] = dp[i-1][j]+A[i][j];
      }
      else{
        dp[i][j] = max(dp[i][j-1]+A[i][j], dp[i-1][j]+A[i][j]);
      }
    }
  }
  cout << dp[1][N-1];
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

void dfs(ll v, vector<bool>& visited, vvl& to) {
    if (visited[v]) return;

    visited[v] = true;
    for (auto nv : to[v]) {
        dfs(nv, visited, to);
    }
}

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

    ll n, m; cin>>n>>m;
    vvl to(n + m);
    rep(i, n) {
        ll k; cin>>k;
        rep(j, k) {
            ll l; cin>>l; l--;
            to[i].push_back(n + l);
            to[n + l].push_back(i);
        }
    }

    vector<bool> visited(n + m);
    dfs(0, visited, to);
    bool f = true;
    rep(i, n) f &= visited[i];
    if (f) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 11748
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int N,A,B,ans;
int main(){
    cin>>N>>A>>B;
    for(int i=1;i<=N;i++){
        int j=i,sum=0;
        while(j){
            sum+=j%10;
            j/=10;
        }
        if(sum>=A&&sum<=B)ans+=i;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    GAME_OVER;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;

bool comp(pair<ll,ll> a,pair<ll,ll> b)
{
    if(a.S<b.S)
    return true;
    return false;
}
void solve()
{
    int n;cin>>n;
    int a;set<int> s;int c=1;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(i==0)
        s.insert(a);
        else
        {
            auto it=s.lower_bound(a);
            if(it==s.begin()&&*it!=a)
            c++;
            s.insert(a);
        }
    }
    cout<<c<<endl;
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 9600
/* 
 * Project: AtCoder Beginners Contest 163 B - Homework 
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/04/19
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <algorithm>
#include <numeric>
using namespace std;

int n, m;
int a[10000];

void solve() {
    int sum = 0;
    sum = accumulate(a,a+m,0);
    if (sum > n)
        printf("%d\n", -1);
    else
        printf("%d\n", n-sum);
}

int main() {

    scanf("%d",&n);
    scanf("%d",&m);
    for (int i=0;i<m;i++) {
        scanf("%d",&a[i]);
    }

    solve();

}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int N, M;

int main(){
    cin >> N >> M;
    priority_queue<ll, vector<ll>, less<ll>> q;
    REP(i,N)
    {
        ll a;
        cin >> a;
        q.push(a);
    }
    while(M>0)
    {
        ll tmp=q.top();
        q.pop();
        tmp=tmp>>1;
        q.push(tmp);
        M--;
    }
    ll sum=0;
    while(!q.empty())
    {
        sum+=q.top();
        q.pop();
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1400
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;


int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    int sum = 0;
    for(int i = 0; i < M; ++i) {
        int x;
        cin >> x;
        sum += x;
    }
    if(sum > N) cout << -1 << endl;
    else cout << N - sum << endl;
    return 0;

}



Measured memory_bytes: 3652
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	string S;

	cin >> S;

	if (S == "Sunny") {
		cout << "Cloudy" << endl;
	} else if (S == "Cloudy") {
		cout << "Rainy" << endl;
	} else {
		cout << "Sunny" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll N,X,D;

int main(){
  cin>>N>>X>>D;

  if(D==0){
      if(X==0) cout<<1<<endl;
      else cout<<N+1<<endl;
      return 0;
  }else if(D<0){
    X=-X;
    D=-D;
  }

  vector<ll> A(N);
  A[0]=X;
  for(int i=1;i<N;i++) A[i]=A[i-1]+D;

  ll M=(N-1)*(N)/2;
  map<ll,int> mp;
  int cnt=0;
  vector<vector<pair<ll,ll>>> v(N+2);
  for(ll i=0;i<=N;i++){
      ll L=0,R=0;
      L=(i-1)*(i)/2;
      R=M-(N-i-1)*(N-i)/2;

      ll p=((i*X%D)+D)%D;
      if(mp.count(p)==false) mp[p]=cnt++;
      v[mp[p]].push_back(mkp(i*X+L*D,i*X+R*D));
  }

  for(int i=0;i<cnt;i++) sort(v[i].begin(),v[i].end());

  ll ans=0;
  for(int i=0;i<cnt;i++){
      ans+=(v[i][0].second-v[i][0].first)/D+1;
      ll R=v[i][0].second;
      for(int j=1;j<v[i].size();j++){
          ll l=v[i][j].first;
          ll r=v[i][j].second;
          if(r<=R) continue;
          l=max(l,R+D);
          ans+=(r-l)/D+1;
          R=r;
      }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 25216
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	string s;
	cin >> s;
	int l = s.size();
	int start, end;
	rep(i, l) {
		if (s[i] == 'A') {
			start = i;
			break;
		}
	}
	REP(j, start, l) if (s[j] == 'Z') end = j;

	cout << end - start + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long x = sc.nextLong();
		long[] list = new long[n];
		for(int i=0;i<n;i++) {
			list[i] = sc.nextLong();
		}
		long ans = 0;
		for(int i=0;i<n;i++) {
			if(list[i]>x) {
				ans += list[i]-x;
				list[i] = x;
			}
		}
	//	System.out.println(ans);
	//	System.out.println(Arrays.toString(list));
		for(int i=1;i<n;i++) {
			if(list[i-1]+list[i]>x) {
				ans += list[i-1]+list[i]-x;
				list[i] -= list[i-1]+list[i]-x;
			}
		}
		System.out.println(ans);
	//	System.out.println(Arrays.toString(list));
	}

}

Measured memory_bytes: 50472
h,*s=open(0)
h,w,k,*m=map(int,h.split())
b=w
while b:
 b-=1;r=t=j=0;d=[0]*h
 while w-j:
  i=c=0;j+=1
  while h-i:
   d[c]+=s[i][~j]>'0';c+=b>>i&1;i+=1
   if max(d)>k:d=[0]*h;f=t<j;r+=1;t=j;j-=f;i=h
 m+=r+c,
print(min(m))

Measured memory_bytes: 44252
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int g[510][510];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		for(int j=i+1;j<a;j++){
			int t=0;
			int I=i;int J=j;
			while(I%2==J%2){
				I/=2;J/=2;
				t++;
			}
			g[i][j]=t;
		}
	}
	for(int i=0;i<a-1;i++){
		for(int j=i+1;j<a;j++){
			printf("%d",g[i][j]+1);
			if(j<a-1)printf(" ");
		}printf("\n");
	}

}

Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout<< name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_time()
#endif


#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007

vector<int> primeDivisors(int n){
	vector<int> ans;
	for(int i = 2; i<=sqrt(n); i++){
		if(n%i==0){
			trace(i);
			ans.pb(i);
			while(n%i==0) n=n/i;
		}
	}
	if(n>2) ans.pb(n);
	return ans;
}
int gcd(int a,int b)
{ while((a)!=0 && (b)!=0){ if((a)>(b)) (a)%=(b); else (b)%=(a);} return ((a)==0 ?(b):(a));}
void solve(){
	// exit(0);
	int a,b;
	cin>>a>>b;
	int k = gcd(a,b);
	trace(k);
	vector<int> v = primeDivisors(k);
	cout<<(v.size()+1)<<"\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	end_time();
	return 0;
}

Measured memory_bytes: 384