akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 2e5 + 7;
const double pi = acos(-1);

int main(){
	string s;
	cin >> s;
	int q;
	scanf("%d",&q);
	int fl = 0;
	string s1 ="",s2 = "";
	while(q--){
		int t;
		scanf("%d",&t);
		if(t == 1){
			fl = 1 - fl;
		}else{
			int f;
			scanf("%d",&f);
			getchar();
			char ch;
			if(f == 1){
				scanf("%c",&ch);
				if(!fl) s1 += ch;
				else s2 += ch;
			}else{
				scanf("%c",&ch);
				if(!fl) s2 += ch;
				else s1 += ch;
			}
		}
	}
	if(fl){
		for(int i = s2.size()-1;i >= 0;i--) printf("%c",s2[i]);
		for(int i = s.size()-1;i >= 0;i--) printf("%c",s[i]);
		for(int i = 0;i < s1.size();i++) printf("%c",s1[i]);
	}
	else{
		for(int i = s1.size()-1;i >= 0;i--) printf("%c",s1[i]);
		for(int i = 0;i < s.size();i++) printf("%c",s[i]);
		for(int i = 0;i < s2.size();i++) printf("%c",s2[i]);		
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1088
#include <algorithm>
#include <cmath>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define MP make_pair

typedef long long LL;
typedef pair<int,int> PII;

double dist(int xp,int xq,int xr,int yp,int yq,int yr,int vw,int vc) {
	
//	double ret = 0;
	double t = ((double)(xp-xr) + ((double)((xq-xp) * (yp-yr)) / (yp-yq) ) )/ (double)vc;
	double s = sqrt((double)((xq-xp)*(xq-xp)+(yq-yp)*(yq-yp))) * ((double)   (yr-yq)/(yp-yq));
	s /= (double)(vw);
	if(t<0) t=-t;
//	cout<<xp<<" "<<yp<<endl;
	//cout<<xq<<" "<<yq<<endl;
//	cout<<xr<<" "<<yr<<endl;
//	cout<<"ret "<<t+s<<endl;
	double ret = t+s;
	//if(ret<0) ret = -ret;
//	cout<<" ts"<<t<<" "<<s<<endl;
	return ret;
	
	
}



int main(){
	while(1) {
		int n;
		cin>>n;
		if(n==0) break;
		int vw,vc;
		cin>>vw>>vc;
		vector<int > x;
		vector<int>y;
		for(int a=0; a<n; a++) {
			int p,q;
			cin>>p>>q;
			x.push_back(p) ;
			y.push_back(q) ;
		}
		
		double DP[2000];
		for(int a=0; a<n; a++) DP[a] =100000.00;
		
		DP[0] = 0.00;
		for(int a=1; a<n; a++) {
			int Min = 30000;
			if(y[a-1]>y[a]) for(int b=a-1; b>=0; b--) {
				if(Min>y[b]) {
//				    cout<<y[b]<<endl;
					Min = y[b];
					if(Min<y[a]) {
				    	double hoge = dist(x[b+1],x[b],x[a],y[b+1],y[b],y[a],vw,vc) ;
				    	if(DP[b]+hoge < DP[a]) DP[a] = DP[b]+hoge;
				    	
				    	break;
				    }
					double hoge = dist(x[a-1],x[a],x[b],y[a-1],y[a],y[b],vw,vc) ;
		//			cout<<DP[b]<<" "<<hoge<<" "<<DP[a]<<endl;
					if(DP[b]+hoge < DP[a]) {
						DP[a] = DP[b]+hoge;
	//					cout<<"jge"<<DP[a]<<endl;
				//	cout<<DP[a]<<endl;
				     }
				}
				
				
					
			}
			else DP[a] = DP[a-1] + sqrt( (double)( (y[a]-y[a-1])*(y[a]-y[a-1])+(x[a]-x[a-1])*(x[a]-x[a-1])  ) ) /(double)vw ;	
	//		cout<<a<<" "<<DP[a]<<endl;
		}		
		printf("%.8lf\n",DP[n-1]);   
		
	}
	return 0;
	
	
}

Measured memory_bytes: 0
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!

const Main = (p)=>{
	// 1行目がinput[0], 2行目がinput[1], …に入る
	
	//let t = input[0].split(" ").map(Number);
	//文字列から10進数に変換するときはparseIntを使います
	//出力
	console.log(p[0]==="7"||p[1]==="7"||p[2]==="7"?"Yes":"No");
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())


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

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

int main(){
    ll a,b;
    cin >> a >> b;

    cout << lcm(a,b) << endl;

    return 0;
}

Measured memory_bytes: 3624
import Control.Applicative

import Data.Char
    (isLower, isUpper, toLower, toUpper)

convert :: Char -> Char

convert char
    | isLower char
        = toUpper char
        
    | isUpper char
        = toLower char
        
    | otherwise
        = char

solve :: String -> String

solve text
    = map convert text

main :: IO ()

main
    = putStrLn =<< solve <$> getLine

Measured memory_bytes: 3644
#include<iostream>
#include<map>
#include<string>
#include<set>

using namespace std;

string s;
map<int, char>mp;
set<string>st;
int c[105];
bool ans = true;


int main(){
  cin >> s;
  //int cnt = 0;
  for(int i = 0; i < s.size(); ++i){
    c[s[i] - 'a']++;
  }
  for(int i = 0; i < 26; i++){
    if(c[i] % 2 == 1){
      ans = false;
    }
  }
  
  if(ans == true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;
int main(void){
    mp::cpp_dec_float_100 a;
    mp::cpp_dec_float_100 b;
    cin >> a >> b;
    b *= 100;
    a *= b;
    a /= 100;
    mp::cpp_int n { mp::cpp_dec_float_50(mp::floor(a)).str() };
    cout << n;
    return 0;
}


Measured memory_bytes: 3888
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in(),x;
	set<int> s;
	while(n--)
	{
		x=in();
		if(s.find(x)==s.end())s.insert(x);
		else s.erase(x);
	}	
	cout<<s.size();
	
}

Measured memory_bytes: 8340
import sys
import heapq

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    K, T = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    h = []
    for i in range(T):
        heapq.heappush(h, (-A[i], i))

    ans = 0
    p = -1

    while h:
        c = heapq.heappop(h)
        if p == c[1]:
            if h:
                c2 = heapq.heappop(h)
                heapq.heappush(h, c)
                x = c2[0]
                y = c2[1]
                p = y
                x += 1
                if x != 0:
                    heapq.heappush(h, (x, y))
            else:
                ans = c[0]
                break
        else:
            x = c[0]
            y = c[1]
            x += 1
            p = y
            if x != 0:
                heapq.heappush(h, (x, y))

    print(-ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9284
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main(void){
    
    string s,p;
    cin>>s>>p;
    
    int ls=s.length();
    int lp=p.length();
    
    string ss=s+s;
    int i,j;

    for(i=0;i<ls;i++){
        j=0;
        while(ss[i+j]==p[j]){
            j++;
            if(j==lp){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    
    cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 3212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			Restaurant[] list = new Restaurant[N];
			for (int i = 0; i < N; i++) {
				string[] vs = Console.ReadLine().Split();
				list[i] = new Restaurant() { Index = i + 1, City = vs[0], Score = int.Parse(vs[1]) };
			}

			foreach (var r in list.OrderByDescending(p => p.Score).OrderBy(p => p.City)) {
				Console.WriteLine(r.Index);
			}
		}
	}

	public class Restaurant
	{
		public int Index;
		public string City;
		public int Score;
	}
}


Measured memory_bytes: 11604
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int dy[5] = {-1, 0, 1, 0, 0};
int dx[5] = {0, -1, 0, 1, 0};

int main(void) {
    int n,a,b;

    cin>>n>>a>>b;

    cout<<min(n*a,b)<<endl;

    return 0;
}


Measured memory_bytes: 256
/*
    Author : DemonStar
*/

#pragma GCC optimize("Ofast")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define loop(i, n) for(ll i = 0; i < n; i++)
#define pl pair<ll, ll>
#define vl vector<ll>
#define endl '\n'
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        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);
    }
};


template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

ll calc(vl &cnt) {
    for (int i = 0; i < cnt.size(); i++) {
        if (!cnt[i]) return i;
    }
    return cnt.size();
}

int main()
{

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    fast;
    ll n;
    cin >> n;
    cout << ((n + 999) / 1000) * 1000 - n << endl;


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s";
#endif

    return 0;
}

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

int main()
{
	int n;
	string s;
	cin >> n >> s;
	vector<vector<ll>> cnt(4,vector<ll>(n));
	vector<int> v(n);
	for(int i = 0;i<n;i++)
	{
		if(s[i]=='R')cnt[1][i]++,v[i]=1;
		if(s[i]=='G')cnt[2][i]++,v[i]=2;
		if(s[i]=='B')cnt[3][i]++,v[i]=3;
	}
	for(int i = 0;i<3;i++)
	{
		for(int j = n-1;j>0;j--)
		{
			cnt[i+1][j-1] += cnt[i+1][j];
		}
	}
	ll ans = 0;
	//for(int i = 0;i<n;i++)cout<<cnt[0][i]<<endl;
	for(int i = 0;i<n-2;i++)
	{
		for(int j = i+1;j<n-1;j++)
		{
			//cout<<(v[i]^v[j])<<endl;
			if(s[i]!=s[j])ans += cnt[(v[i]^v[j])][j];
		}
	}
	//cout<<ans<<endl;
	for(int i = 1;i<n;i++)
	{
		for(int j = 0;j<n;j++)
		{
			if(j+i*2>=n)break;
			//cout<<v[j]<<';'<<v[j+i]<<';'<<v[j+i*2]<<endl;
			if((v[j]^v[j+i])==v[j+i*2])ans --;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3688
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn gcd(mut a: i32, mut b: i32) -> i32 {
    while b != 0 {
        let r = a % b;
        a = b; b = r;
    }
    a
}
fn lcm(x: i32, y: i32)->i32{
    return x /gcd(x, y) * y;
}
fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!{
        a:i32, b:i32,
    }
    let r = (a + b)%2;
    if r==0{
        println!("{}", (a + b)/2);
    }else{
        println!("IMPOSSIBLE");
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int n, q, s, t;
LL a[200100];
LL ans;

LL calc(LL lll) {
	if (lll > 0) {
		return -lll * s;
	}
	else {
		return -lll * t;
	}
}
int main() {
	cin >> n >> q >> s >> t;
	LL prev = 0;
	LL in;
	for (int i = 0; i <= n; i++) {
		cin >> in;
		a[i] = in - prev;
		ans += calc(a[i]);
		prev = in;
	}
	LL l, r, x;
	for (int i = 0; i < q; i++) {
		cin >> l >> r >> x;
		r++;
		ans -= calc(a[l]);
		a[l] += x;
		ans += calc(a[l]);
		if (r <= n) {
			ans -= calc(a[r]);
			a[r] -= x;
			ans += calc(a[r]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 4660
extension String: CollectionType {
    static func getValues(separator: Character = " ") -> [String] {
        return readLine()!.split(separator)
    }
}

typealias PX = (P: Int, X: Int)

let N = Int(String.getValues()[0])
let T = String.getValues().map {Int($0)!}
let M = Int(String.getValues()[0])!

var PXs = [PX]()
(0 ..< M).forEach { i in
    let values = String.getValues()
    let P = Int(values[0])!
    let X = Int(values[1])!
    PXs.append(PX(P, X))
}

let sum = T.reduce(0) { value, current -> Int in
    value + current
}

let results = PXs.map { px -> Int in
    let diff = px.X - T[px.P - 1]
    return sum + diff
}

results.forEach { r in
    print(r)
}


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

int main() {
    int n;
    cin >> n;
    string w;
    int maxNumber = 0;
    map<string, int> strMap;
    for(int i=0;i<n;i++){
        cin >> w;
        maxNumber = max(maxNumber, ++strMap[w]);
    }
    vector<string> str;
    for(auto itr=strMap.begin(); itr!=strMap.end(); itr++){
        if(itr->second == maxNumber) str.push_back(itr->first);
    }
    sort(str.begin(), str.end());
    for(string s : str){
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 26868
n,m=map(int,input().split())
h=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(m)]
connection=[[0] for i in range(n)]
for i in range(m):
  connection[l[i][0]-1].append(h[l[i][1]-1])
  connection[l[i][1]-1].append(h[l[i][0]-1])
ans=0
for i in range(n):
  if max(connection[i])<h[i]:
    ans+=1
print(ans)

Measured memory_bytes: 110820
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.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
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);
        C4Adjacent solver = new C4Adjacent();
        solver.solve(1, in, out);
        out.close();
    }

    static class C4Adjacent {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int one = 0, two = 0, four = 0;
            for (int i = 0; i < n; i++) {
                int val = in.nextInt() % 4;
                switch (val) {
                    case 0:
                        four++;
                        break;
                    case 2:
                        two++;
                        break;
                    default:
                        one++;
                        break;
                }
            }

            if (four > 0) {
                n -= four * 2 + 1;
            }

            if (two > 0) {
                n -= (two / 2) * 2;
            }

            boolean answer = n <= 0;
            out.println(answer ? "Yes" : "No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

int main()
{
	int N, K;
	cin >> N >> K;

	vector<bool> A(N, false);

	for (int i = 0; i < K; ++i)
	{
		int d;
		cin >> d;

		for (int j = 0; j < d; ++j)
		{
			int a;
			cin >> a;
			--a;

			A[a] = true;
		}
	}

	int count = 0;
	for (auto a : A)
	{
		if (!a)
		{
			++count;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3624
use std::io;
use std::collections::VecDeque;


fn main() {
    let (n, q) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut node = vec![Vec::new(); n];
    let mut score = vec![0; n];

    for _ in 0..n - 1 {
        let (a, b) = {
            let i = read::<usize>();
            (i[0] - 1, i[1] - 1)
        };
        node[a].push(b);
        node[b].push(a);
    }

    for _ in 0..q {
        let (p, x) = {
            let i = read::<usize>();
            (i[0] - 1, i[1])
        };
        score[p] += x;
    }

    let mut que = VecDeque::new();
    que.push_back((0, 0));
    while let Some((p, v)) = que.pop_front() {
        for &c in node[v].iter() {
            if c == p { continue; }
            // println!("score[{}] += {}", c, score[v]);
            score[c] += score[v];
            que.push_back((v, c));
        }
    }
    let ans = score.iter()
        .map(|&i| i.to_string())
        .collect::<Vec<String>>()
        .join(" ");
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 35064
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll dp[105][10];

void add(ll &a,ll b)
{
    a += b;
    if(a >= MOD)a -= MOD;
}

int main()
{
    IOS();
    ll h,w,k;
    dp[0][0] = 1;
    cin>>h>>w>>k;
    REP1(i,h)
    {
        REP(j,w)//last
        {
            REP(I,(1<<(w-1)))//bitmask
            {
                bool chk = 1;
                REP(t,w-2)if((I & (1<<t)) && (I & (1<<(t+1))))
                {
                    chk = 0;
                    break;
                }
                if(!chk)continue;
                if(j != 0 && (I & (1<<(j-1))))add(dp[i][j-1],dp[i-1][j]);
                else if(j != w-1 && (I & (1<<j)))add(dp[i][j+1],dp[i-1][j]);
                else add(dp[i][j],dp[i-1][j]);
            }
        }
    }
    cout<<dp[h][k-1]<<endl;
}


Measured memory_bytes: 256
#include <array>
#include <iostream>

int main() {
	int N, M;
	std::cin >> N >> M;

	std::array<int, 30> like{0};

	for(int i = 0; i < N; i++) {
		int K;
		std::cin >> K;

		for(int j = 0; j < K; j++) {
			int A;
			std::cin >> A;
			like[A - 1]++;
		}
	}

	int result = 0;
	for(int i = 0; i < M; i++) {
		if(like[i] == N) {
			result++;
		}
	}

	std::cout << result << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <cassert>
#include <set>
#include <map>
#include <bitset>
#include <unordered_set>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#include <climits>

#define forn(x, n)             for (int x = 0; x < n; x++)
#define fore(x, a, b, c)       for (int x = a; x <= b; x += c)
#define all(container)         (container).begin(), (container).end()
#define rall(container)        (container).rbegin(), (container).rend()
#define sz(container)          (int) container.size()
#define fi                     first
#define se                     second
using namespace std;

#ifdef LOCAL_DEFINE
    #include "../DEBUG.hpp"
#else
    #define dmp(...) 0
#endif

using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const ll maxn = 1e18;
int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif

    int n;
    cin >> n;
    vll arr(n);
    bool ok = false;
    forn(i, n) {
        cin >> arr[i];
        if (!arr[i]) ok = true;
    }
    if (ok) {
        cout << 0 << '\n';
        return 0;
    }
    ll ans = 1;
    forn(i, n) {
        if (maxn / arr[i] < ans) {
            cout << -1 << '\n';
            return 0;
        }
        ans *= arr[i];
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << '\n';
#endif
    return 0;
}

Measured memory_bytes: 3988
#include <stdio.h>
int main()
{
    int n;  scanf("%d", &n);
    int arr[100005] = {0};
    int ans[100005] = {0};
    for(int i=1; i<=n; i++)
        scanf("%d", &arr[i]);
    for(int i=1; i<=n; i++)
        ans[arr[i]]=i;
    for(int i=1; i<=n; i++)
        printf("%d ", ans[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d,sum = 0,max =0;
		for(int i = 0; i < 5; i++) {
			d = sc.nextInt();
			int t = 0;
			t += Math.ceil((double)d/ 10) * 10;
			sum += t;
			if(max < t - d) {
				max = t-d;
			}
		}
		System.out.println(sum - max);
		sc.close();
	}
}

Measured memory_bytes: 23508
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int n, x; cin >> n >> x;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  int cnt = 1;
  int cur = 0;

  for (int i = 0; i < n; ++i) {
    cur += l[i];
    if (cur > x) {
      print(cnt); return 0;
    }
    ++cnt;
  }
  print(cnt);

  return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
broken = set()
for i in range(M):
    broken.add(int(input()))
dp = [0 for i in range(N+1)]
dp[0] = 1
if 1 not in broken:
    dp[1] = 1
for i in range(2,N+1):
    if i in broken:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= 1000000007
print(dp[N])

Measured memory_bytes: 17340
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}


////////////////////////////////////////////////////////////////////

int main(){
string s,t;
cin>>s>>t;
string an="";
for(int i=0;i<t.size();i++){
an+=s[i];
an+=t[i];
}
if(s.size()>t.size()){
	an+=s[s.size()-1];
}
cout<<an<<endl;
return 0;

}


Measured memory_bytes: 256
import bisect
from collections import deque
N = int(input())
nums = [int(input()) for _ in range(N)]
# i<jで、 AiとAjが同じ色で塗られている場合、Ai < Ajが成り立つ.
# その際に、色の最小数をだす。
LIS = deque([nums[0]])
count = 0
for index, num in enumerate(nums):
    if index == 0:
        continue
    if num <= LIS[0]:
        LIS.appendleft(num)
    else:
        insert_index = bisect.bisect_left(LIS, num)
        LIS[insert_index - 1] = num
print(len(LIS))


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

int main(){
    int N, T;
    cin >> N >> T;
    vector<int> imos(T+1);
    for(int i=0; i<N; i++){
        int l, r; cin >> l >> r;
        imos[l]++;
        imos[r]--;
    }
    for(int i=0; i<T; i++)
        imos[i+1] += imos[i];
    
    int ans = 0;
    for(int i=0; i<T+1; i++)
        ans = max(ans, imos[i]);
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3108
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 10000005
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], spf[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

void seivePF() {
	for(int i = 2; i <= 10000000; i += 2) {
		spf[i] = 2;
	}
	for(ll i = 3; i <= 10000000; i += 2) {
		if(!spf[i]) {
			spf[i] = i;
			for(ll j = i; i * j <= 10000000; j += 2) {
				if(!spf[i * j]) {
					// trace2(i, j);
					spf[i * j] = i; 
				}
			}
		}
	}
}

void _findFactors(ll X) {
	while(X > 1) {
		V.push_back(spf[X]);
		X /= spf[X];
	}
}

int main() {
	go;
    cin >> N;
    seivePF();
	ll ans = 0;
    fei(i, 1, N, 1) {
    	ll val = i;
    	V.clear();
    	mp.clear();
    	_findFactors(val);
    	fi(j, 0, V.size(), 1) {
    		mp[V[j]]++;
    	}
    	ll prod = i;
    	for(auto x: mp) {
    		prod *= x.ss + 1;
    	}
    	ans += prod;
    }
    cout << ans << "\n";
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 81732
let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

let rec repl () =
  let l = read_line () in
  match List.map int_of_string (split l ' ') with
  | [] | [_] -> exit 1
  | 0 :: 0 :: _ -> ()
  | n :: x :: _ ->
      let cnt = ref 0 in
      for a = 1 to n - 2 do
        for b = a + 1 to n - 1 do
          let c = x - a - b in
          if b < c && c <= n then cnt := !cnt + 1
        done;
      done;
      Printf.printf "%d\n" !cnt;
      repl ()

let () =
  try repl () with End_of_file -> ()

Measured memory_bytes: 2316
#include <iostream>
#include <algorithm>
using namespace std;
 
long long A, B, C, X, Y, minx = (1LL << 60);
 
int main() {
	cin >> A >> B >> C >> X >> Y;
	for (long long i = 0; i <= 100000; i++) {
		long long x = max(0LL, X - i);
		long long y = max(0LL, Y - i);
		minx = min(minx, x*A + y*B + i*C * 2);
	}
	cout << minx << endl;
	return 0;
}

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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> P(N), Q(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> P[i];
    }
    for (int64_t i = 0; i < N; i++) {
        cin >> Q[i];
    }

    vector<int64_t> v(N);
    iota(v.begin(), v.end(), (int64_t)1);
    int64_t a = -1, b = -1;
    for (int64_t i = 1; ; i++) {
        if (v == P) {
            a = i;
        }
        if (v == Q) {
            b = i;
        }
        if (!next_permutation(v.begin(), v.end())) {
            break;
        }
    }

    cout << abs(a - b) << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 10000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n;
int a[100000 + 5], b[100000 + 5];
int imos[100000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) {
        cin >> a[i] >> b[i];
        imos[a[i]]++;
        imos[b[i] + 1]--;
    }
    rep(i, 100000 + 3) imos[i + 1] += imos[i];
    int ans = 0;
    rep2(i, 2, 100000 + 5) {
        if (i <= imos[i]) ans = i - 1;
        else if (i == imos[i] + 1) ans = imos[i];
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
  int n, x = 100000;
  cin >> n;
  for (int i = 0; i < n; i++) {
    x += x / 20;
    x = (x + 999) / 1000 * 1000;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int ans = 0;
		int N = scn.nextInt(), nige = scn.nextInt()-1, oni = scn.nextInt()-1;
		GraphWay[] GW = new GraphWay[N];
		for(int i = 0;i < N;i++) {
			GW[i] = new GraphWay();
		}
 		for(int i = 0;i < N-1;i++) {
 			int A = scn.nextInt()-1, B = scn.nextInt()-1;
 			GW[A].add(B, 1);
 			GW[B].add(A,1);
		}
 		int[]d = new int[N];
 		int[] prev = GraphArgo.dikstra(oni,d,GW);

 		ArrayList<Integer> way = new ArrayList<Integer>();
 		int s = nige;
 		while(s>-1) {
 			way.add(s);
 			s = prev[s];
 		}

 		int size = way.size();
 		if(size %2 == 0) {
 			ans += size/2 - 1;
 			nige = way.get(size/2 - 1);
 			GW[way.get(size/2-1)].remove(way.get(size/2));
 		}else {
 			ans += size/2;
 			nige = way.get(size/2 - 1);
 			GW[way.get(size/2-1)].remove(way.get(size/2));
 		}
 		prev = GraphArgo.dikstra(nige, d, GW);
 		int max = -1;
 		for(int i = 0;i < N;i++) {
 			if(d[i] == GraphArgo.INF)continue;
 			max = Math.max(max, d[i]);
 		}
 		ans += max;
 		System.out.println(ans);
	}


}

class GraphWay{//有向パス
	ArrayList<Pair> to;
	public GraphWay() {
		to = new ArrayList<Pair>();
	}

	void add(int t,int c) {
		to.add(new Pair(t,c));
	}

	void remove(int t) {
		for(int i = 0;i < to.size();i++) {
			if(to.get(i).first == t) {
				to.remove(i);
				return;
			}
		}
	}

	Iterable<Pair> getItr() {
		return to;
	}
}

class GraphArgo{
	static final int INF = Integer.MAX_VALUE;
	// -----2.2---------------------------------------------------------------------------//
	// -----ダイクストラ法---------------------------------------------------------//
	// 負の辺がない場合
	// 無向グラフでの実装
	public static int[] dikstra(int s,int[] d, GraphWay[] W) {// @param s:satrt d[]:distance W[]:ways
		PriorityQueue<Pair> PQ = new PriorityQueue<Pair>();//first:distance second:node
		int[] prever = new int[W.length];
		Arrays.fill(prever,-1);
		Arrays.fill(d, INF);
		d[s] = 0;
		PQ.add(new Pair(0,s));
		while(!PQ.isEmpty()) {
			Pair p = PQ.poll();
			int v = p.second;
			if(d[v] < p.first)continue;
			for(Pair w:W[v].getItr()) {
				int to = w.first;
				int cost = w.second;
				if(d[to] > d[v] + cost) {
					d[to] = d[v] + cost;
					PQ.add(new Pair(d[to],to));
					prever[to] = v;
				}
			}
		}
		return prever;
	}

}

class Pair implements Comparable<Pair>{
	int first,second;
	public Pair(int f,int s) {
		this.first = f;
		this.second = s;
	}
	@Override
	public int compareTo(Pair o) {//Comparatorを自由記述せよ(これはfirstが小さい順, secondが小さい順)
		if(this.first < o.first) {
			return -1;
		}
		if(this.first > o.first) {
			return 1;
		}
		if(this.second < o.second) {
			return -1;
		}
		if(this.second > o.second) {
			return 1;
		}

		return 0;
	}
}


Measured memory_bytes: 107340
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (x[x.size()-1])

using namespace std;

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

struct Box {
  Int w, h;
  Box() {}
  Box(Int w, Int h): w(w), h(h) {}
  bool operator < (const Box &v) const {
    if (w < v.w && h < v.h) return true;
    if (w == v.w) return h < v.h;
    return w < v.w;
  }
};

bool equal(string a, string b) {
  loop(n,0,a.size()) {
    if (a[n] == '?') continue;
    if (a[n] != b[n]) return false;
  }
  return true;
}

Int find(string &a, string &b) {
  loopdown(n,a.size()-b.size(), -1) {
    if (equal(a.substr(n, b.size()), b)) return n;
  }
  return -1;
}

string S, T;

void input() {
  cin >> S >> T;
}

void solve() {
  auto index = find(S, T);
  if (index < 0) {
    cout << "UNRESTORABLE" << endl;
    return;
  }

  loop(n,0,S.size()) {
    if (index <= n && n < (index+T.size())) cout << T[n-index];
    else if (S[n] == '?') cout << 'a';
    else cout << S[n];
  }
  cout << endl;
  return;
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,n,a,b;cin>>h>>n;
  vector<P> v(n);
  rep(i,n) {cin>>a>>b;v[i]=P(a,b);}
  lvector dp(2e4+10,1e10);dp[0]=0;
  rep(i,n) {
    a=v[i].first,b=v[i].second;
    rep(j,h) if(dp[j+a]>dp[j]+b) dp[j+a]=dp[j]+b;
  }
  ll ans=*min_element(dp.begin()+h,dp.end());
  print(ans);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }
#define ll long long
#define ld long double

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	map<string, int> mp;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << '\n';
	cout << "WA x " << mp["WA"] << '\n';
	cout << "TLE x " << mp["TLE"] << '\n';
	cout << "RE x " << mp["RE"];
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

string S;

ll slove(ll c=0,ll sum=0,ll memo=0){
  memo*=10;
  if(c==S.size()-1)return sum+memo+(S[c]-'0');
  return slove(c+1,sum,memo+(S[c]-'0'))
            + slove(c+1,sum+memo+(S[c]-'0'),0);
}


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

  cin>>S;
  cout<<slove()<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    ll n,m;
    cin>>n>>m;
    vp vec(n);
    cin>>vec;
    sort(all(vec));
    ll ans=0;
    ll sum=0;
    REP(i,n){
        if(sum+vec[i].se>=m){
            ans+=vec[i].fi*(m-sum);
            break;
        }else{
            ans+=vec[i].se*vec[i].fi;
            sum+=vec[i].se;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int k,x;
    cin>>k>>x;
    int l = max(-1000000,x-k+1);
    int r = min(1000000,x+k-1);
    for(int i=l; i<=r; i++) cout<<i<<" ";
    return 0;
}

Measured memory_bytes: 256