akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	
	int a,b,c;
	while(cin>>a>>b){
		int d=1;
		c=a+b;
		while(c>=pow(10,d))d+=1;
		cout<<d<<endl;
	}
	return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b;
	c = (a + b) / 2;
	if ((a + b) % 2 == 0) {
		cout << c << endl;
	}
	else {
		cout << c + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        String S=gs();
        int k=0;
        int mk=0;
        for (int i=0; i<S.length();i++) {
        	char c=S.charAt(i);
        	if(c=='A' || c=='C' || c=='G' || c=='T') {
        		k++;
        		if(k>mk) {
        			mk=k;
        		}
        	} else {
        		k=0;
        	}
        }

        System.out.print(mk);

//        if (s>L[n-2]) {
//        	System.out.println("Yes");
//        }else {
//        	System.out.println("No");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35512
import sys,math,copy,queue,itertools,bisect
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
N,K = LI()
ans = 0
for i in range(K,N+2):
    ans = (ans + (N*i - (i-1) * i // 2) - i*(i-1) // 2 +1) % MOD
print (ans)

Measured memory_bytes: 68832
n,k=map(int,input().split())
mod=10**9+7
count=[0]*(k+1)
def getnum(m):
    ret = pow(k//m,n,mod)
    mul=2
    while m*mul<=k:
        ret-=count[m*mul]
        mul+=1
    return ret%mod
ans=0
for i in range(1,k+1)[::-1]:
    g=getnum(i)
    count[i]=g
    ans+=g*i
    ans%=mod
print(ans)

Measured memory_bytes: 11076
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    readint;
    auto a = readints;

    int lo = a.reduce!min;
    int hi = a.reduce!max;
    int ans = int.max;
    for (int i = lo; i <= hi; i++) {
        int cost = a.map!(e => (e - i) ^^ 2).sum;
        ans = min(ans, cost);
    }
    writeln(ans);
}


Measured memory_bytes: 256
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;


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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF;
    string str;
    cin>>a>>b;
    while(a<=b) {a*=2;f++;}
    cout<<f<<endl;
    return 0;
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.length();
	int count = 0;
	for (int i = 0; i < n; i++) {
		count += s[i] - '0';
	}
	cout << ((count % 9 == 0) ? "Yes" : "No");
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

inline void normal(ll &a) {if(a>=MOD)a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) {normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) {normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) {normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll maxProductSubarrayOfSizeK(ll A[], ll n, ll k)
{
    sort(A, A + n);

    ll product = 1;

    if (A[n - 1] == 0 && (k & 1))
        return 0;

    if (A[n - 1] <= 0 && (k & 1)) {
        for (ll i = n - 1; i >= n - k; i--)
            product = modMul(product,A[i]);

        return product;
    }

    ll i = 0;

    ll j = n - 1;


    if (k & 1) {
        product = modMul(A[j], product);
        j--;
        k--;
    }

    k >>= 1;

    for (ll itr = 0; itr < k; itr++) {

        ll left_product = (A[i] * A[i + 1]);

        ll right_product = (A[j] * A[j - 1]);

        if (left_product > right_product) {
            product = modMul(left_product, product);
            i += 2;
        }
        else {
            product = modMul(product, right_product);
            j -= 2;
        }
    }

    return product ;
}

int main() {
    ll n, k;  cin >> n >> k;
    ll a[n + 2];
    for(ll i = 0; i < n; i++) cin >> a[i];
    cout << maxProductSubarrayOfSizeK(a, n, k) << endl;
    return 0;

}


Measured memory_bytes: 5176
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,m,ans;
int a,b;
signed main(){
	 cin>>n>>a>>b;
	 ans+=n/(a+b)*a;
	 if(n%(a+b)<a)ans+=(n%(a+b));
	 else ans+=a;
	 cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int n;
    cin>>n;
    double k=n/3.0;
    cout<<setprecision(15)<<fixed<<k*k*k<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;


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

	int N;
	cin >> N;
	
	vector<VI> to(N), cost(N);

	REP(i, N - 1) {
		int u, v, w;
		cin >> u >> v >> w;
		u--;
		v--;
		to[u].push_back(v);
		to[v].push_back(u);
		cost[v].push_back(w);
		cost[u].push_back(w);
		
	}
	VI ans(N);
	REP(i, N)ans[i] = -1;
	queue<int> q;
	ans[0] = 0;
	q.push(0);
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		REP(i, to[v].size()) {
			int u = to[v][i];
			int w = cost[v][i];
			if (ans[u] != -1)continue;
			ans[u] = (ans[v] + w) % 2;
			q.push(u);
		}
	}
	REP(i, N)cout << ans[i] << endl;
	return 0;
}



Measured memory_bytes: 13184
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;
using P = pair<int64,int64>;

int main() {
    int64 n,k;
    int64 ans = 0;
    cin >> n >> k;

    vector<P> ab;

    for (int64 i=0; i<n; i++) {
        int64 a,b;
        cin >> a >> b;
        ab.emplace_back(a,b);
    }

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

    for (auto p : ab) {
        k -= p.second;
        if (k <= 0) {
            ans = p.first;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MAXN = 2e3 + 123;
const ld EPS = 1e-12;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

int n, k, ans = MAXN, d[MAXN];
vector<int> g[MAXN];
queue<int> q;

int bfs(){

	while(!q.empty()){
		int v = q.front();
		q.pop();
		for(int to : g[v]){
			if(d[to] == INF){
				d[to] = d[v] + 1;
				q.push(to);
			}
		}
	}

	int res = 0;

	for(int i = 1; i <= n; ++i){
		res += d[i] > (k / 2);
		d[i] = INF;
	}
	
	return res;
}

void solve(){
	cin >> n >> k;

	for(int i = 1, x, y; i < n; ++i){
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}

	for(int i = 1; i <= n; ++i)
		d[i] = INF;

	if(k & 1){
		for(int v = 1; v <= n; ++v){
			for(int to : g[v]){
				q.push(v);
				q.push(to);
				d[v] = d[to] = 0;
				ans = min(ans, bfs());
			}
		}
	}
	else{
		for(int v = 1; v <= n; ++v){
			q.push(v);
			d[v] = 0;
			ans = min(ans, bfs());
		}
	}

	cout << ans;
}

int main(){

	faster();
 
	int T = 1;
	// cin >> T;
	
	while(T--){
		solve();
	}
 
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int n = s.size(), ans = 10000;

    for (int i = 0; i < n; i++)
    {
        int cnt = 0, maxcnt = 0;
        char c = s[i];
        for (int j = 0; j < n; j++)
        {
            if (s[j] != c) cnt++;
            else cnt = 0;
            maxcnt = max(cnt, maxcnt);
        }
        
        ans = min(maxcnt, ans);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
D,G = list(map(int,input().split()))
L=[]
for i in range(D):
    L.append(list(map(int,input().split())))
for i in range(D):
    L[i].append(L[i][0]*(i+1)*100)
    L[i].append(L[i][2]+L[i][1])
answer = 10**4
for bits in range(1<<D):
    point_sum = 0
    n = 0
    j = -1
    for i in range(D):
        if bits & 1<<i:
            point_sum += L[i][3]
            n += L[i][0]
        else:
            j = max(j, i)
    if point_sum >= G:
        answer = min(answer, n)
    elif j >=0 and (point_sum+L[j][2])-(j+1)*100 >= G:
        a = G - point_sum
        b = (j+1)*100
        answer = min(answer, n+int((a+b-1)/b))
    else:
        pass
print(answer)


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#define INF 1e+18
#define MAX_SIZE 1 << 17
using namespace std;

typedef long long ll;

int n,k;
ll v[100000];
ll segMax[2][2 * MAX_SIZE - 1],segAdd[2][2 * MAX_SIZE - 1];

void add(int num,int a,int b,ll x,int k = 0,int l = 0,int r = n){
	if(b <= l || r <= a) return;
	if(a <= l && r <= b){
		segAdd[num][k] += x;
		return;
	}
	add(num,a,b,x,k * 2 + 1,l,(l + r) / 2);
	add(num,a,b,x,k * 2 + 2,(l + r) / 2,r);
	segMax[num][k] = max(segMax[num][k * 2 + 1] + segAdd[num][k * 2 + 1],segMax[num][k * 2 + 2] + segAdd[num][k * 2 + 2]);
}

ll get(int num,int a,int b,int k = 0,int l = 0,int r = n){
	if(b <= l || r <= a) return -INF;
	if(a <= l && r <= b) return segAdd[num][k] + segMax[num][k];
	return max(get(num,a,b,k * 2 + 1,l,(l + r) / 2),get(num,a,b,k * 2 + 2,(l + r) / 2,r)) + segAdd[num][k];
}

void init(){
	int t = 1;
	while(t < n + 1) t *= 2;
	for(int i = 0;i < t * 2 - 1;i++){
		segMax[0][i] = -INF;
		segMax[1][i] = -INF;
	}
	segMax[0][t - 1] = 0;
	for(int i = 0;i < n;i++) segMax[0][i + t] = segMax[0][i + t - 1] + v[i];
	ll ma = -INF;
	for(int i = n;i >= 0;i--) {
		ma = max(ma,segMax[0][i + t - 1]);
		segMax[1][i + t - 1] = ma - segMax[0][i + t - 1];
	}
	for(int i = t - 2;i >= 0;i--) {
		segMax[0][i] = max(segMax[0][i * 2 + 1],segMax[0][i * 2 + 2]);
		segMax[1][i] = max(segMax[1][i * 2 + 1],segMax[1][i * 2 + 2]);
	}
	n = t;
}

int main(){
	/*scanf("%d %d",&n,&k);
	for(int i = 0;i < n;i++) scanf("%lld",&v[i]);
	init();
	for(int i = 0;i < k - 1;i++){
		
	}
	printf("%lld\n",get(1,0,n));*/
	while(1){
		ll ma = -INF;
		scanf("%d",&n);
		if(!n) break;
		for(int i = 0;i < n;i++){
			scanf("%lld",&v[i]);
			ma = max(ma,v[i]);
		}
		init();
		if(ma < 0) printf("%lld\n",ma);
		else printf("%lld\n",get(1,0,n));
	}
	return 0;
}

Measured memory_bytes: 2712
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int compare (const void *a, const void *b)
{
    if(*(uintmax_t *)a < *(uintmax_t *)b)
        return 1;
    if(*(uintmax_t *)a > *(uintmax_t *)b)
        return -1;
    return 0;
}

int main (void)
{
    uintmax_t N, M, A[(int)1e5];
    uintmax_t ans = 0, msb = (INTMAX_C(1) << 63);
    size_t i;

    scanf("%ju%ju", &N, &M);
    for (i = 0; i < N; i++) {
        scanf("%ju", &A[i]);
    }

    qsort(A, N, sizeof(uintmax_t), compare);

    while((msb & A[0]) == 0) msb >>= 1;

    i = 0;
    do {
        if (A[i] & msb) {
            A[i] >>= 1;
            M--;
            i++;
        } else {
            msb >>= 1;
            while (A[i] & msb) i++;
            qsort(A, (i + 1), sizeof(uintmax_t), compare);
            i = 0;
        }
        if (i > N) i = 0;
    } while (M && msb);

    for (i = 0; i < N; i++) {
        ans += A[i];
    }

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 1788
n = int(input())
v_lst = list(map(int,input().split()))
c_lst = list(map(int,input().split()))
ans_lst = []


for i in range(n):
    ans_lst.append(v_lst[i]-c_lst[i])
ans_lst.sort(reverse=True)

ans = 0
for a in ans_lst:
    if a > 0:
        ans += a

print(ans)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String line = in.nextLine();
        int digitsSum = 0;
        for (char c : line.toCharArray()) {
            digitsSum = (digitsSum + c - '0') % 9;
        }
        System.out.println(digitsSum % 9 == 0 ? "Yes" : "No");
    }
}


Measured memory_bytes: 42360
#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;
const int INF (1<<30);

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

  for (int i = a; i <= b; i++) {
    if (i%k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <climits>


using namespace std;


using ll = long long;


const ll MAX = 100;


int main()
{
    ll n;

    cin >> n;
    vector<vector<ll>> m(n + 1);
    for (ll i = 0; i <= n; i++)
        m[i].resize(n + 1);
    vector<pair<ll, ll>> M;
    for (ll i = 0; i < n; i++) {
        ll r, c;
        cin >> r >> c;
        M.push_back(make_pair(r, c));
    }

    for (ll i = 0; i < n; i++) {
        m[i][i] += 0;
    }

    for (ll i = 0; i < n - 1; i++) {
        m[i][i + 1] += M[i].first * M[i].second * M[i + 1].second;
    }

    for (ll len = 2; len < n; len++) {
        for (ll l = 0; l < n - len; l++) {
            ll r = l + len;
            m[l][r] = LONG_LONG_MAX;
            for (ll mid = l; mid < r; mid++) {
                ll tmp = M[l].first * M[mid].second * M[r].second;
                // cout << tmp << endl;
                m[l][r] = min(m[l][r], tmp + m[l][mid] + m[mid + 1][r]);
            }
        }
    }
    cout << m[0][n - 1] << endl;
}



Measured memory_bytes: 3204
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
    int a, b, C;

    cin >> a >> b >> C;

    double PI = acos(-1);

    double rad = C * PI / 180;



    double S = (a * b * sin(rad)) / 2;
    double c = sqrt(a * a + b * b - 2 * a * b * cos(rad));
    double L = a + b + c;
    double h = b * sin(rad);

    printf("%lf\n%lf\n%lf\n", S, L, h);
}



Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n;
  cin >> n;
  vector<string> w(n);
  set<string> s;
  int ans=1;
  string f;
  cin >>f;
  w[0] =f;
  s.insert(f);
  
  for(int i=1;i<n;i++){
    string g;
    cin >> g;
    w[i] = g;
    s.insert(g);
    
    if(w[i-1].at(w[i-1].size()-1) != w[i].at(0)) {
      ans =0;
      break;
    }
    
  }
  if(s.size()!= n) ans =0;
  
  if(ans == 0) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int A1,A2,A3;
    scanf("%d %d %d",&A1,&A2,&A3);

    if(A1+A2+A3 >= 22){
        printf("bust\n");
    } else {
        printf("win\n");
    }
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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;}

int main(){
	//input
	string s,t; cin>>s>>t;

	/*memo


	*/
	//solve
	ll ans=0;
	rep(i,3) if(s[i]==t[i]) ans++;


	//output
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long int D, K;
    cin >> D >> K;

    int d = pow(100, D);


    int ans = 0;
    int i = 0;
    while (i < K)
    {
        i++;
        ans += d;
    }

    if(K == 100) ans += d;
    cout << ans << endl;

}

Measured memory_bytes: 384
sx,sy,tx,ty = map(int,input().split())
dx = tx - sx
dy = ty - sy
ans = "U"*dy+"R"*dx
ans +="D"*dy+"L"*dx
ans += "L"+"U"*(1+dy)+"R"*(1+dx)+"D"
ans += "R"+"D"*(1+dy)+"L"*(1+dx)+"U"
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
using P = pair<int, int>;
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9 + 7;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k%2==0)cout<<a-b<<endl;
    else cout<<b-a<<endl;
}


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

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,a,b;
    cin>>n>>a>>b;
    LL x = a + b;
    PUTS((n/x)*a + min(a, n % x));
}

Measured memory_bytes: 256
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(100);
}
#define int ll
int ans[300000];
int coloring[300000];
int now_dist[300000];
void solve(){
	int n, m;
	cin >> n >> m;
	vector<int> inputs;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.push_back(a);
		coloring[i] = 2; // undetermined
	}
	vector<tuple<int, int, int, int>> edges;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if (inputs[a] == inputs[b]) {
			if (coloring[a] == 2&&coloring[b] == 2) {
				coloring[a] = 0;
				coloring[b] = 1;
				ans[i] = inputs[a];
				now_dist[a] = ans[i];
				now_dist[b] = ans[i];
				continue;
			}
			if (coloring[a] == 2 || coloring[b] == 2) {
				if (coloring[a] == 2) {
					coloring[a] = (coloring[b] + 1) % 2;
				}
				else {
					coloring[b] = (coloring[a] + 1) % 2;
				}
				ans[i] = inputs[a];
				now_dist[a] = ans[i];
				now_dist[b] = ans[i];
				continue;
			}
			ans[i] = 1e9;
			continue;
		}
		if (inputs[a] > inputs[b]) swap(a, b);
		edges.push_back(make_tuple(inputs[a], a, b, i));
	}
	sort(ALL(edges));
	for (auto x : edges) {
		if (coloring[get<1>(x)] == 2) {
			cout << -1 << endl;
			return;
		}
		if (coloring[get<2>(x)] == 2) {
			coloring[get<2>(x)] = coloring[get<1>(x)];
			int geko = inputs[get<2>(x)] - now_dist[get<1>(x)];
			ans[get<3>(x)] = geko;
			now_dist[get<2>(x)] = inputs[get<2>(x)];
		}
		else {
			ans[get<3>(x)] = 1e9;
		}
	}
	REP(i, n) {
		if (coloring[i] == 2) {
			cout << "-1" << endl;
			return;
		}
	}
	REP(i, n) {
		if (coloring[i] == 0) {
			cout << "B";
		}
		else {
			cout << "W";
		}
	}
	cout << endl;
	REP(i, m) {
		cout << ans[i] << endl;
	}
}

#undef int

int main() {
	init();
	solve();
}


Measured memory_bytes: 16364
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = (a), i_len = (b); i < i_len; ++i)

const int INF = 1e9 + 7;

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

    int a[1000], b[1000], c[1000], dist[100][100];

    REP(i, 0, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--, b[i]--;
    }

    REP(i, 0, n) REP(j, 0, n) {
        if(i == j) dist[i][j] = 0;
        else       dist[i][j] = INF;
    }

    REP(i, 0, m) {
        dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
        dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
    }

    REP(k, 0, n) REP(i, 0, n) REP(j, 0, n) 
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

    
    int ans = m;
    REP(i, 0, m) {
        bool shortest = false;
        REP(j, 0, n) if(dist[j][a[i]] + c[i] == dist[j][b[i]]) shortest = true;
        if(shortest) ans -= 1;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define lowbit(x) ((x)&(-x))
#define inf 0x3f3f3f3f
#define endl "\n"
#define MP(x,y) (make_pair(x,y))
#define pll pair<int,int>
#define pi 3.1415926535
using namespace std;
const int mod = 1e9+7;
int n,k;
ll qpow(ll a,ll b){
    ll res = 1;
    while(b){
        if(b&1) res = res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
int p[100005];
ll sum;
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++){
        sum+=qpow(k/i,n)*(i-p[i])%mod;
        sum=(sum%mod+mod)%mod;
        int x=i+i;
        while(x<=k){
            p[x]+=i;
            p[x]-=p[i];
            x+=i;
        }
    }
    cout<<sum<<endl;
    return 0;
}
/*
6 + 3*1 + 2*2 + 1*2 + 1*4 + 1*3
1 2 3 4 5 6
0 1 2 3 4 5
0 0 2 2 4 4

*/


Measured memory_bytes: 4088
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions
ll pow_mod(ll a, ll n, ll MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 0x01) { 
            res *= a;
            res %= MOD;
        }
        a = a * a;
        a %= MOD;
        n >>= 1LL;
    }
    return res;
}

ll recipro_mod(ll num, ll MOD) {
    return pow_mod(num, MOD - 2, MOD);
}

void fact_mod(vl& fact, vl& rFact, const int Size, const ll MOD) {
    fact = vl(Size, 0);

    fact[0] = 1;
    FOR(i, 1, Size) fact[i] = fact[i-1] * i % MOD;

    rFact = vl(Size, 0);
    rFact[0] = 1;
    rFact[Size-1] = recipro_mod(fact[Size-1], MOD);
    for (int i = Size-1; i > 0; i--) rFact[i - 1] = rFact[i] * i % MOD;
}

ll combi_mod(vl& fact, vl& rFact, ll n, ll k, const ll MOD){
    if (n < 0 || k < 0 || n < k) return 0;
    return fact[n] % MOD * rFact[k] % MOD * rFact[n - k] % MOD;
}
#endif


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

    ll N, K; cin >> N >> K;
    ll MOD = 1e9 + 7;
    ll NMAX = 2000;

    vl fact, rFact;
    fact_mod(fact, rFact, NMAX+MGN, MOD);
    
    for (ll i = 1; i <= K; i++) {
        // N-K+1Ci * K-1Ci-1
        ll ans = combi_mod(fact, rFact, N - K + 1, i, MOD);
        ans *= combi_mod(fact, rFact, K - 1, i - 1, MOD);
        ans %= MOD;

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::max;
using std::min;
int n,m,a[200005],ans=0,Ans;
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n*2;i++)
		scanf("%d",&a[i]);
	std::sort(a+1,a+2*n+1);
	int l=0,r=n;
	while (l<=r){
		int mid=(l+r)>>1;
		bool f=true;
		int t=mid<<1;
		int ans=0;
		if (f) for(int i=t+1,j=2*n;i<j;i++,j--)
			if (a[i]+a[j]<m){
				f=false;break;
			}
		if (f){
			Ans=mid;
			r=mid-1;
		}else l=mid+1;
	}
	//Ans=l;
	int t=Ans*2;
	for (int i=1;i<=Ans;i++) ans=max(ans,a[i]+a[t-i+1]);
	for(int i=t+1,j=2*n;i<j;i++,j--) ans=max(ans,a[i]+a[j]-m);
	printf("%d\n",ans);
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long int a,b,c;
  cin>>a>>b;
  c=(a+b)/2;
  if(abs(a-c)==abs(b-c))
  {
    cout<<c;
  }
  else
    cout<<"IMPOSSIBLE";
  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
f = True
for i in range(n):
    if i == 0:
        continue
    else:
        if h[i] < h[i-1]:
            f = False
        else:
            if h[i-1] != h[i]:
                h[i] -= 1
print('Yes' if f else 'No')

Measured memory_bytes: 15020
N=int(input())
List = list(map(int, input().split()))
midList = [0]*(N-1)
mid = 0
for i in range(N-2,-1,-1):
  mid += List[i+1]
  midList[i] = mid
res=0
for i in range(N-1):
  a = List[i] % 1000000007
  b =  midList[i] % 1000000007
  res += a*b
print(res%1000000007)

Measured memory_bytes: 31500
A = int(input())
B = int(input())
C = int(input())

X = int(input())

ans = 0

for a_num in range(A+1):
	for b_num in range(B+1):
		for c_num in range(C+1):
			if (500 * a_num) + (100 * b_num) + (50 * c_num) == X:
				ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cmath>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
//#include "windows.h"

#define pb push_back
#define ppb pop_back
#define mmp make_pair
#define nd second
#define st first
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define irt pair <int, pii>
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

using namespace std; 

int a, b; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	cin >> a >> b; 
	
	if (a + b == 15) puts("+"); 
	else if (a * b == 15) puts("*"); 
	else puts("x"); 
	
	return 0;
}

Measured memory_bytes: 384
H, W = gets.chomp.split.map(&:to_i)
a = []
H.times do |i|
  l = gets.chomp.chars
  if l == ['.'] * W
    a << [nil] * W
  else
    a << l
  end
end

W.times do |i|
  flag = true
  H.times do |j|
    if !a[j][i].nil? && a[j][i] == '#'
      flag = false
      break
    end
  end

  if flag
    H.times do |j|
      a[j][i] = nil
    end
  end
end

a.each do |ai|
  ai.compact!
  puts ai.join if ai.size > 0
end

Measured memory_bytes: 2300
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

string s;
ll ans=0;

ll to_Int(string s){
	int tmp=1;
	ll A=0;
	for(int i=s.size()-1;i>=0;i--){
		A+=(ll)(s[i]-'0')*tmp;
		tmp*=10;
	}
	return A;
}

int main(){
	cin>>s;
	int n=1,l=s.size()-1;
	for(int i=0;i<l;i++) n*=2;
	for(int i=0;i<n;i++){
		int t=0;
		for(int j=l-1;j>=0;j--){
			if(i>>j&1){
				ans+=to_Int(s.substr(t,l-j-t));
				t=l-j;
			}
		}
		ans+=to_Int(s.substr(t));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    for (int i = 0; i < N; i++) {
        cin >> B.at(i);
    }
    for (int i = 0; i < N; i++) {
        cin >> C.at(i);
    }
    sort(ALL(A));
    sort(ALL(B));
    sort(ALL(C));

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        auto l = lower_bound(ALL(A), B[i]);
        auto r = upper_bound(ALL(C), B[i]);
        ans += (l - A.begin()) * (C.end() - r);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
n = int(input())
li = list(map(int,input().split()))
sorted_li = sorted(li)
new_li = []
for i in range(n):
    if i == 0:
        new_li.append(sorted_li[0]/(2**(n-1)))
    else:
        new_li.append(sorted_li[i]/(2**(n-i)))
print(sum(new_li))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main 	
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		String st;
		st = sc.next();
		//System.out.println(st);
		int l = st.length();
		if(l==2)
			System.out.println(st);
		else
		{
			char a[] = st.toCharArray();
			//System.out.println(a[2]);
			String st2 = "";
			st2=st2+a[2];
			st2=st2+a[1];
			st2=st2+a[0];
			System.out.println(st2);
		}
	}
}


Measured memory_bytes: 22868
import math
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
z,a,b=[],0,0
for i in range(n):
    z.append(abs(x[i]-y[i]))
for i in range(n):
    a+=(z[i]**2)
    b+=(z[i]**3)
a=math.sqrt(a)
b=math.pow(b,1.0/3.0)
print('{:.6f}\n{:.6f}\n{:.6f}\n{:.6f}'.format(sum(z),a,b,max(z)))


Measured memory_bytes: 5708
#include <bits/stdc++.h>
/*
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
 */
using namespace std;
#define LSON            id << 1 , l , mid
#define RSON            id << 1 | 1 , mid + 1 , r
#define LS              id << 1
#define RS              id << 1 | 1
#define ROOT            1 , 1 , n
#define CLR(x , y)      memset(x , y , sizeof(x))
#define LOWBIT(x)       x & (-x)
#define FORN(i , a , n)  for(int i = (a) ; i <= (n) ; ++i)
#define FORP(i , n , a)  for(int i = (n) ; i >= (a) ; --i)
#define CASE(x)		printf("Case %d: ", x)
#define CASE#(x) printf("Case #%d: " , x)
#define SFD(x)      scanf("%lf" , &x)
#define SFC(x)      scanf(" %c" , &x)
#define SFS(x)      scanf(" %s" , x)
#define SFI(x)      scanf("%d" , &x)
//#define SFL(x)      scanf("%lld" , &x)
#define SFI64(x)    scanf("%I64d" , &x)
#define PFF(x)         printf("%f" , x)
#define PFD(x)         printf("%lf" , x)
#define PFI(x)         printf("%d" , x)
#define PFC(x)         printf("%c" , x)
#define PFS(x)         printf("%s" , x)
#define PFI64(x)       printf("%I64d" , x)
//#define PFL(x)         printf("%lld" , x)
#define SPACE          printf(" ")
#define PUT            puts("")
#define TEST           printf("pass\n");
#define LPUP(i , j , k) for(int i = j ; i <= k ; ++i)
#define LPDW(i , j , k) for(int i = j ; i >= k ; --i)
#define PB(x)          push_back(x)
#define ALL(A)         A.begin(), A.end()
#define SZ(A)          int((A).size())
#define LBD(A, x)      (lower_bound(ALL(A), x) - A.begin())
#define UBD(A, x)      (upper_bound(ALL(A), x) - A.begin())
//#define LOCAL
static const double PI = acos(-1.0);
static const double EPS = 1e-8;
static const int SEED = 131;
static const int OO = 0X3fffffff;
typedef unsigned long long ULL;
typedef long long LL;
typedef double DB;
inline int read1()
{
    int x = 0;
    int f = 1 ; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {x = (x << 1) + (x << 3) + (ch - '0'); ch = getchar();}
    x *= f;
    return x;
}

struct buf
{
	operator int()
	{
		int x = 0 , y = 0 , c = getchar();
		while(c < 48)
			y = c == 45 , c = getchar();
		while(c > 47)
			x = (x << 1) + (x << 3) + (c - 48) , c = getchar();
		return y ? -x : x;
	}
}read;



inline void write(int x)
{
    int y = 10 , len = 1;
	if(x < 0)
	{
		putchar('-');
		x = -x;
	}
    while(y <= x)
    {
        y *= 10;
        ++len;
    }
    while(len--)
    {
        y /= 10;
        putchar(x / y + 48);
        x %= y;
    }
}

/************************Little Pea****************************/
static const int MAXN = 1e3 + 10;
int fac[MAXN];
int n;
int main()
{
#ifdef LOCAL
    freopen("G:\\desktop\\littlepea\\in.data" , "r" , stdin);
#endif
	fac[0] = 1;
	int pos = 1;
    for( ; fac[pos - 1] <= 100 ; ++pos)
		fac[pos] = fac[pos - 1] << 1;
	scanf("%d" , &n);
	int ans = 1;
	for(int i = 1 ; i <= pos ; ++i)
	{
		if(fac[i] > n)
			break;
		ans = fac[i];
	}
	printf("%d\n" , ans);

#ifdef LOCAL
    fclose(stdin);fclose(stdout);
#endif
}


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

int main() {
string S;
  cin >> S;
  int nagasa = (S.length()-1)/2;
  int N = S.length();
  int count = 0;
  for(int i = 0; i < nagasa; i++){
      if(S[i] != S[nagasa-1-i] || S[i] != S[N-1-i]){
      	count++;
      }
  }

  for(int i = 0; i < nagasa; i++){
      if(S[nagasa+1+i] != S[N-1-i] ){
      	count++;
      }
  }
  
  if(count == 0){
  	cout << "Yes" << endl;
  }
     
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int maxn = 1e6 + 7;
const ll f = 1e6;
int n, m, k, q;
int ar[maxn];

int a[maxn], b[maxn], c[maxn], d[maxn];
ll ans = 0;
void dfs(int cnt, int last){
    if(cnt == n){
        ll tmp = 0;
        for(int i = 0; i < q; i++){
            if(ar[b[i]] - ar[a[i]] == c[i])tmp += d[i];
        }
        ans = max(ans, tmp);
    }
    else{
        for(int i = last; i <= m; i++){
            ar[cnt] = i;
            dfs(cnt + 1, i);
        }
    }
}
int main() 
{
    //ios::sync_with_stdio(0); cin.tie(0); //C++关同步
    int t;
    ans = 0;
    cin >> n >> m >> q;
    for(int i = 0; i < q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    dfs(0, 1);
    cout << ans << '\n';

    return 0;
}


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

int main(){
    int sum = 0;
    int nnum = 10;
    for(int i = 0; i < 5; i++){
        int a; cin >> a;
        sum += a;
        if(a%10 != 0){
            nnum = min(nnum, a%10);
            sum += 10-a%10;
        } 
    }   
    cout << sum - (10-nnum) << endl;
    return 0;
}

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

void solve(){  
        string s,t;
        cin>>s>>t;
        int total=1e5;
        int flag=0;
        for(int i=0;i<(int)s.size();i++){
            int cur=0;
            for(int j=0;j<(int)t.size();j++){
                if(i+j>=(int)s.size()){
                    flag=1;
                    break;
                }
                if(t[j]!=s[i+j])
                    cur++;
            }
            if(flag==1)
                break;
            total=min(total,cur);
        }
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3508
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  
  int oktime = h2 * 60 + m2 - k - h1 * 60 - m1;
  if (oktime < 0) cout << 0;
  else cout << oktime;
  
  return 0;
}


Measured memory_bytes: 3588
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        pp: [u32;n]
    }
    let mut qq = pp.clone();
    qq.sort();
    let x = pp.iter().zip(qq.iter()).filter(|&(p,q)| p != q).count();
    if x <= 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include<cstdio>

using int64=long long;

constexpr int Maxn(100000);
constexpr int p(1000000007);

template<class _Tpx,class _Tpy>
	inline void inc(_Tpx&x,const _Tpy&y)
		{x+=y;(p<=x)&&(x-=p);}

namespace IOManager{
	constexpr int FILESZ(131072);
	char buf[FILESZ];
	const char*ibuf=buf,*tbuf=buf;

	struct IOManager{
		inline char gc()
			{return(ibuf==tbuf)&&(tbuf=(ibuf=buf)+fread(buf,1,FILESZ,stdin),ibuf==tbuf)?EOF:*ibuf++;}

		template<class _Tp>
			inline operator _Tp(){
				_Tp s=0u;char c=gc();
				for(;c<48;c=gc());
				for(;c>47;c=gc())
					s=(_Tp)(s*10u+c-48u);
				return s;
			}
	};
}IOManager::IOManager io;

int inv[Maxn+1];

int main(){
	const int n=io;

	inv[1]=1;
	for(int i=2;i<=n;++i)
		inv[i]=(int64)inv[p%i]*(p-p/i)%p;

	for(int i=2;i<=n;++i)
		inc(inv[i],inv[i-1]);

	int ans=0,*l=inv,*r=inv+n+1;
	for(int i=n;i;--i)
		inc(ans,(int)io*(int64)((*++l)+(*--r)-1)%p);
	for(int i=2;i<=n;++i)
		ans=(int64)ans*i%p;
	printf("%d",ans);

	return 0;
}


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

int main(){
	int n;
	cin >> n;
	int ans = 1;
	for (int i = 1; i <= n; i*=2) {
		ans = max(ans, i);
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}

vector<Int> getNum(Int n, Int b){
  vector<Int> res;
  Int x = 1LL<<(n - 1);
  Int num = (b - 1) - ((1LL<<n) - b);
  while(x){
    if(abs(num + x) < abs(num - x)) num += x, res.push_back(-x);
    else num -= x, res.push_back(x);
    x /= 2;
  }
  reverse(res.begin(), res.end());
  return res;
}

string rev(string s){
  for(char &ch:s) ch = ch == 'L'? 'R':'L';
  return s;
}

string solve(Int n,Int a, Int b){
  a = (1LL<<n) - a + 1;
  Int height = (1LL<<n);
  string res;
  auto dir = getNum(n, b);
  for(Int x:dir){
    Int openL = -1;
    if(height / 2 >= a){ //lower
      if(x > 0) openL = 1;
      if(x < 0) openL = 0;
    }
    else{                //upper
      if(x > 0) openL = 0, a = height - a + 1, res = rev(res);
      if(x < 0) openL = 1, a = height - a + 1, res = rev(res);
    }
    assert(x != 0);
    res += openL? 'L':'R';
    height /= 2;
  }
  reverse(res.begin(), res.end());
  return res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(1){
    Int n, a, b;
    cin>>n>>a>>b;
    if(n == 0 && a == 0 && b == 0) return 0;
    string ans = solve(n, a, b);
    cout<<ans<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3196
#include<stdio.h>
#define SIZE 51
int PAR[SIZE],RANK[SIZE];
void init_uf(int n){for(int i=0;i<n;i++){PAR[i]=i;RANK[i]=0;}}//initialize
int root(int i){return PAR[i]==i?i:(PAR[i]=root(PAR[i]));}//search group
int same(int x,int y){return root(x)==root(y);}//judge same group
void unite(int x,int y){//add edge
  x=root(x);y=root(y);
  if(x==y)return;
  if(RANK[x]<RANK[y])PAR[x]=y;
  else{PAR[y]=x;if(RANK[x]==RANK[y])RANK[x]++;}
}
int main(){
  int e[50][2],i,j,k,n,m,a=0;
  scanf("%d%d",&n,&m);
  for(i=0;i<m;i++)scanf("%d%d",&e[i][0],&e[i][1]);
  for(i=0;i<m;i++){
    init_uf(n+1);
    for(j=0;j<m;j++)if(i!=j)unite(e[j][0],e[j][1]);
    for(j=1;j<=n;j++)for(k=j+1;k<=n;k++)if(!same(j,k)){a++;j=k=n+1;}
  }
  printf("%d",a);
}


Measured memory_bytes: 1696