akhauriyash/Code-Regression huggingface dataset:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int H = one.get(0);
		int N = one.get(1);
		ArrayList<Integer> list = nextIntArray();
		for(int i = 0; i < N; i++){
			H -= list.get(i);
			if(H <= 0){
				myout("Yes");
				return;
			}
		}
		myout("No");
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 46824
#include<iostream>
using namespace std;
int main()
{
	long long a, b, c, d;
	int i = 0;

	cin >> a;

	b = 2;
	c = 1;
	d = 0;

	for (i = 0; i < a-1; i++) {
		d = c + b;
		b = c;
		c = d;
	}

	if (a == 1)
		cout << 1;
	else
		cout << d;


	return 0;
}

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

int size[maxn],n,cnt,head[maxn],d[maxn];

ll dist[maxn];

map < ll , ll > id;

struct E{
	int to,nxt,fr;
}edge[maxn<<1];

inline void add(int u,int v){edge[++cnt]=(E){v,head[u],u};head[u]=cnt;}

template <class T>
void read(T &x){
	char s=getchar();x=0;
	while(s<'0'||s>'9') s=getchar();
	while(s>='0'&&s<='9') x=(x<<3)+(x<<1)+s-'0',s=getchar();
}

void dfs(int u){
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		d[v]=d[u]+1;
		dfs(v);
	}
}

bool check(){
	ll sum=0;
	for(int i=1;i<=n;i++) sum+=d[i];
	return dist[1]==sum;
}

int main(){
	read(n);
	for(int i=1;i<=n;i++) read(dist[i]),id[dist[i]]=i,size[i]=1;
	sort(dist+1,dist+n+1);
	for(int i=n;i>1;i--){
		int fa,u=id[dist[i]];
		ll tmp1=n-size[u]*2;
		if(tmp1<=0) return printf("-1"),0;
		ll tmp2=dist[i]-tmp1;
		if(id.count(tmp2)==0) return printf("-1"),0;
		fa=id[tmp2];
		add(fa,u);
		size[fa]+=size[u];
	}
	dfs(id[dist[1]]);
	if(check()){
		for(int i=1;i<n;i++) printf("%d %d\n",edge[i].fr,edge[i].to);
		return 0;
	}
	printf("-1"),0;
}

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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int main(){
  ll N;
  cin >> N;
  vector<ll>A(N);
  for(ll i=0;i<N;i++){
    cin >>A[i];
  }
  ll B=0;
  for(ll i=0;i<N;i++){
    B=gcd(A[i],B);
  }
  cout << B << endl;
}
      
  
  
  

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int cti(char c){
  if(c=='m')return 1000;
  if(c=='c')return 100;
  if(c=='x')return 10;
  else return 1;
}
int sti(string s){
  int tmp=1;
  int ret = 0;
  FOR(i,0,s.size()){
    if(s[i]<='9'&&s[i]>='1'){
      tmp = s[i]-'0';
    }else{
      ret += tmp*cti(s[i]);
      tmp = 1;
    }
  }
  return ret;
}
string its(int n){
  string charset = "mcxi";
  string ret;
  int d[4];
  REP(i,4){
    d[i] = n%10;
    n/=10;
  }
  REP(i,4){
    if(d[3-i]>1) ret+=(char)(d[3-i]+'0');
    if(d[3-i]>0) ret+=charset[i];
  }
  return ret;
}

int main(void){
  int N;
  cin>>N;
  while(N--){
    string a,b;
    cin>>a>>b;
    int sum = sti(a) + sti(b);
    cout<<its(sum)<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int K, N;
  cin >> K >> N;
  
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  
  int max_distance = 0;
  for(int i=0;i<(N-1);i++){
     max_distance = max(max_distance, A.at(i+1)-A.at(i));
  }
  max_distance = max(max_distance, (K-A.at(N-1)+A.at(0)));

  cout << K-max_distance << endl;
}

Measured memory_bytes: 1024
def solve():
    from sys import stdin
    f_i = stdin
    
    n = int(f_i.readline())
    A = list(map(int, f_i.readline().split()))
    q = int(f_i.readline())
    
    from bisect import bisect_left as bl
    from bisect import bisect_right as br
    ans = []
    for i in range(q):
        k = int(f_i.readline())
        ans.append(' '.join(map(str, (bl(A, k), br(A, k)))))
    
    print('\n'.join(ans))

solve()


Measured memory_bytes: 29276
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }


signed main()
{
	string s, t;
	cin >> s >> t;

	cout << ((s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) ? "YES" : "NO") << endl;
}



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

using namespace std;

const int inf = 2e9;

int h[100100], dp[100100];
int n, k;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> h[i];
	
	for (int i = 0; i < n; i++) dp[i] = inf;
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i - 1; j >= i - k && j >= 0; j--) {
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	
	cout << dp[n - 1] << '\n';
}


Measured memory_bytes: 1024
n, k = gets.chomp.split.map(&:to_i)
ki = 0
# k番目に小さい数...?
# ->ソートしたときの順番だと思われ
arr = {}
n.times do
  a, b = gets.chomp.split.map(&:to_i)
  if arr[a].nil?
    arr[a] = b
  else
    arr[a]+=b
  end
end
arr = arr.sort_by{|x|x[0]} # 頭湧いてるからarr[0]にしてた
arr.each do |a, v|
  if ki+v<k
    ki+=v
  else
    puts a
    exit  # 頭湧いてるからbreakにしてた
  end
end

Measured memory_bytes: 10488
N = int(input())
A = list(map(int,input().split()))
bit = [0]*pow(10,5)
for a in A:
    bit[a-1] += 1
cnt = 0
kind = 0
for b in bit:
    if b > 0:
        cnt += b-1
        kind += 1
if cnt % 2 == 0:
    ans = kind
else:
    ans = kind-1

print(ans)

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

using namespace std;

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

  int tmp = N / 100;
  if(N <= 100 * tmp + 10 * tmp + 1 * tmp) {
    cout << 100 * tmp + 10 * tmp + 1 * tmp << endl;
  }
  else {
    tmp += 1;
    cout << 100 * tmp + 10 * tmp + 1 * tmp << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'

//DP法
template <class T>
inline bool chmin(T &a, T b) //change minimum
{
        if (a > b)
        {
                a = b;
                return true;
        }
        return false;
}
template <class T>
inline bool chmax(T &a, T b) //change max
{
        if (a < b)
        {
                a = b;
                return true;
        }
        return false;
}

typedef long long ll; //64bit型

using namespace std;

// const long long INF = 1LL << 60; //無限大の値
int INF = 1000000;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //三項演算子を使ったgcd(最大公約数)
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //lcm(最小公倍数)
ll f(ll x, int a, int b)
{
        ll res = x;
        res -= x/a;
        res -= x/b;
        res += x / lcm(a, b);

        return res;
}

int main()
{
        ll A, B;
        int C, D;
        cin >> A >> B >> C >> D;
        ll ans = f(B, C, D) - f(A - 1, C, D);

        cout << ans << endl;

        return 0;
}


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

int main(){
    string s; cin >> s;
    int size = s.size();
    int a = 0;
    int dif = 0;
    for(int i = 0; i < size; i++){
        if(s[i] == 'S'){
            a++;
        }else{
            if(a > 0){
                a--;
                dif += 2;
            }
        }
    }
    cout << size - dif << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;

typedef pair<int, int> P;

int main()
{
	int H, W, N, gn = 0, res = 0;
	cin >> H >> W >> N;
	char ch;
	vector< vector<int> > a(W, vector<int>(H, 1000002));
	P start;
	vector< P > goal(N);

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> ch;
			if (ch == 'X') {
				a[j][i] = -1;
			}
			else if (ch == 'S') {
				start.first = j;
				start.second = i;
			}
			else if (ch >= '1' && ch <= '9') {
				goal[ch - '1'].first = j;
				goal[ch - '1'].second = i;
			}
		}
	}
	while (gn < N) {
		queue< P > bfs;
		bfs.push(start);
		a[start.first][start.second] = 0;
		while (!bfs.empty()) {
			P temp = bfs.front();
			bfs.pop();
			if (temp.first + 1 < W && a[temp.first + 1][temp.second] == 1000002) {
				if (goal[gn].first == temp.first + 1 && goal[gn].second == temp.second) {
					res += a[temp.first][temp.second] + 1;
					break;
				}
				else {
					a[temp.first + 1][temp.second] = a[temp.first][temp.second] + 1;
					bfs.push(P(temp.first + 1, temp.second));
				}
			}
			if (temp.first - 1 >= 0 && a[temp.first - 1][temp.second] == 1000002) {
				if (goal[gn].first == temp.first - 1 && goal[gn].second == temp.second) {
					res += a[temp.first][temp.second] + 1;
					break;
				}
				else {
					a[temp.first - 1][temp.second] = a[temp.first][temp.second] + 1;
					bfs.push(P(temp.first - 1, temp.second));
				}
			}
			if (temp.second + 1 < H && a[temp.first][temp.second + 1] == 1000002) {
				if (goal[gn].first == temp.first && goal[gn].second == temp.second + 1) {
					res += a[temp.first][temp.second] + 1;
					break;
				}
				else {
					a[temp.first][temp.second + 1] = a[temp.first][temp.second] + 1;
					bfs.push(P(temp.first, temp.second + 1));
				}
			}
			if (temp.second - 1 >= 0 && a[temp.first][temp.second - 1] == 1000002) {
				if (goal[gn].first == temp.first && goal[gn].second == temp.second - 1) {
					res += a[temp.first][temp.second] + 1;
					break;
				}
				else {
					a[temp.first][temp.second - 1] = a[temp.first][temp.second] + 1;
					bfs.push(P(temp.first, temp.second - 1));
				}
			}
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (a[j][i] != -1) {
					a[j][i] = 1000002;
				}
			}
		}
		start = goal[gn];
		gn++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4964
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<map>
#include<iomanip>
#include<cstring>
#define reg register
#define EN std::puts("")
#define LL long long
inline int read(){
	register int x=0;register int y=1;
	register char c=std::getchar();
	while(c<'0'||c>'9'){if(c=='-') y=0;c=std::getchar();}
	while(c>='0'&&c<='9'){x=x*10+(c^48);c=std::getchar();}
	return y?x:-x;
}
int main(){
	int n=read(),m=read();
	while(m--) n-=read();
	std::printf("%d",n<0?-1:n);
	return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

 
struct Unionfind{
    vector<int> parents;
    int n;
    Unionfind(int n):n(n),parents(n,-1){ }

    int find(int x){
        if(parents[x] < 0) return x;
        else return parents[x] = find(parents[x]);
    }

    void unite(int x,int y){
        // x parent y child
        x = find(x);
        y = find(y);

        if(x==y) return;
        //if(parents[x] > parents[y]) swap(x,y);
        parents[x] += parents[y];
        parents[y] = x;
    }  

   int size(int x){
       return -parents[find(x)];
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }

   vector<int> members(int x){
       int root = find(x);
       vector<int> member;
       for(int i=0;i<n;i++){
           if(find(i)==root ){
               member.push_back(i);
           }
       }
      return member;
  }

  int group_cnt(){
      int c = 0;
      rep(i,n){
          if(parents[i] < 0) ++c;
      }
      return c;
  }
};

int main(){
    int n,k,l;
    scanf("%d%d%d",&n,&k,&l);
    //cin >> n >> k >> l;
    Unionfind uf1(n),uf2(n);
    rep(i,k){
        int p,q;
        scanf("%d%d",&p,&q);
        //cin >> p >> q;
        --p;--q;
        uf1.unite(p,q);
    }
    rep(i,l){
        int p,q;
        scanf("%d%d",&p,&q);
        //cin >> p >> q;
        --p;--q;
        uf2.unite(p,q);
    }
    vector<int> ans(n);
    map<int,vector<int>> mp;
    rep(i,n){
        mp[uf1.find(i)].push_back(i);
    }

    Unionfind uf3(2*n);
    vector<int> cnt(n,1);

    for(auto p:mp){
        for(int i:p.second) uf3.unite(uf2.find(i)+n,i);
        for(int i:p.second) ans[i] = uf3.size(i) - cnt[uf3.find(i)-n];
        for(int i:p.second) cnt[uf3.find(i)-n] = uf3.size(i);
    }
    rep(i,n) printf("%d ",ans[i]);// cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 27808
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INTXT std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());
#define INF 1e9

using namespace std;
typedef long long ll;
static const ll MOD = 1000000007LL;

signed main() {
  IOS
  int n, x;
  cin >> n >> x;
  
  int cnt = 1;
  int cum_sum = 0;
  REP(i, n){
    int l;
    cin >> l;
    cum_sum += l;
    if (cum_sum > x) break;
    cnt++;
  }
  cout << cnt << endl;

}


Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
can = []
mini = min(x,y)
maxi = max(x,y)
can.append( c * 2 * mini + a * (x-mini) + b * (y-mini) )
can.append( c * 2 * maxi )
can.append( a * x + b * y )
print(min(can))

Measured memory_bytes: 3060
using System;

namespace ABC116_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int d;
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            int c = int.Parse(array[2]);
            d = a * b / 2;
            Console.WriteLine(d);
        }
    }
}


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

int main(){
	int n,m = 0;
  	cin >> n;
  	vector<int> a(n);
  	for(int i = 0; i < n;i++)
      	cin >> a[i];
  	sort(a.begin(), a.end());
  	bool alice = true; 
  	for(int i = n-1; i >= 0; i--) {
    	if(alice)
          	m += a[i];
		else
          	m -= a[i];
      	alice = !alice;
    }
  	cout << m << endl;	
}


Measured memory_bytes: 256
console.log((args=>{
  const N = args|0;
  const e = Array(N+1).fill(1);
  e[0] = 0;
  for ( let i = 2; i <= N; i++ ) {
    for ( let j = i; j <= N; j+=i ) {
      e[j]++;
    }
  }
  return `${e.reduce((a,b,i)=>a+b*i)}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 113364
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    r = collections.Counter([str(input().rstrip('\n')) for _ in range(n)])
    m = int(input().rstrip('\n'))
    b = collections.Counter([str(input().rstrip('\n')) for _ in range(m)])
    mt = 0
    for k, v in r.items():
        if k in b:
            if v > b[k]:
                mt = max(mt, v - b[k])
        else:
            mt = max(mt, v)
    print(mt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38640
# coding: utf-8
# Your code here!
n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))

def binarySearch(x,lst):
    left=0
    right=(len(lst))
    while left<right:
        mid=(left+right)//2
        if lst[mid]==x:
            return True
        elif x<lst[mid]:
            right=mid
        else:
            left=mid+1
    return False
a=(list(map(lambda x:binarySearch(x,S),T)))
print(a.count(True))


Measured memory_bytes: 16716
#include <stdio.h>

int main(){
    
    int x,y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x==0 && y==0)break;
        if(x >= y) printf("%d %d\n", y, x);
        else if(x < y) printf("%d %d\n", x, y);
        //if(x > y) printf("%d %d\n", x, y);
    }
}


Measured memory_bytes: 2604
#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;
constexpr int mod = 1000000007;

int main() {
	int r;
	cin >> r;
	cout << r * r << endl;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val hh = readLine()!!.split(" ").map { it.toInt() }

    val dp = IntArray(n){ Int.MAX_VALUE }

    for (i in 0 until n) {
        if (i == 0) {
            dp[i] = 0
            continue
        }

        if (i == 1) {
            dp[i] = Math.abs(hh[0]-hh[1])
            continue
        }

        val step1 = dp[i-1] + Math.abs(hh[i-1]-hh[i])
        val step2 = dp[i-2] + Math.abs(hh[i-2]-hh[i])
        dp[i] = Math.min(step1, step2)
    }

    println(dp[n-1])
}

Measured memory_bytes: 48792
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using NX = System.Int64;


public class Prog
{
    public static void Solve()
    {
        long N = NextLong();
        //Console.WriteLine(f(N));
        //return;
        if (N % 2 == 0)
        {
            long[] box = new long[100];
            box[0] = 10;
            box[1] = 50;
            for (int i = 2; i <= 25; i++) box[i] = box[i - 1] * 5;
            //for (int i = 2; i <= 25; i++) Console.WriteLine(i + " : " + box[i]);
            long ans = 0;
            for (int i = 25; i >= 0; i--)
            {
                ans += N / box[i];
            }
            Console.WriteLine(ans);

        }
        else Console.WriteLine(0);
    }

    public static long f(long n)
    {
        if (n < 2) { return 1; }
        else return n * f(n - 2);
    }

    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 0) return 1;
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        return;
    }
    public static long GCD(long a, long b)
    {
        if (a < b) GCD(b, a);
        long d = a % b;
        while (b != 0)
        {
            d = a % b;
            a = b;
            b = d;
        }
        return a;
    }
    public static long LCM(long a, long b)
    {
        return a / GCD(a, b) * b;
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 13268
int Keta(long long int n) {
  int A = 0;
  while (n > 0) {
    A ++;
    n /= 10;
  }
  return A;
}
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int N; 
cin >> N; 
int ans = 11; 
for (long long int i = 1; i * i <= N; ++i) {
 if(N % i == 0) ans = Keta(N / i); 
}
cout << ans << endl; 
}

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

class UnionFind {
	vector<int> data;
	vector<int> rank;
	int root(int a) {
		return data[a] < 0 ? a : data[a] = root(data[a]);
	}
public:
	UnionFind(int n) : data(n, -1), rank(n, 1) {}
	bool Find(int a, int b) {
		return root(a) == root(b);
	}
	void Union(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b) return;
		if (rank[a] < rank[b]) {
			data[a] += data[b];
			data[b] = a;
		}
		else {
			data[b] += data[a];
			data[a] = b;
			if (rank[a] == rank[b]) rank[b]++;
		}
	}
	int Size(int a) {
		return -data[root(a)];
	}
	int Rank(int a) {
		return rank[root(a)];
	}
};

int main()
{
	ll N, M;
	cin >> N >> M;
	UnionFind uf(N * 2), uf2(N + 1);
	for (int i = 0, u, v; i < M; i++) {
		cin >> u >> v; u--; v--;
		uf.Union(u, v + N);
		uf.Union(u + N, v);
		uf2.Union(u, v);
	}
	ll res = 0, c1 = 0, c2 = 0, c3 = 0, sum = 0;
	for (int i = 0; i < N; i++) {
		if (!uf2.Find(i, N)) {
			if (uf2.Size(i) == 1) {
				c1++;
				sum++;
			}
			else if (!uf.Find(i, i + N)) {
				c2++;
				sum += uf2.Size(i);
			}
			else {
				c3++;
				sum += uf2.Size(i);
			}
			uf2.Union(i, N);
		}
	}
	res = sum * c1 * 2 - c1 * c1 + c2 * c2 * 2 + c2 * c3 * 2 + c3 * c3;
	cout << res << endl;
	return 0;
}


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

int main(){
    int d,n;
    cin>>d>>n;
    if(n!=100){
        if(d==0){
            cout<<n;
        }else if(d==1){
            
            cout<<100*n;
        }else if(d==2){
            cout<<10000*n;
        }
    }else{
        if(d==0){
            cout<<101;
        }else if(d==1){
            cout<<10100;
        }else if(d==2){
            cout<<1010000;
        }
    }
    
}


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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    vector<int> M(N + 1, 0);
    int max = 0;
    for (int i = 0; i < N - 1; i++) {
        if (max < M[i]) {
            max = M[i];
        }
        if (H[i] >= H[i + 1]) {
            M[i + 1] = M[i] + 1;
        } else {
            M[i + 1] = 0;
        }
    }
    if (max < M[N - 1]) {
        max = M[N - 1];
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;
typedef pair<int,int> pii;

int dy[4] = {-1, 0, 1, 0};
int dx[4] = { 0, 1, 0,-1};
int die[7][4] = {
    {0,0,0,0},
    {2,3,5,4},
    {4,6,3,1},
    {6,5,1,2},
    {6,2,1,5},
    {6,4,1,3},
    {4,5,3,2}
};

int main(void){
    int n;
    while (cin>>n && n) {
        vector<vector<vector<int> > > g(40, vector<vector<int> >(40, vector<int>(60, -1)));
        map<int,int> mp;
        while (n--) {
            int a,b;
            cin >> a >> b;
            int x = 20, y = 20, z = 0;
            for (; z < 60; z++) if (g[x][y][z] == -1) break;
            bool f = true;
            while (f) {
                f = false;
                int s;
                for (s = 0; s < 4; s++) if (die[a][s] == b) break;
                vector<pii> vp;
                for (int i = 0; i < 4; i++) {
                    int pos = (s+i)%4;
                    if (die[a][pos] >= 4) vp.push_back(make_pair(die[a][pos], i)); // mp(die(4,5,6) , senw)
                }
                if (vp[0].first < vp[1].first) swap(vp[0], vp[1]);
                
                for (int i = 0; i < 2; i++) {
                    int me = vp[i].first, d = vp[i].second;
                    if (z == 0 || g[y+dy[d]][x+dx[d]][z-1] != -1) continue;
                    
                    f = true;
                    x += dx[d], y += dy[d];
                    while (z && g[y][x][z-1] == -1) z--;
                    if (d == 0) b = a;
                    if (d == 2) b = 7-a;
                    a = 7 - me;
                    break;
                }
                
                if (!f) {
                    g[y][x][z] = a;
                    mp[a]++;
                    if (z) mp[g[y][x][z-1]]--;
                }
            }
        }
        for (int i = 1; i < 7; i++) cout << mp[i] << (i==6? "\n": " ");
    }
}

Measured memory_bytes: 3412
//未通过 

#include <iostream>
#include <limits.h>

#define MAX 10000

using namespace std;

void counting_sort(int A[], int B[], int n);

int main()
{
	

	int n;
	cin >> n;
	
	int * A = new int [n];
	int * B = new int [n];
	
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	
	counting_sort(A, B, n);
	
	for (int i = 0; i < n; i++)
	{
		if (i) cout << ' ';
		cout << B[i];
	}
	cout << endl;
}




void counting_sort(int A[], int B[], int n)
{
	int C[MAX] = {0};
	
	for (int i = 0; i < n; i++) C[A[i]]++;
	
	for (int i = 1; i <= MAX; i++) C[i] += C[i-1];
	
	for (int i =0; i < n; i++)
	{
		B[--C[A[i]]] = A[i];
	}
}



Measured memory_bytes: 18744
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
//最大公約数
long long gcd_(long long a,long long b){
    if(a<b) swap(a,b);
    while(a%b!=0){
        swap(a,b);
        b = b%a;
    }
    return b;
}
int main(){
    ll a,b,c;
    cin >> a;
    ll ans  = 0;
    lrep(i,a) lrep(j,a) lrep(k,a) ans+=gcd_(i+1,gcd_(j+1,k+1));
    cout << ans << endl;
}


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

int main() {
    ll N,M,K;
    cin >>N >>M >>K;
    
    for(int i=0;i<=N;i++)for(int j=0;j<=M;j++){
        if(i*M +j *N-2*i*j == K){
            // cerr <<"i=" <<i <<"j=" <<j << endl;
            cout <<"Yes" << endl;
            return 0;
        }
    }
    cout <<"No"<< endl;

    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
string s;
signed main(){
    cin>>s;
    if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi")puts("Yes");
    else puts("No");
    return 0;
}

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

int dp[31][31],n,i,j,k,r;

int main()
{
	
	for(;scanf("%d",&n),n;)
	{
		r=0;
		memset(dp,0,sizeof(dp));
		dp[0][0]=dp[0][1]=dp[0][2]=1;
		for(i=1;i<n;i++)
			for(j=0;j<n;j++)
			{
				for(k=-1;k>=-3;k--)
					if(j+k>=0)
						dp[i][j]+=dp[i-1][j+k];
			}
		for(i=0;i<n;i++)
			r+=dp[i][n-1];
		printf("%d\n",r/3650+(r%3650?1:0));
	}
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 45;

ll f[N][N][N], ans;
int a[N][N];
char c[N];
int n;

ll dp(int l, int mid, int r) {
    if(l == r) return 1;
    if(l == mid || mid == r) return 0;
    if(~f[l][mid][r]) return f[l][mid][r];
    f[l][mid][r] = 0;
    for(register int i = l; i < mid; i++) {
        for(register int j = r; j > mid; j--) {
            if(a[i][j]) {
                for(register int x = i; x < mid; x++) {
                    for(register int y = j; y > mid; y--) {
                        f[l][mid][r] += dp(l, i, x) * dp(x + 1, mid, y - 1) * dp(y, j, r);
                    }
                }
            }
        }
    }
    return f[l][mid][r];
}

int main() {
    memset(f, -1, sizeof(f));
    read(n); n <<= 1;
    for(register int i = 1; i <= n; i++) {
        scanf("%s", c + 1);
        for(register int j = 1; j <= n; j++) {
            a[i][j] = c[j] - '0';
        }
    }
    for(register int i = 2; i <= n; i++) if(a[1][i]) ans += dp(2, i, n);
    print(ans, '\n');
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define MAX_H 55
#define MAX_W 55

int W, H;
int c[MAX_H][MAX_W];

void dfs(int y, int x){

    c[y][x] = 0;
    for(int i=-1; i<=1; i++){
        for(int j=-1; j<=1; j++){

            int ny = y + i;
            int nx = x + j;
            if(ny >= 0 && ny < H && nx >= 0 && nx < W){
                if(c[ny][nx] == 1){
                    dfs(ny, nx);
                }
            }
        }
    }
}
int main() {
    
    while(1){
        cin >> W >> H;
        if(W == 0 && H == 0) break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cin >> c[i][j];
            }
        }

        int ans = 0;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(c[i][j] == 1){
                    dfs(i, j);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3284
import bisect

N = int(input())
A = []

a = int(input())

val = [-a]
length = 1

for _ in range(N - 1) :
    a = int(input())
    a *= -1
    i = 0

    index = bisect.bisect_right(val, a)
    if index >= length :
        val.append(a)
        length += 1
    else :
        val[index] = a

print(length)

Measured memory_bytes: 7068
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
/* Ordered Set Implementaton:

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;

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

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    ll x;
    cin >> x;
    ll res = 0;
    res += ((x / 500) * 1000);
    x = x % 500;
    res += ((x / 5) * 5);
    cout << res << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        switch (s) {
            case "SUN":
                System.out.println(7);
                break;
            case "MON":
                System.out.println(6);
                break;
            case "TUE":
                System.out.println(5);
                break;
            case "WED":
                System.out.println(4);
                break;
            case "THU":
                System.out.println(3);
                break;
            case "FRI":
                System.out.println(2);
                break;
            case "SAT":
                System.out.println(1);
                break;
            default:
                System.out.println(0);
                break;
        }

    }
}

Measured memory_bytes: 35532
#include <bits/stdc++.h>
     
    using namespace std;
     
    void __print(int x) {
        cerr << x;
    }
    void __print(long x) {
       cerr << x;
    }
    void __print(long long x) {
       cerr << x;
    }
    void __print(unsigned x) {
        cerr << x;
    }
    void __print(unsigned long x) {
        cerr << x;
    }
    void __print(unsigned long long x) {
        cerr << x;
    }
    void __print(float x) {
        cerr << x;
    }
    void __print(double x) {
        cerr << x;
    }
    void __print(long double x) {
        cerr << x;
    }
    void __print(char x) {
        cerr << '\'' << x << '\'';
    }
    void __print(const char *x) {
        cerr << '\"' << x << '\"';
    }
    void __print(const string &x) {
        cerr << '\"' << x << '\"';
    }
    void __print(bool x) {
        cerr << (x ? "true" : "false");
    }
     
    template<typename T, typename V>
    void __print(const pair<T, V> &x) {
        cerr << '{'; 
        __print(x.first); cerr << ','; 
       __print(x.second); cerr << '}';
    }
    template<typename T>
    void __print(const T &x) {
        int f = 0; cerr << '{'; 
        for (auto &i: x) 
            cerr << (f++ ? "," : ""), __print(i); 
        cerr << "}";
    }
    void _print() {
        cerr << "]\n";
    }
    template <typename T, typename... V>
    void _print(T t, V... v) {
        __print(t); 
        if (sizeof...(v)) 
            cerr << ", "; _print(v...);
    }
     
    #ifndef ONLINE_JUDGE
    #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
    #else
    #define debug(x...)
    #endif
     
    #define forn(i, n) for(int i = 0; i < n; i++)
    #define forw(i, w) for(int i = n; i >= 0; i--)
    #define dforn(i, a, b) for(int i = a; i < b; i++)
    #define dforw(i, b, a) for(int i = b; i >= a; i--)
    #define read(v) for(auto &i:v) cin >> i;
    #define all(v) v.begin(), v.end()
     
    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<double> vd;
    typedef pair<int, int> pii;
     
    int n, k;
    vi arr, dp;
     
    int main(){
    	ios_base::sync_with_stdio(0);
    	cout.tie(0);cin.tie(0);
    	
    	cin >> n;
    	k=2;
    	arr.assign(n, 0);
    	dp.assign(n, 999999999);
    	dp[0] = 0;
    	read(arr);
     
    	forn(i, n)
    		for(int j = i+1; j < n && j < i+k+1; j++)
    			dp[j] = min(dp[j], dp[i]+abs(arr[j]-arr[i]));
     
    	cout << dp[n-1] << endl;	
    	return 0;
    }

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

#define _ONE 10001
#define _A 100
#define _B 200
#define _C 300
#define _D 400
#define _LOG 500
#define _BUF1 1001
#define _BUF2 1002
#define _BUF_LOG 2000
#define _BUF 10003
#define _ANS 20000
#define _TEMP 25000
#define _FLAG 30000

vector<string> output;
void COUT(char c, ll s1, ll s2, ll d) {
	string s; s.push_back(c);
	s += " " + to_string(s1) + " " + to_string(s2) + " " + to_string(d);
	output.push_back(s);
}
void _generate(ll src, ll k) {
	for (ll i = 0; i < k; i++) {
		COUT('+', src, src, src);
	}
}

void _and(ll s1, ll s2, ll d) {
	COUT('+', s1, s2, d);
	COUT('<', _ONE, d, d);
}
void _digit(ll src, ll dest) {
	COUT('<', 0, 0, _BUF1);
	COUT('<', 0, 0, _BUF2);

	for (ll i = 60; i >= 0; i--) {
		ll j = dest + i;
		COUT('+', 2, _LOG + i, _BUF_LOG);
		COUT('+', _BUF2, _BUF_LOG, _BUF1);
		COUT('<', _BUF1, src, _BUF_LOG);
		COUT('<', 2, _BUF_LOG, j);
		_generate(_BUF_LOG, i);
		COUT('+', _BUF2, _BUF_LOG, _BUF2);
	}
}

int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(0);
	output.clear();
	
	COUT('<', 2, 0, _TEMP);
	COUT('<', 2, 1, _TEMP + 1);
	COUT('+', _TEMP + 1, _TEMP, _TEMP);// _TEMP : 正数の個数の和
	COUT('<', _TEMP + 2, _TEMP, _TEMP + 2);// _TEMP+2 : 個数の和が1以上かどうか
	COUT('<', _TEMP + 2, _TEMP, _FLAG);// _FLAG : 個数の和が2以上かどうか

	COUT('<', 2, 0, _ONE);
	COUT('+', 0, _ONE, 0);
	COUT('+', 1, _ONE, 1);
	COUT('<', 2, _ONE, _LOG);
	for (ll i = 1; i <= 60; i++) {
		COUT('+', _LOG + i - 1, _LOG + i - 1, _LOG + i);
	}

	_digit(0, _A);
	_digit(1, _B);

	for (ll i = 0; i <= 30; i++) {
		for (ll j = 0; j <= 30; j++) {
			ll s1 = _A + i;
			ll s2 = _B + j;
			ll d = _C + i + j;
			_and(s1, s2, _BUF);
			COUT('+', d, _BUF, d);
		}
	}
	
	for (ll i = 0; i <= 60; i++) {
		ll d = _C + i;

		COUT('<', 0, 0, _BUF);
		for (ll j = 0; j <= 30; j++) {
			COUT('<', _BUF, d, _BUF + 1);
			_generate(_BUF + 1, i);
			COUT('+', _ANS, _BUF + 1, _ANS);
			COUT('+', _BUF, _ONE, _BUF);
		}
	}

	COUT('+', _ONE, _ANS, _ANS);
	_digit(_ANS, _D);
	COUT('<', _ANS, _ANS, _ANS);

	for (ll i = 60; i >= 0; i--) {
		_and(_FLAG, _D + i, _ANS + 1);
		_generate(_ANS + 1, i);
		COUT('+', _ANS, _ANS + 1, _ANS);
	}

	COUT('+', 2, _ANS, 2);

	cout << output.size() << endl;
	for (ll i = 0; i < (ll)output.size(); i++) {
		cout << output[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 9256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    int N, A, B;
    cin >> N >> A >> B;

    if (N * A < B) cout << N * A << endl;
    else cout << B << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , K;
  cin >> N >> K;
  vector<int> price(N);
  for(int i=0;i<N;i++){
    int a;
    cin >>a;
    price[i]=a;
  }
  sort(price.begin() , price.end() );
  int ans=0;
  for(int i=0; i<K; i++)
    ans += price[i];
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,char> pic;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int h,w;
    cin>>h>>w;
    
    
    map<char,int> hist;
    rep(i,h){
        string s;
        cin>>s;
        rep(j,s.size()){
            hist[s[j]]++;
        }
    }
    
    priority_queue<pic> pq;
    for(auto e:hist){
        pq.push(pic(e.second,e.first));
    }
    
    int n = (h/2)*2;
    int m = (w/2)*2;
    
    assert( n*m%4==0 );
    rep(i,n*m/4){
        pic q = pq.top();
        pq.pop();
        if(q.first<4){
            cout<<"No"<<endl;
            return 0;
        }
        q.first-=4;
        pq.push(q);
    }
    
    
    if(h%2 && w%2){
        rep(i,(h+w-2)/2){
            pic q = pq.top();
            pq.pop();
            if(q.first<2){
                cout<<"No"<<endl;
                return 0;
            }
            q.first-=2;
            pq.push(q);
        }
    }else if(h%2 && !(w%2)){
        rep(i,w/2){
            pic q = pq.top();
            pq.pop();
            if(q.first<2){
                cout<<"No"<<endl;
                return 0;
            }
            q.first-=2;
            pq.push(q);
        }
    }else if(!(h%2)&&w%2){
        rep(i,h/2){
            pic q = pq.top();
            pq.pop();
            if(q.first<2){
                cout<<"No"<<endl;
                return 0;
            }
            q.first-=2;
            pq.push(q);
        }
    }
    
    rep(i,( (h%2) * (w%2) )){
        pic q = pq.top();
        pq.pop();
        if(q.first<1){
            cout<<"No"<<endl;
            return 0;
        }
        q.first -= 1;
        pq.push(q);
    }
    
    cout<<"Yes"<<endl;
    
}


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

// ↑　→　↓　←

long long di[4] = {-1, 0, 1, 0};
long long dj[4] = {0, 1, 0, -1};

int main(){

    map<char, long long> direc;
    char Indirec[4] = {'N', 'E', 'S', 'W'};
    direc['N'] = 0;
    direc['E'] = 1;    
    direc['S'] = 2;
    direc['W'] = 3;
    
    

    while(1){
        long long h, w;
        long long l;
        cin >> h >> w >> l;
        if(!h) break;
        long long si, sj, sh;
        vector<vector<bool> > table(h + 2, vector<bool> (w + 2, false));
        for(long long i = 1; i <= h; i++){
            for(long long j = 1; j <= w; j++){
                char c; cin >> c;
                if(c == '.'){
                    table[i][j] = true;
                }else if(c != '#'){
                    table[i][j] = true;
                    si = i;
                    sj = j;
                    sh = direc[c];
                }
            }
        }


        vector<vector<vector<long long> > > dp(h + 2, vector<vector<long long> > (w + 2, vector<long long> (4, -1LL)));
        

        dp[si][sj][sh] = 0LL;
        //cout << si << " " << sj << " " << sh << " :" << 0 << endl;
        long long cnt = 1LL;
        long long now_i = si;
        long long now_j = sj;
        long long now_h = sh;
        long long T;
        long long num;
        for(;;){

            
            now_i += di[now_h];
            now_j += dj[now_h];

            while(!table[now_i][now_j]){
                now_i -= di[now_h];
                now_j -= dj[now_h];
                now_h = (now_h + 1) % 4;
                now_i += di[now_h];
                now_j += dj[now_h];
            }

            //cout << now_i << " " << now_j << " " << now_h << " :" << cnt << endl;            
            if(dp[now_i][now_j][now_h] == -1){
                
                dp[now_i][now_j][now_h] = cnt;
                cnt++;
            }else{
                T = cnt - dp[now_i][now_j][now_h];
                num = dp[now_i][now_j][now_h];
                break;
            }

        }
        //cout << cnt << endl;
        //cout << l << " " << num << " " << T << endl;
        
        if(l >= cnt) l = (l - num) % T + num;

        //cout << l << endl;
        for(long long i = 1; i <= h; i++){
            for(long long j = 1; j <= w; j++){
                for(long long h = 0; h < 4; h++){
                    if(dp[i][j][h] == l){
                        cout << i <<  " " << j << " " << Indirec[h] << endl;
                        i += h;
                        j += w;
                        h += 4;
                    }
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3804
S = input()
list = [chr(i) for i in range(97, 97 + 26)]
x = 0
for i in range(26):
    if list[i] in S:
        x += 1
if x == 26:
    print('None')
    exit()
for i in range(26):
    if list[i] not in S:
        print(list[i])
        exit()

Measured memory_bytes: 9024