akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;

int main() {
   string a,b;
   cin >> a >> b;
   if(a.size()>b.size())
   cout << "GREATER" << endl;
   else if(a.size()<b.size())
   cout << "LESS" << endl;
   else if(a>b)
   cout << "GREATER" << endl;
   else if(a<b)
   cout << "LESS" << endl;
   else 
   cout << "EQUAL" << endl;
}

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

int main(int argc, char *argv[])
{
	bool ans = false;
	int i, N;
	int tx, ty;
	int tmpH;
	cin >> N;
	int x[N], y[N], h[N];

	for (i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> h[i];
	}

	for (tx = 0; tx < 101; tx++) {
		for (ty = 0; ty < 101; ty++) {
			tmpH = -1;
			ans = true;
			for (i = 0; i < N; i++) {
				if (tmpH == -1 && h[i] != 0) {
				   	tmpH = h[i] + abs(tx - x[i]) + abs(ty - y[i]);
					break;
				}
			}
			for (i = 0; i < N; i++) {
				if (max((tmpH - abs(tx - x[i]) - abs(ty - y[i])), 0) != h[i])
					ans = false;
			}
			if (ans == true) {
				cout << tx << ' ' << ty << ' ' << tmpH << endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	char c;
	cin>>c;
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
	
	cout<<"vowel"<<endl;
	else
	cout<<"consonant"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>

long min(long x, long y){
  if(x<y) return x;
  else return y;
}

int main(){
  long long int c,x[100001],v[100000],a[100000][2]={},b[100000][2]={},am[100000]={},bm[100000]={},max=0;
  int n,i,ap[100000],bp[100000],p;
  scanf("%d %ld",&n,&c);
  for(i=0;i<n;i++){
    scanf("%ld %ld",&x[i],&v[i]);
  }
  ap[0]=bp[n-1]=100000;
  x[100000]=0;
  a[0][0]=v[0]-x[0];
  a[0][1]=a[0][0]-x[0];
  if(a[0]>0){
    am[0]=a[0][0];
    ap[0]=0;
  }
  for(i=1;i<n;i++){
    a[i][0]=a[i-1][0]+v[i]-x[i]+x[i-1];
    a[i][1]=a[i][0]-x[i];
    if(am[i-1]<a[i][0]){
      am[i]=a[i][0];
      ap[i]=i;
    }
    else{
      am[i]=am[i-1];
      ap[i]=ap[i-1];
    }
  }
  b[n-1][0]=v[n-1]-c+x[n-1];
  b[n-1][1]=b[n-1][0]-c+x[n-1];
  if(b[n-1][0]>0){
    bm[n-1]=b[n-1][0];
    bp[n-1]=n-1;
  }
  for(i=n-2;i>=0;i--){
    b[i][0]=b[i+1][0]+v[i]+x[i]-x[i+1];
    b[i][1]=b[i][0]-c+x[i];
    if(bm[i+1]<b[i][0]){
      bm[i]=b[i][0];
      bp[i]=i;
    }
    else{
      bm[i]=bm[i+1];
      bp[i]=bp[i+1];
    }
  }
  if(max<bm[0]){
    max=bm[0];
  }
  if(max<am[n-1])
    max=am[n-1];
  for(i=1;i<n;i++){
    if(max<b[i][0]+am[i-1]-min(c-x[i],x[ap[i-1]])){
      max=b[i][0]+am[i-1]-min(c-x[i],x[ap[i-1]]);
    }
  }
  for(i=0;i<n-1;i++){
    if(max<a[i][0]+bm[i+1]-min(x[i],c-x[bp[i+1]])){
      max=a[i][0]+bm[i+1]-min(x[i],c-x[bp[i+1]]);
    }
  }
  printf("%ld\n",max);
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {    
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    if (y < 2019 || (y == 2019 && m < 4) || (y == 2019 && m == 4 && d <= 30)) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int a,b;
    String C="Start";
    while(!(C.equals("?"))){
      a = scanner.nextInt();
      C = scanner.next();
      b = scanner.nextInt();
      if(!(C.equals("?"))){
        switch(C){
          case "+": System.out.println(a+b);break;
          case "-": System.out.println(a-b);break;
          case "*": System.out.println(a*b);break;
          case "/": System.out.println(a/b);break;
        }
      }
    }
  }
}



Measured memory_bytes: 26412
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x,y;
    while(cin>>a>>b>>c>>x>>y)
    {
        int s=0;
        if(2*c<=a+b)
        {
            s=a*x+b*y+(2*c-a-b)*min(x,y);
            if(s>2*c*max(x,y))
                s=2*c*max(x,y);
        }
        else
            s=a*x+b*y;
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>
using namespace std;
int main(int argc, const char *argv[])
{
    int n;
    cin >> n;
    vector<int> v(n);
    double sum = 0, avg;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        sum += v[i];
    }

    avg = sum / n;
    int ans = 0;
    for (int i = 1; i < n; i++)
    {
        if (abs(v[i] - avg) < abs(v[ans] - avg))
        {
            ans = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
//        int t = in.nextInt();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            int n = in.nextInt();
            int k = in.nextInt();
            Queue<Long> heap = new PriorityQueue<>(Collections.reverseOrder());
            for (int i = 0; i < n; i++) {
                heap.add(in.nextLong());
            }
            if (k >= n){
                out.println(0);
                return;
            }
            for (int i = 0; i < k; i++) {
                heap.remove();
            }
            long ans = 0;
            while (!heap.isEmpty()){
                ans += heap.remove();
            }
            out.println(ans);
        }
    }

    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 long nextLong() {
            return Long.parseLong(next());
        }

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

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

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() throws IOException {
            return reader.readLine().trim();
        }
    }
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int X, Y; cin >> X >> Y;
    for (int i = 0; i <= X; i++) {
        if (i * 2 + (X - i) * 4 == Y) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3588
package main

import "fmt"

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func p(x, y int) int {
	fmt.Println(x, y)
	return x - y
}

func main() {
	var n int
	fmt.Scan(&n)
	xs := make([]int, n)
	for i := range xs {
		fmt.Scan(&xs[i])
	}

	num_neg := 0
	neg_i := 0
	pos_i := 0
	abs_min_i := 0
	abs_min := abs(xs[0])
	abs_sum := 0
	for i, x := range xs {
		if x < 0 {
			num_neg++
			neg_i = i
		} else {
			pos_i = i
		}
		abs_sum += abs(x)
		if v := abs(x); abs_min > v {
			abs_min = v
			abs_min_i = i
		}
	}

	ans := 0
	if num_neg == 0 {
		ans = abs_sum - 2*abs_min
	} else if num_neg == 1 {
		ans = abs_sum
	} else if num_neg == n {
		ans = abs_sum - 2*abs_min
	} else {
		ans = abs_sum
	}
	fmt.Println(ans)

	if num_neg == 0 {
		j := 0
		v := abs_min
		for i := 0; i < n-2; i++ {
			if abs_min_i == j {
				j++
			}
			v = p(v, xs[j])
			j++
		}
		if abs_min_i == j {
			j++
		}
		v = p(xs[j], v)
	} else if num_neg == 1 {
		v := xs[neg_i]
		j := 0
		for i := 0; i < n-2; i++ {
			if neg_i == j {
				j++
			}
			v = p(v, xs[j])
			j++
		}
		if neg_i == j {
			j++
		}
		v = p(xs[j], v)
	} else if num_neg == n {
		j := 0
		v := xs[abs_min_i]
		for i := 0; i < n-1; i++ {
			if abs_min_i == j {
				j++
			}
			v = p(v, xs[j])
			j++
		}
	} else {
		neg := xs[neg_i]
		pos := xs[pos_i]
		j := 0
		for i := 0; i < n-2; i++ {
			if neg_i == j || pos_i == j {
				j++
			}
			if x := xs[j]; x < 0 {
				pos = p(pos, xs[j])
			} else {
				neg = p(neg, xs[j])
			}
			j++
		}
		p(pos, neg)
	}
}


Measured memory_bytes: 8872
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
    string s;
    ll k;

    auto f = [&] (ll n)
    {
        return n / 2;
    };

    auto cnt = [] (string r)
    {
        int p = 0;
        while (r[0] == r[p])
            p++;
        return p;
    };

    auto solve_test = [&] {
        if (s == string(s.size(), s[0]))
            return f(k * ll(s.size()));

        const int cnt_left = cnt(s);
        reverse(s.begin(), s.end());
        const int cnt_right = cnt(s);
        reverse(s.begin(), s.end());

        ll ans = 0;
        for (int i = cnt_left, j; i < int(s.size()) - cnt_right; i = j)
        {
            for (j = i; j < int(s.size()) && s[j] == s[i];  )
                j++;

            ans += f(j - i) * k;
        }

        if (s[0] == s.back())
            ans += (k - 1) * f(cnt_left + cnt_right) + f(cnt_left) + f(cnt_right);
        else
            ans += k * (f(cnt_left) + f(cnt_right));
        return ans;
    };

    while (cin >> s >> k)
    {
        auto x = solve_test();
        cout << x << endl;
//        break;
    }
}

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

    cout << fixed;

#ifdef LOCAL
    auto st = clock();

    ifstream fin("../input.txt");

    solve(fin);

    cout << "clock: " << setprecision(4) << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
    solve();
#endif

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

inline int get(int n, int k) {
    if(n < 0)
        return 0;
    return n / k + 1;
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int n, k;
    ios::sync_with_stdio(false);
    cin >> n >> k;
    ll ans = 1LL * (n / k) * (n / k) * (n / k);
    for(int a = 1; a < k; a++) {
        if(2 * a == k)
            ans += 1LL * get(n - a, k) * get(n - a, k) * get(n - (k - a), k);
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}

int digit(int n){
  n /= 10;
  int res = 1;
  while(n){
    res++;
    n/=10;
  }

  return res;
}

int ketame(int x, int n, int y){
  rep(i, y - n){
    x /= 10;
  }

  return (x % 10);
}

int main() {
  int n, m; cin >> n >> m;
  vector<int> s(m), c(m);
  rep(i, m){
    cin >> s[i] >> c[i];
  }

  rep(i, 1000){
    if(n != digit(i)) continue;
    bool flag = true;
    rep(j, m){
      if(ketame(i, s[j], n) != c[j]) flag = false;
    }
    if(flag){
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple


ll n, m, a, b, ans;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


int n;

cin >> n;

if(n<=999){
    cout << "ABC" << endl;
}
else cout << "ABD" << endl;




return 0;}


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

int main() {
    int ans = 0;
    string S;
    cin >> S;
    if(S == "RRR")
        ans = 3;
    else if(S == "RRS" || S == "SRR")
        ans = 2;
    else if(S == "SSS")
        ans = 0;
    else
        ans = 1;
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
  int N,i,j,k,v;
  int A[1000];

  scanf("%d",&N);

  for(i=0;i<N;i++)
    {
    scanf("%d",&A[i]);
    }
    for(i=0;i<N-1;i++){
      printf("%d ",A[i]);
    }
    printf("%d\n",A[i]);
  


  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    
    while(j>=0 && A[j]>v)
    {
	A[j+1]=A[j];
	j--;
	A[j+1]=v;
    }
    
    for(k=0;k<N-1;k++){
      printf("%d ",A[k]);
    }
      printf("%d\n",A[k]);
  }
}



Measured memory_bytes: 2064
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	h := make([]int, n+1)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}

	var result int
LOOP:
	for {
		for i := 1; i < n+1; i++ {
			if h[i-1] > 0 {
				h[i-1]--
				if h[i] == 0 {
					result++
					break
				}
			}
			if i == n {
				if h[i-1] == 0 && h[i] == 0 {
					break LOOP
				}
			}
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int main(){
      unsigned s;
      int n;
      cin>>n;
      while(n--){
            scanf("%x",&s);
            int a=(s&0x7fffffffu)>>7;
            int b=(s&0x7fu)*78125;
            int d=7;
            while(d>1&&b%10==0){
                  b/=10;
                  --d;
            }
            if(s>>31)cout<<'-';
            printf("%d.%0*d\n", a, d, b);
      }
}

Measured memory_bytes: 1248
#include<iostream>
using namespace std;
int k;
int ans;

int main() {
    cin >> k;
    if ( k % 2 == 0) {
        ans = (k / 2) * (k / 2);
    } else {
        ans = (k / 2) * (k / 2 + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

/*二項係数(mod付き)*/
struct Combination{
	const int mod=1e9+7;
	const int num;				//num:=(要素数). 宣言時に適宜変更する!
	vector<llong> fact,inv,finv;//fact[i]:=(iの階乗),inv[i]:=(iの逆元),finv[i]:=(iの逆元の階乗).
	
	Combination(int num_=51e4):num(num_),fact(num_),inv(num_),finv(num_){
		fact[0]=fact[1]=1LL;
		inv[1]=1LL;
		finv[0]=finv[1]=1LL;
		for(int i=2;i<num;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){//組み合わせ.
		if(n<k or (n<0 or k<0)) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	template<typename Type>
	Type big_nCk(Type n,int k){//nが大きいときに使用.
		if(n<k or (n<0 or k<0)) return 0;
		llong res=1LL;
		REP(i,k) res=res*((n-i)%mod)%mod;
		res=res*finv[k]%mod;
		return (Type)res;
	}
	int nPk(int n,int k){//順列.
		if(n<k) return 0;
		return fact[n]*finv[n-k]%mod;
	}
	int nHk(int n,int k){return nCk(n+k-1,n-1);}//重複組み合わせ.
};

int main(){
	int s;
	cin>>s;
	
	llong ans=0LL;
	Combination ob;
	for(int i=1;;++i){
		int n=s/i, m=s%i;
		if(n<3) break;
		
		m=m+i*(n-3);
		ans=(ans+ob.nHk(i,m))%MOD;
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 15132
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  ll ans = 0;
  REP(i, n-1){
    ll d = a[i] + a[i+1] - x;
    if(d <= 0) continue;
    if(a[i+1] >= d){
      a[i+1] -= d;
      ans += d;
    }else{
      ans += d;
      a[i] -= d - a[i+1];
      a[i+1] = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();

    if ((A + B) == (C + D)) {
      System.out.println("Balanced");
    } else if ((A + B) < (C + D)) {
      System.out.println("Right");
    } else {
      System.out.println("Left");
    }

  }
}

Measured memory_bytes: 21716
#include <stdio.h>
int main( void )
{
	int x,num;
	
	num = 0;

	while( 1 )
	{
		num = num++;

		scanf( "%d", &x );
		if( x == 0 )
		{
			break;
		}
		else
		{
			printf( "Case %d: %d\n", num, x );
		}
	}

	return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

int main () {

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;


    string ans = "";
    int dh = ty - sy, dr = tx - sx;
    for (int i = 0; i < dh; i++) {
        ans += 'U';
    }
    for (int i = 0; i < dr; i++) {
        ans += 'R';
    }
    for (int i = 0; i < dh; i++) {
        ans += 'D';
    }
    for (int i = 0; i < dr; i++) {
        ans += 'L';
    }

    ans += 'L';
    for (int i = 0; i < dh + 1; i++) {
        ans += 'U';
    }
    for (int i = 0; i < dr + 1; i++) {
        ans += 'R';
    }
    ans += "DR";
    for (int i = 0; i < dh + 1; i++) {
        ans += 'D';
    }
    for (int i = 0; i < dr + 1; i++) {
        ans += 'L';
    }
    ans += 'U';

    cout << ans << endl;

    return 0;
}

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

template <typename T, typename U> void cmin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U> void cmax(T &a, U b) {
  if (a < b) a = b;
}

template <typename T, T (*op)(T, T), T (*ie)()>
class SegmentTree {
private:
  int N, size, log;
  vector<T> D;
  void apply(int k) { D.at(k) = op(D.at(2 * k), D.at(2 * k + 1)); }
  int ceil_pow(int n) {
    int x = 0;
    while ((1U << x) < (unsigned int)(n)) x++;
    return x;
  }

public:
  SegmentTree() : SegmentTree(0) {}
  SegmentTree(int n) : SegmentTree(vector<T>(n, ie())) {}
  SegmentTree(const vector<T> &v) : N((int)v.size()) {
    log = ceil_pow(N);
    size = 1 << log;
    D = vector<T>(2 * size, ie());
    for (int i = 0; i < N; i++) D.at(size + i) = v.at(i);
    for (int i = size - 1; i >= 1; i--) apply(i);
  }
  void set(int p, T x) {
    p += size;
    D.at(p) = x;
    for (int i = 1; i <= log; i++) apply(p >> i);
  }
  T get(int p) { return D.at(p + size); }
  T query(int l, int r) {
    r++;
    T sml = ie(), smr = ie();
    l += size, r += size;
    while (l < r) {
      if (l & 1) sml = op(sml, D.at(l++));
      if (r & 1) smr = op(D.at(--r), smr);
      l >>= 1, r >>= 1;
    }
    return op(sml, smr);
  }
  T query_all() { return D.at(1); }
  template <bool (*f)(T)> int max_right(int l) {
    return max_right(l, [](T x) { return f(x); });
  }
  template <class F> int max_right(int l, F f) {
    if (l == N) return N;
    l += size;
    T sm = ie();
    do {
      while (l % 2 == 0) l >>= 1;
      if (!f(op(sm, D.at(l)))) {
        while (l < size) {
          l = (2 * l);
          if (f(op(sm, D.at(l)))) sm = op(sm, D.at(l++));
        }
        return l - size;
      }
      sm = op(sm, D.at(l++));
    } while ((l & -l) != l);
    return N;
  }
  template <bool (*f)(T)> int min_left(int r) {
    return min_left(r, [](T x) { return f(x); });
  }
  template <class F> int min_left(int r, F f) {
    if (r == 0) return 0;
    r += size;
    T sm = ie();
    do {
      r--;
      while (r > 1 && (r % 2)) r >>= 1;
      if (!f(op(D.at(r), sm))) {
        while (r < size) {
          r = (2 * r + 1);
          if (f(op(D.at(r), sm))) sm = op(D.at(r--), sm);
        }
        return r + 1 - size;
      }
      sm = op(D.at(r), sm);
    } while ((r & -r) != r);
    return 0;
  }
};

using mono = int;
mono op(mono a, mono b) { return max(a, b); };
mono ie() { return 0; };

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

  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  int MX = 3e5;
  SegmentTree<mono, op, ie> ST(MX + 1);
  for (int i = 0; i < N; i++) {
    int l = A.at(i) - K;
    cmax(l, 0);
    int r = A.at(i) + K;
    cmin(r, MX);
    ST.set(A.at(i), ST.query(l, r) + 1);
  }
  cout << ST.query_all() << "\n";
}

Measured memory_bytes: 9780
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define ALL(c) c.begin(),c.end()
#define cat// cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef int ut;
typedef pair<ut,ut> pr;
typedef vector<ut> VI;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int SIZE=1e6;
//const ut INF=1LL<<60;
int BIT[SIZE];
int pairs[SIZE];
int times[SIZE];
LL ans=0;
int sum(int x){
	int ans=0;
	while(x>0){
		ans+=BIT[x];
		x-=x&-x;
	}
	return ans;
}
void add(int x,int p){
	while(x<=SIZE){
		BIT[x]+=p;
		x+=x&-x;
	}
}
int sum(int a,int b){
	if(a<=b) return sum(b)-sum(a-1);
	return 0;
}
void pairing(string s){
	FOR(i,'a','z'+1){
		vector<int> v;
		REP(j,s.size()){
			if(s[j]==i){
				v.PB(j);
			}			
		}
		REP(i,v.size()/2){
			int rev=v.size()-i-1;
			pairs[v[i]+1]=v[rev]+1;
			pairs[v[rev]+1]=v[i]+1;
			ans-=abs(v[i]-v[v.size()-i-1])-1;
		}
	}
}
int main(){
	string s;
	cin >> s;
	REP(i,s.size()){
		times[s[i]-'a']++;
	}
	int odds=0;
	REP(i,'z'-'a'+1){
		odds+=times[i]&1;
	}
	if(odds>=1){
		cout << -1 << endl;
		return 0;
	}
	LL pnum=s.size()/2;
	ans+=pnum*(pnum-1);
	//cout << ans << endl;
	pairing(s);
	FOR(i,1,s.size()+1){
		if(pairs[i]<i) {
			add(pairs[i],-1);
			ans+=sum(pairs[i]+1,i-1);
		}
		else{
			add(i,1);
		}

	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 6864
#include <bits/stdc++.h>
#define MAX 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */

void solve() {
	string s, t;
	cin >> s >> t;
	t += s;
	cout << t << endl;
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  set<char> ss;
  for (int i = 0; i < s.size(); ++i) {
    ss.insert(s[i]);
  }

  for (char i = 'a'; i <= 'z'; ++i) {
    if (ss.count(i) == 0) {
      cout << i << '\n';
      return 0;
    }
  }

  cout << "None" << '\n';
  return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int n,k;
    cin>>n>>k;
    int ans=0;
    rep(i,n)
    {
        int x;
        cin>>x;
        ans+=2*min(abs(k-x),abs(x));
    }
    cout<<ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long ans = sc.nextLong();
		for(int i = 1; i < n; i++) {
			ans = ans ^ sc.nextLong();
		}
		if(ans == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 47900
def sums(t,w):
    S = 0
    for i in range(t):
        S += w[i]
    return S

n = int(input())
w = list(map(int, input().split()))
S1 = 0 
c = []
W = sums(n,w)
for i in range(n-1):
    c.append(abs(2*sums(i+1,w) - W))
print(min(c))

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N, H, W = MAP()

ans = 0
for _ in range(N):
	A, B = MAP()
	if H <= A and W <= B:
		ans += 1

print(ans)

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

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int left = a+b;
    int right = c + d;
    if(left > right){
        cout << "Left" << endl;
    }else if(left < right){
        cout <<"Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }

}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string & str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/




int main() {

	string s;
	scans(s);
	int ans1 = 0, ans2 = 0;
	rep(i, s.length()) {
		ans1 += (s[i] == '0' + (i % 2));
		ans2 += (s[i] == '0' + not (i % 2));
	}
	printf("%d\n", min(ans1, ans2));

	Please AC;
}

Measured memory_bytes: 3856
#include <iostream>

using namespace std;

int main()
{
    string s;
    int x(0);
    long long ans(0);
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        x += (s[i] == 'B');
        ans += (s[i] == 'W') * x;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int n,max = 0,sum = 0;
  scanf("%d",&n);
  int a[n];
  for(int i = 0;i < n;i++){
    scanf("%d",&a[i]);
    sum += a[i];
    if(max < a[i]){
      max = a[i];
    }
  }
  printf("%d\n",sum - max / 2);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
 
info = []
 
for i in range(N):
    x,y,h = map(int,input().split())
    if h == 0:
        N -= 1
        continue
    info.append([x,y,h])
 
for i in range(101):
    for j in range(101):
        H_0 = info[0][2] + abs(info[0][0] - i) + abs(info[0][1] - j)
        
        for k in range(1, N):
            H = info[k][2] + abs(info[k][0] - i) + abs(info[k][1] - j)
            
            if H_0 != H:
                break
            elif k == N - 1:
                print(i,j,H_0)
                exit()
 
print(info[0][0],info[0][1],info[0][2])

Measured memory_bytes: 3064
# coding: utf-8
# Your code here!

n,m,Q = list(map(int,input().split()))	

#l=[]
#r=[]

A=[[0 for i in range(n)] for j in range(n)]
for _ in range(m):
    a,b= list(map(int,input().split()))
#    print(a,b)
#    l.append(a)
#    r.append(b)
    A[a-1][b-1]+=1

#print("A",A)
ruiseki=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(n):
#        print(i,j)
        ruiseki[i][j+1]=ruiseki[i][j] +ruiseki[i-1][j+1] - ruiseki[i-1][j] + A[i-1][j]

#print("R",ruiseki)        

p=[]
q=[]
for _ in range(Q):
    a,b= list(map(int,input().split()))
    p.append(a-1)
    q.append(b-1)


#print(p,q)

for i in range(Q):
    print(ruiseki[q[i]+1][q[i]+1] - ruiseki[p[i]][q[i]+1] - ruiseki[q[i]+1][p[i]] + ruiseki[p[i]][p[i]])


#if :
#    print("Yes")
#else:
#    print("No")

Measured memory_bytes: 20476
from functools import reduce
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
ans = [reduce(gcd, A)]

if len(A) == 1:
    print(A[0])
    exit()
for i in A:
    b = sorted(A)
    b.remove(i)
    if a.count(i) == 1:
        ans.append(reduce(gcd, b))

print(max(ans))


Measured memory_bytes: 16152
// ConsoleApplication1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <memory>

using namespace std;
int main()
{
	long long x, y, z;
	cin >> x;
	cin >> y;
	cin >> z;

	if(x >= y && x >= z)
	{
		if (x % 2 == 0)
		{
			cout << 0;
			return 0;
		}
		cout << y * z;
	}else if( y >= x && y >= z)
	{
		if (y % 2 == 0)
		{
			cout << 0;
			return 0;
		}
		cout << x * z;
	}else
	{
		if (z % 2 == 0)
		{
			cout << 0;
			return 0;
		}
		cout << x * y;
	}
}
/*
int main()
{
	bool n = false, s = false, w = false, e = false;
	while(int c = std::cin.get())
	{
		if (c == EOF)break;
		switch (c)
		{
		case 'N':
			n = true;
			break;
		case 'S':
			s = true;
			break;
		case 'W':
			w = true;
			break;
		case 'E':
			e = true;
			break;
		}
	}

	if (n && s && !e && !w || n && s && e && w || !n && !s && e & w || !n && !s && !w && !e)
	{
		std::cout << "Yes";
	}
	else
	{
		std::cout << "No";
	}

    return 0;
}
*/


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

// struct fast_io {
	// fast_io(){
		// std::cin.tie(nullptr);
		// std::ios::sync_with_stdio(false);
	// };
// } fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	int ans = 0;
	vector<int> hoge;
	vector<int> fuga;
	
	cin>>N;
	
	hoge.resize(N+2, 1);
	fuga.resize(N+2);
	
	
	for(int i = 1; i <= N; i++){
		fuga[i] = i;
	}
	
	for(int i = 2; i <= N; i++){
		if(fuga[i] == 1) continue;
		
		for(int j = i; j <= N; j += i){
			int con = 0;
			while(fuga[j]%i == 0){
				fuga[j] /= i;
				con++;
			}
			
			hoge[j] *= con + 1;
		}
	}
	
	// for(int i = 1; i <= N; i++){
		// cout<<i<<" "<<hoge[i]<<endl;
	// }
	
	for(int i = 1; i < N; i++){
		int x = N - i;
		int con = 0;
		ans += hoge[x];
		
		// for(int j = 1; j * j <= x; j++){
			// if(x%j == 0) {
				// if(j * j == x) {
					// con++;
				// } else {
					// con += 2;
				// }
			// }
		// }
		// cout<<"x = "<<x<<" "<<con<<" "<<hoge[x]<<endl;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 18824
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    while(1){
        int a,b;
        cin >> a >> b;
        if(a==0 && b==0)break;
        for(int i=0; i<a; i++) {
            for(int j=0; j<b; j++) {
                if ((i+j)%2 == 0 ) {
                    cout << "#";
                }
               else
                   cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3040
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
 
using namespace std;
 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
 
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
 
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
 
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
 
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
 


int main(){
  int a,b;
  cin >> a >> b;
  int ans = 1;
  int sum = a;
  if(b==1){
    cout << 0 << endl;
    return 0;
  }
  while(1){
    if(sum >= b) break;
    ans++;
    sum+=(a-1);
  }
  cout << ans << endl;
}



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

void DFS(int& ans, int i, int n, int m, int x, vector<int>& A, const vector<vector<int>> a)
{
	if (A.size() == i) {
		vector<int> algorithm(m + 1);
		int money = 0;
		for (int j = 0; j < i; j++) {
			money += a[A[j]][0];
			for (int k = 1; k <= m; k++) {
				algorithm[k] += a[A[j]][k];
			}
		}
		for (int j = 1; j <= m; j++) {
			if (algorithm[j] < x) return;
		}
		ans = min(ans, money);
		return;
	}

	int start = A.empty() ? 0 : A.back();
	for (int j = start; j < n; j++) {
		A.push_back(j + 1);
		DFS(ans, i, n, m, x, A, a);
		A.pop_back();
	}
}

int main()
{
	int n, m, x;
	cin >> n >> m >> x;

	vector<vector<int>> a(n + 1, vector<int>(m + 1));
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < m + 1; j++) cin >> a[i][j];
	}

	int ans = INT_MAX;
	for (int i = 1; i <= n; i++) {
		vector<int> A;
		DFS(ans, i, n, m, x, A, a);
	}
	if (ans == INT_MAX) cout << -1 << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue<int>
#define PQR priority_queue<int,VE,greater<int>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<P>key;
	rep(i, m) {
		int a, b; cin >> a >> b;
		int s = 0;
		rep(j, b) {
			int c; cin >> c; c--;
			s |= 1 << c;
		}
		key.emplace_back(s, a);
	}
	VE dp(1 << n); // 2^n
	rep(i, 1 << n)dp[i] = INF;
	dp[0] = 0;
	rep(s, 1 << n) {
		rep(i, m) {
			int t = s | key[i].first;
			int cost = dp[s] + key[i].second;
			dp[t] = min(dp[t], cost);
		}
	}
	int ans = dp.back();
	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int a, b, c;
	while (cin >> a >> b >> c) {
		if (a == 0 && b == 0 && c == 0) {
			break;
		}
	vector<int> data(a+b+c+1, 2);
	int n;
	cin >> n;
	vector< vector<int> > data2(n, vector<int>(4, 0));
	for (int i = 0; i < n; i++) {
		cin >> data2[i][0] >> data2[i][1] >> data2[i][2] >> data2[i][3];
		if (data2[i][3] == 1) {
			data[data2[i][0]] = 1;
			data[data2[i][1]] = 1;
			data[data2[i][2]] = 1;
		}
	}
	for (int i = 0; i < n; i++) {
		if (data2[i][3] == 0) {
			if (data[data2[i][0]] == 1 && data[data2[i][1]] == 1) {
				data[data2[i][2]] = 0;
			} else if (data[data2[i][1]] == 1 && data[data2[i][2]] == 1) {
				data[data2[i][0]] = 0;
			} else if (data[data2[i][2]] == 1 && data[data2[i][0]] == 1) {
				data[data2[i][1]] = 0;
			}
		}
	}
	for (int i = 1; i <= a+b+c; i++) {
		cout << data[i] << endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1268
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    long long int num1 , num2, gcd , res, lcm;
    while(scanf("%lld%lld",&num1,&num2)!=EOF){

        res = num1 * num2 ;
        while(num1 != num2){
            if(num1 > num2)
                num1 = num1 - num2 ;
            else
                num2 = num2 - num1 ;
        }
        gcd = num1 ;
        lcm = res / gcd ;
         printf("%lld %lld\n", gcd, lcm);
    }
    return 0;
}

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

int main() {
  char a[3], b[3];
  cin >> a >> b;

  if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
    cout << "YES";
  }else{
    cout <<"NO";
  }
}


Measured memory_bytes: 256
n, m = map(int, input().split())
actions = [list(map(int, input().split())) for _ in range(m)]
boxes = [[1, True]] + [[1, False] for _ in range(n - 1)]

for i in range(m):
	boxes[actions[i][0] - 1][0] -= 1
	boxes[actions[i][1] - 1][0] += 1
	if boxes[actions[i][0] - 1][1] == True:
		boxes[actions[i][1] - 1][1] = True
	if boxes[actions[i][0] - 1][0] == 0:
		boxes[actions[i][0] - 1][1] = False

ans = 0
for i in range(n):
	if boxes[i][0] > 0 and boxes[i][1] == True:
		ans += 1

print(ans)

Measured memory_bytes: 35400
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, c, cnt=0;
    
    scanf("%d %d %d", &a, &b, &c);
    
    for(int i=a; i<=b; i++) {
        if (c % i == 0) {
            cnt++;
        }
    }
    printf("%d\n", cnt);
    
    return 0;
}



Measured memory_bytes: 2100
# A - Dividing a String
# import sys
# input = sys.stdin.readline

S = input()
ans, prev, cur = 0, "", ""
for s in S:
  cur += s 
  if cur != prev: # True になるまで、curに文字列を追加していく
    ans += 1
    prev, cur = cur, ""

print(ans)

Measured memory_bytes: 3500
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define nep next_permutation
#define MOD 1000000007ll
#define MIN (1e-10)
#define equal(a,b) (abs((a)-(b))<MIN)
#define v2 ten
#define chokusen senbun
#define tenten senbun
#define takaku vec<ten>
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
struct pea{
	ll f,s;
	bool operator<(const pea &p)const{
		return f!=p.f?f<p.f:s<p.s;
	};
};
struct tri{
	ll f,s,t;
	bool operator<(const tri &p)const{
		if(f!=p.f)return f<p.f;
		if(s!=p.s)return s<p.s;
		return t<p.t;
	};
};
class ten{
public:
	ld x,y;
	ten operator+(ten p){return{x+p.x,y+p.y};}
	ten operator-(ten p){return{x-p.x,y-p.y};}
	ten operator*(ld k){return{k*x,k*y};}
	ten operator/(ld k){return{x/k,y/k};}
	ld abs(){return sqrt(abs2());}
	ld abs2(){return x*x+y*y;};
	bool operator<(const ten &p)const{return x!=p.x?x<p.x:y<p.y;};
	bool operator==(const ten &p)const{return (-MIN<x-p.x)&&(x-p.x<MIN)&&(-MIN<y-p.y)&&(y-p.y<MIN);};
	ld naiseki(v2 b){return x*b.x+y*b.y;}
	ld gaiseki(v2 b){return x*b.y-y*b.x;}
};
struct senbun{ten p1,p2;};
struct en{ten o;ld r;};
//反復深化IDA*(15パズル)
ll manhattan[16][16];
ll dfs(vll &state,ll depth,ll limit,ll prestep){
	ll summ=0;
	rep(i,0,16)if(state[i]!=0)summ+=manhattan[state[i]-1][i];else summ+=manhattan[15][i];
	if(summ==0)return depth;
	if(depth+summ>limit)return -1;
	ll cnt=46;
	ll pos=find(ALL(state),0)-state.begin();
	if(pos%4!=3&&prestep!=2){
		swap(state[pos],state[pos+1]);
		ll ret=dfs(state,depth+1,limit,1);
		if(ret!=-1&&ret<cnt)cnt=ret;
		swap(state[pos],state[pos+1]);
	}
	if(pos%4!=0&&prestep!=1){
		swap(state[pos],state[pos-1]);
		ll ret=dfs(state,depth+1,limit,2);
		if(ret!=-1&&ret<cnt)cnt=ret;
		swap(state[pos],state[pos-1]);
	}
	if(pos>3&&prestep!=4){
		swap(state[pos],state[pos-4]);
		ll ret=dfs(state,depth+1,limit,3);
		if(ret!=-1&&ret<cnt)cnt=ret;
		swap(state[pos],state[pos-4]);
	}
	if(pos<12&&prestep!=3){
		swap(state[pos],state[pos+4]);
		ll ret=dfs(state,depth+1,limit,4);
		if(ret!=-1&&ret<cnt)cnt=ret;
		swap(state[pos],state[pos+4]);
	}
	if(cnt==46)return -1;else return cnt;
}
void solve(){
	vll a(16);
	rep(i,0,16)cin>>a[i];
	rep(i,0,16)rep(j,0,16)manhattan[i][j]=abs(i/4-j/4)+abs(i%4-j%4);
	rep(i,0,100){
		ll k=dfs(a,0,i,0);
		if(k!=-1){
			cout<<k<<kai;
			return;
		}
	}
}


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

vector < pair <ll, ll >> res;

ll Gcd(ll x, ll y) {
	if (y == 0) return x;
	Gcd(y, x%y);
}

void prime_factorize(ll n) {
	ll sn = n;
	for (ll i = 2; i*i <= sn; i++) {
		if (n%i != 0) continue;
		pair<ll, ll> p(i, 0);
		while (n%i == 0) {
			n /= i;
			p.second++;
		}
		res.push_back(p);
	}
	if (n != 1) res.push_back(pair<ll, ll>(n, 1));
}

int main() {
	ll a, b;
	cin >> a >> b;
	ll gcd = Gcd(a, b);
	prime_factorize(gcd);
	//cout << gcd << endl;
	for (int i = 0; i < res.size(); i++) {
		//cout << res.at(i).first << ' ' << res.at(i).second << endl;
	}
	cout << res.size() + 1;
}

Measured memory_bytes: 256