akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N; cin >> N;
  if(N%10 == 2 || N%10 == 4 || N%10 == 5 || N%10 == 7 || N%10 == 9){
    cout << "hon" << endl;
  }else if(N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8){
    cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string>
#include <random>

std::mt19937 rsk(0315);

template <class RandomIt>
void bsort(RandomIt first, RandomIt last) {
  while (!std::is_sorted(first, last))
    std::shuffle(first, last, rsk);
}

int main() {
  std::string S;
  std::cin >> S;
  bsort(S.begin(), S.end());
  std::cout << ((S == "abc")? "Yes":"No") << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
main(){int l[4][2]={0},i=0;for(double a;std::cin>>a;i++)a<0.2?l[3][i%2]++:(a<0.6?l[2][i%2]++:(a<1.1?l[1][i%2]++:l[0][i%2]++));for(int i=0;i<4;i++)std::cout<<l[i][0]<<" "<<l[i][1]<<"\n";}

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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        char[] data = s.toCharArray();
        int len = data.length;
        int answer = 0;
        for (int i = 0; i < len / 2; i++) {
            if (data[i] != data[len-i-1]) {
                answer += 1;
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "Yes" : "No")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

template <class T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using ordered_multiset = tree <T, null_type, less_equal <T>, rb_tree_tag, tree_order_statistics_node_update>;

const int siz = 1e3 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "1";

int m, n;
ii s, t;
char a[siz][siz];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int mx[20] = {1, -1, 1, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1};
int my[20] = {1, -1, -1, 1, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2};
int d[siz][siz];
bool done[siz][siz];

bool check(ii p) {
    return (1 <= p.fi && p.fi <= m && 1 <= p.se && p.se <= n && a[p.fi][p.se] == '.');
}

int Dijkstra() {
    priority_queue <iii, vector <iii>, greater <iii> > pq;
    memset(d, 0x3f, sizeof(d));
    d[s.fi][s.se] = 0;
    pq.push(iii(d[s.fi][s.se], s));

    while (!pq.empty()) {
        ii u = pq.top().se;
        pq.pop();

        if (done[u.fi][u.se]) {
            continue;
        }
        done[u.fi][u.se] = true;

        for (int i = 0; i < 4; i++) {
            ii v = ii(u.fi + dx[i], u.se + dy[i]);

            if (!check(v)) {
                continue;
            }

            if (d[v.fi][v.se] > d[u.fi][u.se]) {
                d[v.fi][v.se] = d[u.fi][u.se];
                pq.push(iii(d[v.fi][v.se], v));
            }
        }

        for (int i = 0; i < 20; i++) {
            ii v = ii(u.fi + mx[i], u.se + my[i]);

            if (!check(v)) {
                continue;
            }

            if (d[v.fi][v.se] > d[u.fi][u.se] + 1) {
                d[v.fi][v.se] = d[u.fi][u.se] + 1;
                pq.push(iii(d[v.fi][v.se], v));
            }
        }
    }

    if (d[t.fi][t.se] > m * n) {
        return -1;
    }
    return d[t.fi][t.se];
}

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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    cin >> m >> n;
    cin >> s.fi >> s.se >> t.fi >> t.se;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> a[i][j];
        }
    }

    cout << Dijkstra();

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 13580
#include <cmath>
#include <iostream>
#define PI 3.1415926535897932384626433832795028842L
using namespace std;
void solve(long double xa, long double ya, long double xb, long double yb, int d) {
	if (!d) return;
	long double xc = (xa * 2 + xb) / 3;
	long double yc = (ya * 2 + yb) / 3;
	long double xe = (xa + xb * 2) / 3;
	long double ye = (ya + yb * 2) / 3;
	long double xd = (xe - xc) * cos(PI / 3) - (ye - yc) * sin(PI / 3) + xc;
	long double yd = (xe - xc) * sin(PI / 3) + (ye - yc) * cos(PI / 3) + yc;
	solve(xa, ya, xc, yc, d - 1);
	printf("%.20Lf %.20Lf\n", xc, yc);
	solve(xc, yc, xd, yd, d - 1);
	printf("%.20Lf %.20Lf\n", xd, yd);
	solve(xd, yd, xe, ye, d - 1);
	printf("%.20Lf %.20Lf\n", xe, ye);
	solve(xe, ye, xb, yb, d - 1);
}
int n;
int main() {
	cin >> n;
	printf("%.20Lf %.20Lf\n", 0.0L, 0.0L);
	solve(0.0, 0.0, 100.0, 0.0, n);
	printf("%.20Lf %.20Lf\n", 100.0L, 0.0L);
	return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return exp(x,big-2);
}

int find(vector<int> &a,int i,int j,int l,int r){//a[i]+a[j]>a[s]を満たすsのmax
    if(r-l==1)return l;
    int k=a[i]+a[j];
    int n=(l+r)/2;
    if(a[n]>=k)return(find(a,i,j,l,n));
    else return(find(a,i,j,n,r));
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    int n;cin >> n;
    vector<int> l(n);
    rep(i,n)cin >> l[i];
    int cnt=0;
    sort(l.begin(),l.end());
    //最大のものa a<b+cで十分
    rep(i,n-2)rep2(j,i+1,n-1){
        //l[j+1]~l[n-1]のうち条件を満たすものの個数
        cnt+=max(find(l,i,j,0,n)-j,0);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N,K;
  cin >> N >> K;
  vi p(N);
  rep(i,N) cin >> p[i];
  sort(p.begin(),p.end());
  
  int ans=0;
  rep(i,K) ans+=p[i];
  cout << ans << endl;
}

Measured memory_bytes: 3628
a,b,h,m = map(int, input().split())
import math
x=2*math.pi * m / 60
y=(2*math.pi * h / 12) + (x/12)

csq = a**2 + b**2 - 2*a*b*math.cos(abs(x-y))

print(math.sqrt(csq))

Measured memory_bytes: 62384
N,M = list(map(int,input().split()))

X=[list(map(int,input().split())) for i in range(N)]

X.sort(key = lambda x:x[0])

from heapq import heappush,heappop


q = []

prev = X[0][0]
ans = 0
for x in X:
    if x[0]>M:
        break
    if x[0]!=prev:
        for i in range(x[0]-prev):
            if len(q)==0:
                break
            a=-heappop(q)
            ans+=a
        prev=x[0]
    heappush(q,-x[1])

for i in range(M-prev+1):
    if len(q)==0:
        break
    a=-heappop(q)
    ans+=a
    
print(ans)

Measured memory_bytes: 82136
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int min = Integer.MAX_VALUE;
      int max = Integer.MIN_VALUE;
      int minIdx = 0, maxIdx = 0;

      for(int i = 1; i <= n; i++) {
        int num = sc.nextInt();
        if(num < min) {
          min = num;
          minIdx = i;
        }
        if(num >= max) {
          max = num;
          maxIdx = i;
        }
      }
      System.out.println(2*n-1);
      if(Math.abs(min) > Math.abs(max)) {
        for(int i = 1; i <= n; i++) {
          System.out.println(minIdx + " " + i);
        }
        for(int i = n; i > 1; i--) {
          System.out.println(i + " " + (i-1));
        }
      } else {
        for(int i = 1; i <= n; i++) {
          System.out.println(maxIdx + " " + i);
        }
        for(int i = 1; i < n; i++) {
          System.out.println(i + " " + (i+1));
        }
      }
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
bool used[100];

string ask(vector<int> v){
    cout << "? ";
    for(int i = 0; i < v.size(); i++) {
        if(i+1 == v.size()) cout << v[i] << endl;
        else cout << v[i] << ' ';
    }
    string res;
    cin >> res;
    return res;
}

char ans[300];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    cin >> N;
    vector<int> blue, red;
    int s = blue.size();
    int l = 1;
    int r = N+1;
    vector<int> buf;
    for(int j = 1; j <= N; j++){
        buf.push_back(j);
    }  
    string res = ask(buf);
    while(r-l > 1){
        int c = (l+r)/2;
        buf.clear();
        for(int j = c; j < N+c; j++){
            buf.push_back(j);
        }
        string tmp = ask(buf);
        if(tmp == res) l = c;
        else r = c;
    }
    vector<int> b1, b2;
    // cout << l << ' ' << r << endl;
    for(int i = l+1; i <= l+N-1; i++) b1.push_back(i);
    for(int i = 1; i <= l-1; i++) b2.push_back(i);
    for(int i = l+N+1; i <= 2*N; i++) b2.push_back(i);
    for(int i = 1; i <= l; i++){
        b1.push_back(i);
        string res = ask(b1);
        b1.pop_back();
        if(res == "Red") ans[i] = 'R';
        else ans[i] = 'B';
    }
    for(int i = l+N; i <= 2*N; i++){
        b1.push_back(i);
        string res = ask(b1);
        b1.pop_back();
        if(res == "Red") ans[i] = 'R';
        else ans[i] = 'B';
    }
    for(int i = l+1; i <= l+N-1; i++){
        b2.push_back(i);
        string res = ask(b2);
        b2.pop_back();
        if(res == "Red") ans[i] = 'R';
        else ans[i] = 'B';
    }
    cout << "! ";
    for(int i = 1; i <= 2*N; i++) cout << ans[i];
    cout << endl;
}

Measured memory_bytes: 724
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

s = sinput()

a = "dream"
b = "dreamer"
c = "erase"
d = "eraser"

s = "".join(s.split(d))
s = "".join(s.split(c))
s = "".join(s.split(b))
s = "".join(s.split(a))

ans = "YES" if s=="" else "NO"
print(ans)


Measured memory_bytes: 19764
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int>data(3);
    for(int i=0;i<3;i++)cin >> data[i];
    sort(data.begin(),data.end());
    if(data[0] == 5 && data[1]==5 && data[2]==7)cout << "YES"<<endl;
    else cout <<"NO"<<endl;
    
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint A, B; cin >> A >> B;
    lint g = __gcd(A, B);
    unordered_set<lint> primes;
    lint num = 2, cur_g = g;
    while (num * num <= g) {
        if (cur_g % num == 0) {
            while (cur_g % num == 0) cur_g /= num;
            primes.emplace(num);
        }
        num++;
    }
    if (cur_g != 1) primes.emplace(cur_g);
    cout << primes.size() + 1 << "\n";
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, res = 0;
	cin >> n;
	for(ll i = 1; i <= n; i++) {
		ll up = n / i;
		res += (i * up * (up + 1))/2;
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

bool iskaibun(string s) {
	if (s.size() % 2 == 0) {
		for (int i = 0; i < s.size() / 2; ++i){
			if (s[i] != s[s.size() - i-1]) {
				return false;
			}
		}
		return true;
	}
	else {
		for (int i = 0; i < (s.size() - 1) / 2; ++i) {
			if (s[i] != s[s.size() - i - 1]) {
				return false;
			}
		}
		return true;
	}
}

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

	string notx = "";

	REP(i, s.size()) {
		if (s[i] != 'x') {
			notx += s[i];
		}
	}

	if (iskaibun(notx)) {

		int sum = 0;

		int left = 0;
		int right = s.size() - 1;


		REP(i,(notx.size()+1) / 2) {
			int leftsum = 0;
			int rightsum = 0;
			while (s[left]=='x') {
				left++;
				leftsum++;
			}
			while (s[right] == 'x') {
				right--;
				rightsum++;
			}
			left++;
			right--;

			sum += abs(leftsum - rightsum);
		}

		cout << sum << endl;
	}
	else {
		cout << "-1" << endl;
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int id;
vector<int> cc_id;   
void dfs(const vector<vector<int>> &G, int v, int &cnt) {
    cc_id[v] = id;
    cnt++;
    for (auto i : G[v]) {
        if (cc_id[i] != -1) continue;
        dfs(G, i, cnt);
    }
}
int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<vector<int>> G(N);  
    vector<int> cc_num;  
    rep(i, M) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cc_id.assign(N, -1);  
    id = 0;
    rep(i, N) {
        if (cc_id[i] == -1) {
            int cnt = 0;
            dfs(G, i, cnt);
            cc_num.push_back(cnt);
            id++;
        }
    }
    vector<int> ans(N);
    rep(i, N) ans[i] = cc_num[cc_id[i]]-(int)G[i].size()-1;
    rep(i, K) {  
        int c,d;
        cin >> c >> d;
        c--;d--;
        if (cc_id[c] == cc_id[d]) {
            ans[c]--;
            ans[d]--;
        }
    }
    rep(i,N) cout << ans[i] << ' ';
    cout << endl;
}

Measured memory_bytes: 10428
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
	for(int i = 0; i < 4; i++){
		int temp; cin >> temp;
		int x; cin >> x;
		switch(temp){
			case 1: cout << x * 6000 << endl;	break;
			case 2: cout << x * 4000 << endl;   break;
			case 3: cout << x * 3000 << endl;   break;
			case 4: cout << x * 2000 << endl;   break;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
def check(i, j):
    if s[i][j] == '.':
        return 1
    else:
        return 0
H, W = map(int, input().split())
s = [input() for i in range(H)]
dp = [[0]*W for i in range(H)]
dp[0][0] = int(s[0][0] == '#')
for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            if i > 0 and j > 0:
                dp[i][j] = min(dp[i-1][j], dp[i][j-1])
            elif i > 0:
                dp[i][j] = dp[i-1][j]
            elif j > 0:
                dp[i][j] = dp[i][j-1]
        else:
            if i > 0 and j > 0:
                dp[i][j] = min(dp[i-1][j]+check(i-1, j), dp[i][j-1]+check(i, j-1))
            elif i > 0:
                dp[i][j] = dp[i-1][j]+check(i-1, j)
            elif j > 0:
                dp[i][j] = dp[i][j-1]+check(i, j-1)
print(dp[H-1][W-1])


Measured memory_bytes: 41840
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;

#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define ff first
#define ss second
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr clear
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define len(s) (s).length()

int main()
{
     crap;
     int n;
     cin>>n;
     int x[n],y[n],h[n];
     rep(i,n)
      cin>>x[i]>>y[i]>>h[i];
     rep(i,101)
     {
          rep(j,101)
          {
               int H=0;
               bool f=false;
               vi v;
               int t;
               rep (k,n)
               {
                   t=fabs(i-x[k])+fabs(j-y[k]);
                   if(h[k]==0)
                   {
                       if(t==0)
                       {
                          f=true;
                          break;
                       }
                       v.pb(t);
                       if(H==0)
                        continue;
                       if(H>t)
                       {
                          f=true;
                          break;
                       }
                   }
                   else
                   {
                       if(H==0)
                       {
                           H=h[k]+t;
                           continue;
                       }
                       if(H!=h[k]+t)
                       {
                           f=true;
                           break;
                       }
                   }
               }
               if(!f)
               {
                   rep(l,sz(v))
                   {
                       if(H>v[l])
                       {
                           f=true;
                           break;
                       }
                   }
                   if(f)
                    continue;
                  else
                  {
                     cout<<i<<" "<<j<<" "<<H;
                     return 0;
                  }
               }
          }
     }
 }

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()

{
    long a,b = 0;
    cin >>a;
   
    for(int i = 0; i<=a;i++)
    {
        if(!((i%3)==0 || (i%5)==0))
        {
            b+=i;
        }
    }
    cout << b;
    return 0;

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
int main()
{    
    map<char,int> m;
    string s;
    cin >> s;
    for(int i = 0;i < (int)s.size();++i)
    {
        if(!m.count(s[i]))
        {
            m.insert(make_pair(s[i],1));
        }
        else
        {
            m[s[i]]++;
        }
    }

    bool is = true;
    for(auto i : m)
    {
        if(i.second % 2 != 0)
            is  = false;
    }
    cout << (is ? "Yes\n" : "No\n");
}   



Measured memory_bytes: 256
#include <stdio.h>

int main( void )
{
	int n, m, l, line_cou, column_cou, repeat_cou;
	long long int matrix_A[100][100] = {};
	long long int matrix_B[100] [100]= {};
	long long int ans_A, ans_B;
	long long int product[100][100] = {};
	
	ans_A = 0;
	ans_B = 0;
	
	scanf( "%d %d %d", &n, &m, &l );
	
	for( line_cou = 0; line_cou < n; line_cou++ )
	{
		for( column_cou = 0; column_cou < m; column_cou++ )
		{
			scanf( "%lld", &matrix_A[line_cou][column_cou] );
		}
	}
	
	for( line_cou = 0; line_cou < m; line_cou++ )
	{
		for( column_cou = 0; column_cou < l; column_cou++ )
		{
			scanf( "%lld", &matrix_B[line_cou][column_cou] );
		}
	}
	
	for( repeat_cou = 0; repeat_cou < n; repeat_cou++ )
	{
		for( line_cou = 0; line_cou < l; line_cou++ )
		{
			ans_B = 0;
			for( column_cou = 0; column_cou < m; column_cou++ )
			{
				ans_A = matrix_A[repeat_cou][column_cou] * matrix_B[column_cou][line_cou];
				ans_B = ans_B + ans_A;
			}
			product[repeat_cou][line_cou] = ans_B;
		}
	}
	
	for( repeat_cou = 0; repeat_cou < n; repeat_cou++ )
	{
		for( line_cou = 0; line_cou < l - 1; line_cou++ )
		{
			printf( "%lld ", product[repeat_cou][line_cou] );
		}
		printf( "%lld\n", product[repeat_cou][line_cou] );
	}
	
	return 0;
}

Measured memory_bytes: 844
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur=nil->next;
  
  while(cur!=nil && cur->key!=key){
    cur=cur->next;
  }

  return cur;
}

void init(){
  nil=malloc(sizeof(struct node));
  nil->next=nil;
  nil->prev=nil;
}

void printList(){
  NodePointer cur=nil->next;
  int isf=0;

  while(1){
    if(cur==nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }

  printf("\n");
}

void deleteNode(NodePointer t){
  
  if(t==nil) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t=nil->next;

  if(t==nil) return;

  deleteNode(t);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void delete(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  NodePointer x=malloc(sizeof(struct node));
  
  x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key,n,i,size=0,np=0,nd=0;
  char com[20];

  scanf("%d",&n);

  init();

  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);

    if(com[0]=='i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0]=='d') {
      if(strlen(com)>6){
	if(com[6]=='F') deleteFirst();
	else if(com[6]=='L') deleteLast();
      }
      else{
	delete(key);
	nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}



Measured memory_bytes: 32944
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    int pass=0,ab=1;
    for(int i=0;i<s.length();i++){
        if(s[i]=='c') cout<<"No"<<endl;
        else if(s[i]=='a'){
            if(pass<a+b){
                cout<<"Yes"<<endl;
                pass++;
            }else{
                cout<<"No"<<endl;
            }
        }else if(s[i]=='b'){
            if(pass<a+b && ab<=b){
                cout<<"Yes"<<endl;
                pass++;
                ab++;
            }else{
                cout<<"No"<<endl;
            }
        }
    }
    return 0;
}

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

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

  if (s == "RSS") {
    cout << 1 << endl;
    exit(0);
  }
  if (s == "SRS") {
    cout << 1 << endl;
    exit(0);
  }
  if (s == "SSR") {
    cout << 1 << endl;
    exit(0);
  }
  if (s == "RRS") {
    cout << 2 << endl;
    exit(0);
  }
  if (s == "SRR") {
    cout << 2 << endl;
    exit(0);
  }
  if (s == "RRR") {
    cout << 3 << endl;
    exit(0);
  }
  if (s == "SSS") {
    cout << 0 << endl;
    exit(0);
  }
  if (s == "RSR") {
    cout << 1 << endl;
    exit(0);
  }
}

Measured memory_bytes: 3600
n,p=map(int,input().split())
if n==1:
  print(p)
else:
  n=min(50,n)
  ans=1
  for i in range(2,int(p**0.5)+1):
    if i**n>p:
      break
    else:
      if p%(i**n)==0:
        ans=i
  print(ans)

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

#define mp make_pair
#define f first
#define s second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define speed() ios_base::sync_with_stdio(0), cin.tie()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); ++it)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N = (int)2e5;

int n;
int a[N];
ll e[N];
vector<int> g[N];

void BAD() {
	puts("NO");
	exit(0);
}

void dfs(int v, int pr=0) {
	if (sz(g[v]) == 1) {
		e[v] = a[v];
		return;
	}
	ll mx = 0;
	ll sum = 0;
	for (int u : g[v]) if (u != pr) {
		dfs(u, v);
		mx = max(mx, e[u]);
		sum += e[u];
		e[v] -= e[u];
	}
	e[v] = a[v] + a[v] - sum;
	if (e[v] < 0) BAD();
	sum += e[v];
	mx = max(e[v], mx);
	if (sum % 2 != 0) BAD();
	if (mx + mx > sum) BAD();
}

int main() { 
	#ifdef LOCAL
	freopen("a.in", "r", stdin);
	#endif
	
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
	}
	if (n == 2) {
		puts(a[1] == a[2] ? "YES" : "NO");
		return 0;
	}
	for (int i = 1, a, b; i < n; i++) {
		scanf("%d %d", &a, &b);
		g[a].pb(b);
		g[b].pb(a);
	}
	int root;
	for (int i = 1; i <= n; i++) {
		if (sz(g[i]) >= 2) {
			root = i;
			break;
		}
	}

	ll sum = 0;
	ll mx = 0;
	for (int u : g[root]) {
		dfs(u, root);
		sum += e[u];
		mx = max(mx, e[u]);
	}
	
	if (sum % 2 != 0) BAD();
	if (sum / 2 != a[root]) BAD();
	if (mx + mx > sum) BAD();

	puts("YES");
	


	
	return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int count = 0;
  for(int i=0;i<N;i++){
    int h;
    scanf("%d", &h);
    //cin >> h;
    if(h >= K) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1000000007;

string S;
int N;
vector<ll> num;

ll dfs(int v){
    if(num[v] != -1) return num[v];
    num[v] = 0;
    if(v - 1 >= 0 && S[v - 1] == '<'){
        num[v] = max(num[v], dfs(v - 1) + 1);
    }
    if(v + 1 < N && S[v] == '>'){
        num[v] = max(num[v], dfs(v + 1) + 1);
    }
    return num[v];
}

int main() {
    cin >> S;
    N = S.size() + 1;
    num.assign(N, -1);

    ll ans = 0;
    for(int i=0;i<N;i++){
        ans += dfs(i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 28164
#include<bits/stdc++.h>
using namespace std;
char *TT,*tmo,but[(1<<15)+2];
#define getc() ((TT==tmo&&(tmo=((TT=but)+fread(but,1,1<<15,stdin)),TT==tmo))?-1:*TT++)
inline int rd(){
  int x,c,f=1;while(!isdigit(c=getc()))f&=c!='-';x=c-'0';
  while(isdigit(c=getc()))x=x*10+c-'0';return f?x:-x;
}
typedef long long L;
const int N=1e5+11;
int n,a[N],c[N];
L b[N];
int main(){
#ifdef flukehn
	freopen("g.in","r",stdin);
#endif
	int i;
	n=rd();
	for(i=1;i<=n;++i)
		a[i]=rd();
	c[n+1]=n+1;
	for(i=n;i;--i){
		b[i]=b[i+1]+abs(a[i]);
		c[i]=a[i+1]<0?i+1:c[i+1];
	}
	L an=-LONG_LONG_MAX,tm=0;
	for(i=1;i<=n;++i){
		tm+=a[i];
		if(a[i]<0)
			an=max(an,tm+2*b[c[i]]-b[i+1]);
	}
	an=max(an,tm);
	cout<<an;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int X; cin>>X;
	cout<<(X>=30 ? "Yes" : "No")<<"\n";
	return 0;
}

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

int main()
{
	int N,i,j,k,l,m,n,o,p;
	int A[3] = {};
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	cout << A[2] - A[0] << endl;
	
    return 0;
}



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

int main()
{
    int a,b;
	scanf("%d %d",&a,&b);
	if      (a<b) printf("a < b\n");
	else if (a>b) printf("a > b\n");
	else if (a==b) printf("a == b\n");
    return 0;
}


Measured memory_bytes: 2596
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (n, _, w) = (v[0], v[1], v[2]);
    let w = w as i64;
    let a: Vec<i64> = read_vec();

    if n == 1 {
        println!("{:?}", (w - a[a.len() - 1]).abs());
    } else {
        println!("{:?}", std::cmp::max((w - a[a.len() - 1]).abs(), (a[a.len() - 2] - a[a.len() - 1]).abs()));
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<deque>
using namespace std;
bool check(int key) {
	deque<int>d;
	while (key >= 10) {
		d.push_front(key % 10);
		key /= 10;
	}
	d.push_front(key);
	for (int i = 1; i < d.size(); i++)if (d[i] != d[i - 1] + 1)return false;
	return true;
}
int main() {
	int n; cin >> n;
	int a[114514];
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = -1;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i+ 1; j < n; j++) {
			if (check(a[i] * a[j]))ans = max(ans, a[i] * a[j]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
using namespace std;

int main()
{
	long long X, A, B;
	cin >> X >> A >> B;

	if (B - A <= 0) {
		printf("delicious\n");
	}
	else if (B - A <= X) {
		printf("safe\n");
	}
	else {
		printf("dangerous\n");
	}
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int A, B;
	scanf("%d", &A);
	scanf("%d", &B);
	int c = A * B;
	if (c % 2 == 0) {
		printf("No");
	}
	else {
		printf("Yes");
	}
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var DX = ReadLine().Split().Select(int.Parse).ToArray();
        var D = DX[0];
        var X = DX[1];
        var A = new int[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = int.Parse(ReadLine());
        }

        var c = 0;
        for (int i = 0; i < N; i++)
        {

            if (A[i] != 1)
            {
                for (int j = 1; j <= D; j++)
                {
                    if (j % A[i] == 1) c++;
                }
            }
            else
            {
                c = c + D;
            }

        }
        WriteLine(c + X);
    }
}

Measured memory_bytes: 13396
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, M);
    OUT(N * (N - 1) / 2 + M * (M - 1) / 2);
}

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

// @author: pashka

vector<int> q;
void build(int k, int l) {
    if (k == 0) {
        q[l] = 1;
        return;
    }
    int c = 1;
    while (c * 2 <= k) c *= 2;
//    cout << k << " " << l << " " << c << "\n";
    build(k - c, l);
    build(k - c, l + c);
}

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    string s;
    cin >> s;
    n--;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = abs((int)s[i] - s[i + 1]);
    }
    q.resize(n);
    build(n - 1, 0);
    int ss = 0;
    for (int i = 0; i < n; i++) {
//        cout << q[i];
        ss += a[i] * q[i];
        ss %= 2;
    }
//    cout << "\n";
    if (ss == 1) {
        cout << 1 << "\n";
    } else {
        bool ok = true;
        for (int i = 0; i < n; i++) {
            if (a[i] == 1) ok = false;
        }
        if (!ok) {
            cout << 0 << "\n";
        } else {
            for (int i = 0; i < n; i++) {
                ss += a[i] * q[i];
                ss %= 4;
            }
            cout << ss << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 9116
#include <iostream>
#include <queue>

using namespace std;

int n;
char c;

int main(void){
  
  queue<int> s;
 
  cin >> n;
  s.push(n);

  while(1){

    cin >> c;
    if( c == '=' ) break;

    cin >> n;

    if( c == '+' ){
      s.push( s.front() + n );
    }   
    else if( c == '-' ){
      s.push( s.front() - n );
    }
    else if( c == '*' ){
      s.push( s.front() * n );
    }
    else if( c == '/' ){
      s.push( s.front() / n );
    }
    s.pop();
   
  }
  cout << s.front() << endl;
  return 0;
}

Measured memory_bytes: 1200
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            long X = long.Parse (Console.ReadLine ());

            for (long A = -120; A < 120; A++)
            {
                for (long B = -120; B < 120; B++)
                {
                    if (A * A * A * A * A - B * B * B * B * B == X)
                    {
                        Console.Write (A + " " + B);
                        return;
                    }
                }
            }
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 27544
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);

int main()
{
    BeatMeScanf;
    /*#ifndef ONLINE_JUDGE
        freopen("/home/shafayetemon/Documents/in.txt", "r", stdin);
        freopen("/home/shafayetemon/Documents/out.txt", "w", stdout);
    #endif*/

    int N, R;

    cin >> N >> R;

    if(N >= 10)
        cout<<R<<endl;
    else
    {
        cout<<(R+(100*(10-N)))<<endl;
    }
   
    return 0;
}



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

int main() {
  double x[3], y[3];
  for(int i = 0; i < 3; i++) cin >> x[i] >> y[i];
  double a, b, c;
  a = sqrt(pow(x[0]-x[1], 2)+pow(y[0]-y[1], 2));
  b = sqrt(pow(x[1]-x[2], 2)+pow(y[1]-y[2], 2));
  c = sqrt(pow(x[2]-x[0], 2)+pow(y[2]-y[0], 2));
  double s = (a+b+c) / 2;
  double S = sqrt(s*(s-a)*(s-b)*(s-c));
  double maxL = max({a, b, c});
  double h = 2*S/maxL;
  double r = S/(s+h);
  cout << setprecision(12);
  cout << r << endl;
  return 0;
}


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

public class Main{
    public static void main(String[] args){
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
            try{
            int m=Integer.parseInt(reader.readLine());
            String line=reader.readLine();
            String li="...";
            if(m<line.length()){
                line=line.substring(0, m)+li;
            }
            System.out.println(line);
        }catch (IOException e){    
        }
    }
}

Measured memory_bytes: 36892
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int sx = sc.nextInt();
    int sy = sc.nextInt();
    int tx = sc.nextInt();
    int ty = sc.nextInt();
    int N = (tx - sx)+ (ty - sy);
    for (int i =0; i<N; i++) {
      if(i < (ty - sy)) {
        System.out.print('U');
        continue;
      }
      System.out.print('R');
    }
    for (int i =0; i<N; i++) {
      if(i < (ty - sy)) {
        System.out.print('D');
        continue;
      }
      System.out.print('L');
    }
    System.out.print('L');
    System.out.print('U');     
    for (int i =0; i<N; i++) {
      if(i < (ty - sy)) {
        System.out.print('U');
        continue;
      }
      System.out.print('R');
    }
    System.out.print('R');
    System.out.print('D');     
    System.out.print('R');
    System.out.print('D');     
    for (int i =0; i<N; i++) {
      if(i < (ty - sy)) {
        System.out.print('D');
        continue;
      }
      System.out.print('L');
    }
    System.out.print('L');
    System.out.print('U'); 
  }
}

Measured memory_bytes: 27308
#include <algorithm>
#include <iostream>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{

    int n;
    cin >> n;

    int64_t m = 2 * 1e14;
    int64_t s = 0;
    rep(i, n)
    {
        int64_t a, b;
        cin >> a >> b;
        s += a;
        if (a > b) {
            m = min(m, b);
        }
    }
    int64_t result = s - min(m, s);
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
// g++ -std=c++14 submit.cpp
// #define INF 9223372036854775807

# include <bits/stdc++.h>
// # define INF 1e9 + 1
using namespace std;

int main(){

    long int N, T; cin >> N >> T;
    vector<vector<long int>> C;
    for(long int i=0; i<N; i++) {
      long int a, b;
      cin >> a >> b;
      C.push_back({b, a});
    }

    vector<long int> dp;
    vector<unordered_set<long int>> vtd;
    for(long int i=0; i<T; i++){
      dp.push_back({0});
      unordered_set<long int> s;
      vtd.push_back(s);
    }

    long int ans = 0;

    for(long int i=0; i<T; i++){
      for(long int j =0; j<N; j++){
        if(vtd[i].find(j) == vtd[i].end()){
          int k = i + C[j][1];
          if(k > T-1){
            ans = max(ans, dp[i] + C[j][0]);
          }
          else if ((dp[i]+C[j][0]) > dp[k]){
            dp[k] = dp[i]+C[j][0];
            vtd[k] = vtd[i];
            vtd[k].insert(j);
          }
        }
      }
      ans = max(ans, dp[i]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 193996
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = S()
ans = []
for c in n:
    if c == '1':
        ans.append('9')
    else:
        ans.append('1')
print("".join(ans))


Measured memory_bytes: 63980
N = int(input())
src = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(N-1)]
es = [[] for i in range(N)]
for a,b in src:
    es[a].append(b)
    es[b].append(a)

INF = float('inf')
dists = [INF] * N
dists[0] = 0
visited = [0]*N
back = [None]*N
stack = [0]
while stack:
    v = stack.pop()
    visited[v] = 1
    if v == N-1:
        break
    d = dists[v]
    for to in es[v]:
        if visited[to] : continue
        dists[to] = d+1
        back[to] = v
        stack.append(to)

path = [N-1]
while back[path[-1]] is not None:
    b = back[path[-1]]
    path.append(b)
path.reverse()

f_cantgo = path[dists[-1]//2 + 1]

visited = [0]*N
visited[f_cantgo] = 1
f_can_go = 0
stack = [0]
while stack:
    v = stack.pop()
    visited[v] = 1
    f_can_go += 1
    for to in es[v]:
        if visited[to]: continue
        stack.append(to)

s_can_go = N - f_can_go
print('Fennec' if f_can_go > s_can_go else 'Snuke')


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

int main()
{
    int n;
    cin >> n;
    char a[n + 1], b[n + 1];
    cin >> a >> b;

    for (int i = 0; a[i]; i++) cout << a[i] << b[i];
    cout << "\n";
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

memory = {}


def solve(N: int, C: "List[int]"):
    # print(dfs(tuple(C), N, 0))

    dp = [0]*N
    last = [-1]*(2*(10**5)+1)
    for i, s in enumerate(C):
        if i == 0:
            dp[i] = 1
        else:
            dp[i] = dp[i-1]
            if last[s] != -1 and last[s] < i-1:
                dp[i] = (dp[i] + dp[last[s]]) % MOD
        last[s] = i
    # print(dp, souwa, pre)
    print(dp[-1])
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20532
S = input()
len_S = len(S)
cnt1 = 0

if len_S%2 == 0:
  ans = "01"*(len_S//2)
else:
  ans = "01"*(len_S//2)+"0"
for i in range(len_S):
  if S[i]!=ans[i]:
    cnt1 += 1
final_ans = min(len_S-cnt1,cnt1)
print(final_ans)

Measured memory_bytes: 3188