akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;

template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	string S;
	cin >> S;
	vb A(26, false);
	for (char s : S) {
		if (A[(int)s - (int)'a']) {
			OUT("no");
			return 0;
		}
		A[(int)s - (int)'a'] = true;
	}
	OUT("yes");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int min(int a,int b)
{
 	return (a<b)?a:b; 
}
 
int main()
{
 	int n;
  
  	cin>>n;
  
  	vector<int> v(n);
  	
  	for(auto& i:v)
  		cin>>i;
  
  	vector<int> dp(n);
  
  	dp[0]=0;
  	dp[1]=abs(v[1]-v[0]);
 
  	for(int i=2;i<n;i++)
    {	
    	dp[i]=min(abs(v[i]-v[i-1])+dp[i-1],abs(v[i]-v[i-2])+dp[i-2]);
    
    }  
  
  	cout<<dp[n-1];
  

}

Measured memory_bytes: 1024
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
A = read_int()
A2d = [[A[i], i + 1] for i in range(N)]

def solve():
    ans = 0
    A2d.sort(key=lambda x: x[0], reverse=False)
    # print(A2d)
    return

if __name__ == "__main__":
    solve()
    for a in A2d:
        print(a[1], end=" ")
    print()

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

int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int p, q, r;
	p = 0;
	q = abs(a[1] - a[0]);
	r = q;
	for (int i = 2; i < n; i++) {
		//cout << "at " << i << "\n";
		r = min(q + abs(a[i] - a[i - 1]), p + abs(a[i] - a[i - 2]));
		p = q;
		q = r;
		//cout << "p is " << p << ", q is " << q << "\n";
	}
	cout << r;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

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

count = 1
break_count = 0

for i in range(N):
    if a_list[i] == count:
        count += 1
    else:
        break_count += 1
    
if break_count == N:
    print(-1)
else:
    print(break_count)

Measured memory_bytes: 24988
import numpy as np

# 初期値を入力

N, M = map(int, input().split())

A = np.zeros((M, 2))

for i in range(M):
    A[i, 0], A[i, 1] = map(int, input().split())

# メインプログラム

Flag = 0

Length = np.array([A[i, 0], A[i, 1]])

for i in range(M - 1):
    Length[0] = max(Length[0], A[i, 0])
    Length[1] = min(Length[1], A[i, 1])
    if Length[1] < Length[0]:
        Flag = 1


if Flag == 0:
    print(int(Length[1] - Length[0] + 1))
else:
    print(int(0))


Measured memory_bytes: 14008
if __name__ == "__main__":
    h, w = map(int, input().split())
    c = []
    for i in range(h):
        c.append(input())
    newC = []
    for i in range(2*h - 1):
        newC.append(c[(i) // 2])
    newC.append(c[len(c) - 1])
    for i in newC:
        print(i)

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

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

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  struct edge {
    int u, v, w;
    edge(){}
    edge(int u, int v, int w):u(u), v(v), w(w){}
    bool operator < (const edge& e) const {
      return w < e.w;
    }
  };

  int n, m, x;
  cin >> n >> m >> x;
  vector<edge> es;
  rep(i, m) {
    int u, v, w;
    cin >> u >> v >> w;
    --u, --v;
    es.emplace_back(u, v, w);
  }
  sort(all(es));

  int cnt = 0;
  int cnt_no = 0;
  rep(i, m) {
    UnionFind uf(n);
    int sum = es[i].w;
    uf.unite(es[i].u, es[i].v);
    rep(j, m) {
      edge e = es[j];
      if(!uf.same(e.u, e.v)) {
	uf.unite(e.u, e.v);
	sum += e.w;
      }
    }
    if(sum == x) ++cnt;
    else if(sum < x) ++cnt_no;
  }

  vint pow2(m+1);
  pow2[0] = 1;
  rep(i, m) pow2[i+1] = pow2[i]*2%mod;

  int ans = 0;
  if(cnt == 0) ans = 0;
  else if(cnt_no == 0) ans = (pow2[cnt]+mod-2)%mod*pow2[m-cnt-cnt_no]%mod;
  else ans =(pow2[cnt]+mod-1)%mod*pow2[m-cnt-cnt_no]%mod*2%mod;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <complex>

using namespace std;

typedef complex<double> P;
double EPS = 1e-8;

double dot(P a, P b) { return real(conj(a)*b); }
double cross(P a, P b) { return imag(conj(a)*b); }

double dist(P la, P lb, P p){
	if(dot(lb-la,p-la)<EPS) return abs(p-la);
	if(dot(la-lb,p-lb)<EPS) return abs(p-lb);
	return abs(cross(lb-la,p-la)) / abs(lb-la);
}

bool crossLine(P la, P lb, P ma, P mb){
	return cross(lb-la,ma-la)*cross(lb-la,mb-la)<0&&
		cross(mb-ma,la-ma)*cross(mb-ma,lb-ma)<0;
}

double distSquare(P la, P lb, double ma, double mb, double Ma, double Mb){
	P L[2]; L[0] = la, L[1] = lb;
	P M[4]; M[0] = P(ma,mb); M[1] = P(Ma,mb); M[2] = P(Ma,Mb); M[3] = P(ma,Mb);
	double a = dist(L[0], L[1], M[0]);
	for(int i=1;i<4;i++){
		double b = dist(L[0], L[1], M[i]);
		if(a>b) a = b;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<2;j++){
			double b = dist(M[i],M[(i+1)%4],L[j]);
			if(a>b) a = b;
		}
	}
	return a;
}

bool rightup(P a, P b){
	return real(a)<real(b)&&imag(a)<imag(b);
}

bool crossSquare(P la, P lb, double ma, double mb, double Ma, double Mb){
	if(crossLine(la,lb,P(ma,mb),P(Ma,mb))) return true;
	if(crossLine(la,lb,P(ma,mb),P(ma,Mb))) return true;
	if(crossLine(la,lb,P(Ma,mb),P(Ma,Mb))) return true;
	if(crossLine(la,lb,P(ma,Mb),P(Ma,Mb))) return true;
	if(rightup(P(ma,mb),la)&&rightup(la,P(Ma,Mb))
		&&rightup(P(ma,mb),lb)&&rightup(lb,P(Ma,Mb))) return true;
	return false;
}

int main(){
	int N;
	P a, b;
	int mx[50], my[50], Mx[50], My[50], h[50];
	while(cin >> N){
		if(!N) break;
		int sx, sy, ex, ey; cin >> sx >> sy >> ex >> ey;
		a = P(sx,sy); b = P(ex,ey);
		for(int i=0;i<N;i++)
			cin >> mx[i] >> my[i] >> Mx[i] >> My[i] >> h[i];
		bool flag = false;
		for(int i=0;i<N;i++){
			if(crossSquare(a, b, mx[i], my[i], Mx[i], My[i])){
				flag = true;
				break;
			}
		}
		if(flag) { cout << 0 << endl; continue; }
		double r = 10000;
		for(int i=0;i<N;i++){
			double d = distSquare(a,b,mx[i],my[i],Mx[i],My[i]);
			if(d<h[i]) { if(d<r) r = d; }
			else    {
				double tmp = (d*d+h[i]*h[i])/(2*h[i]);
				if(tmp<r) r = tmp;
			}
		}
		printf("%.8lf\n", r);
	}
}

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


int main(void){
  ll n,a,b; cin >> n >> a >> b;
  ll stock = a + b;
  ll ans;
  ll i = n / stock;
  ll count;
  if(n < a + i * stock){
    count = n - i * stock;
  }
  else count = a;
  ans = a * i + count;
  cout << ans << endl;
  return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int h;
	cin>>h;
	vector<int>a(h+1);
	for(int i=1;i<=h;++i)cin>>a.at(i);
	for(int i=1;i<=h;++i){
		cout<<"node "s<<i<<": key = "s<<a.at(i);
		if(i!=1)cout<<", parent key = "s<<a.at(i/2);
		if(i*2<=h)cout<<", left key = "s<<a.at(i*2);
		if(i*2+1<=h)cout<<", right key = "s<<a.at(i*2+1);
		cout<<", \n"s;
	}
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int SZ=1<<18;
vector<int> adj[200000], V[200000], B;
vector<pair<int,int>> tree[2*SZ];
int N, C[200000], color[200000], cnt[200000];

int find_(int a)
{
	while(a!=color[a]) a=color[a];
	return a;
}

void union_(int a, int b)
{
	if(cnt[a]<cnt[b]) swap(a,b);
	color[b]=a;
	cnt[a]+=cnt[b];
	B.push_back(b);
}

void restore(int sz)
{
	while(B.size()>sz) {
		cnt[color[B.back()]]-=cnt[B.back()];
		color[B.back()]=B.back();
		B.pop_back();
	}
}

void add_edge(int s, int e, int a, int b)
{
	for(s+=SZ,e+=SZ;s<=e;s>>=1,e>>=1) {
		if(s&1) tree[s++].emplace_back(a,b);
		if(~e&1) tree[e--].emplace_back(a,b);
	}
}

void solve(int bit, int s, int e)
{
	int m=(s+e)>>1, bsz=B.size();
	if(N<=s) return;
	for(auto[a,b]: tree[bit]) union_(find_(a),find_(b));
	if(s==e) {
		long long ans=0;
		for(auto c: V[m]) {
			ans++;
			for(auto n: adj[c]) {
				int a=find_(c), b=find_(n); 
				if(a==b) continue;
				ans+=1LL*cnt[a]*cnt[b];
				union_(a,b);
			}
		}
		cout<<ans<<'\n';
		restore(bsz);
		return;
	}
	solve(2*bit,s,m);
	solve(2*bit+1,m+1,e);
	restore(bsz);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	cin>>N;
	for(int i=0;i<N;i++) {
		cin>>C[i];
		V[--C[i]].push_back(i);
		cnt[color[i]=i]=1;
	}
	for(int i=1;i<N;i++) {
		int a, b;
		cin>>a>>b;
		adj[--a].push_back(--b);
		adj[b].push_back(a);
		if(C[a]>C[b]) swap(a,b);
		add_edge(0,C[a]-1,a,b);
		add_edge(C[a]+1,C[b]-1,a,b);
		add_edge(C[b]+1,N-1,a,b);
	}
	solve(1,0,SZ-1);
	return 0;
}

Measured memory_bytes: 120732
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<int> s(n);
        for (int i = 0; i < n; i++) {
            cin >> s[i];
        }
        sort(s.begin(), s.end());
        int minv = numeric_limits<int>::max();
        for (int i = 0; i < n - 1; i++) {
            if (minv > s[i + 1] - s[i]) {
                minv = s[i + 1] - s[i];
            }
        }
        cout << minv << endl;
    }
    return 0;
}

Measured memory_bytes: 3172
# coding: utf-8

def BubbleSort(A, n):
    for i in range(n-1):
        for j in range(n-1, i, -1):
            if int(A[j][1]) < int(A[j-1][1]):
                A[j], A[j-1] = A[j-1], A[j]
    return A


def SelectionSort(A, n):
    mini = 1
    for i in range(n):
        mini = i
        for j in range(i, n):
            if int(A[j][1]) < int(A[mini][1]):
                mini = j
        A[i], A[mini] = A[mini], A[i]
    return A

n = int(input())
A = input().split()

b_ans = BubbleSort(A[:], n)
s_ans = SelectionSort(A[:], n)

print(" ".join(b_ans))
print("Stable")
print(" ".join(s_ans))
if b_ans == s_ans:
    print("Stable")
else:
    print("Not stable")

Measured memory_bytes: 7772
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
    // 整数の入力
    int A, B;
    int result;
    cin >> A >> B;

    if (A +B >= 24) {
        cout << A +B -24 << endl;
    } else {
        cout << A +B << endl;
    } 

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INF 100000000
#define INFLL (long long)1e14
#define Loops(i, n) for(int i = 0; i < (int)n; i++)
#define Loops1(i, n) for(int i = 1; i <= (int)n; i++)
std::string s;
bool flag=false;
int check(int TextIndex){
	if(flag==false && TextIndex==s.length()){
		std::cout<<"YES"<<std::endl;
		flag=true;
		return 0;
	}
	int index=TextIndex;
		std::string tmp1;
		std::string tmp2;
		std::string tmp3;		
		for(int i=index;i<index+5;i++){
			if(i<s.length()){
				tmp1+=s[i];
			}else {
				return 0;
			}
		}
		if(tmp1=="dream" || tmp1=="erase"){
			check(index+5);
		}

		for(int i=index;i<index+6;i++){
			if(i<s.length()){
				tmp2+=s[i];
			}else {
				return 0;
			}
		}
		if(tmp2=="eraser"){
			check(index+6);
		}			

		for(int i=index;i<index+7;i++){
			if(i<s.length()){
				tmp3+=s[i];
			}else {
				return 0;
			}
		}
		if(tmp3=="dreamer"){
			check(index+7);
		}	
		return 0;				
}
int main(void){
	std::cin>>s;
	int index=0;
	int mode=0;
	check(0);
	if(flag==false){
		std::cout<<"NO"<<std::endl;
	}
/*	Loops(i,s.length()){
		if(mode==0){
			if(s[i]=='d'){
				mode=1;
			}else if(s[i]=='e'){
				mode=2;
			}else {
				std::cout<<"NO"<<std::endl;
				return 0;
			}
		}else if(mode==1){
			std::string tmp;
			tmp=s[]
		}
	}*/
	
	return 0;
}

Measured memory_bytes: 4480
mod = 998244353
n = int(input())
A = [int(x) for x in input().split()]

if A[0] != 0:
    print(0)
else:
    L = [0]*(n+1)
    for i in range(n):
        L[A[i]] += 1

    if L[0]!=1:
        print(0)
    else:
        ans = 1
        for i in range(1,n+1):
            if L[i]>0:
                for k in range(L[i]):
                    ans *= L[i-1]
                    ans %= mod
            else:
                nxt = i
                break
        for j in range(nxt,n+1):
            if L[j] != 0:
                print(0)
                break
        else:
            print(ans)



Measured memory_bytes: 53932
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c;
    d=0;
    for(int i=a;i<b+1;i++){
    if(c%i==0){d+=1;}
    else {d+=0;}
    }
    cout<<d<<endl;
    return 0;

}



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

const int mod = 1e9 + 7;

ll quick_pow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=(ans*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return ans;
}

ll inv(ll x, ll mod)//x关于p的逆元，p为素数
{
    return quick_pow(x, mod - 2, mod);
}

ll C(ll n, ll m, ll mod)//组合数C(n, m) % p
{
    if(m > n)return 0;
    ll up = 1, down = 1;//分子分母;
    for(int i = n - m + 1; i <= n; i++)up = up * i % mod;
    for(int i = 1; i <= m; i++)down = down * i % mod;
    return up * inv(down, mod) % mod;
}

ll Lucas(ll n, ll m, ll mod)
{
    if(m == 0)return 1;
    return C(n % mod, m % mod, mod) * Lucas(n / mod, m / mod, mod) % mod;
}

ll n,a,b;

int main()
{
	
	std::ios::sync_with_stdio(false);cin.tie(0);
	cin >> n >> a >> b;
	ll ans = ((quick_pow(2,n % (mod - 1),mod) - Lucas(n,a,mod) + mod) % mod - Lucas(n,b,mod) + mod) % mod;
	cout << (ans - 1 + mod ) % mod << endl;
	return 0;
}

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

int main() {
    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for (int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
    }
    vector<int> v;
    for (int i = 0; i < (1 << D); i++) {
        int num = 0;
        int sum = 0;
        int max_p = 0;
        for (int j = 0; j < D; j++) {
            if (i & (1 << j)) {
                sum += p[j] * (100 * (j + 1)) + c[j];
                num += p[j];
            } else {
                max_p = j;
            }
        }
        if (G <= sum) {
            v.push_back(num);
            continue;
        }
        int rest = G - sum;
        int tmp_num = (rest + 100 * (max_p + 1) - 1) / (100 * (max_p + 1));
        if (p[max_p] > tmp_num) {
            num += tmp_num;
            v.push_back(num);
        }
    }
    cout << *min_element(v.begin(), v.end()) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans;

    int dx=tx-sx, dy=ty-sy;

    for(int i=0;i<dx;i++){
        ans.push_back('R');
    }
    for(int i=0;i<dy;i++){
        ans.push_back('U');
    }
    for(int i=0;i<dx;i++){
        ans.push_back('L');
    }
    for(int i=0;i<dy;i++){
        ans.push_back('D');
    }
    ans.push_back('L');
    for(int i=0;i<dy+1;i++){
        ans.push_back('U');
    }
    for(int i=0;i<dx+1;i++){
        ans.push_back('R');
    }
    ans.push_back('D');
    ans.push_back('R');
    for(int i=0;i<dy+1;i++){
        ans.push_back('D');
    }
    for(int i=0;i<dx+1;i++){
        ans.push_back('L');
    }
    ans.push_back('U');

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int min = 100001;

		for (int A = 1; A < N; A++) {
			int B = N - A;
			int tmp = calSumOfDigits(A) + calSumOfDigits(B);

			if(tmp < min) {
				min = tmp;
			}
		}
		System.out.println(min);
	}
	//各桁の和を計算
	public static int calSumOfDigits(int n) {
		int sum = 0;
		while(n > 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int K;
bool u[100010];


int solve(){
	deque<PII> q;
	q.pb({ 1, 0 });
	while(!q.empty()){
		int x = q.front().fi;
		int y = q.front().se;
		q.pop_front();
		if(x == 0) return y+1;
		u[x] = true;
		int a = (x+1)%K;
		int b = (x*10)%K;
		if(!u[a]) q.pb({ a, y+1 });
		if(!u[b]) q.pf({ b, y });
	}
	return -1;
}


signed main(){
	cin >> K;

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cnt = 0;
        long X = sc.nextLong(), val = 100;

        while(val < X) {
            val += val/100;
            cnt++;
        }
        System.out.print(cnt);
    }
}


Measured memory_bytes: 35748
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,M;

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

    vector<vector<int> > job(M);

    for(int i = 0;i < N;i++) {
        int a,b;
        cin>>a>>b;
        if(a <= M) {
            job[a-1].push_back(b);
        }
    }

    Int reward = 0;
    priority_queue<int> cand;
    for(int i = 0;i < M;i++) {
        for(auto v : job[i]) {
            cand.push(v);
        }
        if(!cand.empty()) {
            reward += cand.top();
            cand.pop();
        }
    }

    cout<<reward<<endl;
    
    return 0;
}


Measured memory_bytes: 5632
#include <stdio.h>
#include <string.h>
int main(){
  int a, b, c;
  int ans = 3;

  scanf("%d%d%d", &a, &b, &c);

  if(a == b && b == c){
    ans = 1;
  }else{
    if(a == b){
      ans--;
    }else if(b == c){
      ans--;
    }
    if(a == c){
      ans--;
    }
  }
  printf("%d\n", ans);
  
}


Measured memory_bytes: 128
N=int(input())
A=[int(input()) for _ in range(N)]
mp=A[1]-A[0]
mn=A[0]
for i in range(1,N):
    if mp < (A[i]-mn):
        mp=A[i]-mn
    if A[i]<mn:
        mn=A[i]
print(mp)

Measured memory_bytes: 13596
#include<iostream>
#include<cmath>
#include<vector>

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

using namespace std;

#define MAX 100100

struct Edge {
  int s,w;
};

int V;
vector<Edge> G[MAX];
double p;

double dfs(int cur,int pre,double coef=0.0) {
  double ex = 0;
  rep(i,(int)G[cur].size()) {
    Edge &e = G[cur][i];
    if( e.s == pre ) continue;
    ex +=  p * ( ( ( e.w + coef ) + dfs(e.s,cur,coef) ) ) ;
    //ex += ( dfs(e.s,cur,coef) + p * coef * (double)e.w );
  }
  return ex;
}

void compute() {
  double X = dfs(0,-1);
  printf("%.10f\n",dfs(0,-1,X)+X);
}

int main() {
  cin >> p;
  cin >> V;
  rep(i,V-1) {
    int a,b,c;
    cin >> a >> b >> c;
    --a, -- b;
    G[a].push_back((Edge){b,c});
    G[b].push_back((Edge){a,c});
  }
  compute();
  return 0;
}

Measured memory_bytes: 16416
#include<iostream>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

ll combination(int n,int r){
    if(2*r > n){
        r=n-r;
    }
    ll divided=1;
    ll divisor=1;
    for(int i=1; i<=r; i++){
        divided *= (n-i+1);
        divisor *= i;
    }
    return divided/divisor; 
}

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

    vector<int> a(n);
    vector<ll> ans(n,0);
    map<ll,ll> cnt;
    ll all=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        cnt[a[i]]++;
    }

    for(auto c : cnt){
        all+=c.second*(c.second-1)/2;
    }

    for(int k=0; k<n; k++){
        ll value=cnt[a[k]];
        ll before=value*(value-1)/2;
        ll after=(value-1)*(value-2)/2;

        cout<<all-before+after<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ld d,t,s;
    cin>>d>>t>>s;
    if (d/s<=t)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int sum_head(vector<int> v,int l){  //vの初めからI要素の和
  int s=0;
  for(int i=0;i<l;i++){
    s += v[i];
  }
  return s;
}
int main() {
  int N;
  cin >>N;
  vector<int> a(N),b(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  for(int i=0;i<N;i++){
    cin >> b[N-1-i];
  }
  int ans=0;
  for(int j=0;j<N;j++){
    ans = max(ans,sum_head(a,j+1)+sum_head(b,N-j));
  }
  cout << ans << endl;
}

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

int main() {
	int n, t[110], m, sum = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> t[i];
		sum += t[i];
	}
	
	cin >> m;
	for (int i = 1; i <= m; i++) {
		int p, x;
		cin >> p >> x;
		cout << sum - t[p] + x << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vl>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
vvl G;
queue<ll> que;
void BFS(ll v,vl &dist){
    dist[v]=0;
    que.push(v);
    while(que.size()){
        ll v=que.front();
        que.pop();
        for(auto nv:G[v]){
            if(dist[nv]>dist[v]+1){
                dist[nv]=dist[v]+1;
                que.push(nv);
            }
        }
    }
}
int main(){
    ll N;cin>>N;
    vl id(N);
    G=vvl(N,vl());
    rep(i,N){
        cin>>id[i];
        ll k;cin>>k;
        rep(j,k){
            ll a;cin>>a;
            G[i].push_back(a-1);
        }
    }
    vl dist(N,INF);
    BFS(0,dist);
    vector<pl> ans(N);
    rep(i,N){
        ans[i].fi=id[i],ans[i].se=dist[i];
        if(ans[i].se==INF)ans[i].se=-1;
    }
    sort(all(ans));
    rep(i,N)cout<<ans[i].fi<<" "<<ans[i].se<<endl;
    return 0;
}


Measured memory_bytes: 3180
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define ll long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<ppi>
#define vll vector<ll>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

const int N=20001;
vi adj[N];
int a[N];

void bfs(int s)
{
	bool vis[2001];
	memset(vis,false,sizeof vis);
	queue<ppi> que;
	que.push({s,1});
	while(!que.empty())
	{
		ppi t=que.front();
		que.pop();
		vis[t.fi]=1;
		for(int v:adj[t.fi])
		{
			if(!vis[v])
			{
				a[t.se]++;
				vis[v]=1;
				//cout<<t.fi<<" "<<v<<" "<< t.se<<endl;
				que.push({v,t.se+1});
			}
		}
	}
}


int main()
{      
  fastio();
  int n,x,y,i;
  cin>>n>>x>>y;
  if(x>y)
  	swap(x,y);
  for(i=1;i<=n-1;i++)
  {
  	adj[i].pb(i+1);
  	adj[i+1].pb(i);
  }
  adj[x].pb(y);
  adj[y].pb(x);
  for(i=1;i<=n;i++)
  {
  		bfs(i);
  }
  for(i=1;i<=n-1;i++)
  	cout<<a[i]/2<<"\n";
  return 0;
}

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

      int n = sc.nextInt();
      int m = sc.nextInt();

      int[] p = new int[m];
      String[] s = new String[m];
      for (int i = 0; i < p.length; i++) {
         p[i] = sc.nextInt();
         s[i] = sc.next();
      }

      int w = 0;
      int a = 0;

      
      int[] c = new int[n+1];
      int[] count = new int[n+1];
      int[] acount = new int[n+1];
      for (int i = 0; i < c.length; i++) {
         c[i] = 0;
         count[i] = 0;
         acount[i] = 0;
      }

      for (int i = 0; i < m; i++) {
         int pc = p[i];
         count[pc] = count[pc] + 1;
         if("AC".equals(s[i])){
            acount[pc] = acount[pc] + 1;
         }
         else{
            if(acount[pc]<1){
               c[pc] = c[pc] + 1;
            } 
         }
      }
      for (int i = 1; i <= n; i++) {
         if(c[i] < count[i]){
            w = w + c[i];
         }
         if(acount[i]>= 1){
            a = a + 1;
         }
      } 

      System.out.print(a);
      System.out.print(' ');
      System.out.println(w);
   }
}

Measured memory_bytes: 71984
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

typedef long long ll;

const int N=1000000;
double ans;

bool a[N];
int b[N];
int ind;

int generate(){
  for(int i=0;i<N;i++)a[i]=i%2;
  for(int i=3;i*i<=N;i+=2){
    if (a[i])for(int j=2*i;j<N;j+=i)a[j]=false;
  }
  int index=0;
  b[index++]=2;
  for(int i=3;i<N;i+=2){
    if (a[i])b[index++]=i;
  }
  return index;
}

void solve(ll n,int *pri,int now,double val,double sum){
  if (val > n || now == ind)return;
  ans=max(ans,sum/val);
  if (pri[now] > n)return;
  
  ll tmp  =  1;
  ll tsum =  1;
  while(true){
    if (tmp > n)break;
    if (tmp!=1)solve(n,pri,now+1,val*tmp,sum*tsum);
    tmp*=pri[now];
    tsum+=tmp;
  }

}

main(){
  ind=generate();
  ll n;
  while(cin>>n && n){
    ans = 1;
    solve(n,b,0,1,1);
    printf("%.6lf\n",ans);
  }
  return false;
}

Measured memory_bytes: 2188
//verified against AOJ GRL_3_C
#include <bits/stdc++.h>
using namespace std;

const int N = 10001;
int group[N];

class Graph {
private:
  int V;
  int E;
  vector <vector <int>> adj;
  void sccUtil(int u, vector <bool> &visited, vector <int> &dis, vector <int> &low, vector <bool> &active, stack <int> &st);
public:
  Graph(int n, int m);
  void addEdge(int s, int t);
  void scc();
};

Graph::Graph(int n, int m) {
  this->V = n;
  this->E = m;
  adj.resize(n);
}

void Graph::addEdge(int s, int t) {
  adj[s].push_back(t);
} 

void Graph::sccUtil(int u, vector <bool> &visited, vector <int> &dis, vector <int> &low, vector <bool> &active, stack <int> &st) {  
  static int timer = 0;
  static int grp = 0; //..for grouping
  visited[u] = true;
  active[u] = true;
  st.push(u);

  dis[u] = low[u] = ++timer;
  for (int v : adj[u]) {
    if (!visited[v]) {
      sccUtil(v, visited, dis, low, active, st);
      low[u] = min(low[u], low[v]);
    } else if (active[v]) {
      low[u] = min(low[u], dis[v]);
    }
  }
  
  if (low[u] == dis[u]) {
    //..print SCC
    while (st.top() != u) {
      int node = st.top();
      group[node] = grp;
      active[node] = false;
      st.pop();
    } 
    int node = st.top();
    group[node] = grp;
    active[node] = false;
    st.pop();
    grp++;
  } 
} 

void Graph::scc() {
  vector <bool> visited(V, false);
  vector <int> low(V, 0);
  vector <int> dis(V, 0);
  vector <bool> active(V, false);
  stack <int> st;

  for (int i = 0; i < V; i++) {
    if (!visited[i]) {
      sccUtil(i, visited, dis, low, active, st);
    }
  }
}

int main() {
  int n, m;
  int s, t;
  cin >> n >> m;
  Graph g(n, m);
  for (int i = 0; i < m; i++) {
    cin >> s >> t;
    g.addEdge(s, t);
  }
  g.scc();
  int q, u, v;
  cin >> q; 
  for (int i = 0; i < q; i++) {
    cin >> u >> v;
    if (group[u] == group[v]) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 4704
/*
 * FileName:     set_union
 * CreatedDate:  2020-06-09 15:54:08 +0900
 * LastModified: 2020-06-09 16:09:14 +0900
 */

#include <stdio.h>
#include <stdlib.h>
#define ultra 2e9
int main(void){
    int n;scanf("%d",&n);
    int *a = malloc((n+1)*sizeof(int));
    for(int i=0;i<n;i++)scanf("%d",a+i);
    a[n]=ultra;
    int m;scanf("%d",&m);
    int *b = malloc((m+1)*sizeof(int));
    for(int i=0;i<m;i++)scanf("%d",b+i);
    b[m]=ultra;
    int ia=0,ib=0;
    while(ia<n||ib<m){
        if(a[ia]>b[ib]){
            printf("%d\n",b[ib]);
            ib++;
        }
        else if(a[ia]<b[ib]){
            printf("%d\n",a[ia]);
            ia++;
        }
        else{
            printf("%d\n",a[ia]);
            ia++;
            ib++;
        }
    }
    free(a);
    free(b);
    return 0;
}



Measured memory_bytes: 3124
#include <stdio.h>
 
int main()
{
  int a, b, c, x;    
 
  scanf("%d %d %d", &a, &b, &c);
 
  if (a > b) {
    x = a;
    a = b;
    b = x;
  }

  if (a > c) {
    x = c;
    c = a;
    a = x;
  }

  if (b > c) {
    x = b;
    b = c;
    c = x;
  }

  printf ("%d %d %d\n", a, b, c);
 
  return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, m;
  cin >> n >> m;
  if (n == 1 && m == 1)
	cout << 1 << endl;
  else if (n==1 || m==1)
	cout << n * m - 2 << endl;
  else
	cout << (n-2) * (m-2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define inf 1000000000

using namespace std;

int n;
int N;
vector<string> str;
int G[15][15];
int dp[1 << 15][15];

int count(int i, int j)
{
	string s1 = str[i], s2 = str[j];
	int l = min(s1.size(), s2.size());
	
	int ret = 0;
	for(int i = 1; i <= l; i++){
		if(s1.substr(s1.size()-i, i) == s2.substr(0, i)) ret = i;
	}
	return ret;
}

int main(void)
{
	while(1){
		cin >> n;
		if(n == 0) break;
		
		string tmp;
		bool flag;
		int len = 0;
		
		str.clear();
		for(int i = 0; i < n; i++){
			cin >> tmp;
			flag = false;
			for(int i = 0; i < str.size(); i++){
				if(str[i].find(tmp) != -1){
					flag = true;
					break;
				}
				if(tmp.find(str[i]) != -1){
					str.erase(str.begin() + i);
					i--;
				}
			}
			if(!flag){
				str.push_back(tmp);
			}
		}
		N = str.size();
		for(int i = 0; i < N; i++) len += str[i].size();
		
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				if(i == j){
					G[i][j] = inf;
					continue;
				}
				G[i][j] = count(i, j);
			}
		}
		
		for(int i = 0; i < (1<<N); i++){
			for(int j = 0; j < N; j++){
				dp[i][j] = -inf;
			}
		}
		for(int i = 0; i < N; i++) dp[1<<i][i] = 0;
		
		int next;
		for(int s = 1; s < (1<<N); s++){
			for(int i = 0; i < N; i++){
				for(int j = 0; j < N; j++){
					if( (s & (1<<j)) == 0 ){
						next = s | (1<<j);
						dp[next][j] = max(dp[next][j], dp[s][i] + G[i][j]);
					}
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < N; i++) ans = max(ans, dp[(1<<N)-1][i]);
		cout << len - ans << endl;
	}
	
	return 0;
}

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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    ll a, b;
    cin >> a >> b;
   ll s = 0;
   s = ((a * (a - 1))/ 2) + ((b*(b - 1))/2);
   cout << s << endl;
   
}



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

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

    ll n, k; cin >> n >> k;
    vector<ll> p(n,0); for (ll i=0; i<n; i++) cin >> p[i];

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

    ll ans = 0;
    for (ll i=0; i<k; i++) {
        ans += p[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3660
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created on 2018/03/02 19:17.
 */
public class Main{
    public static void main(String[] args) throws IOException {
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);

        while (sc.hasNextInt()) {
            int t[] = new int[3];
            for (int i = 0; i < 3; i++) {
                t[i] = sc.nextInt();
            }
            Arrays.sort(t);
            if (t[0] == 5 && t[1] == 5 && t[2] == 7) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}


Measured memory_bytes: 21716
import java.io.*;
import java.util.*;

public class Main {

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

        FastReader fs = new FastReader();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = fs.nextInt();
        int freq[] = new int[n+1];
        for(int i= 2 ; i<=n ; i++){
            freq[fs.nextInt()]++;
        }

        for(int i=1 ; i<=n ; i++){
            out.println(freq[i]);
        }

        out.close();

    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------
}


Measured memory_bytes: 54276
#include<bits/stdc++.h>
#define pi              acos(-1)
#define ll              long long
#define ld              long double
#define gcd             __gcd
#define bitscount       __builtin_popcount
#define ff              first
#define ss              second
#define MAXX            1e18
#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL)
//__builtin_popcount()  -->  counts how many 1 s are in a binary represented integer
//accumulate() --> finds sum of an array of integers
using namespace std;
int main()
{
    ll n, i;
    cin>>n;
    vector<ll> v(n), dp(n);
    for(i=0; i<n; i++)
        cin>>v[i];
    for(i=0; i<n; i++){
        if(i == 0)
            dp[i] = v[i];
        else if(i>0 && i<=2)
            dp[i] = abs(v[i]-v[0]);
        else{
//            if(abs(v[i]-v[i-1]) <= abs(v[i]-v[i-2]))
//                dp[i] = abs(v[i]-v[i-1]) + dp[i-1];
//            else
//                dp[i] = abs(v[i]-v[i-2]) + dp[i-2];
            dp[i] = min(dp[i-1]+abs(v[i]-v[i-1]), dp[i-2]+abs(v[i]-v[i-2]));
        }
    }
//    for(i=0; i<n; i++)
//        cout<<dp[i]<<" ";
    cout<<endl<<dp[n-1];
}


Measured memory_bytes: 1792
import itertools

N, K = map(int, input().split())
a = list(map(int, input().split()))
beautiful_num = []

for i in range(N):
    temp = 0
    for n in a[i:]:
        temp += n
        beautiful_num.append(temp)

ma_b_cnt = 0
target_set = None

result = 0
for i in range(40, -1, -1):
        for b in beautiful_num:
            if b & 1 << i != 0:
                ma_b_cnt += 1
        if ma_b_cnt >= K:
            result += 2**i
            beautiful_num = [b for b in beautiful_num if b & 1 << i != 0]
        ma_b_cnt = 0

print(result)

Measured memory_bytes: 27816
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int costA, costB;
  costA = costB = 0;
  int P;
  rep(i, M) {
    cin >> P;
    if(P < X) {
      costA++;
    }
    else {
      costB++;
    }
  }
  cout << min(costA, costB) << endl;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

int main()
{
  int t;
  t=1;
  //cin>>t;
  
  while(t--)
  {
    long long n,i,j,x,y,c=0,mx=0;
    cin>>n;
    int a[n+3];
    FOR(i,1,n) cin>>a[i];
    FOR(i,1,n-1)
    {
      if(a[i]>=a[i+1])
      {
        c++;
      }else
      {
        mx=max(c,mx);
        c=0;
      }
    }
    mx=max(c,mx);
    cout<<mx<<endl;
  }

}


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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

ll calc(ll x) { return x * x * x * x * x; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  VLL a;
  VLL b;
  ll x = -1000;
  while(calc(x) <= 1000000000000000ll) {
    a.push_back(calc(x));
    b.push_back(x);
    x++;
  }
  int n = a.size();
  ll xx;
  cin >> xx;
  rep(i, n) FOR(j, i + 1, n) {
    if(a[j] - a[i] == xx) {
      cout << b[j] << " " << b[i] << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <iomanip>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

int main() {
    int n,m;
    cin >> n >> m;
    vvi matrics;
    vi vec;
    vi result;
    F(i, 0, n){
        vi vect;
        F(k, 0, m){
            int l;
            cin >> l;
            vect.pb(l);
        }
        matrics.pb(vect);
    }
    F(i, 0, m){
        int l;
        cin >> l;
        vec.pb(l);
    }
    F(i, 0, n){
        int sum = 0;
        F(k, 0, m){
             sum += matrics[i][k] * vec[k];
        }
        result.pb(sum);
    }
    F(i, 0, n){
        cout << result[i] << endl;
    }
}



Measured memory_bytes: 3172
N, K = map(int, input().split())
P = list(map(int, input().split()))

max_sub = sum(P[0:K])
sub = max_sub
l = 0

for n in range(N-K):
    sub += P[n+K] - P[n]

    if max_sub < sub:
        max_sub = sub
        l = n + 1

print((sum(P[l:l+K])+K) / 2)


Measured memory_bytes: 25060
/*input

*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int n;
	cin >> n;
	int a[n+1], b[n+1], c[n+1];
	rep(i, n) cin >> a[i+1] >> b[i+1] >> c[i+1];
	int dp[n+1][3];
	rep(i, 3) dp[0][i]=0;
	repl(i, 1, n+1) {
		dp[i][0]=a[i]+max(dp[i-1][1], dp[i-1][2]);
		dp[i][1]=b[i]+max(dp[i-1][0], dp[i-1][2]);
		dp[i][2]=c[i]+max(dp[i-1][0], dp[i-1][1]);
	}
	cout << max({dp[n][0], dp[n][1], dp[n][2]});
	return 0;
}

Measured memory_bytes: 5900
package main

import "fmt"

func main() {
    var h, w int

    for {
        fmt.Scanf("%d %d", &h, &w)
        if h == 0 && w == 0 {
            break
        }

        for i:=0; i<h; i++ {
            for j:=0; j<w; j++ {
                fmt.Print("#")
            }
            fmt.Println("")
        }
        fmt.Println("")
    }
}


Measured memory_bytes: 1128