akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

static int A[500000];
int cnt = 0;

void merge(int A[], int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    int *L;
    int *R;
    int i, j, k;

    L = malloc(sizeof(int) * (n1 + 1) );
    R = malloc(sizeof(int) * (n2 + 1) );

    for ( i = 0; i < n1; i++ ) {
        L[i] = A[left + i];
    }
    for ( i = 0; i < n2; i++ ) {
        R[i] = A[mid + i];
    }
    
    L[n1] = INT_MAX;
    R[n2] = INT_MAX;

    i = 0;
    j = 0;

    for ( k = left; k < right; k++ ) {
        if ( L[i] <= R[j] ) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
        cnt++;
    }

    free(L);
    free(R);
}

void mergeSort(int A[], int left, int right)
{
    int mid;

    if ( left + 1 < right ) {
        mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(void)
{
    int n;

    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &A[i]);
    }

    mergeSort(A, 0, n);

    for ( int i = 0; i < n; i++ ) {
        printf("%d", A[i]);
        if ( i != n - 1 ) {
            printf(" ");
        } else {
            printf("\n");
        }
    }

    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 5424
#include <iostream>
#include <algorithm>
using namespace std;
int n, q, c, x, y, size_, dat[262144];
inline void update(int pos, int x) {
	pos += size_; dat[pos] = x;
	while(pos != 1) {
		pos >>= 1;
		dat[pos] = min(dat[2 * pos], dat[2 * pos + 1]);
	}
}
inline int query(int a, int b, int k, int l, int r) {
	if(r <= a || b <= l) return 2147483647;
	if(a <= l && r <= b) return dat[k]; k <<= 1;
	int lc = query(a, b, k, l, (l + r) / 2);
	int rc = query(a, b, k + 1, (l + r) / 2, r);
	return min(lc, rc);
}
int main() {
	scanf("%d%d", &n, &q);
	for(size_ = 1; size_ < n;) size_ *= 2;
	for(int i = 0; i < size_ * 2; i++) dat[i] = 2147483647;
	for(int i = 0; i < q; i++) {
		scanf("%d%d%d", &c, &x, &y);
		if(c == 0) update(x, y);
		else printf("%d\n", query(x, y + 1, 1, 0, size_));
	}
}

Measured memory_bytes: 4228
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;

int dfs(int cue, int a, int b, int c, int A,int B,int C, int n, int mp,int l[] ) {
	if (cue == n) {
		if (min(min(a,b),c) > 0) {
			return  (abs(A - a) + abs(B - b) + abs(C - c) - 30 );
			
		}
		else {
			return 100000000;
		}
	}

	int p1 = dfs(cue + 1, a, b, c, A, B, C, n, mp,l);
	int p2 = dfs(cue + 1, a + l[cue], b, c, A, B, C, n, mp,l) + 10;
	int p3 = dfs(cue + 1, a, b + l[cue], c, A, B, C, n, mp,l) + 10;
	int p4 = dfs(cue + 1, a, b, c + l[cue], A, B, C, n, mp,l) + 10;
	return min(min(p1, p2), min(p3, p4));
}

int main()
{
	int n, A, B, C;
	cin >> n >> A >> B >> C;
	int l[10];
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}

	cout << dfs(0,0,0,0,A,B,C, n, 0,l) << endl;
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,k,h,h1,ans,ans1;
char c[100100],a[100100];
bool no=false;
int main()
{
	cin>>n>>k;
	h1=k;
	for(int i=0;i<n;i++)
	{
		cin>>c[i];
		a[i]=c[i];
	}
	for(int i=0;i<n;i++)
	{
		if(k==0)
			break;	
		if(c[i]=='R' && no==false)
		{
			no=true;
			h=i;
		}
		if((c[i+1]=='L' || i==n-1)&& no==true)
		{
			for(int o=h;o<=i;o++)
				c[o]='L';
			no=false;
			k--;	
		}
	}	
	for(int i=0;i<n;i++)
	{
		//cout<<c[i];
		if(c[i]=='L' && c[i-1]=='L' && i!=0)
			ans++;
		if(c[i]=='R' && c[i+1]=='R' && i!=n-1)
			ans++;	
	}
	//cout<<endl;
	for(int i=0;i<n;i++)
		c[i]=a[i];
	k=h1;
	no=false;	
	for(int i=0;i<n;i++)
	{
		if(k==0)
			break;	
		if(c[i]=='L' && no==false)
		{
			no=true;
			h=i;
		}
		if((c[i+1]=='R' || i==n-1)&& no==true)
		{
			for(int o=h;o<=i;o++)
				c[o]='R';
			no=false;
			k--;	
		}
	}	
	for(int i=0;i<n;i++)
	{
		//cout<<c[i];
		if(c[i]=='L' && c[i-1]=='L' && i!=0)
			ans1++;
		if(c[i]=='R' && c[i+1]=='R' && i!=n-1)
			ans1++;	
	}
	//cout<<endl;
	cout<<max(ans,ans1)<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N, M, h[1500], w[1500];
 
  while(cin >> N >> M, N){
    for(int i = 0; i < N; i++){
      cin >> h[i];
    }
    for(int i = 0; i < M; i++){
      cin >> w[i];
    }
     
    map< int, int > foo, piyo;
    for(int i = 0; i < N; i++){
      int sum = 0;
      for(int j = i; j < N; j++){
        sum += h[j];
        foo[sum]++;
      }
    }
    for(int i = 0; i < M; i++){
      int sum = 0;
      for(int j = i; j < M; j++){
        sum += w[j];
        piyo[sum]++;
      }
    }
 
 
    int cnt = 0;
    for(map< int , int >::iterator it = foo.begin(); it != foo.end(); it++){
      cnt += it -> second * piyo[it -> first];
    }
    cout << cnt << endl;
  }
}


Measured memory_bytes: 34408
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int mul(int a,int b){return(ll)a*b%mod;}
void inc(int&a,int b){(a+=b)>=mod?a-=mod:0;}
int a[210];
bool cmp(int x,int y){return x>y;}
int f[100010],g[100010];
int main(){
	int n,x,i,j,s;
	scanf("%d%d",&n,&x);
	for(i=1;i<=n;i++)scanf("%d",a+i);
	sort(a+1,a+n+1,cmp);
	f[x]=1;
	for(i=1;i<=n;i++){
		memset(g,0,sizeof(g));
		for(j=0;j<=x;j++){
			if(f[j]){
				inc(g[j],mul(n-i,f[j]));
				inc(g[j%a[i]],f[j]);
			}
		}
		memcpy(f,g,sizeof(g));
	}
	s=0;
	for(i=0;i<a[n];i++)inc(s,mul(i,f[i]));
	printf("%d",s);
}

Measured memory_bytes: 896
s = input()
odd = ["R", "U", "D"]
even = ["L", "U", "D"]

for i in range(0,len(s),2):
	if s[i] not in odd:
		print("No")
		exit()
		
for j in range(1,len(s),2):
	if s[j] not in even:
		print("No")
		exit()
		
print("Yes")	

Measured memory_bytes: 3060
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int D,x,y;
vector<int> d1;
vector<int> d2;

int f(int a,int b){
	int sum = 0;
	for(int i = 0;i < a;i++){
		sum += d1[d1.size() - 1 - i];
	}
	for(int j = 0;j < b;j++){
		sum += d2[d2.size() - 1 - j];
	}
	return sum;
}

int main(){
	cin>>D;
	cin>>x;

	for(int i = 0;i < x;i++){
		char c;
		int z;
		cin>>c>>z;
		if(c != 'D')continue;
		d1.push_back(z);
	}
	sort(d1.begin(),d1.end());
	cin>>y;
	for(int i = 0;i < y;i++){
		string c;
		cin>>c;
		int z;
		cin>>z;
		if(c != "DD")continue;
		d2.push_back(z);
	}
	sort(d2.begin(),d2.end());
	int x = d1.size();
	int y = d2.size();
	int ans = 0;
	for(int i = 0;i <= x;i++){
		for(int j = 0;j <= y;j++){
			if(i + j*2 > D)break;
			ans = max(ans,f(i,j));
		}
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 1236
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let k: i64 = input();
    let x: Vec<i64> = (0..n).map(|_| input()).collect();
    println!(
        "{}",
        x.iter()
            .fold(0, |acc, &x| acc + 2 * std::cmp::min(x, k - x))
    );
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int n,m,x,y,a[200005],b[200005];
int main()
{
    cin>>n>>m;
    int k=0,f=0;
    for(int i=0;i<m;i++)
    {
            cin>>x>>y;
            if(x==1) {a[k]=y;k++;}
            if(y==n) {b[x]=1;}
    }
    for(int i=0;i<k;i++)
        if(b[a[i]]==1) f=1;
    if(f) printf("POSSIBLE");
    else printf("IMPOSSIBLE");
}

Measured memory_bytes: 1408
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Node nodes[] = new Node[n];
        for(int i = 0 ; i < n ; i++)
            nodes[i] = new Node(i);
        for(int i = 0 ; i < n ; i++){
            int index = sc.nextInt();
            int k = sc.nextInt();
            for(int j = 0 ; j < k ; j++)
                nodes[index].children.add(sc.nextInt());
        }
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < nodes[i].children.size() ; j++)
			nodes[nodes[i].children.get(j)].parent = nodes[i];
	}
        for(int i = 0 ; i < n ; i++)
            System.out.println("node " + nodes[i].index + ": parent = " + nodes[i].get_parent() + ", depth = " + nodes[i].depth() + ", " + nodes[i].type() + ", " + nodes[i].children);
    }
}
class Node{
    int index;
    Node parent = null;
    List<Integer> children;
    int get_parent(){
        if(parent == null)
            return -1;
        else
            return parent.index;
    }
    int depth(){
        if(parent == null)
            return 0;
        else
            return parent.depth() + 1;
    }
    String type(){
        if(parent == null)
            return "root";
        else if(children.size() == 0)
            return "leaf";
        else
            return "internal node";
    }
    Node(int index){
        this.index = index;
        children = new ArrayList<Integer>();
    }
}


Measured memory_bytes: 160132
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define REP(i,a,b) for(long long int i=a ; i<b ; i++)
#define mp make_pair
#define INF 1000000000000000000
#define mod 1000000007
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define vi vector<ll>
#define vd vector<ld>
#define vvi vector<vi>
#define vvd vector<vd>
#define vpi vector<pi>
#define vpd vector<pd>
#define us unordered_set<ll>
#define um unordered_map<ll,ll>
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<ll>())
#define all(a) a.begin(),a.end()
#define N 100005


#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define in insert
#define fbo find_by_order
#define ook order_of_key


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

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

ll powmod(ll x,ll y)
{
	if(x==0)
		return 0;
	if(y==0 || x==1)
		return 1;
	if(y%2==0)
		return powmod((x*x)%mod,y/2)%mod;
	return (x*powmod(x,y-1)%mod)%mod;
}
void print1D(vi a)
{
	for(ll i=0;i<a.size();++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
void print2D(vector<vi> a)
{
	for(ll i=0;i<a.size();++i)
	{
		for(ll j=0;j<a[i].size();++j)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}
void solve()
{
	ll n;
	cin>>n;
	vi a(n+1);
	for(ll i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	vvi dp(n+2,vi(n+2));
	for(ll i=1;i<=n;++i)
	{
		dp[i][i]=a[i];
	}
	for(ll l=2;l<=n;++l)
	{
		for(ll i=1;i<=n-l+1;++i)
		{
			ll j=i+l-1;
			ll x=min(dp[i+2][j]+a[i]-a[i+1],dp[i+1][j-1]+a[i]-a[j]);
			ll y=min(dp[i][j-2]+a[j]-a[j-1],dp[i+1][j-1]+a[j]-a[i]);
			dp[i][j]=max(x,y);
			// debug(i,j,dp[i][j]);
		}
	}
	cout<<dp[1][n]<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

ll n;

ll LCM()
{
    return 2ll/__gcd(2ll,n)*n;
}

int main()
{
    cin >> n;
    cout << LCM() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#define maxn 10005
#define MAXN 10005
#define inf 0x0f0f0f0f

using namespace std;

int head[maxn],tol,dis[maxn],vis[maxn],n,m,mi[maxn];
int cost[MAXN];

struct node
{
    int a,len,to,next,cost;
}edge[50005];



void INIT()
{
    tol=0;
	memset(head,-1,sizeof(head));
}

void add(int a,int b,int c,int d)
{
    edge[tol].to=b;
    edge[tol].len=c;
    edge[tol].cost=d;
    edge[tol].next=head[a];
    head[a]=tol++;
}

void SPFA()
{
    int i,a,p;

    for(i=0;i<n;i++)
        dis[i]=inf,vis[i]=0,cost[i]=inf;
    queue<int> que;
    vis[0]=1,cost[i]=dis[0]=0;
    que.push(0);
    while(!que.empty())
    {
        a=que.front(),que.pop();
        vis[a]=0;
        for(p=head[a];p!=-1;p=edge[p].next)
        {
            if(dis[edge[p].to]>dis[a]+edge[p].len)
            {
                dis[edge[p].to]=dis[a]+edge[p].len;
                cost[edge[p].to]=edge[p].cost;
                if(!vis[edge[p].to])
                {
                    vis[edge[p].to]=1;
                    que.push(edge[p].to);
                }
            }
            if(dis[edge[p].to]==dis[a]+edge[p].len&&cost[edge[p].to]>edge[p].cost)
            {
            //    puts("Debug");
                cost[edge[p].to]=edge[p].cost;
                if(!vis[edge[p].to])
                {
                    vis[edge[p].to]=1;
                    que.push(edge[p].to);
                }
            }
        }
    }
}

int main(){
    int i,j;
    int a,b,l,c;
    while(scanf("%d%d",&n,&m),n||m){
       INIT();
       for(i=0;i<m;i++){
            scanf("%d%d%d%d",&a,&b,&l,&c);
            a--;
            b--;
            add(a,b,l,c);
            add(b,a,l,c);
       }
       SPFA();
       int res=0;
       for(i=1;i<n;i++)
           // printf("Debug :%d\n",father[i]);
            res+=cost[i];
        printf("%d\n",res);
       //bfs();
    }
    return 0;
}
/*
5 6
1 2 2 2
2 3 1 1
1 4 1 1
3 5 1 1
4 2 2 1
4 5 1 1

*/

Measured memory_bytes: 2180
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n - 1, -1, -1):
    cnt = 0
    for j in range(2 * (i + 1), n + 1, i + 1):
        cnt += b[j - 1]
    if cnt % 2 != a[i]:
        b[i] = 1
m = b.count(1)
print(m)
for i in range(n):
    if b[i]:
        print(i + 1, end=' ')


Measured memory_bytes: 7148
// AOJ 2539: Counting 1's
// 2017.12.1 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define INF 1000000000000000000LL
int n;

long long k[65];

long long calc(long long a, int x)
{
	long long mask, t, ans;

    mask = 1LL << x;
	a++;
//    t = a/mask, ans = (t >> 1)*mask;
    t = a >> x, ans = (t >> 1)*mask;
    if (t & 1) ans += a & (mask-1);
    return ans;
}

int check(long long a, long long b)
{
	int i;

    for (i = n-1; i >= 0; i--)
        if (calc(b, i) - calc(a-1, i) != k[i]) return 0;
    return 1;
}

long long solve(long long w)
{
	int i;
    long long a = 0, b = -1, c = -1;

    for (i = n-1; i >= 0; i--) {
        if (k[i] > w) return -1;
	    if (k[i] == w) a |= 1LL << i;
        else if (k[i]) {
            b = a | (1LL<<i);
            c = b + k[i]-1;
            a = c - w + 1;
            break;
        }
    }
    if (c == -1) c = a;
    if (a == 0 || c > INF) return -1;
    if (a + w - 1 == c && check(a, c)) return a;
    return -1;
}

char buf[50], *p;
long long getlong()
{
	long long n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int i;
	long long a, b, w, ans;

	while (fgets(p=buf, 5, stdin) && *p != '0') {
		n = atoi(buf);
		for (i = 0; i < n; i++) {
			fgets(p=buf, 30, stdin);
			k[i] = getlong();
		}

        a = -1;
        for (w = 2*k[0]-1; w <= 2*k[0]+1; w++) {
			if (w <0) continue;
            ans = solve(w);
            if (ans != -1) {
				if (a != -1) { puts("Many"); goto done; }
                a = ans; b = ans + w - 1;
            }
        }
        if (a == -1) puts("None");
        else printf("%lld %lld\n", a, b);
done:   ;
	}
    return 0;
}

Measured memory_bytes: 1756
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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



signed main () {
    int h,w,k;cin >>h>>w>>k;
    vector<string> s(h);
    rep(i,h)cin >>s[i];
    int ans=0;

    for (int bit = 0; bit < (1<<h+w); ++bit) {
        vector<int> S;
        for (int i = 0; i < h+w; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }
        vector<string> a=s;
        //i<h....h全体を垢,それ以上でなにもしない
        rep(i,S.size()){
            if(S[i]<h){
                rep(j,w){
                    a[S[i]][j]='.';
                }
            }else{
               rep(j,h){
                    a[j][S[i]-h]='.';
                }
            }
        }
        int cnta=0;
        rep(i,h){
            rep(j,w){
                if(a[i][j]=='#')cnta++;
            }
        }
        if(cnta==k)ans++;
    }

cout <<ans<<endl;
}





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

def int_to_bit(N):
  lst=[]
  ans=''
  if N==0:
    return 0
  while N!=1 and N!=0:
    lst.append(str(N%2))
    N//=2
  for i in range(1,len(lst)+1):
    ans+=lst[-i]
  if N==0:
    pass
  else:
    ans='1'+ans
  return int(ans)

def bit_to_int(N):
  N=str(N)
  ans=0
  for i in range(len(N)):
    ans+=int(N[i])*2**(len(N)-1-i)
  return ans

def XOR(a,b):
  a,b=min(a,b),max(a,b)
  a,b=str(a),str(b)
  length=len(a)
  lst=[]
  ans=''
  for i in range(1,length+1):
    if a[-i]==b[-i]=='1' or a[-i]==b[-i]=='0':
      lst.append('0')
    else:
      lst.append('1')
  for i in range(1,length+1):        
    ans+=lst[-i]
  if length==len(b):
    pass
  else:
    add=b[0:len(b)-length]
    ans=add+ans
  return bit_to_int(ans)

if A%2==0 and B%2==0:
  v=(B-A)//2
  if v%2==0:
    print(B)
  else:
    print(XOR(1,int_to_bit(B)))
elif A%2==0 and B%2==1:
  v=(B-A+1)//2
  if v%2==0:
    print(0)
  else:
    print(1)
elif A%2==1 and B%2==0:
  v=(B-1-A)//2
  if v%2==0:
    print(XOR(int_to_bit(A),int_to_bit(B)))
  else:
    print(XOR(1,int_to_bit(XOR(int_to_bit(A),int_to_bit(B)))))
else:
  v=(B-A)//2
  if v%2==0:
    print(A)
  else:
    print(XOR(int_to_bit(A),1))

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define rep(x,y) for(int x=0;x<y;x++)
int n,tmp;
long long res,res_1,res_2;
vector<int> a,f,r,f_2,r_2;
int main(){
  cin>>n;
  rep(i,n){
    cin>>tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  if(n%2==0){
    rep(i,n){
      if(i<n/2){
        f.push_back(a[i]);
      }else{
        r.insert(r.begin(),a[i]);
      }
    }
    rep(i,f.size()){
      if(i==f.size()-1){
        res-=f[i];
        res+=r[i];
      }else{
        res-=f[i]*2;
        res+=r[i]*2;
      }
    }
  }else{
    rep(i,n){
      if(i<n/2){
        f.push_back(a[i]);
        f_2.push_back(a[i]);
      }
      if(i==n/2){
        r.insert(r.begin(),a[i]);
        f_2.push_back(a[i]);
      }
      else{
        r.insert(r.begin(),a[i]);
        r_2.insert(r_2.begin(),a[i]);
      }
    }
    rep(i,n/2){
      res_1-=f[i]*2;
      res_2+=r_2[i]*2;
    }
    rep(i,n/2+1){
      if(i>=n/2-1){
        res_1+=r[i];
        res_2-=f_2[i];
      }else{
        res_1+=r[i]*2;
        res_2-=f_2[i]*2;
      }
    }
    res=max(res_1,res_2);
  }
  cout<<res;
  return 0;
}


Measured memory_bytes: 2424
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

typedef long long ll;

int main() {
    ll X;
    cin >> X;
    ll a, b;
    a = X/500;
    b = (X - a*500)/5;
    cout << a*1000+b*5 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

string s;

int main(){
	cin >> s;
	if (s == "a" || s == "e" || s == "i" || s == "u" || s == "o"){
		cout << "vowel" << endl;
	}
	else cout << "consonant" << endl;
}

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

	using namespace std;

	const int maxn = 5010;

	int n,k,a[maxn],res;

	bitset<maxn> L[maxn], R[maxn];

	int main() {
		ios_base::sync_with_stdio(0); cin.tie(0);
		cin>>n>>k;
		long long s=0;
		for (int i=1;i<=n;i++) {
			cin>>a[i];
			s+=a[i];
		}
		if (s<k) {
		   cout<<n<<endl;
		   return 0;
		}   
		L[0][0] = R[n+1][0] = 1;
		for (int i=1;i<=n;i++) L[i] = L[i-1] | (L[i-1]<<a[i]);
		for (int i=n;i>=1;i--) R[i] = R[i+1] | (R[i+1]<<a[i]);
		res=n; 
		for (int i=1;i<=n;i++) {
		   bitset<maxn> allsumL=L[i-1];
		   bitset<maxn> allsumR=R[i+1];
		   static int sum[maxn];
		   sum[0]=1;
		   for (int j=1;j<maxn;j++) sum[j] = sum[j-1] + allsumR[j];
		   for (int j=0;j<maxn;j++)
			   if (allsumL[j]) {
				  int lo = max(0,k-a[i]-j);
				  int hi = min(maxn-1,k-j-1);
				  if (lo<=hi) {
					 int total = sum[hi];
					 if (lo) total -= sum[lo-1];
					 if (total) {
						res--;
						break;
					 }
				  }
			   }
		}
		cout<<res<<endl;
	}


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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600
#define MAX 1000000

vector<int> nums,odds;

int  dp[MAX+1];
int dp2[MAX+1];

int dfs(int n, int *memo, vector<int> &vec){
  if(memo[n]!=-1) return memo[n];
  int ret = INF;
  for(int nxt : vec){
    if(n==nxt) return 1;
    if(n>nxt) ret = min(ret, dfs(n-nxt, memo, vec)+1);
  }
  return memo[n] = ret;
}

int main(){
  int tmp=0, n=1;
  while(tmp<=MAX){
    tmp+=n*(n+1)/2;
    nums.pb(tmp);
    if(tmp%2==1) odds.pb(tmp);
    n++;
  }

  fill(dp, dp+MAX+1, -1);
  fill(dp2, dp2+MAX+1, -1);

  dp[0] = dp2[0] = 0;

  // ??§????????????????????????????????¨?????°?????°????¢????????????????
  reverse(all(nums));
  reverse(all(odds));

  while(cin>>n, n){
    cout << dfs(n, dp, nums) << " " << dfs(n, dp2, odds) << endl;
  }

  return 0;
}

Measured memory_bytes: 10864
/*Aonyx Cinerea*/
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pai;
const int MAXN = 100000 + 17;

vector<pai> Adj[MAXN];
bool vis[MAXN];
int val[MAXN];

bool DFS(int u)
{
    for(const auto& e: Adj[u])
    {
        int v = e.first, w = e.second;
        if(!vis[v])
        {
            vis[v] = 1;
            val[v] = val[u] + w;
            if(DFS(v))
                return true;
        }
        if(val[v] != val[u] + w)
            return true;
    }
    return false;
}

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

    int n, m;   cin >> n >> m;
    for(int i=1; i<=m; ++i)
    {
        int a, b, w;    cin >> a >> b >> w;
        Adj[a].emplace_back(b, w);
        Adj[b].emplace_back(a, -w);
    }

    bool st = true;
    for(int i=1; i<=n; ++i)
        if(!vis[i])
        {
            vis[i] = 1;
            if(DFS(i))
            {
                st = false;
                break;
            }
        }
    if(st)
        cout << "Yes";
    else
        cout << "No";
}


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

int main(){

  int n;
  cin>>n;
  int a[10000];
  for(int i=0;i<n;i++) cin>>a[i];


  int mn = a[0], mx = a[0];
  long long sum = 0;
  for(int i=0;i<n;i++){
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
    sum += a[i];
  }

  cout<<mn<<" "<<mx<<" "<<sum<<endl;

  return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin >> x;
  int i, j;
  vector<int> sosuu;
 
  /* 判定フラグ */
  int flag;
 
  /* 素数かどうかを判定 */
  for( i=2;i<=100020;++i ) {
    flag = 0;
    for( j=2;j<i;++j ){
      if( i%j==0 ) {
        flag = 1;
        break;
      }
    }
    /* 判定結果を出力 */
    if( flag==0 )
      sosuu.push_back(i);

  }
  int count = 0;
  for(int j = 0; j < sosuu.size(); j++){
      if(x > sosuu[j]){
          count +=1;
      }else{
          cout << sosuu[j];
          break;
      }
  }
  }



Measured memory_bytes: 384
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix
# CreatedDate:  2020-09-15 21:36:31 +0900
# LastModified: 2020-09-15 22:19:28 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from collections import deque


class BFS():
    def __init__(self, path, N):
        self.N = N
        self.color_path = [-1]*self.N
        self.path = path
        self.init = 1
        self.Q = deque([[0, self.init]])

    def forward(self):
        while self.Q:
            prev_path, u = self.Q.popleft()
            p_cnt = 1
            for cp, v in self.path[u]:
                if self.color_path[cp] == -1:
                    if prev_path == p_cnt:
                        p_cnt += 1
                    self.Q.append([p_cnt, v])
                    self.color_path[cp] = p_cnt
                    p_cnt += 1
#            print(self.color_path)

    def print_ans(self):
        self.color_path.pop(0)
        print(max(self.color_path))
        for cp in self.color_path:
            print(cp)


def main():
    N = int(input())
    path = [[] for _ in range(N+1)]
    for i in range(1, N):
        a, b = map(int, input().split())
        path[a].append([i, b])
        path[b].append([i, a])
    bfs = BFS(path, N)
    bfs.forward()
    bfs.print_ans()



if __name__ == "__main__":
    main()


Measured memory_bytes: 46896
'use strict'
function Main(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  var A=input.shift();
  var B=input.shift();
  var result=Math.max(2*A-1,2*B-1,A+B);
  console.log(result);
}

Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include<stdio.h>
int main(){
  int i,j,k;
  int d;	//365
  int c[26];
  int score[9490];
  int t[365] = {0};
  int day1[26] = {0};
  double x = 0.36787944117;
  int tmp1=-99999,tmp2=-99999;
  
  scanf("%d",&d);
  for(i=0;i<26;i++){
      scanf("%d ",&c[i]);
  }
  for(i=0;i<d*26;i++){
      scanf("%d ",&score[i]);
  }
  //st
  
  for(i=0;i<d;i++){
    for(j=0;j<26;j++){
      if(score[i*26+j]-c[j]*(1+day1[j])>tmp1){
       	tmp1 =  score[i*26+j]-c[j]*(1+day1[j]);
        t[i] = j;
      }
      for(k=0;k<26;k++){
       //if(day1[k]!=0){
        day1[k] += 1; 
       //}
      }
      day1[t[j]] = 0;
    }
  }
  
  //en
  for(i=0;i<d;i++){
      printf("%d\n",t[i]+1);
  }
 return 0; 
}




Measured memory_bytes: 2196
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
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;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

int N,mx1=-inf,mx2=-inf,mn1=inf,mn2=inf;
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N;
	rep(i,N){
		int a,b;cin>>a>>b;
		chmax(mx1,a+b);
		chmax(mx2,a-b);
		chmin(mn1,a+b);
		chmin(mn2,a-b);
	}
	cout<<max(mx1-mn1,mx2-mn2)<<"\n";
}

Measured memory_bytes: 3644
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	string field;
	cin >> field;

	char start = field[0];
	char end = field[field.size()-1];

	if(start == end) {
		cout << start << endl;
	} else {
		cout << 'o' << endl;
	}
}

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

const int MAX_N = 100100;
int du[MAX_N], dv[MAX_N];
vector<int> tree[MAX_N];
bool visited[MAX_N];
int N, u, v;

void dfs(int prev, int cur, int *d){
    for(int i = 0; i < tree[cur].size(); ++i) if(tree[cur][i] != prev){
        int leaf = tree[cur][i];
        d[leaf] = d[cur] + 1;
        dfs(cur, leaf, d);
    }
}

int main()
{
    scanf("%d %d %d", &N, &u, &v);
    --u, --v;
    for(int i = 0; i < N-1; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        --a, --b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    dfs(-1, u, du); dfs(-1, v, dv);
    int goal = u;
    for(int i = 0; i < N; ++i) if(du[i] < dv[i] && dv[goal] < dv[i]) goal = i;
    printf("%d\n", dv[goal]-1);
    return 0;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N; cin >> N; vector<int> B(N-1);
 for(int i = 0; i < N-1; i++){ cin >> B[i];}
  ll res = 0;
  for(int i = 0; i < N; i++){
    if(i == 0){ res += B[0];} else if( i == N-1){ res += B[N-2];}
    else{
      res += min(B[i-1], B[i]);}
  }
  
  cout << res << endl; return 0;}


Measured memory_bytes: 256
#include <ctype.h>
#include <iostream>
#include <string>

using namespace std;

bool IsPostalCode(string s, int a, int b) {
  for (int i = 0; i < a; ++i) {
    if (!isdigit(s[i])) return false;
  }
  if (s[a] != '-') return false;

  for (int i = a + 1; i < a + b + 1; ++i) {
    if (!isdigit(s[i])) return false;
  }
  return true;
}

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

  int a, b;
  string s;
  cin >> a >> b;
  cin >> s;

  if (IsPostalCode(s, a, b)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby
# require 'pry'

# dpテンプレ
# 最小化
# dp = Hash.new{ Float::INFINITY }
# dp[i] = [dp[i], dp[i-1] + hoge].min
# dp[0] = 0
# 最大化
# dp = Hash.new{ 0 }
# dp[i] = [dp[i], dp[i-1] + hoge].max
# dp[0] = 0

x = gets.to_i
n = x.lcm(360)
puts n / x


Measured memory_bytes: 14384
# -*- coding: utf-8 -*-

import sys

sys.setrecursionlimit(10 ** 9)
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()))
INF=2**31-1

class SegTreeMin:
    """
    以下のクエリを処理する
    1.update:  i番目の値をxに更新する
    2.get_min: 区間[l, r)の最小値を得る
    """
 
    def __init__(self, n):
        """
        :param n: 要素数
        """
        self.n = n
        # nより大きい2の冪数
        n2 = 1
        while n2 < n:
            n2 <<= 1
        self.n2 = n2
        self.tree = [INF] * (n2 << 1)
 
    def update(self, i, x):
        """
        i番目の値をxに更新
        :param i: index(0-indexed)
        :param x: update value
        """
        i += self.n2
        self.tree[i] = x
        while i > 1:
            self.tree[i >> 1] = x = min(x, self.tree[i ^ 1])
            i >>= 1
 
    def get_min(self, a, b):
        """
        [a, b)の最小値を得る
        :param a: index(0-indexed)
        :param b: index(0-indexed)
        """
        return self._get_min(a, b, 1, 0, self.n2)
 
    def _get_min(self, a, b, k, l, r):
        """
        [a, b)の最小値を得る内部関数
        :param k: 現在調べている区間のtree内index
        :param l, r: kが表す区間の左右端index [l, r)
        :return: kが表す区間と[a, b)の共通区間内での最小値。共通区間を持たない場合はINF
        """
        # 範囲外ならINF
        if r <= a or b <= l:
            return INF
        # [a,b)が完全に[l,r)を包含するならtree[k]の値を採用
        if a <= l and r <= b:
            return self.tree[k]
        # 一部だけ範囲内なら2つに分けて再帰的に調査
        m = (l + r) // 2
        return min(
            self._get_min(a, b, k << 1, l, m),
            self._get_min(a, b, (k << 1) + 1, m, r)
        )

N,Q=MAP()
st=SegTreeMin(N)
for _ in range(Q):
    com,x,y=MAP()
    if com==0:
        st.update(x, y)
    else:
        print(st.get_min(x, y+1))



Measured memory_bytes: 9464
N = int(input())
S = input()

# 1 S -1 W
d = [0]*N

def check(a, b):
    d[-1] = a
    d[0] = b
    for i in range(N-2):
        if S[i] == "o":
            if d[i] == 1:
                d[i+1] = d[i-1]
            else:
                d[i+1] = d[i-1]*-1
        else:
            if d[i] == 1:
                d[i+1] = d[i-1]*-1
            else:
                d[i+1] = d[i-1]
        
    for i in range(N-1):
        if d[i] == 1:
            if S[i] == "o":
                if d[i-1] != d[i+1]:
                    return False
            else:
                if d[i-1] == d[i+1]:
                    return False
        else:
            if S[i] == "o":
                if d[i-1] == d[i+1]:
                    return False
            else:
                if d[i-1] != d[i+1]:
                    return False
    if d[N-1] == 1:
        if S[N-1] == "o":
            if d[N-2] != d[0]:
                return False
        else:
            if d[N-2] == d[0]:
                return False
    else:
        if S[N-1] == "o":
            if d[N-2] == d[0]:
                return False
        else:
            if d[N-2] != d[0]:
                return False
    return True

if check(1, 1):
    pass
elif check(1, -1):
    pass
elif check(-1, -1):
    pass
elif check(-1, 1):
    pass
else:
    print(-1)
    exit()

ans = ""
for i in range(N):
    if d[i] == 1:
        ans += "S"
    else:
        ans += "W"
print(ans)



Measured memory_bytes: 10084
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
#define mo 998244353
#define maxn 205
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,x[maxn],y[maxn],po[maxn],ans;
inline bool bd(int i,int j,int k)
{
    int a=x[k]-x[i],b=y[k]-y[i];
    int c=x[j]-x[k],d=y[j]-y[k];
    if(1ll*a*c<0)return false;
    if(1ll*b*d<0)return false;
    if(1ll*a*d!=1ll*b*c)return false;
    return true;
}
int main()
{
    n=read();reg int i,j,k,tot;po[0]=1;
    for(i=1;i<=n;++i)x[i]=read(),y[i]=read();
    for(i=1;i<=n;++i)po[i]=po[i-1]*2%mo;
    ans=po[n]-n-1;
    for(i=2;i<=n;++i)
        for(j=1;j<i;++j)
        {
            tot=0;
            for(k=1;k<=n;++k)
                if(i!=k&&j!=k&&bd(i,j,k))
                    ++tot;
            ans=(ans+mo-po[tot])%mo;
        }
    cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
#################
n = int(input())
d = list(map(int, input().split()))
d.sort()
lend = len(d)

if lend % 2 == 1:
    ans = 0
else:
    lend2 = lend//2
    a1 = d[lend2-1]
    a2 = d[lend2]
    ans = a2 - a1

print(ans)

Measured memory_bytes: 52776
# coding: utf-8
N = int(input())
S = list(input())

R = S.count("R")
G = S.count("G")
B = S.count("B")

ans = R * G * B
count = 0

for i in range(N - 2):
    for j in range(i + 1, N):
        k = j * 2 - i
        if k >= N:
            break
        if {S[i], S[j], S[k]} == {"R", "G", "B"}:
            count += 1
ans -= count
print(ans)


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

string UR(string s,int Y,int X){
  for(int i=0;i<Y;i++){
    s+='U';
  }
  for(int i=0;i<X;i++){
    s+='R';
  }
 // cout<<s;
  return s;
}

string DL(string s,int Y,int X){
  
  for(int i=0;i<Y;i++){
    s+='D';
  }
  for(int i=0;i<X;i++){
    s+='L';
  }
  return s;
}

int main() {
 int a,b,c,d,X,Y;
  cin>>a>>b>>c>>d;
  X=c-a;
  Y=d-b;
  string s="";
  s=UR(s,Y,X);
  s=DL(s,Y,X);
  s+="LU";
  s=UR(s,Y,X);
  s+="RDRD";
  s=DL(s,Y,X);
  s+="LU";
      
  
  cout<<s;
}


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

int main(){
	//~ double Min=LLONG_MAX;
	//~ vector<int>v;
	//~ for(int i=111111111;i>=1;i--){
		//~ int a=i,c=0;
		//~ while(a)c+=a%10,a/=10;
		//~ double d=i/(double)c;
		//~ if(i<=100000000){
			//~ if(d<=Min)v.push_back(i);
		//~ }
		//~ Min=min(Min,d);
	//~ }
	//~ reverse(v.begin(),v.end());
	//~ for(int i:v){
		//~ cout<<i<<endl;
	//~ }
	vector<ll>v;
	for(int i=1;i<=99999;i++)v.push_back(i);
	for(int i=6;i<=16;i++){//桁数
		for(int j=100000;j<=999999;j++){
			ll d=j+1;rep(k,i-6)d*=10;d--;
			v.push_back(d);
		}
	}
	vector<ll>ans;
	double Min=LLONG_MAX;
	for(int i=v.size()-1;i>=0;i--){
		ll a=v[i],c=0;
		while(a)c+=a%10,a/=10;
		double d=v[i]/(double)c;
		if(d<=Min){
			ans.push_back(v[i]);
		}
		Min=min(Min,d);
	}
	reverse(ans.begin(),ans.end());
	int k;scanf("%d",&k);
	rep(i,k){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 132316
import java.util.*;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] a = new String[h];
		for (int i = 0;i < h;i++) a[i] = sc.next();
		p(w);
		for (int i = 0;i < h;i++) {
			System.out.print("#");
			System.out.print(a[i]);
			System.out.println("#");
		}
		p(w);
	}

	public static void p(int w) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0;i < w+2;i++) sb.append("#");
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 22996
#include<stdio.h>
int main(void)
{
	int n;
	int a[10000],b[10000],c[10000],d[10000];
	int t[10000],s[10000];
	int i,j;
	int cnt[10000];
	
	scanf("%d",&n);
	for(i=1;i<=n*(n-1)/2;i++){
		scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
		t[i]=0;
		cnt[i]=1;
	}
	for(i=1;i<=n*(n-1)/2;i++){
		if(c[i]>d[i]){
			t[a[i]]+=3;
		}
		else if(c[i]==d[i]){
			t[a[i]]+=1;
			t[b[i]]+=1;
		}
		else{
			t[b[i]]+=3;
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(t[i]<t[j]){
				cnt[i]++;
			}
		}
	}
	for(i=1;i<=n;i++){
		printf("%d\n",cnt[i]);
	}
	return 0;
}

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

#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=300010;

int N;
string S;

int main(){
	cin>>N;
	cin>>S;
	int right[N],left[N];
	REP(i,N){
		right[i]=left[i]=0;
	}
	for(int i=1;i<N;i++){
		if(S[i-1]=='E')right[i]=right[i-1];
		else right[i]=right[i-1]+1;
	}
	for(int i=N-2;i>=0;i--){
		if(S[i+1]=='W')left[i]=left[i+1];
		else left[i]=left[i+1]+1;
	}
	int res=N;
	REP(i,N){
		//cout<<right[i]<<" "<<left[i]<<endl;
		res=min(res,right[i]+left[i]);
	}
	cout<<res<<endl;
	return 0;
}


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

#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define hell (ll)(1e9+7)
#define pii pair <ll,ll>
#define vi vector <ll>
#define pb push_back
#define inf 1000000000000000

using namespace std;

void solve()
{
    ll a,b;
    cin>>a>>b;
    if(a<=9&&b<=9)
        cout<<a*b;
    else
        cout<<-1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	//cin>>t;
	t=1;
	while(t--)
	{
		solve();
	}
	return 0;
}


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

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    map<int,int>m;
    for(int i=0;i<n-1;++i){
    	int x;
    	cin >> x;
    	m[x]++;
    }

    for(int i=1;i<=n;++i){
    	cout << m[i] << endl;
    }

    

	return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  bool approved = true;
  for(int i = 0; i < N; i++){
    int A;
    cin >> A;
    
    if((A & 1) == 0 && (A % 3 != 0 && A % 5 != 0)){
      approved = false;
      break;
    }
  }
  
  if(approved) puts("APPROVED");
  else puts("DENIED");
  
  return 0;
}



Measured memory_bytes: 256
//
//  main.cpp
//  1
//
//  Created by RISHAV SINGH MEHTA on 09/02/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define ll long long
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    ll int T,i,j,ss,yy,k,l,N,a,b,c;
    string S,U,Y;
    cin>>S>>Y;
    cin>>ss>>yy;
    cin>>U;
    if (S == U) {
        ss = ss -1;
    }
    if (Y == U) {
        yy = yy -1;
    }
    cout<<ss<<" "<<yy<<endl;
    
    return 0;
}


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

const int maxn = 2e5+1;
typedef long long ll;

int n;
ll a[maxn];

void add(int x, int y)
{
  printf("%d %d\n", x, y);
}
int main()
{
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%lld", a+i);
  int pick = 1;
  for (int i = 1; i <= n; ++i)
    if (abs(a[i]) > abs(a[pick]))
      pick = i;
  printf("%d\n", 2*n);
  if (a[pick] < 0)
    {
      add(pick, 1);
      add(pick, 1);
      for (int i = n; i >= 2; --i)
	{
	  add(1, i);
	  add(1, 1);
	}
    }
  else
    {
      add(pick, n);
      add(pick, n);
      for (int i = 1; i <= n-1; ++i)
	{
	  add(n, i);
	  add(n, n);
	}
    }
}


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

using namespace std;
int main() {
	int a;
	cin >> a;

	if (a < 1200)
		cout << "ABC";
	else if (a < 2800)
		cout << "ARC";
	else
		cout << "AGC";
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll n; cin >> n;
  V a(n); cin >> a;

  int cnt = 0;
  rep(i, n) cnt ^= (a[i]&1);
  cout << (cnt ? "NO" : "YES") << '\n';
  return 0;
}


Measured memory_bytes: 3692
#include <stdio.h>

int N, M;
int K[32];
int A[32][32];

int asumikana[32];

int main(void) {
	int i, j;
	int mizuhasikaori = 0;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &K[i]) != 1) return 1;
		for (j = 0; j < K[i]; j++) {
			if (scanf("%d", &A[i][j]) != 1) return 1;
		}
	}

	for (i = 0; i < N; i++) {
		for (j = 0; j < K[i]; j++) {
			asumikana[A[i][j]]++;
		}
	}
	for (i = 1; i <= M; i++) {
		if (asumikana[i] == N) mizuhasikaori++;
	}
	printf("%d\n", mizuhasikaori);
	return 0;
}


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

using namespace std;

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  int hoge[2][n];
  for(int i=0;i<2;i++)for(int j=0;j<n;j++)cin>>hoge[i][j];
  int cnt,ans=0;
  for(int shake=n;shake>0;shake--){
    cnt=0;
	  for(int i=0;i<shake;i++){
      cnt+=hoge[0][i];
	  }
	  for(int i=shake-1;i<n;i++){
      cnt+=hoge[1][i];
	  }
    ans=max(cnt,ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256