akhauriyash/Code-Regression huggingface dataset:
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    ll x[110],y[110],h[110];
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> x[i]>>y[i]>>h[i];
    }
    
    // std::cout << min_xv<<"->"<<max_xv<<" "<<min_yv<<"->"<<max_yv << std::endl;
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            ll now_h = -1;
            ll h_max = 10000000000;
            ll ok = true;
            for (int k = 0; k < n; k++) {
                if(h[k] == 0){
                    h_max = min(h_max,(ll)abs(i-x[k]) + (ll)abs(j-y[k]));
                }else{
                    if(now_h == -1){
                        now_h = h[k] + (ll)abs(i-x[k]) + (ll)abs(j-y[k]);
                    }else{
                        // std::cout << now_h << std::endl;
                        // std::cout << now_h<<" noww "<< h[k] + (ll)abs(i-x[k]) + (ll)abs(j-y[k]) << std::endl;
                        if( now_h != h[k] + (ll)abs(i-x[k]) + (ll)abs(j-y[k]) ){
                            ok = false;
                            break;
                        }
                    }
                }
            }
            if( now_h > h_max ){
                ok = false;
            }
            if(ok){
                std::cout << i <<" "<<j <<" "<<now_h<< std::endl;
                return 0;
            }
        }
    }
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int R = 46;
int vis[R][100001];

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

    int K;
    cin >> K;
    queue<pii> Q;
    Q.push(mp(0, 0));
    while (sz(Q)) {
        auto p = Q.front();
        Q.pop();
        if (vis[p.first][p.second]++)continue;
        rep(i, 10) {
            pii q = p;
            q.first = q.first + i;
            q.second = (q.second * 10 + i) % K;
            if (q.first < R && !vis[q.first][q.second]) {
                Q.push(q);
            }
        }
    }
    FOR(i, 1, R) {
        if (vis[i][0]) {
            cout << i << endl;
            break;
        }
    }
}


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

bool ip(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
	int x;
	cin >> x;
	while(1){
		if(ip(x)){
			cout << x << endl;
			return 0;
		}
		x++;
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
 
 
public class Main{
	
	public int x;
	public int y;

 
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd(long a, long b) {
		if (b == 0) {
			return a;			
		}
		return gcd(b, a % b);
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}
 
 
 
	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
 
 
	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}
 
 
	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
 
 
	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	
	 char[] c=sc.next().toCharArray();
	  long result = 0;
	 int bnum=0;
	 for(int i=0;i<c.length;i++) {
		 if(c[i]=='B') {
			 bnum++;
		 }else {
			 result+=bnum;
		 }
	 }
	 
	 System.out.println(result);
	 
	 
	 
			 
	 
	 
	
	 

	 
	
	 
    
}
}

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

public class Main {

  private static final int LEN_INDEX = 10;

  private static void solve() {
    int n = nextInt();
    int m = nextInt();

    int[] d = new int[10];
    int[] c = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    for (int i = 1; i <= m; i++) {
      int cur = nextInt();
      d[cur] = c[cur];
    }

    int[][] dp = new int[n + 10][11];

    for (int i = 1; i <= n; i++) {
      dp[i][10] = -1;
    }

    int[] ans = get(n, d, dp);

    StringBuilder sb = new StringBuilder();

    for (int i = 9; i >= 1; i--) {
      for (int j = 0; j < ans[i]; j++) {
        sb.append(i);
      }
    }

    System.out.println(sb.toString());
  }

  private static int[] get(int n, int[] d, int[][] dp) {
    if (dp[n][LEN_INDEX] != -1) {
      return dp[n];
    }

    int[] ans = new int[11];
    for (int i = 1; i < 10; i++) {
      if (d[i] != 0 && n >= d[i]) {
        int[] prev = Arrays.copyOf(get(n - d[i], d, dp), 11);
        if (n - d[i] != 0 && prev[LEN_INDEX] == 0) continue;

        prev[i]++;
        prev[LEN_INDEX]++;

        boolean greater = false;
        for (int j = 9; j >= 1; j--) {
          if (prev[j] != ans[j]) {
            greater = ans[j] > prev[j];
            break;
          }
        }

        if (prev[LEN_INDEX] > ans[LEN_INDEX] || (prev[LEN_INDEX] == ans[LEN_INDEX] && !greater)) {
          ans = prev;
        }
      }
    }

    return dp[n] = ans;
  }

  private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

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

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

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

  public static void main(String[] args) {
    run();
  }
}

Measured memory_bytes: 27780
def main():
    import sys
    input=sys.stdin.readline
    s=input()
    alpha="abcdefghijklmnopqrstuvwxyz"
    l=len(s)
    alpha2={j:i for i,j in enumerate(alpha)}
    memo=[[0]*26 for _ in range(l,-1,-1)]
    for i in range(26):
        memo[l][i]=l+1
    for x,y in alpha2.items():
        for i in range(l-1,-1,-1):
            if s[i]==x:
                memo[i][y]=i+1
            else:
                memo[i][y]=memo[i+1][y]
    
    search=[1]*(l+2)
    search[l+1]=0
    for i in range(l-1,-1,-1):
        m=max([memo[i][j] for j in range(26)])
        if m!=l+1:
            search[i]=search[m]+1
    
    n,seq=0,0
    ans_len=search[0]
    ans=""
    temp=0
    for i in range(ans_len):
        for j in range(26):
            n=memo[temp][j]
            seq=search[n]+i
            if seq+1==ans_len:
                ans+=alpha[j]
                temp=memo[temp][j]
                break
    print(ans)
if __name__=='__main__':
    main()

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

vector<int> fr[100000];
vector<int> bl[100000];

int main(void){
    //友達候補となり得るのは木上で連結であるものだけ
    //uf木のサイズから友達の数を除くと,友達候補またはブロック関係のものが残る
    //uf木で同じものに属していてブロック関係にある人を除けばよい
    //ブロック関係は高々K<=10^5個なので間に合いそう
    int N, M, K; cin >> N >> M >> K;
    UnionFind uf(N);
    rep(i, M){
        int a, b; cin >> a >> b;
        a--; b--;
        fr[a].push_back(b);
        fr[b].push_back(a);
        uf.merge(a, b);
    }
    rep(i, K){
        int a, b; cin >> a >> b;
        a--; b--;
        bl[a].push_back(b);
        bl[b].push_back(a);
    }
    rep(i, N){
        int ans = uf.size(i) - fr[i].size() - 1; //自分自身を引くのを忘れない
        rep(j, bl[i].size()){
            if(uf.issame(i, bl[i][j])) ans--;
        }
        if(i == N-1) cout << ans << endl;
        else cout << ans << " ";
    }
    return 0;
}

Measured memory_bytes: 12152
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int prize =-1;
		for (int i=1;i<20000;i++) {
			if((int)(i*0.08)==a&& (int)(i*0.1)==b) {
				prize = i;
				break;
			}
		}
		System.out.println(prize);

	}
}

Measured memory_bytes: 23124
#include <iostream>     
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#define LL long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n,m,k;
int a[510][510];
int main()
{
	cin >>n>>m>>k;
	for (int i=0;i<m;i++)
	{
		int x,y;
		cin >>x>>y;
		x--,y--;
		a[x][y]++;
	}
	for (int i=0;i<n;i++)
	{
		for (int j=1;j<n;j++)
		    a[i][j]+=a[i][j-1];
	}
	/*cout <<"\n";
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<n;j++)
		{
			cout <<a[i][j]<<" ";
		}
		cout <<"\n";
	}
	cout <<"\n";*/
	for (int i=0;i<k;i++)
	{
		int x,y;
		cin >>x>>y;
		x--,y--;
		int r=0;
		for (int j=x;j<n;j++) r+=a[j][y];
		cout <<r<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 200100;

typedef long double ld;
const ld inf = 1e18;

struct cht {
	struct line {
		ll k, b; ld x;
		ll val; bool isquery;

		line(ll _k = 0, ll _b = 0) :
			k(_k), b(_b), x(-inf), val(0), isquery(false) {}

		ll eval(ll x) const { return k * x + b; }
		bool parallel(const line& l) const {return k == l.k; }
		ld intersection(const line& l) const {
			if(parallel(l)) return inf;
			return (1.0*l.b - b) / (1.0 * k - l.k);
		}

		bool operator <(const line& l) const {
			if(l.isquery) return x < l.val;
			else return k < l.k;
		}
	};

	set<line> hull;
	typedef set<line>::iterator iter;

	bool cPrev(iter it) { return it != hull.begin(); }
	bool cNext(iter it) { return it != hull.end() && next(it) != hull.end(); }

	bool bad(const line &l1, const line &l2, const line &l3) {
		return l1.intersection(l3) <= l1.intersection(l2);
	}
	bool bad(iter it) {
		return cPrev(it) && cNext(it) && bad(*prev(it), *it, *next(it));
	}	

	iter update(iter it) {
		if(!cPrev(it)) return it;

		ld x = it -> intersection(*prev(it));
		line tmp(*it); tmp.x = x;

		it = hull.erase(it);
		return hull.insert(it, tmp);
	}

	void addLine(ll k, ll b) {
		line l(k, b);
		iter it = hull.lower_bound(l);
		if(it != hull.end() && l.parallel(*it)) {
			if(it->b < b) it = hull.erase(it);
			else return;
		}

		it = hull.insert(it, l);
		if(bad(it)) return (void) hull.erase(it);

		while(cPrev(it) && bad(prev(it))) hull.erase(prev(it));
		while(cNext(it) && bad(next(it))) hull.erase(next(it));

		it = update(it);
		if(cPrev(it)) update(prev(it));
		if(cNext(it)) update(next(it));
	}

	ll query(ll x) {
		if(hull.empty()) return -inf;

		line tmp;
		tmp.val = x; tmp.isquery = true;
		iter it = --hull.lower_bound(tmp);
		return it->eval(x);
	}
}ds;

ll n, c;
ll h[maxn];
ll dp[maxn];

int main() {
	cin>>n>>c;
	for(int i=1;i<=n;i++) {
		cin>>h[i];
	}

	dp[1] = 0LL;
	ds.addLine(2*h[1], -(h[1]*h[1] + dp[1]));

	// dp[i] = min(dp[j] + (h[i] - h[j])^2 + C)
	// dp[i] = min(dp[j] + h[i]^2 - 2*h[i]*2[j] + h[j]^2 + C)
	// slope: -2*h[j], extra = h[j]^2 + dp[j] 

	for(int i=2;i<=n;i++) {
		ll curr = -ds.query(h[i]);
		dp[i] = curr + c + h[i] * h[i];

		ds.addLine(2*h[i], -(h[i]*h[i] + dp[i]));
	}

	cout<<dp[n]<<"\n";
}

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

using namespace std;
const int N=100000;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL);
	int n,i,j,k,dp[N],a[N];
	cin>>n>>k;
	for(i=0;i<n;++i) cin>>a[i];
	dp[0]=0;
	for(i=1;i<=k;++i){
		dp[i]=abs(a[i]-a[0]);
	}
	for(i=k+1;i<n;++i){
		dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
		for(j=2;j<=k;++j) dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	}
	cout<<dp[n-1];
}

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

using namespace std;

#define ll long long

std::vector< ll > A, F, C;

bool ok(ll m, ll k){

    for(int i = 0; i < A.size(); i++) {

        if(-F[i]*A[i] <= m) continue;

        ll to = m / (-F[i]);
        k -= (A[i] - to);
        if(k < 0) return 0;
    }
    return 1;
}

int main() {

    int n;
    ll x, k;

    cin >> n >> k;
    for(int i = 0;i < n; i++){
        cin >> x; A.push_back(x);
    }
    for(int i = 0;i < n; i++){
        cin >> x; F.push_back(-x);
    }
    sort(A.begin(), A.end());
    sort(F.begin(), F.end());

    long long lo = 0, hi = (ll)1e12;

    while(hi - lo > 2) {

        ll m = lo + hi >> 1;
        if(ok(m, k ))hi = m;
        else lo = m;
    }
    for(ll i = lo;i <= hi;i++){
        if(ok(i, k)){
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 4848
#include<stdio.h>
int main()
{
	int top[3]={0};
	for(int i=0;i<10;i++)
	{
		int temp;
		scanf("%d",&temp);
		if(temp>top[0])
		{
			top[2]=top[1];
			top[1]=top[0];
			top[0]=temp;
		}
		else if(temp>top[1])
		{
			top[2]=top[1];
			top[1]=temp;
		}
		else if(temp>top[2])
		{
			top[2]=temp;
		}
	}
	printf("%d\n%d\n%d\n",top[0],top[1],top[2]);
}

Measured memory_bytes: 0
from heapq import heappop, heapify


N, K, *V = map(int, open(0).read().split())

# i: 操作回数
# j: 取り出す個数
# k: 左から取り出す範囲 [0, k)
ans = 0
for i in range(K + 1):
    for j in range(min(N + 1, i + 1)):
        for k in range(j + 1):
            right = N - j + k
            tmp = V[:k] + V[right:]

            put_out_cnt = i - j
            heapify(tmp)
            while tmp and put_out_cnt > 0:
                heappop(tmp)
                put_out_cnt -= 1
            ans = max(ans, sum(tmp))
print(ans)


Measured memory_bytes: 9148
A, B, Q = map(int, input().split())

INF=1e50

s=sorted([int(input())for i in range(A)])
t = sorted([int(input())for i in range(B)])
X=[int(input())for i in range(Q)]

rs = list(map(lambda x: -x, s[::-1]))
rt = list(map(lambda x: -x, t[::-1]))

s+=[INF]
t+=[INF]
rs+=[INF]
rt+=[INF]

import bisect

for x in X:
    se = s[bisect.bisect_left(s, x)] - x
    sw = rs[bisect.bisect_left(rs, -x)] + x
    te = t[bisect.bisect_left(t, x)] - x
    tw = rt[bisect.bisect_left(rt, -x)] + x
    kouho = []
    kouho.append(max(se,te))
    kouho.append(max(sw,tw))
    kouho.append(sw*2+te)
    kouho.append(se*2+tw)
    kouho.append(tw*2+se)
    kouho.append(te*2+sw)

    print(min(kouho))
    # print(bisect.bisect_left(s, x))
    # print(s[bisect.bisect_left(s, x)])


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< int, int > P;
typedef pair< int, P > PP;

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

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

    int n, m;
	cin >> n >> m;
	int d[n];
	REP(i, n) cin >> d[i];
	int c[m];
	REP(i, m) cin >> c[i];
	int dp[n + 1];
	REP(i, n) dp[i + 1] = INF;
	dp[0] = 0;
    REP(i, m) {
		for(int j = n; j > 0; j--) {
			dp[j] = min(dp[j], dp[j - 1] + c[i] * d[j - 1]);
		}
	}
	cout << dp[n] << endl;

    return 0;
}





Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  sort(a,a+n,greater<ll>());
  ll ans=0;
  ll c[n];
  mem(c);
  c[0]=1;
  ll k=0;
  REP(i,1,n) {
    ans+=a[k];
    c[k]++;
    if(c[k]>=2) k++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 6772
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 1000000007;//998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main() {
   int n;cin>>n;
   mint eight=8,nine=9,ten=10;
   mint ans=ten.pow(n)-mint(2)*nine.pow(n)+eight.pow(n);
   cout<<ans<<endl;
}

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

	int ans;
	if(a>=k) ans=k;
	else if(a+b>=k) ans=a;
	else ans=a-(k-(a+b)); 
	cout << ans << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define loop(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main()
{
  int n;
  cin >> n;
  int a[n];
  loop(i,n)  cin >> a[i];
  int ans=1000010001;
  for(int p=1;p<=100;p++)
  {
    int now=0;
   loop(i,n) now+=(a[i]-p)*(a[i]-p);
    ans=min(ans,now);
  }
  cout<<ans;
  return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    
    st s ;
    cin >> s ;
    ll len = s . size () , res = 1e9 ;
    vector <ll> m1 ;
    loop( len - 2) {
        st ss ;
        ss = s . substr (i , 3) ;
        ll t = stoi(ss);
        t = abs(t - 753) ;
        res = min(res , t) ;
    }
    cout << res << endl ;
   
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h, w;
	cin >> h >> w;
	vector<vector<char>> vec(h, vector<char>(w));
	REP(i, h){
		REP(j, w){
			cin >> vec[i][j];
		}
	}
	REP(i, h){
		REP(j, w){
			if (vec[i][j]=='#'){
				if ((i!=0) && (vec[i-1][j]=='#')){
					continue;
				} else if ((i!=h-1) && (vec[i+1][j]=='#')){
					continue;
				} else if ((j!=0) && (vec[i][j-1]=='#')){
					continue;
				} else if ((j!=w-1) && (vec[i][j+1]=='#')){
					continue;
				} else {cout << "No" << endl; return 0;}
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)
#include <climits>

using namespace std;
#define ll long long
#define MOD 1000000007

bool condition(int j, int k, int l, int m) {
  if(j == 0 && k == 2 && l == 1) // AGCx
    return false;
  if(j == 0 && k == 1 && l == 2) // ACGx
    return false;
  if(j == 2 && k == 0 && l == 1) // GACx
    return false;
  if(j == 0 && l == 2 && m == 1) // AxGC
    return false;
  if(k == 0 && l == 2 && m == 1) // xAGC
    return false;
  if(k == 2 && l == 0 && m == 1) // xGAC
    return false;
  if(k == 0 && l == 1 && m == 2) // xACG
    return false;
  if(j == 0 && k == 2 && m == 1) // AGxC
    return false;
  return true;
}

int main(){
  int N;
  cin >> N;
  vector<vector<ll> > dp(4*4*4, vector<ll>(N+1, 0));
  char C[] = {'A', 'C', 'G', 'T'};
  for(int j=0; j<4; j++) {
    for(int k=0; k<4; k++) {
      for(int l=0; l<4; l++) {
	if(condition(j, k, l, INT_MAX))
	  dp[(j<<4)+(k<<2)+l][3] = 1;
      }
    }
  }
  for(int i=4; i<=N; i++) {
    for(int j=0; j<4; j++) {
      for(int k=0; k<4; k++) {
	for(int l=0; l<4; l++) {
	  for(int m=0; m<4; m++) {
	    if(condition(j, k, l, m)) {
	      dp[(k<<4)+(l<<2)+m][i] += dp[(j<<4)+(k<<2)+l][i-1];
	      dp[(k<<4)+(l<<2)+m][i] %= MOD;
	    }
	  }
	}
      }
    }
  }
  ll ans = 0;
  for(int i=0; i<4*4*4; i++) {
    ans += dp[i][N];
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
x, n = map(int,input().split())

try:
  p = list(map(int,input().split()))
except EOFError:
  p = []

ab=10**18
ans=ab
for i in range(101):
  if not (x - i in p):
    print(x-i)
    break
  if not (x + i in p):
    print(x+i)
    break

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

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void) {
  ll a, b;
  cin >> a >> b;
  ll ans = lcm(a, b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			string s = Console.ReadLine();
			int count = 0;
			for (int i = 0; i < 3; ++i) {
				if (s[i] == '1') {
					++count;
				}
			}

			Console.WriteLine($"{count}");
			Console.ReadKey();
		}


	}
}

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

int main()
{
    int n,i,j,k;
    cin>>n;
    int a[n],cnt=0,sum=0,mx=INT_MAX;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<n;i++)
    {
        if(a[i]==a[i-1])
            cnt++;
        else
            break;
    }
    if(cnt==n)
    {
        cout<<0<<endl;
        return 0;
    }
    sort(a,a+n);
    int low=a[0],high=a[n-1];
    for(i=low;i<=high;i++)
    {
        sum=0;
        for(j=0;j<n;j++)
        {
            sum+=((a[j]-i)*(a[j]-i));
        }
        mx=min(sum,mx);
    }
    cout<<mx<<endl;
}


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

using namespace std;

int main(){
    int n;
    int64_t m;
    cin >> n >> m;
    vector<int64_t> A(n);
    copy_n(istream_iterator<int64_t>(cin), n, A.begin());

    sort(A.begin(), A.end(), greater<int64_t>());

    auto check = [&](auto k){
        int64_t res = 0;
        int r = n - 1;
        for (int i = 0; i < n; i++){
            while (r >= 0 and A[i] + A[r] < k) r--;
            res += r + 1;
        }
        return res >= m;
    };

    auto b_search = [](auto ok, auto ng, auto check){
        while (abs(ok - ng) > 1){
            auto mid = (ok + ng) / 2;
            if (check(mid))
                ok = mid;
            else 
                ng = mid;
        }
        return ok;
    };

    int64_t k = b_search(0L, (int64_t)1e18, check);

    vector<int64_t> acc(n + 1);
    for (int i = 0; i < n; i++)
        acc[i + 1] = acc[i] + A[i];

    int64_t ans = 0;
    int64_t cnt = 0;
    for (int i = 0; i < n; i++){
        int64_t j = b_search(-1, n, [&](auto j){return A[i] + A[j] > k;}) + 1;
        cnt += j;
        ans += acc[j] + A[i] * j;
    }

    cout << ans + (m - cnt) * k << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){

	int i, j, k, N, *W, min=0, left, right, kari;	
	
	scanf("%d", &N);

	
	W = (int *)malloc(N * sizeof(int));
	for (i = 0; i < N; i++)
		scanf("%d", &W[i]);

	for (i = 0; i < N; i++)
		min += W[i];

	for (i = 0; i < N; i++){
		left = right = 0;
		for (j = 0; j < i; j++){
			left += W[j];
		}

		for (j = i; j < N; j++){
			right += W[j];
		}
		kari = abs(left - right);
		if (min > kari)
			min = kari;
	}
	printf("%d\n", min);

  return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef map<string, int> msi;
typedef pair<int, int> PII;

int ans = 0;
vector<vector<int>> v;
vector<int> h;

void func(int n){
    rep(i, n){
        int temp = h.at(i);
        bool flag = true;
        for(auto x : v.at(i)){
            if(temp <= h.at(x)) flag = false;
        }
        if(flag) ans++;
    }
}

int main() {
    int n, m; cin >> n >> m;
    h = vector<int>(n);
    rep(i, n){
        int x; cin >> x;
        h.at(i) = x;
    }
    v.resize(n);
    rep(i, m){
        int x, y; cin >> x >> y;x--;y--;
        v.at(x).push_back(y);
        v.at(y).push_back(x);

    }
    func(n);
    cout << ans << endl;
    return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= i201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  void solve() {
    set<int> a;
    for (int i = 0; i < 3; ++i) {
      a.insert(i);
    }
    for (int i = 0; i < 2; ++i) {
      int tmp;
      cin >> tmp;
      a.erase(--tmp);
    }
    cout << *a.begin() + 1 << endl;
  }
};
class Solver2 {
 public:
  int n, m;
  Solver2(LL n, LL m) : n(n), m(m){};

  void solve() {
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);

  Problem::Solver sol;
  sol.solve();
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(register int i=x;i<y;i++)
#define rept(i,x,y) for(register int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
const int maxn=3005;
const int mod=998244353;

ll dp[maxn][maxn];
ll a[maxn];
ll qpow(ll a,ll b)
{
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1) ans=ans*a%mod;
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll ans=0;
	int n,s;
	cin>>n>>s;
	rept(i,1,n) cin>>a[i];
//	for(int i=n;i>=1;i--) cin>>a[i];
	dp[0][0]=1;
	rept(i,1,n)
	{
		rept(j,0,3000) if(j>=a[i]) dp[i][j]=(dp[i-1][j]*2+dp[i-1][j-a[i]])%mod;
		else dp[i][j]=dp[i-1][j]*2%mod;
	}
	cout<<dp[n][s]<<"\n";
	//cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 74076
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())

m = map(int,read().split())
ST = zip(m,m)
 
edge_out = [[] for i in range(N)] #edge_out[i]はiから出ている道
edge_in = [[] for i in range(N + 1)] # edge_in[i]はiに行く道
 
for s,t in ST:
    edge_out[s].append(t)
    edge_in[t].append(s)
    

edge_sum = [len(edge_out[i]) for i in range(N)] # edge_sum[i] = iから出ている道の本数

dp = [0.0]*(N + 1) # dp[i]はiからNへの距離の期待値
dp[N - 1] = 1.0
# 道を塞がない場合
for i in range(N - 2, 0, - 1):
    dp[i] = 1 + sum(dp[j] for j in edge_out[i])/edge_sum[i]
    
p_to_i = [0]*(N + 1) # p_to_i[i]は1から各iへ到達する確率
p_to_i[1] = 1
for i in range(2, N + 1):
    p_to_i[i] = sum(p_to_i[j]/edge_sum[j] for j in edge_in[i])


t = 0

for i in range(1, N - 1):
    if edge_sum[i] == 1:
        continue
        # iから出ている道の先にある部屋のうち、その部屋からNまでの距離の期待値が最も大きいものへ通ずる道を塞ぐ
    t = max(t, p_to_i[i]*(dp[i] - 1- ((dp[i] - 1)*edge_sum[i] - max(dp[j] for j in edge_out[i]))/(edge_sum[i] - 1)))
    
print(dp[1] - t)

Measured memory_bytes: 29724
A,B,K = map(int,input().split())
i = 1
c = 1
while i <= K:
    if c % 2 == 1:
        if A % 2 == 0:
            A_ = A // 2
            A = A_
            B = B + A_
        else:
            A -= 1
            A_ = A // 2
            A = A_
            B = B + A_

        i += 1
        c += 1
    else:
        if B % 2 == 0:
            B_ = B //2
            A = A + B_
            B = B_
        else:
            B -= 1
            B_ = B //2
            A = A + B_
            B = B_

        i += 1
        c += 1
print(A,B)


Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
// clang-format on

ll init(int k) {
  vector<ll> a;
  REP(i, 9) { a.push_back(i + 1); }
  queue<ll> q;
  REP(i, 9) { q.push(i + 1); }

  while (!q.empty()) {
    ll bb = q.front();
    q.pop();
    ll d = bb % 10;
    for (ll i = max<ll>(0, d - 1); i <= min<ll>(d + 1, 9); i++) {
      ll temp = bb * 10 + i;
      a.push_back(temp);
      q.push(temp);
    }
    if (a.size() >= 3 * k) {
      break;
    }
  }
  sort(a.begin(), a.end());
  return a[k - 1];
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k;
  cin >> k;
  cout << init(k) << endl;

  return 0;
}


Measured memory_bytes: 7628
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<int> A(N); cin >> A;
  sort(A.begin(),A.end());
  cout << A[N-1] - A[0] << endl;
}


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

int		main(void)
{
	ll		h, w;
	cin >> h >> w;

	if (h == 1 || w == 1){
		cout << 1 ;
		return 0;
	}
	if (!(h & 1) && !(w & 1))
		cout << h * w / 2;
	else if (!(h & 1) && (w & 1))
		cout << h * (w - 1) / 2 + h / 2;
	else if ((h & 1) && !(w & 1))
		cout << (h - 1) * w / 2 + w / 2;
	else
		cout << (h - 1) * (w - 1) / 2 + h / 2 + w / 2 + 1;
}


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

int main() {
    string S;
    cin >> S;
    string T = "AKIHABARA";

    if(S.size() > 9) {
        cout << "NO" << endl;
        return 0;
    }
    
    int cur = 0;
    for(int i = 0; i < T.size(); ++i) {
        if(T[i] != S[cur]) {
            if(T[i] == 'A') continue;
            else {
                cout << "NO" << endl;
                return 0; 
            }
        } else {
            ++cur;
        }
    }
    
    if(cur == S.size()) cout << "YES" << endl;
    else cout << "NO" << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long
struct Point {
	int x, y;

	double dis(Point a, Point b) {
		double x = a.x - b.x;
		double y = a.y - b.y;
		return sqrt(x*x + y * y);
	}
};

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

	string s;
	cin >> s;

	for (int i = 0; i < 4; i++)
	{
		cout << s[i];
	}
	cout << " ";
	for (int i = 4; i < 12; i++)
	{
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
typedef long double ld;
typedef long long ll;

using namespace std;


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

    int a, b;
    cin >> a >> b;
    int ct = 0;
    for(int i = a; i <= b; i++){
    	int u = i;
    	int v = 0;
    	while(u){
    		v = v * 10 + (u % 10);
    		u /= 10;
    	}
    	ct += (v == i);
    }
    cout << ct << endl;

    return 0;
}

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


void solve(){
 int a,b;
 cin>>a>>b;
 if(a==1&&b==2) cout << 3;
 if(a==2&&b==1) cout << 3;
 if(a==1&&b==3) cout << 2;
 if(a==3&&b==1) cout << 2;
 if(a==2&&b==3) cout << 1;
 if(a==3&&b==2) cout << 1;


}


int main(){
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

int main()
{
//	freopen("TEXT.inp", "r", stdin); freopen("TEXT.out", "w", stdout);
	fastio();

    ll a, b, c;
    cin >> a >> b >> c;
    ll k; cin >> k;
    ll s = 0;

    s += min(a, k);
    k -= min(a, k);

    if (k > 0) {
        k -= min(b, k);
    }
    if (k > 0) {
        s -= min(c, k);
        k -= min(c, k);
    }
    cout << s;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<"\t\n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  ll n, m; cin >> n >> m;
  vl a(n), b(m); ina(a,n); ina(b,m);
  sort(all(a)); sort(all(b));
  rep(i,n-1) if (a[i]==a[i+1]) { puts("0"); return 0; }
  rep(i,m-1) if (b[i]==b[i+1]) { puts("0"); return 0; }
  ll ans = 1;
  for (ll now = n*m; now > 0; now--) {
    auto ita = lower_bound(all(a), now);
    auto itb = lower_bound(all(b), now);
    int st = (*ita == now) + (*itb == now);
    if (st == 0) {
      ans *= (a.end() - ita)*(b.end() - itb) - (n*m - now);
    }
    if (st == 1 && *ita == now) {
      ans *= (b.end() - itb);
    }
    if (st == 1 && *itb == now) {
      ans *= (a.end() - ita);
    }
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


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



int A, B, C;
int X[4][4];
//-----------------------------------------------------------------
void solve() {
	rep(sm, 0, 500) {
		X[1][3] = sm - X[1][1] - X[1][2];
		X[3][2] = sm - X[1][2] - X[2][2];
		X[3][1] = sm - X[2][2] - X[1][3];
		X[2][1] = sm - X[1][1] - X[3][1];
		X[2][3] = sm - X[2][1] - X[2][2];
		X[3][3] = sm - X[3][1] - X[3][2];

		bool ok = true;
		set<int> se;
		rep(i, 1, 4) {
			int s = 0;
			rep(j, 1, 4) s += X[i][j];
			se.insert(s);
		}

		rep(j, 1, 4) {
			int s = 0;
			rep(i, 1, 4) s += X[i][j];
			se.insert(s);
		}

		se.insert(X[1][1] + X[2][2] + X[3][3]);
		se.insert(X[3][1] + X[2][2] + X[1][3]);

		if (se.size() == 1) return;
	}

	cout << "Error!!" << endl;
}
//-----------------------------------------------------------------
int main() {
	cin >> A >> B >> C;
	X[1][1] = A;
	X[1][2] = B;
	X[2][2] = C;
	
	solve();

	rep(i, 1, 4) {
		rep(j, 1, 4) {
			printf("%d ", X[i][j]);
		}
		cout << endl;
	}
}

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

int main(){
    long long a,b,k;
    cin >> a >> b >> k;

    if(k <= a){
        cout << a - k <<' '<< b << endl;
    }else if(k <= a + b){
        cout << 0 << ' ' << b - (k - a) << endl;
    }else{
        cout << 0 << ' ' << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3532
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll i = 0;
    while (1)
    {
        if (i % 2 == 0)
        {
            c -= b;
            if (c <= 0)
            {
                cout << "Yes" << endl;
                exit(0);
            }
        }
        else
        {
            a -= d;
            if (a <= 0)
            {
                cout << "No" << endl;
                exit(0);
            }
        }

        i++;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9 + 7;
const ll inf = 1e12;
const double pi = 3.141592;

struct UnionFind{
    vector<int> par;

    UnionFind(int N) : par(N){
        for (int i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

    int root(int x){
        if(par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)
            return;
        par[rx] = ry;
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m)
    {
        int ai, bi;
        cin >> ai >> bi;
        a[i] = ai-1;
        b[i] = bi-1;
    }
    int ans = 0;
    rep(i, m)
    {
        UnionFind s = UnionFind(n);
        rep(j, m){
            if(i == j)
                continue;
            s.unite(a[j], b[j]);
        }
        if(!s.same(a[i], b[i]))
            ++ans;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
// kartikay26
#include <bits/stdc++.h>
using namespace std;
#define debug(x...) 
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
void print(){cout << endl;} void prints(){}
template<typename T=int> T get(){T x; cin >> x; return x;}
template<typename T> void get(T* x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T> void get(T& x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T, typename... A> void print(T x,A... r){cout << x << " ";print(r...);}
template<typename T, typename... A> void prints(T x,A... r){cout << x << " ";prints(r...);}
typedef long long int ll; typedef double db; typedef vector<ll> vi; typedef pair<ll, ll> pii;
#define int ll
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define clear(x) memset(x, 0, sizeof(x))
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int mod = 1e9+7;
const int N = 1e6+1;

int32_t main(){
	fast_io();

	int n, k; cin >> n >> k;
	vi a(n); get(a,n);

	vector<bool> dp(k+1);
	// dp[i] = true if player stating with i stones wins the game

	for (int i = 0; i < k+1; ++i) {
		for(auto x : a){
			if(i>=x and !dp[i-x]){
				dp[i] = 1;
			}
		}
	}
	debug(dp);

	print(dp[k] ? "First" : "Second");
	
	return 0;
}

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

int main() {
    int n;
    map<int,int> mp;
    cin >> n;
    for ( int i=0; i<n; i++ ) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans=0;
    for ( auto p:mp ) {
        if ( p.second&1 ) ans++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    char ch;
    cin>>ch;
    if ( ch >= 'a' && ch <= 'z' ){
        cout<<"a"<<endl;
    }
    else{
        cout<<"A"<<endl;
    }
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3608