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

using namespace std;
using ll = long long;

ll res = 1e18;

int main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    ll x, k, d;
    cin >> x >> k >> d;
    
    x = abs(x);
    
    ll shft = min(k, x / d);
    
    if (shft <= k)
    {
        k -= shft;
        x -= shft * d;
    }
    
    if (k & 1)
        cout << min(abs(x + d), abs(x - d));
    else
        cout << x;
}

Measured memory_bytes: 3624
use proconio::{input, marker::Chars};

fn main() {
    input! {
        n: usize,
        s: Chars,
    }

    let mut count_white = 0;
    for &c in s.iter() {
        if c == '.' {
            count_white += 1;
        }
    }

    let mut count_black = 0;
    let mut ans = n;

    for c in s {
        match c {
            '.' => {
                count_white -= 1;
                ans = std::cmp::min(ans, count_black + count_white);
            },
            '#' => {
                ans = std::cmp::min(ans, count_black + count_white);
                count_black += 1;
            },
            _ => {}
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 3016
x, y, z = input().split()

# print(x, y, z)

# print("shuffle")
c = x
x = y
y = c
# print(1, "回目", x, y, z)
c = x
x = z
z = c
# print(2, "回目", x, y, z)

# print("result")
print(x, y, z)



Measured memory_bytes: 8940
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  int A{0}, B{0};
  int N;
  std::cin >> N;

  std::vector<int> a(N);
  for (int i = 0; i < N; i++) std::cin >> a[i];
  std::sort(a.begin(), a.end(), std::greater<int>());

  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) A += a[i];
    else
      B += a[i];
  }
  std::cout << A - B << std::endl;
}

Measured memory_bytes: 256
using namespace std;

#include<iostream>



int main()
{
    long int num[100];

    num[0] = 2;
    num[1] = 1;

    int N;

    cin >> N;

    for (int i=2;i<=N;i++)
    {
        num[i] = num[i-1] + num[i-2]; 
    }

    cout << num[N] << endl;

}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,K = list(map(int, input().split()))
from collections import defaultdict
current = []
nums = defaultdict(int)
td = [None]*n
for i in range(n):
    t,d = list(map(int, input().split()))
    td[i] = (d,t)
td.sort(reverse=True)
ans = 0
for i in range(K):
    d,t = td[i]
    current.append((d, t))
    ans += d
    nums[t] += 1
j = K-1
total = len(nums)
ans += total**2
cur = ans
for i in range(K, n):
#     print(ans)
    d,t = td[i]
    if t not in nums:
        while j>=0 and nums[current[j][1]]<=1:
            j -= 1
        if nums[current[j][1]]>=2:
            nums[current[j][1]] -= 1
            nums[t] = 1
            cur -= current[j][0]
            cur += total*2+1 + d
            total += 1
            ans = max(ans, cur)
#             print(cur,j)
            j -= 1
print(ans)

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

int main()
{
    long long a,b,c;
    cin>>a>>b>>c;
    
    long long tot=a/b;
    if(a%b)
    {
        tot+=1;
    }
    tot*=c;
    cout<<tot<<endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

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

		int n = Integer.parseInt(sc.next());

		int[] num = new int[n];
		int total = 0;
		int left = 0;
		int min = 1000000000;

		for (int i = 0; i < n; i++) {
			num[i] = Integer.parseInt(sc.next());
			total += num[i];
		}

		for (int i = 0; i < n; i++) {
			left += num[i];
			if(Math.abs((total - left) - left) < min) {
				min = Math.abs((total-left) - left);
			}
		}

		System.out.println(min);
	}
}

Measured memory_bytes: 21844
from itertools import count
N,M = map(int,input().split())

adj = [list() for _ in range(N)]


for _ in range(M):
    u,v = map(int,input().split())
    adj[u-1].append(v-1)

S,T = map(int,input().split())
S,T = S-1,T-1

visited = [False]*(N*3)
visited[S] = True
q = [S]

for step in count(1):
    offset = N*(step % 3)
    nq = []
    for u in q:
        for v in adj[u]:
            if not visited[v+offset]:
                nq.append(v)
                visited[v+offset] = True
    q = nq

    if visited[T] or not q:
        break
if visited[T]:
    print(step//3)
else:
    print(-1)

Measured memory_bytes: 60140
#include<stdio.h>
#include<stdlib.h>


int main(){
  int sum[100],x,i=0,a1,a2;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      i--;     
      a1=sum[i];
      i--;
      a2=sum[i];
      sum[i]=a1+a2;
      i++;
    } else if ( s[0] == '-' ){
      i--;    
      a1=sum[i];
      i--;
      a2=sum[i];
      
      sum[i]=a2-a1;
      i++; 
    } else if ( s[0] == '*' ){
      i--;    
      a1=sum[i];
      i--;
      a2=sum[i];
      sum[i]=a1*a2;
      i++;
    } else {
      x = atoi(s);
      sum[i]=x;      
      i++;    
    }
   
  }
  
  
  printf("%d\n",sum[i-1]);
  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H;
    cin >> H;
    ll ans = 0;
    ll num = 1;
    while(H){
        ans += num;
        num *= 2;
        H /= 2;
    }
    cout << ans << endl;
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 510;

int H, W, h, w;
int ans[N][N];

int main(){
	scanf("%d%d%d%d", &H, &W, &h, &w);
	
	int cx = H / h, cy = W / w;
	int sum = H * W - cx * cy * h * w;
	int C = 1e8 / (h * w);

	if(sum <= 0){
		puts("No");
		return 0;
	}

	puts("Yes");
	For(i, 1, H) For(j, 1, W) ans[i][j] = C;
	For(i, 1, cx) For(j, 1, cy) ans[i * h][j * w] = -(h * w - 1) * C - 1;

	For(i, 1, H) For(j, 1, W) printf("%d%c", ans[i][j], j == W ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

int main(void) {
  int r;cin>>r;
  pr(r*2*3.1415926535);
  return 0;
}


Measured memory_bytes: 3804
import java.util.*;
import java.io.*;
class Main{

     public static void main(String []args) throws Exception{
        BufferedReader br =new BufferedReader (new InputStreamReader(System.in));
        int N=0;
        
        N=Integer.parseInt(br.readLine());
        int arr[]=new int[N];
        
        String s=br.readLine();
        String ss[]=s.split(" ");
        int val=0;
        for(int i=0;i<N;i++)
        {
            arr[i]=Integer.parseInt(ss[i]);
            
        }
        int dp[]=new int [N];
        dp[0]=arr[0];
        dp[1]=Math.abs(arr[0]-arr[1]);      
        int n=N;         
        if(N==2)
        {
            val= Math.abs(arr[0]-arr[1]);
            
        }
         else{
             
              //val=Math.min(Math.abs(arr[0]-arr[1]),Math.abs(arr[0]-arr[2]));
             for(int i=2;i<N;i++)
             {
                 if(i==2)
                 {
                     dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),Math.abs(arr[0]-arr[i]));
                 }
                 else{
                 dp[i]=Math.min(dp[i-2]+Math.abs(arr[i]-arr[i-2]),dp[i-1]+Math.abs(arr[i]-arr[i-1]));
                 }
                 //val+=Math.min(temp,temp1);
             }
             
             
             
             
             
             
         }
         System.out.println(dp[n-1]);
         
         
         
         
     }
}

Measured memory_bytes: 33048
#include <cstdio>
using namespace std;
int N, t, ans;
int main() {
  int N; scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    scanf("%d", &t);
    while(t%2==0) {t/=2; ans++;}
  }
  printf("%d", ans);
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scanln(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &arr[i])
	}
	temp := 0
	for i := 0; i < n/2; i++ {
		temp = arr[i]
		arr[i] = arr[n-i-1]
		arr[n-i-1] = temp
	}
	for i, e := range arr {
		if i != n-1 {
			fmt.Printf("%d ", e)
		} else {
			fmt.Printf("%d\n", e)
		}
	}
	return
}



Measured memory_bytes: 1168
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	string s;
	cin >> s;
	s.push_back('T');
	int x, y;
	cin >> x >> y;
	vector<int> a, b;
	int cnt = 0;
	int f = 0;
	REP(i, s.size()) {
		if (s[i] == 'T') {
			if (f == 0) {
				a.push_back(cnt);
			} else {
				b.push_back(cnt);
			}
			cnt = 0;
			f = 1 - f;		
		} else {
			cnt++;
		}
	}
	vector<set<int>> s1(a.size()), s2(b.size() + 1);
	s1[0].insert(a[0]);
	s2[0].insert(0);
	FOR(i,1, a.size()) {
		for (auto v : s1[i-1]) {
			s1[i].insert(v + a[i]);
			s1[i].insert(v - a[i]);
		}
	}
	REP(i, b.size()) {
		for (auto v : s2[i]) {
			s2[i + 1].insert(v + b[i]);
			s2[i + 1].insert(v - b[i]);
		}
	}
	auto itr1 = s1.back().find(x);
	auto itr2 = s2.back().find(y);
	if (itr1 != s1.back().end() && itr2 != s2.back().end()) {
		put("Yes");
	} else {
		put("No");
	}
	return 0;
}


Measured memory_bytes: 232192
#include<algorithm>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int n;
vector< vector<int> > g;
int root = 0;

int parent[20][100000];
int depth[100000];

void dfs(int v, int p, int d){
    parent[0][v] = p;
    depth[v] = d;
    for(int i = 0 ; i < g[v].size() ; ++i){
        if(g[v][i] != p){
            dfs(g[v][i], v, d + 1);
        }
    }
}

void init(int v){
    dfs(root, -1, 0);

    for(int k = 0 ; k + 1 < 20 ; ++k){
        for(int i = 0 ; i < v ; ++i){
            if(parent[k][i] < 0){
                parent[k + 1][i] = -1;
            }else{
                parent[k + 1][i] = parent[k][parent[k][i]];
            }
        }
    }
}

int lca(int u, int v){
    if(depth[u] > depth[v]){
        swap(u, v);
    }
    for(int k = 0 ; k < 20 ; ++k){
        if((depth[v] - depth[u]) >> k & 1){
            v = parent[k][v];
        }
    }
    if(u == v){
        return u;
    }
    for(int k = 19 ; k >= 0 ; --k){
        if(parent[k][u] != parent[k][v]){
            u = parent[k][u];
            v = parent[k][v];
        }
    }

    return parent[0][u];
}

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

    cin >> n;

    g.resize(n);
    reps(i, n - 1){
        int p;
        cin >> p;
        g[--p].emplace_back(i);
    }

    init(n);

    lint ans = 0;
    int prev = 0;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int now = que.front();
        que.pop();
        int p = lca(now, prev);
        ans += depth[now] + depth[prev] - 2LL * depth[p];
        prev = now;
        for(auto to : g[now]){
            que.push(to);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 21172
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int INF = 1e9 + 5;
/////////////////////////////////////////////////////////////////////


const int nax = 1e5 + 5;
vector<int> edges[nax];
int in_degree[nax]; // the number of edges going to 'b'
int dist[nax];
bool visited[nax];

void dfs(int a) {
    visited[a] = true;
    for (int b : edges[a]) {
        dist[b] = max(dist[b], dist[a] + 1);
        --in_degree[b];
        if (in_degree[b] == 0) {
            dfs(b);
        }
    }
}

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    while (m--) {
        int a, b;
        scanf("%d%d", &a, &b);
        edges[a].push_back(b);
        ++in_degree[b];
    }

    for (int i = 0; i <= n; ++i) {
        if (!visited[i] && in_degree[i] == 0) {
            dfs(i);
        }
    }

    int res = 0;
    for (int i = 1; i <= n; ++i) {
        res = max(res, dist[i]);
    }
    printf("%d\n", res);

    return 0;
}

Measured memory_bytes: 9728
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main() {
	int a, b;
	int ca[5000], cb[5000];
	cin >> a >> b;
	for (int i = 0; i < a; i++) cin >> ca[i];
	for (int i = 0; i < b; i++) cin >> cb[i];
	int sum = 0;
	for (int i = 0; i < b; i++) {
		int c = -1,sum2=1;
		for (int j = 0; j < a; j++) {
			if (cb[i] == ca[j]) {
				c = j;
				break;
			}
		}
		if (c == -1) {
			goto stop;
		}
		for (int j = i + 1; j < b; j++) {
			bool l = false;
			for (int z = c + 1; z < a; z++) {
				if (ca[z] == cb[j]) {
					l = true;
					c = z;
					break;
				}
			}
			if (l) {
				sum2++;
			}
			else {
				break;
			}
		}
		sum = max(sum, sum2);
	stop:;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vr vector
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl

bool isvowel(char a)
{
    if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
     return true;
     else
        return false;
}

  int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     //ll t;
     //cin>>t;
     //while(t--)
     {
      ll n;
      cin>>n;
      ll p=n/500;
      p*=1000;
      n=n%500;
      p+=(n/5)*5;

      cout<<p;




        cout<<endl;

     }

 return 0;
  }



Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i) 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e6+10;
const int N = 1e5+10;
const int E = 1e6+10;  
int x,n;
int vis[maxn];
int a[maxn];

int main(){
	cin>>n;
	F(i,1,n){
		scanf("%d",&a[i]);
		vis[a[i]]++;
	}
	int ans = n;
	F(i,1,n){
		if(vis[a[i]]>1){
			ans--;
			continue;
		}
		else{
			vis[a[i]]--;
			F(j,1,floor((double)sqrt(a[i]))){
				if(a[i]%j==0){
					if(vis[j]){
					//	cout<<i<<" "<<j<<endl; 
						ans--;
						break;
					}
					else if(vis[a[i]/j]){
					//	cout<<i<<" "<<j<<endl; 
						ans--;
						break;
					}
				}
			}
			vis[a[i]]++;
		}
	} 
	cout<<ans<<endl;
}


Measured memory_bytes: 8300
n = int(raw_input())

x = lambda: map(int, raw_input().strip().split())

A = x()
B = x()
C = x()

points = 0
for i in xrange(n):
  points += B[A[i]-1]
  if i > 0 and A[i] == A[i-1] + 1:
    points += C[A[i]-2]

print points


Measured memory_bytes: 2568
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
    cout<<fixed;
}
int main(){
    init();

    ll N;cin>>N;
    vector<ll>A(N);
    for(int i=0;i<N;i++)cin>>A[i];

    ll ans=-1;
    ll num=INF;
    for(int i=0;i<N;i++){
        if(A[i]<num){
            ans=i+1;
            num=A[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3588
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long mod = 1000000000 + 7;
        long answer = (powMod(10,n,mod)-2*powMod(9,n,mod)+powMod(8,n,mod))%mod;
        answer = (answer+mod)%mod;
        System.out.println(answer);
    }
    public static long powMod(long a, long b, long mod) {
        long p = 1;
        if (b==1) {
            return a;
        }else if(b==2) {
            return (a*a)%mod;
        }else {
            long tmp = powMod(a,b/2,mod);
            long answer = (tmp*tmp)%mod;
            if (b%2 == 1) {
                answer = (answer * a)%mod;
            }
            return answer;
        }
    }
}


Measured memory_bytes: 35832
a,b,c,d=map(int,input().split())
x=c-a
y=d-b
s=["U"]*y+["R"]*x
t=["D"]*y+["L"]*x
q=s+t+["L"]+["U"]+s+["R"]+["D"]+["R"]+["D"]+t+["L"]+["U"]
print("".join(q))

Measured memory_bytes: 3384
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>

using namespace std;

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

    int sub = b - a, height = 0;

    while(sub-- > 0){
        height += sub;
    }

    printf("%d\n", height - a);

    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;

typedef struct{
  int num;
  int first;
  int second;
}Walk;

int main(){
  int n,max=-1,add;
  Walk people[10005];

  while(1){
    scanf("%d",&n);
    if(n==0) break;

    for(int i=0;i<n;i++){
      scanf("%d %d %d",&people[i].num,&people[i].first,&people[i].second);
      if(max<people[i].first+people[i].second){
	max=people[i].first+people[i].second;
	add=i;
      }
    }
    printf("%d %d\n",people[add].num,max);
    add=0;
    max=-1;
  }

  return 0;
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 2e5+10;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;

int n, x;
int niz[maxn];

int main() {
	scanf("%d%d", &x, &n);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		niz[x] = 1;
	}
	
	int sol = -1;
	for (int i = 0; i < maxn; i++) {
		if (niz[i] == 0) {
			if (sol == -1 || abs(x - sol) > abs(x - i)) sol = i;
		}
	}
	printf("%d", sol);
	return 0;
}



Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int target[]{1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << target[k - 1] << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  ll n, k;
  cin >> n >> k;
  map<ll, ll> mp;

  rep(i, n) {
    ll a, b; cin >> a >> b;
    mp[a] += b;
  }

  for (auto& p : mp) {
    k -= p.second;
    if (k <= 0) {
      cout << p.first << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <deque>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while(1){
        int n,x; cin >> n >> x;
        if(n==0&&x==0)break;
        int ans=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x)ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


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

using namespace std;

int main () {
	long long n , h = 0;
	cin >> n;
	long long  a[n] , b[n];
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	for (int i = n - 1 ; i >= 0 ; i--){
		while ( (a[i] + h) % b[i] != 0){
			h+= b[i]-((a[i] + h) % b[i]);
		}
	}
	cout<<h<<endl;
return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n; cin >>n;
  ll maxa=-INF64,mina=INF64,maxm=-INF64,minm=INF64;
  for(int i=0; i<n; i++){
    ll x,y; cin >>x >>y;
    maxa=max(maxa,x+y);
    mina=min(mina,x+y);
    maxm=max(maxm,x-y);
    minm=min(minm,x-y);
  }
  cout <<max(maxa-mina,maxm-minm);
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  solve();
return 0;}


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

#define lint long long
#define P pair<int, int>

int main() {
    int N; cin >> N;
    
    vector<int> L(N);
    for(int i = 0; i < N; ++i){
        cin >> L[i];
    }
    
    sort(L.begin(), L.end());
    
    int sum = 0;
    for(int i = 0; i < N - 1; ++i){
        sum += L[i];
    }
    if(sum > L[N - 1]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

// I'm trying to ~~~
int main(){
    long long A; cin >> A;
    if(A%2==0) cout << A << endl;
    else cout << A*2 << endl;
}
 


Measured memory_bytes: 256
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {

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

        int min = -1;
        int max = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == 'A' && min == -1)min = i;
            if(s.charAt(i) == 'Z')max = i;
        }
        System.out.println(max - min + 1);
    }








}




Measured memory_bytes: 14604
/*
sonu_verma1
*/
#include <bits/stdc++.h>
// For policy based data structure
/*#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> */
using namespace std;
/*using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set;*/
 
#define MD 1000000007
#define X first
#define Y second
#define pb push_back
#define debug(val, ch) cout <<val <<ch
#define FOR(i, st, en, ch) for(register int i = (st); i <= (en) ; i += (ch))
#define RFOR(i, st, en, ch) for(register int i = (st); i >= (en) ; i -= (ch))
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
 
typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<int, bool> pib;
typedef pair<bool, int> pbi;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
/*********************************************************************/
void test(int r)
{
	ll n;
	cin>>n;
	vector<ll>v(n);
	ll i,j;
	for(i=0;i<n;i++)
		cin>>v[i];
	ll rm=0,ns=1,ps=1000;
	for(i=0;i<n;i++)
	{
		ll t=ns*ps+rm;
		if(ps<v[i])
		{
			ps=v[i];
		}
		else
		{
			ns=t/v[i];
			rm=t%v[i];
			ps=v[i];
		}
	}
	cout<<ns*ps+rm<<endl;
	

}
/***********************************************************************/
int main()
{
	fast();
    int t=1,r;
    // cin>>t;
    for(r=1;r<=t;r++)
        test(r);
    return 0;
}

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

// N人 に K個 の 飴 を配る場合の総数を保管.
LL dp[101][100001];
// 各子供(1, 2, ..., N) が受け取る飴の個数上限.
LL A[101];

int main() {
    
    // 1. 入力情報取得.
    LL N, K;
    scanf("%lld %lld", &N, &K);
    for(LL i = 1; i <= N; i++) scanf("%lld", &A[i]);
    
    // 2. 飴 の 配り方を確認.
    // dp[N][K] = 
    // dp[N - 1][K - 0]    (N人目 に 0個配る場合) +
    // dp[N - 1][K - 1]    (N人目 に 1個配る場合) +
    // dp[N - 1][K - 2]    (N人目 に 2個配る場合) +
    // ...
    // dp[N - 1][K - A[N]] (N人目 に A[N]個配る場合)
    // のような関係が成り立つことに注意.
    // ※但し, 第二成分 K - XX が, 0以上となる必要がある.

    // 2-1. 1人目の情報.
    for(LL j = 0; j <= A[1]; j++) dp[1][j] = 1;

    // 2-2. 2人目以降の情報.
    for(LL i = 2; i <= N; i++){
        dp[i][0] = dp[i - 1][0];
        for(LL j = 1; j <= K; j++){
            dp[i][j] = dp[i][j - 1];
            dp[i][j] += dp[i - 1][j], dp[i][j] %= MOD;
            if(j > A[i]) dp[i][j] += MOD, dp[i][j] -= dp[i - 1][j - 1 - A[i]], dp[i][j] %= MOD;
        }
    }
    
    // for(LL i = 0; i <= N; i++){
    //     for(LL j = 0; j <= K; j++) printf("%lld ", dp[i][j]);
    //     printf("\n");
    // }
    
    // 3. 出力.
    printf("%lld\n", dp[N][K]);
    return 0;
}

Measured memory_bytes: 78336
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let v: Vec<usize> = (0..n).map(|_| read()).collect();
    let c: Vec<usize> = (0..n).map(|_| read()).collect();

    let mut ans = 0;
    for i in 0..n {
        if v[i] > c[i] {
            ans += v[i] - c[i];
        }
    }
    println!("{}", ans);
}

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


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.WriteAns();
	}
}

class Sol{

	List<String> Content;
	int R;
	int C;
	String buf;
	
	public void WriteAns(){
		foreach(String s in Content){
			Console.Write(s);
		}
	}

	public Sol(){
		Content=new List<String>();
		while(true){
			var s=Console.ReadLine()+"\n";
			if(s=="END_OF_TEXT\n")break;
			Content.Add(s);
		}
//WriteAns();
		R=0;C=0;buf="";
		while(true){
			var s=Console.ReadLine();
			if(s[0]=='-')break;
			Operation(s[0]);
//Console.WriteLine("Ope={2},R={0},C={1},buf=\"{3}\"",R,C,s[0],buf=="\n"?"\\n":buf);WriteAns();
		}
	}
	

	void Operation(char c){
		switch(c){
			case 'a':
				C=0;
			break;
			case 'e':
				C=Content[R].Length-1;
			break;
			case 'p':
				if(R>0){C=0;R--;}
				else if(R==0){C=0;}
			break;
			case 'n':
				if(R<Content.Count-1){C=0;R++;}
				else if(R==Content.Count-1){C=0;}
			break;
			case 'f':
				if(C<Content[R].Length-1){C++;}
				else if(C==Content[R].Length-1 && R<Content.Count-1){R++;C=0;}
			break;
			case 'b':
				if(C>0){C--;}
				else if(C==0 && R>0){R--;C=Content[R].Length-1;}
			break;
			case 'd':
				if(Content[R].Length>1 && C<Content[R].Length-1){
					if(C>0){Content[R]=Content[R].Substring(0,C)+Content[R].Substring(C+1);}
					if(C==0){Content[R]=Content[R].Substring(C+1);}
				}
				else if(C==Content[R].Length-1 && R<Content.Count-1){
					if(C>0)Content[R]=Content[R].Substring(0,C)+Content[R+1];
					if(C==0)Content[R]=Content[R+1];
					Content.RemoveAt(R+1);
				}
			break;
			case 'k':
				if(C==Content[R].Length-1 && R<Content.Count-1){
					if(C>0)Content[R]=Content[R].Substring(0,C)+Content[R+1];
					if(C==0)Content[R]=Content[R+1];
					Content.RemoveAt(R+1);
					buf="\n";
				}
				else if(C<Content[R].Length-1){
					buf=Content[R].Substring(C);
					buf=buf.Substring(0,buf.Length-1);
					Content[R]=Content[R].Substring(0,C)+"\n";
				}
			break;
			case 'y':
				if(buf==""){;}
				else if(buf=="\n"){
					String sss=Content[R].Substring(C);
					if(C>0){Content[R]=Content[R].Substring(0,C)+"\n";}
					if(C==0){Content[R]="\n";}
					Content.Insert(R+1,sss);
					R++;C=0;
				}
				else{
					if(C>0){Content[R]=Content[R].Substring(0,C)+buf+Content[R].Substring(C);}
					if(C==0){Content[R]=buf+Content[R].Substring(C);}
					C+=buf.Length;
				}

			break;
		}
	}
}

Measured memory_bytes: 5508
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = sorted(A)
    B = A[::-1]
    C = N-1
    ans = 0
    if N%2 == 0:
      ans += B[0]
      for i in range(N//2-1):
        ans += 2*B[i+1]
    else:
      ans += B[0]
      ans += B[N//2]
      for i in range(N//2-1):
        ans += 2*B[i+1]
    print(ans)    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 31360
#include <stdio.h>

int main(void)
{
        int n,m,c,i,j,cont=0,s;
        scanf("%d%d%d",&n,&m,&c);
        int a[n][m],b[m];
        for(i=0;i<m;i++)
                scanf("%d",&b[i]);
        for(i=0;i<n;i++)
                for(j=0;j<m;j++)
                        scanf("%d",&a[i][j]);

        for(i=0;i<n;i++){
                s=0;
                for(j=0;j<m;j++){
                        s+=a[i][j]*b[j];
                }
                if(s+c>0)cont++;
        }
        printf("%d\n",cont);
        return 0;
}


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

const int mod = 1e9+7;

long long mpow(long long a, int n) {
	if (n == 0) return 1;
	if (n == 1) return a;
	if (n%2) return (a * (mpow(a, n-1) % mod)) % mod;
	else {
		long long tmp = mpow(a, n/2) % mod;
		return tmp * tmp % mod;
	}
}

const int MAX = 2000006;
long long fac[MAX], finv[MAX], inv[MAX];

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

long long nCk(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
	int k;
	string s;
	cin >> k >> s;

	COMinit();

	long long ans = 0;
	for (int i = 0; i <= k; i++) {
		ans = (ans + mpow(26,i)*mpow(25,k-i)%mod * (nCk(s.size()+k-1-i, s.size()-1))%mod) % mod;
	}

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


Measured memory_bytes: 51212
def is_balanced(s):
    stack = []
    for c in s:
        if c == '(' or c == '[':
            stack.append(c)
        elif c == ')':
            if not stack:
                return "no"
            elif stack[-1] == '(':
                stack.pop()
            else:
                return "no"
        elif c == ']':
            if not stack:
                return "no"
            elif stack[-1] == '[':
                stack.pop()
            else:
                return "no"
    if stack:
        return "no"
    else:
        return "yes"

import sys

file_input = sys.stdin

lines = file_input.readlines()
lines = lines[:-1]
 
print('\n'.join(map(is_balanced, lines)))



Measured memory_bytes: 5984
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int n;
	cin >> n;
	int ans = 0;
	vector<bool> v(n + 1,false);
	vector<int> a(n + 1);
	FOR(i, 1, n + 1) {
		cin >> a[i];
	}
	int x = 1;
	while (1) {
		if (v[x]) {
			ans = -1;
			break;
		}
		v[x] = true;
		ans++;
		if (a[x] == 2)break;
		x = a[x];
	}
	cout << ans << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(ll i=0; i<n; ++i)
#define FOR(i,a,b) for(ll i=a; i<=b; ++i)
#define FORR(i,a,b) for (ll i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int main() {
    int n;
    cin >> n;

    set<P> p;
    for (int j = 1; j < n; j += 2){
        p.insert(P(0, j));
    }
    FOR(i,1,n-2){
        if (i % 2){
            for (int j = 4; j < n; j += 6) p.insert(P(i, j));
        }else{
            for (int j = 1; j < n; j += 6) p.insert(P(i, j));
        }
    }

    REP(j,n){
        if ((n - 1 + j) % 2) p.insert(P(n-1, j));
    }
    REP(i,n){
        if (i % 2) p.insert(P(i, 0));
        if ((i + n - 1) % 2) p.insert(P(i, n-1));
    }

    cout << p.size() << endl;
    for (P pp : p){
        cout << pp.first << " " << pp.second << endl;
    }
 
    return 0;
}

Measured memory_bytes: 9344
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  string S;
  while (cin >> S) {
    if (S.size() < 26) {
      string res = S;
      for (char c = 'a'; c <= 'z'; c++) {
        if (S.find_first_of(c) == string::npos) {
          res += c;
          break;
        }
      }
      cout << res << endl;
    } else {
      int p = -1;
      for (int i = S.size() - 2; i >= 0; i--) {
        if (S[i] < S[i + 1]) {
          p = i;
          break;
        }
      }
      if (p == -1) {
        cout << -1 << endl;
      } else {
        string res = S.substr(0, p);
        for (int i = S.size() - 1; i > p; i--) {
          if (S[i] > S[p]) {
            res += S[i];
            break;
          }
        }
        cout << res << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define trace1(a) cout << a << 'n';
#define trace2(a, b) cout << a << ' ' << b << 'n';
#define trace3(a, b, c) cout << a << ' ' << b << ' ' << c << 'n';
#define trace4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d << 'n';
#define trace5(a, b, c, d, e) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << 'n';
#define trace6(a, b, c, d, e, f) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << 'n';
#define range(n) for(int i = 0; i < n; i++)
#define printArr(harry, tam) range(tam) cout << harry[i] << " n"[i == tam -1];
#define maxn -2000000 //negative value to break code and force you to put right constraint
#define mod 1000000007
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 1000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;
int main()
{
    ll a,b;
    cin>>a>>b;
    cout<<max(a-2*b,0LL);
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    mod = (10**9)+7
    if abs(N-M) >= 2:
        print(0)
    else:
        ans = 1
        for n in range(1, N+1):
            ans = ans * n % mod
        for m in range(1, M+1):
            ans = ans * m % mod
        if N == M:
            ans = ans * 2 % mod
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)

const int N = (int) 2e5 + 5, mod = (int) 1e9 + 7;
int pw(int a, int b) { return b != 0? 1ll * pw(1ll * a * a % mod, b >> 1) * (b & 1? a: 1) % mod: 1; }
int f[N], inv[N];
int comb(int n, int r) {
    if (r > n || n < 0 || r < 0) return 0;
    return f[n] * 1ll * inv[n - r] % mod * inv[r] % mod;
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    inv[0] = f[0] = 1;
    for (int i = 1; i < N; ++i)
        f[i] = f[i - 1] * 1ll * i % mod, inv[i] = pw(f[i], mod - 2);
    int n, m, r, c;
    cin >> n >> m >> r >> c;
    int res = comb(n + m - 2, n - 1);
    for (int i = 0; i < c; ++i) {
        int d = n - r;
        int val = comb(d + i, d);
        if (i)
            val = (val - comb(d + i - 1, d) + mod) % mod;
        res = (res - val * 1ll * comb(r - 1 + m - i - 1, r - 1) % mod + mod) % mod;
    }
    cout << res << endl;




}








Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
using namespace std;
typedef long long ll;
const int maxn=1e5+50;
const int inf=0x3f3f3f3f;
const int MOD=10007;


int main()
{
    ll x,k,d;
    scanf("%lld %lld %lld",&x,&k,&d);
    if(x<0) x=-x;
    if(x==0)
    {
        if(k%2==0) {printf("0\n");}
        else printf("%lld",d);
        return 0;
    }
    ll need=x/d;//need*d>x
    if(need*d<x) need++;
    if(k>=need&&need%2==k%2) printf("%lld\n",need*d-x);
    else if(k>=need)
    {
        printf("%lld\n",x-(need-1)*d);
    }
    else printf("%lld\n",(x-k*d));
    return 0;
}


Measured memory_bytes: 3820
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        int a = Integer.parseInt(lines[0]);
        int b = Integer.parseInt(lines[1]);
        String s = "";
        if (a == b) {
            s = "==";
        } else if (a < b) {
            s = "<";
        } else {
            s = ">";
        }
        System.out.println("a "+s+" b");
    }

}

Measured memory_bytes: 24340
#include<cstdio>
#include<utility>
#include<queue>
#define N 800
using namespace std;

int a[N+2][N+2];
char s[N+1];

queue<pair<int,int> > Q;

int minim(int a,int b){
    return (a<b) ? a : b;
}

int main(){
    int n,m,k;
    int i,j;

    scanf ("%d%d%d\n",&n,&m,&k);

    pair<int,int> S;
    for(i=1;i<=n;i++){
        scanf ("%s",&s);

        for(j=0;j<m;j++){
            if (s[j]=='S') S={i,j+1};
            else
            if (s[j]=='#') a[i][j+1]=-1;
        }
    }

    for(i=1;i<=n;i++)
        a[i][0]=a[i][m+1]=-1;
    for(j=1;j<=m;j++)
        a[0][j]=a[n+1][j]=-1;

    a[S.first][S.second]=1;
    Q.push({S.first,S.second});
    int min=n;

    while(!Q.empty()){
        S=Q.front();
        Q.pop();

        min=minim(min,minim(S.first-1,minim(S.second-1,minim(n-S.first,m-S.second))));

        if (a[S.first][S.second]<=k){
            if (a[S.first+1][S.second]==0){
                a[S.first+1][S.second]=a[S.first][S.second]+1;
                Q.push({S.first+1,S.second});
            }
            if (a[S.first-1][S.second]==0){
                a[S.first-1][S.second]=a[S.first][S.second]+1;
                Q.push({S.first-1,S.second});
            }
            if (a[S.first][S.second+1]==0){
                a[S.first][S.second+1]=a[S.first][S.second]+1;
                Q.push({S.first,S.second+1});
            }
            if (a[S.first][S.second-1]==0){
                a[S.first][S.second-1]=a[S.first][S.second]+1;
                Q.push({S.first,S.second-1});
            }
        }
    }

    if (min==0) printf ("1");
    else printf ("%d",1+(min-1)/k+1);

    return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 3e5 + 5 ;
const ll mod = 1e9 + 7 ;
int n ;
ll zero[105] , one[105] ;
ll two[105] ;
void init()
{
	memset(zero , 0 , sizeof(zero)) ;
	memset(one , 0 , sizeof(one)) ;
	two[0] = 1 ;
	for(int i = 1 ; i <= 62 ; i ++)
	  two[i] = two[i - 1] * 2ll % mod ;
}
void solve(ll x)
{
	for(int i = 0 ; i <= 62 ; i ++)
	{
		if(x % 2 == 0)
		  zero[i] ++ ;
		else
		  one[i] ++ ;
		x /= 2 ;
	}
}
int main()
{
	init() ;
	scanf("%d" , &n) ;
	for(int i = 1 ; i <= n ; i ++)
	{
		ll x ;
		scanf("%lld" , &x) ;
		solve(x) ;
	}
	ll ans = 0 ;
	for(int i = 0 ; i <= 62 ; i ++)
	  ans = (ans + zero[i] * one[i] % mod * two[i] % mod) % mod ;
	printf("%lld\n" , ans) ;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  char S[101][101]={'\0'};
  char T[101]={'\0'};
  int N,L,i,j;
  scanf("%d %d",&N,&L);
  for(i=0;i<N;i++){
    scanf("%s",S[i]);
  }
  for(i=0;i<N-1;i++){
    for(j=i+1;j<N;j++){
      if(strcmp(S[i],S[j])>0){
        strcpy(T,S[i]);
        strcpy(S[i],S[j]);
        strcpy(S[j],T);
      }
    }
  }
  for(i=0;i<N;i++){
    printf("%s",S[i]);
  }
  printf("\n");
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> a(n);
    int cnt2=0, cnt4=0;
    for(int i=0; i<n; i++) {
        cin>>a[i];
        if(a[i] % 2 == 0 && a[i] % 4 != 0) cnt2++;
        else if(a[i] % 4 == 0) cnt4++;
    }

    if(cnt2 > 1) n-=(cnt2-1);

    if(n/2 <= cnt4) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640