akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

struct Tree {
	using T = LL;
	T f(T a, T b) { return min(a, b); }
	vector<T> nodes;
	int size = 1;

	Tree(int n, T val = 0) {
		while(size < n) size *= 2;
		nodes.resize(size * 2, val);
	}


	T get(int pos) {
		T ret = nodes[pos += size];
		while(pos /= 2)
			ret = f(ret, nodes[pos]);
		return ret;
	}

	void update(int l, int r, T val) {
		l += size, r += size;
		for(int v : {l, r}) 
			nodes[v] = f(nodes[v], val);
		while(l + 1 < r) {
			if(l % 2 == 0)
				nodes[l + 1] = f(nodes[l + 1], val);
			if(r % 2 == 1)
				nodes[r - 1] = f(nodes[r - 1], val);
			l /= 2, r /= 2;
		}
	}
};

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

	int n, m;
	cin >> n >> m;
	Tree dp(n, 1e18);
	dp.update(0, 0, 0);
	
	struct seg { int l, r, c; };
	vector<seg> q(m);
	REP(i, m) {
		cin >> q[i].l >> q[i].r >> q[i].c;
		q[i].l--, q[i].r--;
	}
	sort(q.begin(), q.end(), [&](seg a, seg b) { return a.l < b.l; });
	for(seg s : q)
		dp.update(s.l, s.r, dp.get(s.l) + s.c);
	LL ans = dp.get(n - 1);
	if(ans == 1e18) ans = -1;
	cout << ans << "\n";
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

const int mod = 1000000007;

long long pw(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1ll) {
			res = res * a % mod;
		}
		b >>= 1;
		a = a * a % mod;
	}
	return res;
}

int main() {
	int n = nxt(), k = nxt();
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		a[i] = nxt();
	}

	int g = a[0];
	for (int x : a) {
		g = __gcd(g, x);
	}

	puts(k % g == 0 && k <= *max_element(all(a)) ? "POSSIBLE" : "IMPOSSIBLE");

	// int n = nxt();
	// string s;
	// cin >> s;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

//グラフの隣接リスト
VI g[100010];
//頂点の入次数を管理
int h[100010];
signed main(void) {
    int N, M; cin >> N >> M;
    cout << ((N-M)*100+1900*M)*pow(2, M) << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};
#define MAX 100000
int main(){
    int n,a,b,c,x;
    while(cin >> n >> a >> b >> c >> x,n|a|b|c|x){
        vector<int> y(n);
        rep(i,n) cin >> y[i];
        int cnt = 0;
        int frame = 0;
        while(1){
            if(frame > 10000) {
                cout << -1 << endl;
                break;
            }
            if(x==y[cnt]) cnt++;
            if(cnt == n) {
                cout << frame << endl;
                break;
            }
            x = (a*x+b)%c;
            frame++;
        }
    }
    return 0;
}



Measured memory_bytes: 2992
X,Y = (int(num) for num in input().split(" "))
flag = True
if X % Y == 0:
    flag = False
n = 2
while flag:
    if n * X % Y != 0:
        break
    if n * X > 10**18:
        flag = False
    n += 1

if flag:
    print(n * X)
else:
    print(-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  long long L, R;
  cin >> L >> R;
  long long ans = 2019;
  long long key = L % 2019;
  if(key == 0) {
    cout << 0 << endl;
    return 0;
  } else {
    if(R >= L + (2019 - key)) {
      cout << 0 << endl;
      return 0;
    } else {
      for(long long i = L; i <= R; i++) {
        for(long long j = i + 1; j <= R; j++) {
          ans = min(ans, (i * j) % 2019);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n, k;

int main()
{
    cin>>n>>k;
    cout<<(int)(log(n) / log(k) + 1)<<endl;

    return 0;
}


Measured memory_bytes: 640
//by tzupengwang™
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

set< ii > st ;
ll H , W , n ;
int s[ 100005 ][ 2 ] ;

void init() {
  scanf( "%lld%lld%lld" , &H , &W , &n ) ;
  for ( int i = 0 ; i < n ; i ++ ) {
    scanf( "%d%d" , &s[ i ][ 0 ] , &s[ i ][ 1 ] ) ;
    st.insert( ii( s[ i ][ 0 ] , s[ i ][ 1 ] ) ) ;
  }
}

ll ans[ 15 ] ;

void chck( int x , int y ) {
  if ( x - 1 <= 0 || y - 1 <= 0 || x + 1 > H || y + 1 > W ) return ;
  int ret = 0 ;
  for ( int i = -1 ; i <= 1 ; i ++ ) {
    for ( int j = -1 ; j <= 1 ; j ++ ) {
      if ( st.count( ii( x + i , y + j ) ) ) ret ++ ;
    }
  }
  //bool gd = false ;
  //if ( st.count( ii( x , y ) ) ) gd = true ;
  //if ( gd ) ans[ ret ][ 1 ] ++ ;
  //else ans[ ret ][ 0 ] ++ ;
  ans[ ret ] ++ ;
}

void process() {
  for ( int k = 0 ; k < n ; k ++ ) {
    for ( int i = -1 ; i <= 1 ; i ++ ) {
      for ( int j = -1 ; j <= 1 ; j ++ ) {
        chck( s[ k ][ 0 ] + i , s[ k ][ 1 ] + j ) ;
      }
    }
  }
  for ( int i = 1 ; i <= 9 ; i ++ ) {
    ans[ i ] /= i ;
  }
  ll tot = ( H - 2 ) * ( W - 2 ) ;
  ans[ 0 ] = tot ;
  for ( int i = 1 ; i <= 9 ; i ++ ) ans[ 0 ] -= ans[ i ] ;
  for ( int i = 0 ; i <= 9 ; i ++ ) printf( "%lld\n" , ans[ i ] ) ;
}

int main() {
  init() ;
  process() ;
  return 0 ;
}


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

int main(){
    ll n,k;
    cin >> n >> k;
    vector<int> a(n),f(n);
    priority_queue<pair<int,int>> pq;
    rep(i,n) cin >> a.at(i);
    rep(i,n) cin >> f.at(i);
    sort(a.begin(),a.end());
    sort(f.rbegin(), f.rend());
    ll l=-1,r=INF;
    while(l+1<r) {
        ll x = (l+r)/2;

        ll nk = 0;
        for(ll i=0;i<n;i++){
            nk += max((ll)0, (ll)a.at(i)-x/f.at(i));
        }
        if(nk <= k) r = x;
        else l = x;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1792
m,d=map(int, input().split())
a = 0
for i in range(1,m+1):
    for j in range(1,d+1):
        d1 = j % 10
        d10 = j // 10
        if d1>=2 and d10>=2 and d1*d10 == i:
            a += 1
print(a)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define int long long
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"
#include "string"
const int N = 81;
const int M = 1001;
int n;
int a[N];

int32_t main(){
	boost;
	cin >> n;
	int dp[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		dp[i] = 1000;
	}
	int ans  = 1000;
	
	for(int i = 0; i < n; i++) {
		int stoke = dp[i] / a[i];
		int rem = dp[i] % a[i];
		for(int j = i + 1; j < n; j++){ 
			dp[j] = max(dp[j], stoke * a[j] + rem);
			dp[j] = max(dp[j] , dp[i]);
		}
		ans = max(ans, dp[i]);
	}

	cout << ans << endl;
}


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

public class Main {

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

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int p = scanner.nextInt();
		int[] d = new int[m];
		for (int i = 0; i < m; i++) {
			int a = scanner.nextInt();
			d[i] = (a - p + n) % n;
		}
		Arrays.sort(d);
		int ret = Math.min(n - d[0], d[m - 1]);
		for (int i = 0; i < m; i++) {
			if (i > 0) {
				int a = 2 * (n - d[i]) + d[i - 1];
				ret = Math.min(ret, a);
			}
			if (i < m - 1) {
				int b = 2 * d[i] + n - d[i + 1];
				ret = Math.min(ret, b);
			}
		}
		System.out.println(ret * 100);
	}
}

Measured memory_bytes: 34332
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int color[100000];
typedef pair<int, int> P;

bool dfs(int x, int c, vector<vector<P>>& node){
    color[x] = c;
    for(int i=0;i<node[x].size();i++){
        if(color[node[x][i].first]==0){
            if(node[x][i].second%2!=0 && !dfs(node[x][i].first, -c, node)) return false;
            else if(node[x][i].second%2==0 && !dfs(node[x][i].first, c, node)) return false;
        }
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    vector<vector<P> > node(N);
    for (int i = 0; i < N-1; ++i) {
        int u, v, w;
        P p;
        cin >> u >> v >> w; 
        --u; --v;
        p.first = v;
        p.second = w;
        node[u].push_back(p);
        p.first = u;
        node[v].push_back(p);
    }
    //cout << node[0][0].second%2<<" " << node[2][0].second%2<<endl;
    dfs(0, 1, node);
    for(int i=0;i<N;i++){
        if(color[i]==1) cout << 0 <<endl;
        else cout << 1 << endl;
    }
}

Measured memory_bytes: 8960
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();

            if (Math.abs(a - c) <= d || Math.abs(a - b) <= d && Math.abs(b - c) <= d) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  vector<pair<int, int>> vp;
  for (int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    vp.emplace_back(a, b);
  }

  int K = 0;
  map<pair<int, int>, int> I;
  vector<int> cs(N, 0);

  vector<int> used(N, 0);
  queue<int> que;
  used[0] = 1;
  que.emplace(0);
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    if (K < (int)G[v].size()) K = G[v].size();
    int cur = 1;
    for (int u : G[v]) {
      if (used[u]) continue;
      if (cur == cs[v]) cur++;
      cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
      used[u] = 1;
      que.emplace(u);
    }
  }

  cout << K << endl;
  for (auto p : vp) cout << I[p] << endl;
  return 0;
}


Measured memory_bytes: 20084
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<(b))

using namespace std;

int main(){
	int D,E;
	while(cin>>D>>E,D){
		double mn=1000;
		REP(x,0,D/2+1)	mn=min(mn,abs(sqrt(x*x+(D-x)*(D-x))-E));
		printf("%.5lf\n",mn);
	}
	return 0;
}

Measured memory_bytes: 3112
N=int(input())
a=[11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 
761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381]
print(*a[:N])

Measured memory_bytes: 3064
D,N = map(int,input().split())

L = []

for i in range(N*2) :
    l = 100**D
    l *= (i+1)
    if D == 0 :
        if (l % 100) != 0 :
            L.append(l)
    elif D == 1 :
        if (l % 10000) != 0 :
            L.append(l)
    else :
        if (l % 1000000) != 0 :
            L.append(l)
ans = L[N-1]
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define ump gp_hash_table<int,int,custom_hash>
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*int **dp,in main function,int row,col;dp=new int*[n];rep(i,n)dp[i]=new int[m]*/
//**** Maths Section*******/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);
/***************************/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  fastio
  string s;
  cin>>s;
  if(s[0]==s[1] && s[1]==s[2])cout<<"No\n";
  else cout<<"Yes\n";
  return 0;
}

int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}

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

bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}


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

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

  vector<int> mochi(n);
  for(int i=0; i<n; i++) {
    cin>>mochi[i];
  }

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

  int res = 1;

  for (int i=0; i<mochi.size()-1; i++) {
    if (mochi[i] < mochi[i+1]) res++;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
long long fast(long long a,long long b,long long p){
	long long ans=1;
	long long cur=a;
	while(b){
		if(b&1){
			ans*=cur;
			ans%=p;
		}
		cur*=cur;
		cur%=p;
		b>>=1;
	}
	return ans;
}
int main(){
	int n,m;
	while(cin>>n>>m){
		cout<<fast(n,m,1e9+7)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3100
var sx,sy,tx,ty,i:Integer;
begin
	read(sx,sy,tx,ty);
	dec(tx,sx);
	dec(ty,sy);
	for i:=1 to ty do write('U');
	for i:=1 to tx do write('R');
	for i:=1 to ty do write('D');
	for i:=1 to tx do write('L');
	write('L');
	for i:=1 to ty do write('U');
	write('UR');
	for i:=1 to tx do write('R');
	write('DR');
	for i:=1 to ty do write('D');
	write('DL');
	for i:=1 to tx do write('L');
	write('U');
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int H, N; cin >> H >> N;
    vector<int> A(N), B(N);
    REP(i, 0, N) cin >> A[i] >> B[i];

    int MAX_H = pow(10, 9) + 1;
    int dp[N + 1][H + 1] = {};
    REP(i, 0, N + 1) {
        REP(j, 0, H + 1) {
            dp[i][j] = 1 << 28;
        }
    }
    dp[0][0] = 0;

    REP(i, 0, N) {
        REP(j, 0, H + 1) {
            if (j <= A[i]) {
                dp[i + 1][j] = min(dp[i][j], B[i]);
            } else {
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - A[i]] + B[i]);
            }
        }
    }
    cout << dp[N][H] << endl;
    return 0;
}

Measured memory_bytes: 39296
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main (){
    int N; cin >> N;
    vector<int> V(N);
    for(int &i:V){
        int a; cin >> a;
        a--;
        i = a;
    }

    vector<int> ans;
    for(int i=0; i<N; i++){
        int add = 0;
        bool f = false;
        for(int j=0; j<V.size(); j++){
            if(V[j]==j){
                f = true;
                add = j;
            }
        }
        if(!f) {
            cout << -1 << endl;
            return 0;
        }
        V.erase(V.begin() + add);
        ans.push_back(add+1);
    }

    for(int i=N-1; i>=0; i--){
        cout << ans[i] <<  endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import*
n,*a=map(int,open(0).read().split())
odd =Counter([v for k,v in enumerate(a) if k%2==0]).most_common()
even=Counter([v for k,v in enumerate(a) if k%2==1]).most_common()


if len(odd)==len(even)==1:
    if odd[0][0]==even[0][0]:
        print(len(a)//2)
    else:
        print(0)
elif odd[0][0]!=even[0][0]:
    print(sum(t for(s,t)in odd[1:])+sum(t for(s,t)in even[1:]))
else:
    a=odd[0][1]+sum(t for(s,t)in odd[2:])+sum(t for(s,t)in even[1:])
    b=even[0][1]+sum(t for(s,t)in even[2:])+sum(t for(s,t)in odd[1:])
    print(min(a,b))


Measured memory_bytes: 20572
#include<stdio.h>
int main(void)
{
	int a, b, c, swap;
	scanf("%d%d%d", &a, &b, &c);
	swap = a;
	a = b;
	b = swap;
	swap = a;
	a = c;
	c = swap;
	printf("%d %d %d", a, b, c);
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int64_t a, v, b, w, t; //a,v鬼 b,w子供 t時間
  int ans = 0;
  int i =0 ;
  cin >> a >> v >> b >> w >> t;
  

  for(i=0;i<t;i++){
  if (a > b){
    a -= v;
    b -= w;
    
    if ( a == b || a < b ){
    ans = 1;
    i = t;
    }
    else{
    }
    
  }
    
  else{
    a += v;
    b += w;
  
    if ( a == b || a > b ){
      ans = 1;
      i = t;
    }
    else{
    }
  }
  
  }
  
  if(ans == 1){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  
  
}

Measured memory_bytes: 3620
class UnionFind
  def initialize
    @obj_to_node = {}
  end

  def size(x)
    node = @obj_to_node[x]
    node ? node.root.size : 1
  end

  class UnionFind::Node
    def initialize(obj)
      @obj = obj
      @parent = self
      @size = 1
      @rank = 0
    end

    def root
      return self if @parent == self
      @parent = @parent.root
    end  

    attr_accessor :parent, :size, :rank
  end

  def union(x, y)
    u = (@obj_to_node[x] ||= UnionFind::Node.new(x)).root
    v = (@obj_to_node[y] ||= UnionFind::Node.new(y)).root
    return if u == v
    if u.rank > v.rank
      v.parent = u
      u.size += v.size
    elsif v.rank > u.rank
      u.parent = v
      v.size += u.size
    else
      u.parent = v
      v.rank += 1
      v.size += u.size
    end
  end

  def same_group?(x, y)
    return false unless u = @obj_to_node[x]
    return false unless v = @obj_to_node[y]
    u.root == v.root
  end
end

n, m = gets.split.map(&:to_i)
tree = Hash[(0..n-1).map {|i| [i, {}] }]
edges = (1..m).map { gets.split.map(&:to_i) }.sort_by(&:last)

answer = 0
uf = UnionFind.new
edges.each do |i, j, w|
  next if uf.same_group?(i, j)
  uf.union(i, j)
  answer += w
end
p answer


Measured memory_bytes: 16716
#include<bits/stdc++.h>
using namespace std;
int main() {
  string n;
  int i;
  cin>>n;
  for(i=0;i<3;i++){
    if (n.at(i)=='7') break;
  }
  if (i==3) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3628
#include <string>
#include <iostream>

using namespace std;

int solve(string S)
{
    int ret = 0;
    
    for(int i = 1; i < S.size(); i++)
    {
        string S1 = S.substr(0, i);
        string S2 = S.substr(i, S.size() - i);
        
        if(S2[0] != '0')
        {
            int r1 = stoi(S1);
            int r2 = stoi(S2);
            
            if((r1 + r2) % 2 == 0 && r1 <= r2)
            {
                ret++;
            }
        }
    }
    
    if(stoi(S) % 2 == 0) { ret++; }
    
    return ret;
}

int main()
{
    string S;
    
    cin >> S;
    
    cout << solve(S) << endl;
    
    return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
static const double pi = 3.141592653589793;
int main(){
    double A,B,H,M; cin>>A>>B>>H>>M;
    double x=0,y=0;
    x=6*M;
    y=30*H+0.5*M;
    double minimum=min(x,y);
    double maximum=max(x,y);
    double kaku=min(maximum-minimum,360-maximum+minimum)*(pi)/180;
    double ans=0;
    ans=pow(A,2)+pow(B,2)-2*A*B*cos(kaku);
    ans=sqrt(ans);
    printf("%10.9f",ans);
    return 0;
}

Measured memory_bytes: 4132
import System.IO (isEOF)
import Data.List.Split

loop rec loz = do done <- isEOF
                  if done
                    then do putStrLn $ show rec
                            putStrLn $ show loz
                            return ()
                    else do input <- getLine
                            let (r, l) = result input rec loz
                                in loop r l

result str rec loz = let [a, b, c] = map (read :: String -> Int) $ splitOn "," str
                         in if (a^2 + b^2 == c^2)
                              then (rec + 1, loz)
                              else if (a /= b)
                                     then (rec, loz)
                                     else (rec, loz + 1)

main = do loop 0 0

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    set<string>s;
    string st;
    for(int i=0;i<n;i++)
    {
        cin>>st;
        s.insert(st);
    }
    cout<<s.size()<<endl;
}

Measured memory_bytes: 19232
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n; 
    cin>>n; 
    int a[n+1],c=1,ans=0;
    for (int i=1;i<=n;i++) cin >> a[i] ; 
    for (int i=1;i<=n;i++) {
        if (a[i]==c) ans++,c++;
    } 
    cout << (ans?n-ans:-1) << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 5168
import sys
input = sys.stdin.readline
from collections import *

H, W, K = map(int, input().split())
c = [input()[:-1] for _ in range(H)]
row = []

for i in range(H):
    cnt = 0
    
    for j in range(W):
        if c[i][j]=='#':
            cnt += 1
    
    row.append(cnt)

col = []

for i in range(W):
    cnt = 0
    
    for j in range(H):
        if c[j][i]=='#':
            cnt += 1
    
    col.append(cnt)

total = sum(row)
ans = 0

for s1 in range(1<<H):
    for s2 in range(1<<W):
        l1, l2 = [], []
        
        for i in range(H):
            if (s1>>i)&1:
                l1.append(i)
        
        for i in range(W):
            if (s2>>i)&1:
                l2.append(i)
    
        now = total
        
        for l1i in l1:
            now -= row[l1i]
        
        for l2i in l2:
            now -= col[l2i]
            
        for l1i in l1:
            for l2i in l2:
                if c[l1i][l2i]=='#':
                    now += 1
        
        if now==K:
            ans += 1

print(ans)

Measured memory_bytes: 69192
#include<stdio.h>
#include<string.h>
#include<math.h>

double hi[100][100],len,max,mae[100],ato[100];

int main(){
	int i,j,n,m,k;
	
	while(0<=scanf("%d%d",&n,&m)){
		if(n==0&&m==0)break;
		memset(hi,0,sizeof(hi));
		
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				scanf("%lf",&hi[i][j]);
			}
		}
		
		for(i=0;i<n;i++){
			mae[i]=1;
		}
		
		for(i=1;i<m;i++){
			memset(ato,0,sizeof(ato));
			
			for(j=0;j<n;j++){
				//printf("%lf ",mae[j]);
			}
			//printf("\n");
			
			for(j=0;j<n;j++){
				for(k=0;k<n;k++){
					if(ato[j]<mae[k]*hi[k][j])ato[j]=mae[k]*hi[k][j];
				}
			}
			
			memcpy(mae,ato,sizeof(ato));
		}
		max=0;
		for(i=0;i<n;i++)if(max<mae[i])max=mae[i];
		
		printf("%.2lf\n",max);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
    int alphabet[30];
    for(int i = 0; i < 30; ++i) alphabet[i] = 0;
    for(int i = 0; i < 4; ++i) ++alphabet[fgetc(stdin) - 'A'];
    int cnt = 0;
    for(int i = 0; i < 30; ++i) {
        if(alphabet[i] == 2) ++cnt;
    }
    if(cnt == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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


int main() 
{
    int n,k,x,y,e,f,g;
    
    scanf("%d",&n);
    scanf("%d",&k);
    scanf("%d",&x);
    scanf("%d",&y);
    if(k>n)
    {
        printf("%d",x*n);
    }else{
    
    e=k*x;
    f=n-k;
    g=f*y;
    
    
    printf("%d",g+e);
    }
    
   
}

Measured memory_bytes: 128
from itertools import permutations, combinations,combinations_with_replacement,product
n , d= map(int,input().split())

a=[i for i in range(n)]
p = list(combinations(a,2))

s = []
for i in range(n):
    w = list(map(int,input().split()))
    s.append(w)

ans = 0
for x , y in p:
    ty = 0
    for j in range(d):
        ty += (s[x][j]-s[y][j])**2
    if ((ty)**0.5).is_integer():
        ans += 1
print(ans)

Measured memory_bytes: 3064
n=int(input())
arr=list(map(int,input().split()))
print(' '.join(map(str,arr)))
for i in range(1,n):
  v=arr[i]
  j=i-1
  while j>=0 and arr[j]>v:
    arr[j+1]=arr[j]
    j-=1
  arr[j+1]=v
  print(' '.join(map(str,arr)))


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

int main(void){
    ll a,b;
    cin >> a >> b;
    bool is_res = false;
    for(int i=1;i<= 1000;i++){
        if((int)(i*0.08) == a && (int)(i*0.1) == b){
            cout << i << endl;
            is_res = true;
            break;
        }
    }
    if(!is_res)cout << "-1" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

vector<int> v;
map<vector<int>, bool> dp[N];
int n;
map<char, int> mp;
string s[N];

bool solve(int idx){
    if(v[0] < 0 || v[1] < 0 || v[2] < 0) return 0;
    if(idx == n) return 1;
    if(dp[idx].find(v) != dp[idx].end()) return dp[idx][v];
    int x = mp[s[idx][0]], y = mp[s[idx][1]];
    bool op1 = 0, op2 = 0;

    v[x]++;
    v[y]--;
    op1 = solve(idx + 1);
    v[x]--;
    v[y]++;
    if(op1) return dp[idx][v] = 1;

    v[y]++;
    v[x]--;
    op2 = solve(idx + 1);
    v[x]++;
    v[y]--;
    return dp[idx][v] = op2;

}

void build(int idx){
    if(idx == n) return;
    int x = mp[s[idx][0]], y = mp[s[idx][1]];
    bool op1 = 0, op2 = 0;

    v[x]++;
    v[y]--;
    op1 = solve(idx + 1);
    if(op1){
        cout << s[idx][0] << '\n';
        build(idx + 1);
        return;
    }
    v[x]--;
    v[y]++;

    v[y]++;
    v[x]--;
    op2 = solve(idx + 1);
    cout << s[idx][1] << '\n';
    build(idx + 1);



}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    mp['B'] = 1;
    mp['C'] = 2;
    cin >> n;
    for(int i = 0; i < 3; i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    if(solve(0)){
        cout << "Yes\n";
        build(0);
    }
    else cout << "No";

    return 0;

}


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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;
int c = 0;


void merge(int a[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int l[n1+1], r[n2+1];
    REP(i, n1) l[i] = a[left + i];
    REP(i, n2) r[i] = a[mid + i];
    l[n1] = INF;
    r[n2] = INF;
    int i = 0;
    int j = 0;
    for(int k = left; k < right ; k++){
        c++;
        if(l[i] <= r[j]){
            a[k] = l[i];
            i++;
        } else {
            a[k] = r[j];
            j++;
        }
    }
    return;
}

void merge_sort(int a[], int left, int right){
    if (left+1 < right){
        int mid = (left + right) / 2;
        merge_sort(a, left, mid);
        merge_sort(a, mid, right);
        merge(a, left, mid, right);
    }
    return;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    REP(i, n) cin >> a[i];
    merge_sort(a, 0, n);

    REP(i, n-1) cout << a[i] << " ";
    cout << a[n-1] << endl << c << endl;

    return 0;
}

Measured memory_bytes: 5064
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

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

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 1e5 + 10, K = 26, inf = 1e9, infll = 1e18;
const double pi = acos(-1);
int n, m, ans[maxn];
ii a[maxn];

bool cmp(ii a, ii b){
	if(a.fi == b.fi){
		return a.se < b.se;
	}
	return a.fi > b.fi;
}

void solve(){
	int j, k, l, r; cin >> n ;
	for(int i = 1; i <= n; ++i){
		cin >> a[i].fi; a[i].se = i;
	}
	sort(a + 1, a + n + 1, cmp);
	for(int i = 1, pick = i, val = a[pick].fi; i <= n;){
		if(i <= n && a[i].fi == a[i + 1].fi) ++i;
		int it = i + 1;
		ans[a[pick].se] += (it - 1) * (val - a[it].fi);
		val = a[it].fi;
		pick = (a[pick].se > a[it].se ? it : pick);
		i = it; 
	}
	for(int i = 1; i <= n; ++i) cout << ans[i] << '\n';
}

signed main() {
    //freopen(".INP", "r", stdin);
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}


Measured memory_bytes: 5944
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



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

  vector<int> c;
  c.assign(n+1, 0);
  rep(i, n) {
    int a;
    cin >> a;
    c[a]++;
  }

  sort(all(c), greater<int>());

  int ans = 0;
  for(int i=k; i<n; i++) {
    ans += c[i];
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
	{
		int n,m,c;
		cin>>n>>m>>c;
		int b[25]={0};
		int cnt=0;
		for(int i=1;i<=m;i++)
			{
				cin>>b[i];
			}
		while(n--)
			{
				int ans=c;
				int f;
				for(int i=1;i<=m;i++)
					{
						cin>>f;
						ans+=b[i]*f;
					}
				if(ans>0)
					cnt++;
			}
		cout<<cnt;
		return 0;
	} 

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	var D []int
	var cnt int

	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		var d int
		fmt.Scan(&d)
		D = append(D, d)
	}

	sort.Sort(sort.Reverse(sort.IntSlice(D)))

	for i := 0; i < N; i++ {
		if i == 0 || D[i-1] > D[i] {
			cnt++
		}
	}

	fmt.Println(cnt)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }return 0; }
#define all(a)  (a).begin(),(a).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vll vector<ll>
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
const ll INF =1LL << 62;

int main(){
  string s;
  cin >> s;
  int ans =0;
  int res=0;
  for(int i=0;i<s.size();i++){
    if(s[i] == 'A' || s[i]=='T' || s[i] == 'C' || s[i] == 'G'){
      res ++;
      if(i == s.size()-1){
        chmax(ans,res);
      }
    }
    else {
      chmax(ans,res);
      res=0;
    }
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector< vector<int> > VVI;
typedef vector< vector<int> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair

int main(){
  int N;
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  int tmp=1;
  int ans=0;
  rep(i,N){
    if(A[i]==tmp){
      tmp++;
      ans++;
    }
  }
  if(ans==0) cout<<-1<<endl;
  else cout<<N-ans<<endl;
}

Measured memory_bytes: 1024
k=int(input())
b=[0]
c=1
c=1
for i in range(k):
    if  b[len(b)-c]+1-b[len(b)-c-1]<=1 and b[len(b)-c]!=9:
        b[len(b)-c]+=1
    elif b==[9]*len(b):
        b=[1]+[0]*len(b)
    else:
        while b[len(b)-c]+1-b[len(b)-c-1]>1 or b[len(b)-c]+1==10:
            c+=1
        b[len(b)-c]+=1
        
        for i in range(c-1):
            if b[len(b)-(c-i)]-1<0:
                b[len(b)-(c-i)+1]=0
            else:
                b[len(b)-(c-i)+1]=b[len(b)-(c-i)]-1
        c=1
    
print(int(''.join(map(str,b))))

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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    
    int push = max(A,C);
    int sep = min(B,D);
    
    int ans = sep - push;
    
    if(ans<0){
        cout << 0 << endl;
    }else{
        cout << ans << endl;
    }
}


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

int main() {
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a <= k) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}


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

char s[50], t[50];

int search() {
  for (int j = strlen(s)-strlen(t); j >= 0; j--) {
    int k = 0, l = j;
    while (k < strlen(t) && l < strlen(s) && (s[l] == '?' || s[l] == t[k])) {
      k++, l++;
    }
    if (k == strlen(t)) return j;
  }
  return -1;
}




int main()
{
  
  scanf("%s %s", s, t);
  int flag = search();
  
  if (flag == -1) {
    printf("UNRESTORABLE\n");
  } else {
    //tを代入
    for (int i = flag, j = 0; j < strlen(t); i++, j++) {
      s[i] = t[j];
    }
    //?にaを代入
    for (int i = 0; i < strlen(s); i++) {
      if (s[i] == '?') {
        s[i] = 'a';
      }
    }
    printf("%s\n", s);
  }
  
  return 0;
}


Measured memory_bytes: 128
class WeightUnionFindTree
  def initialize(n)
    @nodes = (0..n).map { |i| Node.new(i) }
  end

  def unite(a, b, w)
    pa = find(a)
    pb = find(b)
    return if pa == pb
    
    if @nodes[pa].rank < @nodes[pb].rank
      @nodes[pa].parent = pb
      @nodes[pa].weight = - w - @nodes[a].weight + @nodes[b].weight
    else
      @nodes[pb].parent = pa
      @nodes[pb].weight = w + @nodes[a].weight - @nodes[b].weight 
      @nodes[pa].rank += 1 if @nodes[pa].rank == @nodes[pb].rank
    end
  end

  def same?(a, b)
    find(a) == find(b)
  end

  def find(a)
    return a if @nodes[a].parent == a
    pa = find(@nodes[a].parent)
    @nodes[a].weight += @nodes[@nodes[a].parent].weight
    @nodes[a].parent = pa
  end
  
  def weight(a)
    find(a)
    @nodes[a].weight
  end
  
  def diff(a, b)
    weight(b) - weight(a)
  end
  
  def max_diff
    min = @nodes.map { |node| node.weight } .min
    max = @nodes.map { |node| node.weight } .max
    max - min
  end
  
  def parents
    @nodes.map(&:parent)
  end
  
  private 
  
  class Node
    attr_accessor :parent, :weight, :rank 
  
    def initialize(n)
      @parent = n
      @weight = 0
      @rank = 0
    end
  end
end

n, m = gets.chomp.split.map(&:to_i)
info = Array.new(m) { gets.chomp.split.map(&:to_i) }

tree = WeightUnionFindTree.new(n)
info.each do |l, r, d|
  if tree.same?(l, r)
    unless tree.diff(l, r) == d
      puts "No"
      exit
    end
  end
  tree.unite(l, r, d)
end
puts tree.max_diff <= 10 ** 9 ? "Yes" : "No"


Measured memory_bytes: 19324
n,k=map(int,input().split())
ab=[[int(i) for i in input().split()]for j in range(n)]
dic={}
for a,b in ab:
    if a in dic:
        dic[a]+=b
    else:
        dic[a]=b
dic=sorted(dic.items() , key=lambda x:x[0])
check=0
for i,j in dic:
    check+=j
    if check>=k:
        print(i)
        break

Measured memory_bytes: 30044
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int A, B, count = 0;
  cin >> A >> B;
  for (int i = 0; i < B - A + 1; i++)
  {
    if((A+i)%10==(A+i)/10000 && (A+i)%100/10==(A+i)/1000%10)
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <utility>
#include <iomanip>
#include <queue>

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

const ll inf=1000000000000000;

using namespace std;

int main(){
    
    int N;
    ll W;
    cin>>N;
    cin>>W;
    
    ll w[N+1];
    int v[N+1];
    
   
    w[0]=0;
    v[0]=0;
    for(int i=1;i<=N;++i){
        cin>>w[i];
        cin>>v[i];
    }
    
 
    ll dp[N+1][100101];
    /*
    vector<vector<ll> > dp;
    
    dp.resize(N+1);

    rep(i,N+1){
        dp[i].resize(100100);
    }
    
    */
    
    rep(i,N+1){
        for(int j=0;j<=100100;++j){
             dp[i][j]=inf;
        }
    }
    
       
/*
    
    rep(i,N+1){rep(j,100101){cout<<dp[i][j]<<" ";}
          cout<<endl;
      }
    */
    
    for(int i=1;i<=N;++i){
        for(ll j=0;j<=100100;++j){
            if(j==v[i]){
                dp[i][j]=min(w[i],dp[i-1][j]);
                 //cout<<i<<":"<<j<<":"<<dp[i][j]<<endl;
            }else if(v[i]<j){
                if(dp[i-1][j-v[i]]!=inf){
                    dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
                    //cout<<i<<":"<<j<<":"<<dp[i][j]<<endl;
                }else if(dp[i-1][j]!=inf){
                    dp[i][j]=dp[i-1][j];
                   // cout<<i<<":"<<j<<":"<<dp[i][j]<<endl;
                }
            }else{
                if(dp[i-1][j]!=inf){
                     dp[i][j]=dp[i-1][j];
                    //cout<<i<<":"<<j<<":"<<dp[i][j]<<endl;
                }
            }
        }
    }
    /*
    rep(i,N+1){rep(j,100100){cout<<dp[i][j]<<" ";}
        cout<<endl;
    }
    */
    
    
   // cout<<dp[N][W]<<endl;
    ll ans=0;
    for(ll i=0;i<=100100;++i){
        if(dp[N][i]<=W){
            //cout<<dp[N][i]<<":"<<i<<endl;
            ans=max(ans,i);
        }
    }
    cout<<ans<<endl;
    
    
    
}


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

int main()
{
    string s;
    cin >> s;
    string t = s;
    reverse(t.begin(), t.end());
    int cnt = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i])
            cnt++;
    }
    cout << cnt / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
s=[int(s) for s in input()][::-1]
i=0
k=m
cnt=0
a=[]
while i<n:
  j=-1
  while i<n and k:
    k-=1
    i+=1
    if s[i]==0:j=i
  if j==-1:
    print(-1)
    exit()
  a+=[j]
  k=m-i+j
  cnt+=1
for i in range(len(a)-1,0,-1):
  a[i]-=a[i-1]
print(*a[::-1])

Measured memory_bytes: 89012
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
#include <cstdint>                                                                                                              

template <std::uint_fast64_t Modulus> class modint {
	using u64 = std::uint_fast64_t;

public:
	u64 a;

	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};

using mint = modint<MOD>;
int main() {
	mint a, b, c, d;
	vector<mint> kaijo;
	kaijo.push_back(1);
	rep(i, 2000010) {
		kaijo.push_back(kaijo.back() * (i + 1));
	}

	cin >> x >> y >> z >> w;
	z++;
	w++;
	a = kaijo[x + y] / (kaijo[x] * kaijo[y]) - 1;
	b = kaijo[z + y] / (kaijo[z] * kaijo[y]) - 1;
	c = kaijo[x + w] / (kaijo[x] * kaijo[w]) - 1;
	d = kaijo[z + w] / (kaijo[z] * kaijo[w]) - 1;
	
	//cout<<a.a<<" "<<b.a<<" "<<c.a<<" "<<d.a<<endl;

	cout << (a + d - b - c).a << endl;
}

Measured memory_bytes: 18664