akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

const int MAX = 100010;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int N, K;
int A[100010];

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

	COMinit();

	cin >> N >> K;
	rep(i, 0, N)
	{
		cin >> A[i];
	}

	if (K == 1)
	{
		cout << 0 << endl;
		return 0;
	}

	sort(A, A + N);

	int ans = 0;
	int c = 0;
	rep(i, K - 1, N)
	{
		c += COM(i-1, K - 2);
		c %= MOD;
		ans += c * A[i];
		ans %= MOD;
	}
	c = 0;
	rrep(i, 0, N - K+1)
	{
		c += COM(N - 1 - i - 1, K - 2);
		c %= MOD;
		ans = (ans - c * A[i] + MOD)%MOD;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
const int M=2e5+10;
ll val[M];
int n,q;
vector<int> to[M];
void dfs(int node,ll s,int fa)
{
    val[node]+=s;
    s=val[node];
    for(int i=0;i<to[node].size();i++)
        if(to[node][i]!=fa)
            dfs(to[node][i],s,node);
}
int main()
{
    scanf("%d%d",&n,&q);
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        to[x].push_back(y);
        to[y].push_back(x);
    }
    while(q--)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        val[x]+=y;
    }
    dfs(1,0,0);
    for(int i=1;i<=n;i++)
        printf("%d ",val[i]);
    return 0;
}


Measured memory_bytes: 27392
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>
#include <tuple>

using namespace std;

typedef long long ll;
const ll MOD = (1e9 + 7ll);
const int MAXN = 200001;
ll f[MAXN];
ll finv[MAXN];

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

ll inv(ll x) {
    return power(x, MOD - 2);
}

void table() {
    f[0] = 1; finv[0] = 1;
    f[1] = 1; finv[1] = 1;
    for (ll i = 2; i < MAXN; i++) {
        f[i] = (i * f[i - 1]) % MOD;
        finv[i] = inv(f[i]);
    }
}

ll mn(int m, int n) { // return (m + n)! / m! n!
    return (((f[m + n] * finv[m]) % MOD) * finv[n]) % MOD;
}

map<pair<int, int>, pair<ll, int>> mem;

pair<ll, int> weight(vector<vector<int>> &tree, int k, int root) {
    ll ans = 1;
    int sz = 0;
    auto it = mem.find({k, root});
    if (it != mem.end()) return it->second;
    for (auto child : tree[k]) {
        if (child == root) continue;
        auto sub = weight(tree, child, k);
        ans = (((ans * sub.first) % MOD) * mn(sz, sub.second)) % MOD;
        sz += sub.second;
    }
    mem[{k, root}] = {ans, sz + 1};
    return {ans, sz + 1};
}

void deduce(vector<vector<int>> &tree, int k, int root, vector<ll> &ans) {
    int n = tree.size();
    auto r = mem[{root, root}];
    auto q = mem[{k, root}];
    // calculate mem[{root, k}] first
    ll root_val = (((((((r.first * inv(q.first)) % MOD) * f[q.second]) % MOD) * f[n - 1 - q.second]) % MOD) * finv[n - 1]) % MOD;
    ll root_sz = n - q.second;
    mem[{root, k}] = {root_val, root_sz};

    ll k_val = (((((((q.first * root_val) % MOD) * finv[q.second - 1]) % MOD) * f[n - 1]) % MOD) * finv[root_sz]) % MOD;
    mem[{k, k}] = {k_val, n};
    ans[k] = k_val;
    for (auto child : tree[k]) {
        if (child == root) continue;
        deduce(tree, child, k, ans);
    }
}

int main()
{
    table();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    vector<vector<int>> tree(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    vector<ll> ans(n);
    auto r = weight(tree, 0, 0);
    ans[0] = r.first;

    for (auto c : tree[0]) {
        deduce(tree, c, 0, ans);
    }
    for (int i = 0; i < n; i++)
        cout << ans[i] << endl;
}

Measured memory_bytes: 56180
S = input()
T = input()

len_S = len(S)
len_T = len(T)

min_count = float('inf')
for i in range(len_S - len_T + 1):
    # print(S[i:i+len(T)])
    match = 0
    for j in range(len_T):

        if T[j] == S[i + j]:
            match += 1
    min_count = min(len_T-match, min_count)
print(min_count)

Measured memory_bytes: 67536
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
int l,r,mid,res;
vector < int > v[30];
string s,t;
int main() {
	cin>>s>>t;
	
	for (int i=0; i<s.size(); i++) 
		v[s[i]-'a'].push_back(i);
	
	long long idx=-1,ANS=0,N=s.size();
	
	for (int i=0; i<t.size(); i++) {
		char c=t[i];
		
		l=0,r=v[c-'a'].size()-1,mid,res=-1;
		
		while (l<=r) {
			mid=(l+r)/2;
			
			if (idx<v[c-'a'][mid]) { res=v[c-'a'][mid]; r=mid-1; }
					else l=mid+1;
		}
		
		if (res!=-1) {
			idx=res;
			continue;
		}
			else {
			ANS++;
			idx=-1;
			
			l=0,r=v[c-'a'].size()-1,mid,res=-1;
		
			while (l<=r) {
				mid=(l+r)/2;
				
				if (idx<v[c-'a'][mid]) { res=v[c-'a'][mid]; r=mid-1; }
						else l=mid+1;
			}
			
			if (res==-1) {
				cout<<"-1"<<endl;
				return 0;
			}
			
			idx=res;
		}
	}
	
	cout<<ANS*N+idx+1<<endl;
	
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, m;
  cin >> n >> m;
  
  ll x, y, xs = 0, ys = 0;
  for (int i = 0; i < n; i++){
    cin >> x;
    xs = (xs + (1 - n + 2*i)*x) % MOD;
  }
  for (int i = 0; i < m; i++){
    cin >> y;
    ys = (ys + (1 - m + 2*i)*y) % MOD;
  }

  cout << xs * ys % MOD << endl;

  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

class Eratosthenes_sieve{
	vector<int> pf_min,p;
public:
	Eratosthenes_sieve(int n):pf_min(n+1){
		for(int i=2;i<=n;i++) if(pf_min[i]==0) {
			pf_min[i]=i;
			for(auto j=1LL*i*i;j<=n;j+=i) if(pf_min[j]==0) pf_min[j]=i;
			p.emplace_back(i);
		}
	}

	const vector<int>& primes()const{ return p; }

	bool is_prime(int a)const{
		assert(a<=(int)pf_min.size()-1);
		return a>0 && pf_min[a]==a;
	}

	map<int,int> prime_factorize(int a)const{
		assert(a<=(int)pf_min.size()-1);
		map<int,int> pf;
		for(;a>1;a/=pf_min[a]) ++pf[pf_min[a]];
		return pf;
	}
};

int main(){
	Eratosthenes_sieve S(1e6);

	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	map<int,int> pf;
	rep(i,n){
		for(auto q:S.prime_factorize(a[i])){
			pf[q.first]=max(pf[q.first],q.second);
		}
	}

	mint L=1;
	for(auto q:pf) L*=pow(mint(q.first),q.second);

	mint ans=0;
	rep(i,n) ans+=L/a[i];
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 4984
#include <iostream>
#include <cstring>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int lh;
    cin >> lh;
    lh--;
    for (int i = 1; i < n; i++) {
        int h;
        cin >> h;
        if (h - 1 >= lh) {
            lh = h - 1;
        } else if (h < lh) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
import math
a, b, C=map(int,input().split())
S=a*b*math.sin(math.pi*C/180)/2
c=math.sqrt(a**2+b**2-2*a*b*math.cos(math.pi*C/180))
L=a+b+c
h=2*S/a
print('{:.4f}'.format(S))
print('{:.4f}'.format(L))
print('{:.4f}'.format(h))


Measured memory_bytes: 5708
H, W, M = map(int, input().split())
bomb = [0] * M
H_list = [0] * H
W_list = [0] * W
for i in range(M):
  h, w = map(int, input().split()) 
  bomb[i] = [h - 1, w - 1]
  H_list[h - 1] += 1
  W_list[w - 1] += 1
  
#print(HW, H_list, W_list)  
H_max = max(H_list)
W_max = max(W_list)
H_count = H_list.count(H_max)
W_count = W_list.count(W_max)
HW_max = H_max + W_max

count = 0
for i, j in bomb:
  if H_list[i] + W_list[j] == HW_max:
    count += 1
    
if count == H_count * W_count:
  x = 1
else:
  x = 0
  
print(HW_max - x)      
    
    
    
    






Measured memory_bytes: 109844
#include <cstdio>
#define max_n 80
using namespace std;
int a[max_n+2];
int main(){
	int n,k;
	long long ans=1000,cnt=0,cnt1;
	scanf("%d",&n);
	for(int i=0; ++i<=n; scanf("%d",a+i));
	for(int i=0; ++i<n; ){
		if(a[i]>a[i+1]){
			ans+=cnt*a[i];
			cnt=0;
			continue;
		}
		if(a[i]<a[i+1]){
			cnt1=ans/a[i];
			ans-=cnt1*a[i],cnt+=cnt1;
			continue;
		}
	}
	ans+=cnt*a[n];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline void write(int x)
{
    if(x<0)
	{
    	putchar('-');
		x=-x;
	}
    if(x>9)
		write(x/10);
    putchar(x%10+'0');
}
int main()
{
	ios::sync_with_stdio(false);
	char a,b;
	a=getchar();
	b=getchar();
	b=getchar();
	if(a=='H')
	{
		if(b=='H') putchar('H');
		else putchar('D');
	}else{
		if(b=='D') putchar('H');
		else putchar('D');
	}
	puts("");
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int x,y,z;
    cin >> x;
    cin >> y;
    cin >> z;
    if(x>y){
        int a = x;
        x = y;
        y = a;
    }
    if(y>z){
        int b = y;
        y = z;
        z = b;
    }
    if(x>y){
        int c = x;
        x = y;
        y = c;
    }
    cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 3092
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int a[202020], b[202020];
int main()
{
  int num;
  scanf("%d", &num);
  for (int i = 0; i < num; i++)scanf("%d", &a[i]);
  for (int i = 0; i < num; i++)scanf("%d", &b[i]);
  int ans = 0;
  for (int i = 0; i <= 29; i++)
  {
    vector<int>v;
    for (int j = 0; j < num; j++)v.push_back(b[j] % (1 << (i + 1)));
    for (int j = 0; j < num; j++)v.push_back((1 << (i + 1)) + b[j] % (1 << (i + 1)));
    sort(v.begin(), v.end());
    int cnt = 0;
    for (int j = 0; j < num; j++)
    {
      int low1 = lower_bound(v.begin(), v.end(), (4 << i) - a[j] % (1 << (i + 1))) - v.begin();
      int low2 = lower_bound(v.begin(), v.end(), (3 << i) - a[j] % (1 << (i + 1))) - v.begin();
      cnt += low1 - low2;
      cnt %= 2;
    }
    ans += cnt << i;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 5956
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		int[] b = new int[n]; 
		int[] c = new int[10000];
		int k = Integer.MIN_VALUE;
		StringTokenizer st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(st.nextToken());
			k = Math.max(k, a[i]);
			c[a[i]]++;
		}
		countingSort(a, b, c, k);
		StringBuilder sb = new StringBuilder();
		sb.append(b[0]);
		for (int i = 1; i < n; i++) {
			sb.append(' ').append(b[i]);
		}
		System.out.println(sb.toString());
	}

	private static void countingSort(int[] a, int[] b, int[] c, int k) {
		for (int i = 1; i <= k; i++) {
			c[i] += c[i - 1];
		}
		for (int i = a.length - 1; i >= 0; i--) {
			c[a[i]]--;
			b[c[a[i]]] = a[i];
		}
	}
}



Measured memory_bytes: 165268
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
#define LOCAL  1
#define UPLOAD 2
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';

#define ll long long

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  ll N = input();
  
  ll ret = 0;
  for(ll i=0;i<N;i++){
    ret += i;
  }

  output(ret);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n,height=0,maxHeight=0;
    char c;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>c;
        if(c == 'I')
        {
            height++;
            if(height>maxHeight)
                maxHeight=height;
        }
        else if(c == 'D')
            height--;
    }
    cout<<maxHeight<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // Tenka1 Programmer Beginner Contest 2019 A - On the Way
  int A, B, C; cin >> A >> B >> C;
  if((A < C && C < B) || (B < C && C < A)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main(){
  int N;
  ll H;
  cin >> N >> H;

  vector<P> damage,damage_sub;

  ll max_a = 0;
  for(int i=0;i<N;i++){
  	ll a, b;
  	cin >> a >> b;
  	damage_sub.push_back(make_pair(b,a));
  	max_a = max(a, max_a);
  }

  /*int i=0;
  int l = damage.size();
  while(i<l){
  	if(damage[i].first<=max_a){
  		damage.erase(damage.begin()+i);
  		l--;
  	}else{
  		i++;
  	}
  }*/

  for(int i=0;i<N;i++){
  	if(damage_sub[i].first>max_a){
  		damage.push_back(damage_sub[i]);
  	}
  }


  sort(damage.begin(),damage.end());
  int l = damage.size();

  ll sum = 0;
  ll ans = 0;
  int i= l-1;
  while(i>=0 && sum < H){
  	sum += damage[i].first;
  	ans++;
  	i--;
  }

  if(sum>=H){
  	cout << ans <<endl;
  	return 0;
  }

  ans += (H-sum + max_a -1)/max_a;

  cout << ans <<endl;

    
  return 0;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N;
	scanf("%d",&N);

	printf("%d\n",(N*(N+1))/2);

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int n, k;
long long T[MAX];

int check(long long P) {
	int i=0;
	for (int j=0; j<k; j++) {
		long long s = 0;
		while (s+T[i] <= P) {
			s += T[i];
			i++;
			if (i == n) return n;
		}
	}
	return i;
}

long long solve(){
	long long left = 0;
	long long right = 100000 * 10000;
	long long mid;
	while (right - left > 1) {
		mid = (left + right) / 2;
		int v = check(mid);
		if (v >= n) right = mid;
		else left = mid;
	}
	return right;
}

int main(){
	int i;
	long long ans;
	scanf("%d %d", &n, &k);
	for(i=0; i<n; i++)
        scanf("%d", &T[i]);
	ans = solve();
	printf("%lld\n", ans);
	return 0;
}



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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0): d(n, -1) {};
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        uf.unite(a, b);
    }
    int res = 0;
    for (int i = 0; i < N; ++i) res = max(res, uf.size(i));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define sunil ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
//int vv[100003];
int main()
{
    sunil;
    int n,p,l,j=2;
    cin>>n;
    vector<int>v(n);
    for(auto &u :v) cin>>u;
    vector<int>vv(n);
   // if(v[i]>v[0])
   // vv.push_back=(v[1]-v[0]);
   // else vv.push_back(v[0]-v[1]);
   vv[1]=abs(v[1]-v[0]);

    for(int i=2;i<n;i++){
            p=abs(v[i]-v[i-1]);
            l=abs(v[i]-v[i-2]);
        vv[j]=min(p+vv[i-1],l+vv[i-2]);
        j++;
    }
   int  m=vv.size()-1;
    cout<<vv[m]<<endl;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    rep(i, n) scanf("%d", &a[i]);
    sort(a, a+n);
    int ans = 0;
    rep(i, MAX){
        int tmp = upper_bound(a, a+n, i+1) - lower_bound(a, a+n, i-1);
        chmax(ans, tmp);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
#define INF 1234567890
#define ll long long

ll T, N, M, K;
ll A, B, C, D;
ll res;

int main()
{
	scanf("%lld", &N);
	for(ll i=2; i*i<=N; i++)
	{
		ll cnt = 0;
		while(N%i==0)
		{
			cnt++;
			N /= i;
		}
		for(ll j=1; j<=cnt; j++)
		{
			cnt -= j;
			res++;
		}
	}
	if (N > 1) res++;
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 3824
import math

def all_divisor(n):
    small = [1]
    large = [n]
    for i in range(2, int(n ** 0.5) + 1):
        if not (n % i):
            small.append(i)
            large.append(n//i)
    return large[-1]

n = int(input())
a = all_divisor(n)
print(int(math.log10(a)) + 1)


Measured memory_bytes: 3060
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    H, A = MI()


    if H<=A:
        print(1)
    elif H%A==0:
        print(H//A)
    else:
        print((H//A)+1)


if __name__ == "__main__":
	main()

Measured memory_bytes: 9048
package main

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

func abs(x float64) float64 {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n, t, a int
	fmt.Scan(&n, &t, &a)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var x float64
	min := 100000000.0
	index := 0
	for i := 0; i < n; i++ {
		sc.Scan()
		x, _ = strconv.ParseFloat(sc.Text(), 64)
		if v := abs(float64(t) - x*0.006 - float64(a)); v < min {
			min = v
			index = i + 1
		}
	}
	fmt.Println(index)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fo(i,n) for(i=0;i<n;i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
vector<int>g[100005];

int func(vector<int>a,vector<int>b)
{
	int i,j,sum=0;
	for(i=0;i<a.size();i++)
	{
		sum+=((a[i]-b[i])*(a[i]-b[i]));
	}
	j=sqrt(sum);
	if(j*j==sum)return 1;
	return 0;
}

int main()
{
	IOS
    int t,n,m,i,j,x,y;
     cin>>n>>m;
     vector<vector<int> >vec;
     for(i=0;i<n;i++)
     {
     	vector<int>temp;
            for(j=0;j<m;j++)
            {
                         cin>>x;
                         temp.push_back(x);
            }
            vec.push_back(temp);
     }
     y=0;
     for(i=0;i<n;i++)
     {
     	for(j=i+1;j<n;j++)
     	{
             if(func(vec[i],vec[j]))y++;
     	}
     }
     cout<<y;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define Inf 10000000000ll
#define ll long long
using namespace std;

set<vector<ll> > hashed;

int main() {
    vector<ll> v;
    v.resize(3);
    cin>>v[0]>>v[1]>>v[2];
    sort(v.begin(),v.end());
    bool isinf=false;
    int ans=0;
    while(1) {
        ll A=v[0];
        ll B=v[1];
        ll C=v[2];
        if (A%2 || B%2 || C%2)
            break;
        ll a=(B+C)/2;
        ll b=(A+C)/2;
        ll c=(A+B)/2;
        v[0]=a;
        v[1]=b;
        v[2]=c;
        sort(v.begin(),v.end());
        ans++;
        if (hashed.find(v) != hashed.end())
        {
            isinf=true;
            break;
        }
        hashed.insert(v);
        
    }
    if (isinf)
        ans=-1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define REP(i,a,b) for (auto i = a; i != b; i++)
#define ll long long int
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pb push_back
#define SQ(a) (a)*(a)
 
using namespace std;


int main()
{
    std::ios::sync_with_stdio(false);
    int T = 1;
    //cin>>T;
    for(int t = 1;t<=T;t++)
    {
        int n;
        cin>>n;
        ll d;
        cin>>d;
        int count = 0;
        for(int i = 0;i<n;i++)
        {
        	ll a,b;
        	cin>>a>>b;
        	long double x = sqrt(a*a + b*b);
        	if(x <= d)
        		count++;
        }
        cout<<count<<endl;
    }

    return 0;
}


Measured memory_bytes: 3688
#define DAY 365
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    if(n%1000==0){
        cout << "0";
    }else{
        int mn =(1000 - n % 1000);
        cout << mn;
    }
}

Measured memory_bytes: 3640
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列
#define CO(a, b, c) ((a) ? (b) : (c))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;

int main(void)
{

    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

    return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int cnt = 0;
	rep(i,n){
		cin >> a[i];
		if(a[i]<0) cnt++;
		a[i] = abs(a[i]);
	}
	sort(a.begin(), a.end());
	ll ans = 0;
	if(cnt&1){
		rep(i,n) {
			if(i==0) ans -= a[i];
			else ans += a[i];
		}
	}else{
		rep(i,n) ans += a[i];
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
n, a = map(int, input().split())
ns = list(map(int, input().split()))
ns = [0] + ns
ma = max(ns+[a])
dp = [[[0] * (ma * n+1) for i in range(n+1)] for i in range(n+1)]
for i in range(n+1):
    for j in range(i+1):
        for k in range(n * ma+1):
            if i == j == k == 0:
                dp[i][j][k] = 1
            elif i > 0 and k < ns[i]:
                dp[i][j][k] = dp[i - 1][j][k]
            elif i > 0 and j >= 1 and k >= ns[i]:
                dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - ns[i]]
print(sum(dp[n][i][i*a] for i in range(1, n+1)))



Measured memory_bytes: 93532
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        String S=sc.next();
        int B=sc.nextInt();
        if(S.charAt(0)=='+'){
            System.out.println(A+B);
        }else{
            System.out.println(A-B);
        }
        
}
        
        
    }


Measured memory_bytes: 21972
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]



r,g,b = map(int, input().split())

if (r*100+g*10+b)%4 == 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9144
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    ll x;
    cin>>x;
    ll ans=(x/11)*2;
    x-=(x/11)*11;
    if(1<=x&&x<=6) ans++;
    else if(x>6) ans+=2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	while (1) {
		auto x = readln.chomp.split.map!(to!int).array;
		if (x[0] == 0) break;
		x[1]--;
		int winner, sum;
		foreach (i; 0..x[0]) {
			auto a = readln.chomp.to!int;
			if (i == x[1]) winner = a;
			sum += a;
		}
		if (!winner) writeln(0);
		else {
			writeln(sum * (100-x[2]) / winner);
		}
	}
}

Measured memory_bytes: 1156
#define _USE_MATH_DEFINES
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#define INF 10000000
using namespace std;
typedef long long ll;

int cost[110][110];
int tim[110][110];

int main(void)
{
	while (1) {
		int n, m;
		cin >> n >> m;

		if (n == 0 && m == 0)break;

		for (int i = 0; i < m; i++) {
			for (int j = 0; j < m; j++) {
				if (i == j) {
					cost[i][j] = 0;
					tim[i][j] = 0;
				}
				else {
					cost[i][j] = INF;
					tim[i][j] = INF;
				}
			}
		}

		for (int i = 0; i < n; i++) {
			int a, b, c, t;
			cin >> a >> b >> c >> t;
			cost[a - 1][b - 1] = cost[b - 1][a - 1] = c;
			tim[a - 1][b - 1] = tim[b - 1][a - 1] = t;
		}

		for (int k = 0; k < m; k++) {
			for (int j = 0; j < m; j++) {
				for (int i = 0; i < m; i++) {
					cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
					tim[i][j] = min(tim[i][j], tim[i][k] + tim[k][j]);
				}
			}
		}
		int k;
		cin >> k;
		for (int i = 0; i < k; i++) {
			int p, q, r;
			cin >> p >> q >> r;
			if (r == 0)
				cout << cost[p - 1][q - 1] << endl;
			else if (r == 1)
				cout << tim[p - 1][q - 1] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int N,M,Q;
int a[55];
int b[55];
int c[55];
int d[55];
int ans = -1;
int res;

void DFS(vector<int> A) {
  int s = A.size();
  if (s == N) {
    res = 0;
    for (int i = 0; i < Q; i++) {
      if (A[b[i]] - A[a[i]] == c[i]) {
        res += d[i];
      }
    }
    ans = max(ans,res);
    return ;
  }
  for (int i = A[s-1]; i <= M; i++) {
    A.push_back(i);
    DFS(A);
    A.pop_back();
  }
  return ;
}

int main() {
  cin >> N >> M >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  for (int i = 1; i <= M; i++) {
    vector<int> X(0);
    X.push_back(i);
    DFS(X);
    X.pop_back();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    for i in range(100):
        for j in range(100):
            if i * 4 + j * 7 == n:
                print('Yes')
                return
    print('No')


if __name__ == '__main__':
    main()


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

int n,m;
int fatigue[1010]  = {} ;
int load[1010]     = {} ;
int dp[1010][1010] = {} ; // day(fatigue),city


int main(){
	
	cin >> n >> m;
	for( int i=0 ; i<n ; i++ ){
		cin >> load[i] ;
	}
	for( int i=0 ; i<m ; i++ ){
		cin >> fatigue[i] ;
	}
	
	for( int i=0 ; i<m ; i++){
		dp[0][i] = load[0] * fatigue[i] ;
	}
		
	for( int i=1 ; i<n ; i++ ){
		int tmp = 1000000000 ;
		for( int j=i ; j<m ; j++ ){
			dp[i][j] = (tmp = min( tmp , dp[i-1][j-1] )) ;
			dp[i][j] += load[i] * fatigue[j] ;
		}
	}
	
	int ans = 1000000000;
	for( int i=0 ; i<m ; i++ ){
		if( dp[n-1][i] > 0 ){
			ans = min( ans , dp[n-1][i] ) ;
		}
	}
	cout << ans << endl ;
	
	return 0;
}

Measured memory_bytes: 4376
#include<iostream>
#include<cmath>
using namespace std;
void pp(char* f, long x){
long i,p,k;
for(i=1;i<=x;i++)f[i]=0;
f[2]=f[3]=1;
for(i=7;i<=x;i+=6)f[i]=1;
for(i=5;i<=x;i+=6)f[i]=1;
for(i=0;i<=ceil(sqrt(x)/6);i++){
p=6*i+1;
if(f[p]){
for(k=p*p;k<=x;k+=p*6)f[k]=0;
for(k=p*(p+4);k<=x;k+=p*6)f[k]=0;
}
p=6*i+5;
if(f[p]){
for(k=p*p;k<=x;k+=p*6)f[k]=0;
for(k=p*(p+2);k<=x;k+=p*6)f[k]=0;
}
}
}
int main(){
long i,n,s;
char* f;
f=new char[50001];
pp(f,50000);
while(cin>>n,n){
s=0;
if(n==4){
s++;
}else if(n/2*2==n){
for(i=3;i*2<=n;i+=2)if(f[i]&&f[n-i])s++;
}else{
if(f[n-2])s++;
}
cout<<s<<endl;
}
return 0;
}

Measured memory_bytes: 1240
import java.util.Scanner;

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

		int n = scan.nextInt();
		int h = scan.nextInt();
		int w = scan.nextInt();
		int num = 0;
		for(int i = 0 ; i < n; i++){

			int x = scan.nextInt();
			int y = scan.nextInt();
			if(x >= h && y >= w) num++;
		}
		System.out.println(num);
	}
}


Measured memory_bytes: 25424
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin>>s>>t;
  int n,m,k;
  n=s.size();
  m=t.size();
  k=n-m;
  vector<int>v;
  for(int i=0;i<=k;i++){
        int k=0;
    for(int j=0;t[j]!='\0';j++){
        if(s[j+i]!=t[j])
            k++;
    }
    v.push_back(k);
  }
  sort(v.begin(),v.end());
  cout<<v[0];
}


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

void solve(std::string S, std::string T, long long A, long long B, std::string U) {
    if (S == U) {
        A--;
    }
    if (T == U) {
        B--;
    }
    cout << A << ' ' << B << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    std::string U;
    std::cin >> U;
    solve(S, T, A, B, U);
    return 0;
}


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

int main()
{
  int m=0, n=0;
  while(cin >> m >> n && (m > 0 && n > 0)){
    int h[m];
    int w[n];
    int hcum[m];
    int wcum[n];

    cin >> h[0];
    hcum[0] = h[0];
    for(int i=1; i<m; i++){
      cin >> h[i];
      hcum[i] = hcum[i-1] + h[i];
    }
    cin >> w[0];
    wcum[0] = w[0];
    for(int i=1; i<n; i++){
      cin >> w[i];
      wcum[i] = wcum[i-1] + w[i];
    }

    int hend = hcum[m-1];
    int wend = wcum[n-1];
    int hcurs[hend];
    int wcurs[wend];
    for(int i=0; i<hend; i++) hcurs[i] = 0;
    for(int i=0; i<wend; i++) wcurs[i] = 0;

    for(int i=0; i<m; i++) hcurs[hcum[i]-1] += 1;
    for(int i=0; i<n; i++) wcurs[wcum[i]-1] += 1;

    for(int i=1; i<m; i++){
      for(int j=i; j<m; j++){
        int l = hcum[j] - hcum[i-1];
        hcurs[l-1] += 1;
      }
    }

    for(int i=1; i<n; i++){
      for(int j=i; j<n; j++){
        int l = wcum[j] - wcum[i-1];
        wcurs[l-1] += 1;
      }
    }

    int cnt = 0;
    int l = hend < wend ? hend : wend;
    for(int i=0; i<l; i++){
      cnt += hcurs[i] * wcurs[i];
    }
    cout << cnt << endl;
  }
}

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

typedef long long ll;
typedef unsigned long long ull;

bool eval(const vector<int>& A, int K, int L){
    const int N = A.size();
    ll count = 0;
    for(int i=0;i<N;i++){
        if(A[i] <= L) break;
        count += (A[i] - 1) / L;
    }
    return count <= K;
}

int main()
{
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<int>());

    if(eval(A, K, 1)){
        cout << 1 << endl;
        return 0;
    }

    int Lmin = 1;
    int Lmax = 1e+9;
    while(Lmin + 1 < Lmax){
        auto L = (Lmin + Lmax) / 2;
        if(eval(A, K, L)){
            Lmax = L;
        }else{
            Lmin = L;
        }
    }
    if(Lmax - Lmin == 2){
        if(eval(A, K, Lmin+1)) cout << (Lmin+1) << endl;
        else                   cout << (Lmin+2) << endl;
    }else{
        cout << Lmax << endl;
    }

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++ )
#define MAX 1000
#define INFTY (1<<21)
struct Point{ int x, y; };
int H, W, sy, sx, gy, gx, cnt[5];
Point P[5][MAX];
int D[5][MAX];

inline int mdist(int x1, int y1, int x2, int y2){
    return max(x1, x2) - min(x1, x2) + max(y1, y2) - min(y1, y2);
}

void compute(){
    int opts, optc = INFTY;
    int t;
    rep(s, 5){
        rep(i, 5) rep(j, cnt[i]) D[i][j] = INFTY;
        t = (s+1)%5;
        rep(j, cnt[t]) D[t][j] = mdist(sx, sy, P[t][j].x, P[t][j].y );
        for ( int i = s+1; i < s + 5; i++ ){
            int b = (i)%5;
            int e = (i+1)%5;
            rep(k, cnt[b]) rep(l, cnt[e]) {
		D[e][l] = min(D[e][l], D[b][k] + mdist(P[b][k].x, P[b][k].y, P[e][l].x, P[e][l].y));
	    }
        }
	t = (s+4)%5;
        rep(j, cnt[t] ){
            if ( D[t][j] + mdist(gx, gy, P[t][j].x, P[t][j].y ) < optc ){
                optc = D[t][j] + mdist(gx, gy, P[t][j].x, P[t][j].y);
                opts = s;
            }
        }
    }
    if ( optc == INFTY ) cout << "NA" << endl;
    else cout << opts+1 << " " << optc << endl;
}

main(){
    char ch;
    while(cin >> W >> H && W){
        rep(i, 5) cnt[i] = 0;
        rep(y, H) rep(x, W) {
	    cin >> ch;
	    if ( ch == '.' ) continue;
	    if ( ch == 'S' ){
		sy = y; sx = x;
	    } else if ( ch == 'G' ){
		gy = y; gx = x;
	    } else {
		int p = ch -'0' - 1;
		P[p][cnt[p]].x = x;
		P[p][cnt[p]++].y = y;
	    }
        }
        compute();
    }
}

Measured memory_bytes: 920
package main
import "fmt"

func main() {
	var n, count int
	count = 0
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	for i := 0; i < n; i++ {
    count += count2Dividable(a[i])
  }
	fmt.Println(count)
}

func count2Dividable(n int) int {
  count := 0;
  if(n%2 == 0) {
    count = count2Dividable(n/2) + 1;
  }
  return count;
}


Measured memory_bytes: 1280
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

int main() {

	long A, B; cin >> A >> B;
	if ((A + B) % 2 == 1) cout << "IMPOSSIBLE" << endl;
	else cout << (A + B) / 2 << endl;
}

Measured memory_bytes: 764
#include <stdio.h>
#include <map>
#include <algorithm>

int64_t exp_mod(int a, int b, int p) {
  int64_t ans = 1;
  int64_t cur = a;
  while (b > 0) {
    if (b % 2 == 1)
      ans = (ans * cur) % p;
    cur = (cur * cur) % p;
    b /= 2;
  }
  return ans;
}

int main(int argc, char **argv) {
  int n, x, y;

  scanf("%d", &n);

  std::map<int, int> h;
  for (int i = 0; i < n + 1; ++i) {
    int k;
    scanf("%d", &k);

    std::map<int, int>::iterator it = h.find(k);
    if (it != h.end()) {
      x = it->second;
      y = i + 1;
    }
    else
      h[k] = i + 1;
  }

  const int P = 1000000007;
  int64_t a = 1;
  int64_t b = 1;
  int prev_exp = 1;
  for (int k = 1; k <= n + 1; ++k) {
    int exp_k = exp_mod(k, P - 2, P);
    a = (a * (n + 2 - k)) % P;
    a = (a * exp_k) % P;

    if (k >= 2) {
      b = (b * (n + x - y - k + 2)) % P;
      b = (b * prev_exp) % P;
    }
    prev_exp = exp_k;

    int c = (a - b) % P;
    if (c < 0) c += P;
    printf("%d\n", c);
    //printf("%d: %d %lld %lld\n", k, c, a, b);
  }

  return 0;
}

Measured memory_bytes: 5888
n = int(input())

d = {}
for i in range(2,int(n**0.5)+1):
    if n%i == 0:
        d[i] = 0
        while n%i == 0:
            d[i] += 1
            n //= i
if n > 1:
    d[n] = 1

ans = 0
for i in d.values():
    x = i
    for j in range(1,10000):
        if x >= j:
            x -= j
            ans += 1
        else:
            break
print(ans)



Measured memory_bytes: 9460
n,m = map(int,input().split())
ll = [list(input().split()) for _ in [0]*m]
ac = set()
pena = 0
d = dict(zip(map(str,range(1,n+1)),[0]*n))
for l in ll:
  if l[0] not in ac:
    if l[1] == 'AC':
      ac.add(l[0])
      pena += d[l[0]]
    else:
      d[l[0]]+=1
print(' '.join(map(str,[len(ac),pena])))

Measured memory_bytes: 44460
#include <iostream>
#include <string>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  for (int i=0; i<s.size(); i++) {
    if (s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3612
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for i in a:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1

d = sorted(d.items(), key=lambda x:x[1], reverse=True)
ans = 0
if len(d) <= k:
    print(0)
else:
    for i in range(len(d) - k):
        ans += d[-i-1][1]
    print(ans)

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

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

    int len = S.length();
    string T = "";

    for( int i = 0; i < len-1; ){
        if( S[i] == 'd' ){
            // "dream"
            i += 5;
            T += "dream";

            // "dream" + "era" でないならば "dreamer"
            if( S[i] == 'e' && S[i+2] != 'a' ){
                i += 2;
                T += "er";
            }

        } else if( S[i] == 'e' ){
            // "erase"
            i += 5;
            T += "erase";

            // "eraser"
            if( S[i] == 'r' ){
                i += 1;
                T += "r";
            }
        } else {
            cout << "NO" << endl;
            return 0;
        }

        if( S.substr(0, i) != T ){
            cout << "NO" << endl;
            return 0;
        }
    }

    if( S == T ) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

using namespace std;

vector < int > l;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int maksi=0, maksi1=0;
	int br;
	int n, a;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a;
		l.push_back(a);
		if(a>maksi){
			maksi1=maksi;
			maksi=a;
			br=1;
		}
		else if(a==maksi){
			br++;
		}
		else{
			maksi1=max(maksi1, a);
		}
	}
	for(int i=0; i<n; i++){
		if(maksi==l[i] && br==1){
			cout << maksi1 << '\n';
		}
		else{
			cout << maksi << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;

int main(){
	int sx, sy, tx, ty;
	cin>>sx>>sy>>tx>>ty;	
	for(int i=sy; i<ty; i++)
		cout<<"U";
	for(int i=sx; i<tx; i++)
		cout<<"R";
	for(int i=ty; i>sy; i--)
		cout<<"D";
	for(int i=tx; i>sx; i--)
		cout<<"L";
	cout<<"L";
	for(int i=sy; i<=ty; i++)
		cout<<"U";
	for(int i=sx; i<=tx; i++)
		cout<<"R";
	cout<<"D";
	cout<<"R";
	for(int i=ty; i>=sy; i--)	
		cout<<"D";
	for(int i=tx; i>=sx; i--)
		cout<<"L";
	cout<<"U";	
	cout<<endl;
	return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	H := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &H[i])
	}
	var result int
	var least_height int
	for i, h := range H {
		if i == 0 {
			result += 1
			least_height = h
		} else {
			if least_height <= h {
				result += 1
				least_height = h
			}
		}
	}
	fmt.Println(result)
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}


	public void run() {
		Scanner sc = new Scanner(System.in);
		int d=sc.nextInt();
		int g=sc.nextInt();
		int p[]=new int[d];
		int c[]=new int[d];
		for(int i=0; i<d; i++) {
			p[i]=sc.nextInt();
			c[i]=sc.nextInt();
		}
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<(1<<d); i++) {
			int s=0;
			int rest=-1;
			int cnt=0;
			for(int j=0; j<d; j++) {
				if(((i>>j)&1)==1) {
					s += (j+1)*100*p[j]+c[j];
					cnt += p[j];
				}else {
					rest=j;
				}
			}
			if(s<g) {
				int s1 = 100 * (rest+1);
				int need = (g-s+s1-1)/s1;
				if(need>=p[rest]) continue;
				cnt += need;
			}
			ans = Math.min(ans, cnt);
		}
		System.out.println(ans);
		sc.close();
	}


}


Measured memory_bytes: 21844
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static final long MOD = 1000000007;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    String S[] = new String[H];
    char s[][] = new char[H][W];
    for(int i=0; i<H; i++){
      S[i] = sc.next();
      s[i] = S[i].toCharArray();
    }
    String ans = "Yes";
    boolean flag = false;
    for(int i=0; i<H; i++){
      if(flag == true) break;
      for(int j=0; j<W; j++){
        if(flag == true) break;
        if(s[i][j] == '#'){
          if(i > 0 && s[i-1][j] == '#') continue;
          if(i < H-1 && s[i+1][j] == '#') continue;
          if(j > 0 && s[i][j-1] == '#') continue;
          if(j < W-1 && s[i][j+1] == '#') continue;
          ans = "No";
          flag = true;
        }
      }
    }
    System.out.println(ans);
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

Measured memory_bytes: 22608