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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	char a[3];
	
	cin >> a[0] >> a[1] >> a[2];
	
	rep(i, 3){
		if(a[i] == '1')
			cout << 9;
		else
			cout << 1;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long  x = 0; 
    long  sum = 0;
    cin >> x;
    
    for(long i =1;i <= x; i++){
        if(i % 3 > 0 && i % 5 > 0){
            sum +=  i;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
const int MOD = 3;

string s[2];
int cnt[2][N];

inline int fix(int a)
{
	if (a >= MOD)
		a -= MOD;
	if (a < 0)
		a += MOD;
	return a;
}

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

	for (int i=0; i<2; i++)
	{
		cin >> s[i];
		for (int j=0; j<(int)s[i].size(); j++)
			cnt[i][j+1] = fix(cnt[i][j] + (s[i][j] == 'A' ? 1 : -1));
	}
	int q;
	cin >> q;
	while (q--)
	{
		int l, r, L, R;
		cin >> l >> r >> L >> R;
		l--, L--;
		if (fix(cnt[0][r] - cnt[0][l]) != fix(cnt[1][R] - cnt[1][L]))
			cout << "NO\n";
		else
			cout << "YES\n";
	}
	

	return 0;
}

Measured memory_bytes: 1744
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int n;
  string s;
  cin>>n>>s;
  deque<char> q;
  int cnt=0;
  REP(i,n){
    if(s[i]=='('){
      q.PB('(');
      cnt++;
    }else if(s[i]==')'){
      if(cnt){
        q.PB(')');
        cnt--;
      }else{
        q.push_front('(');
        q.PB(')');
      }
    }
  }
  if(cnt)while(cnt--)q.PB(')');
  for(auto x:q)cout<<x;
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){
	char div[100];
	long double a,b;
	int ans,i,n;
	while(scanf("%Lf %Lf %d",&a,&b,&n)!=EOF){
		sprintf(div,"%.*Lf",n+1,a/b-floorl(a/b));
		for(ans=0,i=0;i<n;i++){
			ans+=div[i+2]-'0';
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 676
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define print(n) std::cout << n << std::endl
#define FOR(i,n) for(int i = 0; i < n; i++)
using namespace std;

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

    if(c >= a && c <= b)print("Yes");
    else print("No");
}

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll fac(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll npr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
	ll a,b,k; cin >> a >> b >> k;
	cout << max(0LL,a-k) << " " << max(0LL,min(b,a+b-k)) << endl;
}

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

int main(){
    int arr[32]={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};

    // 標準入力K
    int K;
    cin >> K;

    if(K <= 32){
        int out = arr[K-1];
        cout << out << endl;
    }
}

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

int main() {
  int num, a, thr, cnt;

  cin >> num >> thr;
  cnt = 0;

  map<int, int> M {};
  for(int i=0; i<num; i++) {
    cin >> a;
    M[a] = M[a] + 1;
  }

  vector <int> v;

  for(map<int, int>::iterator it = M.begin(); it != M.end(); it++) {
    v.push_back( it->second );
  }

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

  if(v.size() >= thr) {
    for(int j = 0; j < v.size() - thr; j++) {
      cnt += v[j];
    }
  }

  cout << cnt << endl;

}


Measured memory_bytes: 10748
use strict;
use warnings;

my $n = <STDIN>;
chomp $n;
my @array;
{
    my $in = <STDIN>;
    @array = split(" ", $in);
}
@array = sort {$b <=> $a} @array;
my $alice = 0;
my $bob = 0;
for (my $i=0; $i<$n; $i++)
{
    $alice += $array[$i] if $i%2==0;
    $bob += $array[$i] unless $i%2==0;    
}
my $ans = abs($alice-$bob);

print "$ans\n";

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const long long INF=(1LL<<50);
int n; 
long long a[30];
long long DFS(int l,int r,long long cntl,long long cntr){
	if(r-l<=1) return 0;
	long long ret=INF;
	for(int i=l+1;i<=r-1;++i)
		ret=min(ret,DFS(l,i,cntl,cntl+cntr)+DFS(i,r,cntl+cntr,cntr)+(cntl+cntr)*a[i]);
	return ret;	
}
int main(){
	
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%lld",&a[i]);
	printf("%lld\n",DFS(1,n,1,1)+a[1]+a[n]); 
	return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d))puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
a_yen = 0
b_yen = 0
c_yen = 0
if a + b <= 2*c:
    a_yen = a*x
    b_yen = b*y
    print(a_yen + b_yen)

elif a + b > 2*c:
    c_yen = 2*c*min(x, y)

    if min(x, y) == x and b <= 2*c:
        b_yen = b*(y-x)
    elif min(x, y) == x and b > 2*c:
        c_yen += 2*c*(y-x)

    elif min(x, y) == y and a <= 2*c:
        a_yen = a*(x-y)
    elif min(x, y) == y and a > 2*c:
        c_yen += 2*c*(x-y)

    print(a_yen + b_yen + c_yen)

Measured memory_bytes: 38384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <array>
#include <tuple>
#include <utility>
#include <cctype>
#include <typeinfo>
using namespace std;

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define ii(n)    ff(i, n)
#define kk(n)    ff(k, n)
#define mm(n)    ff(m, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define iii(a, b) fff(i, a, b)
#define kkk(a, b) fff(k, a, b)
#define mmm(a, b) fff(m, a, b)
#define xx first
#define yy second
#define bb begin()
#define ee end()
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }

using LL = long long;
using pii = pair<int, int>;


const LL INF = 9223372036854775807LL;
//const int INF = 2147483647;
   
const LL MOD = LL(1e9) + 7;




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << '\n';
    

    int N;
    cin >> N;
    vector<LL> xs(N);
    ii (N)
        cin >> xs[i];

    xs[0] = 1;
    LL full = 1;
    LL add = 0;
    vector<LL> adds(N, 0);
    iii (1, len(xs)) {
        adds[i] = add;
        LL x = xs[i];
        if (full <= x-2) {
            full += 2;
        } else {
            ++add;
        }
    }

    LL rr = 1;
    for (int i = N-1; i >= 0; --i) {
        LL places = N - adds[i];
        LL allocated = N-1 - i;
        rr = (rr * (places - allocated)) % MOD;
    }

    cout << rr << '\n';

    return 0;
}



Measured memory_bytes: 1792
import math
class SegmentTree:
    __slots__ = ["elem_size", "tree_size", "tree", "default", "op"]

    def __init__(self, a: list, default: int, op):
        real_size = len(a)
        self.elem_size = 1 << math.ceil(math.log2(real_size))
        self.tree_size = 2 * self.elem_size
        self.tree = [default] * self.elem_size + a + [default] * (self.elem_size - real_size)
        self.default = default
        self.op = op
        self.init_tree()

    def init_tree(self) -> None:
        tree = self.tree
        for i in range(self.elem_size - 1, 0, -1):
            left, right = tree[i << 1], tree[(i << 1) + 1]
            # ===== change me =====
            tree[i] = self.op(left, right)

    def get_value(self, x: int, y: int):
        l, r = x + self.elem_size, y + self.elem_size
        tree, result = self.tree, self.default
        while l < r:
            if l & 1:
                # ===== change me =====
                result = self.op(tree[l], result)
                l += 1
            if r & 1:
                r -= 1
                # ===== change me =====
                result = self.op(tree[r], result)
            l, r = l >> 1, r >> 1

        return result

    def set_value(self, i: int, value: int, op: str = "="):
        tree = self.tree
        k = self.elem_size + i
        if op == "=":
            tree[k] = value
        elif op == "+":
            tree[k] += value
        elif op == "?":
            # ===== change me =====
            tree[k] = value if value < tree[k] else tree[k]

        while k > 1:
            k >>= 1
            left, right = tree[k << 1], tree[(k << 1) + 1]
            # ===== change me =====
            tree[k] = self.op(left, right)

import sys
n, q = map(int, input().split())
tree = SegmentTree([2**31-1]*n, 2**31-1, min)
ans = []
append = ans.append
for com, x, y in (map(int, l.split()) for l in sys.stdin.readlines()):
    if com == 0:
        tree.set_value(x, y)
    else:
        append(tree.get_value(x, y+1))
print(*ans, sep="\n")


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

typedef long long ll;
typedef unsigned long long ull;

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

int main(){
    ll N, M;
    cin >> N >> M;
    string S,T;
    cin >> S >> T;

    if(S[0]!=T[0]){
        cout << -1 << endl;
        return 0;
    }
    if(gcd(N,M)==1){
        cout << M*N << endl;
        return 0;
    }else{
        string SS="", TT="";
        ll step=gcd(M,N);
        for(ll i=0;i<N;i+=N/step) SS=SS+S[i];
        for(ll i=0;i<M;i+=M/step) TT=TT+T[i];
        if(SS==TT) cout << M*N/step << endl;
        else cout << -1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 640
/* Author rumoisen */
/* created 2018/10/13 */

#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include<iostream>
#include <algorithm>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll ans;  
    ans=min((a%2)*b*c,min((b%2)*a*c,(c%2)*a*b));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, n;
    while(cin >> h >> w >> n && h) {
        vector<vector<int>> fld(h + 1, vector<int>(w + 1, -1));
        for(int i : in(h))
          for(int j : in(w))
            cin >> fld[i][j];
        vector<vector<int>> dp(h + 1, vector<int>(w + 1, 0));
        dp[0][0] = n - 1;
        for(int i : in(h)) for(int j : in(w)) {
            dp[i + 1][j] += (dp[i][j] + !fld[i][j]) >> 1;
            dp[i][j + 1] += (dp[i][j] + fld[i][j]) >> 1;
        }
        int x = 0, y = 0;
        while(true) {
            if(fld[y][x] == -1) {
                cout << y + 1 << ' ' << x + 1 << endl;
                break;
            }
            int num = fld[y][x];
            if(dp[y][x] & 1) num ^= 1;
            if(num) ++x; else ++y;
        }
    }
    return 0;
}

Measured memory_bytes: 10820
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <cctype>
#include <bits/stdc++.h>
using namespace std;
int ans1=0,ans2=0;
int main(){
	string s;
	cin>>s;
	for (int i=0;i<s.size();i++){
		if (s[i]=='0') ans1++;
		else ans2++;
	}
	cout<<min(ans1,ans2)*2;
}

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

using namespace std;

int main()
{
    int c1, c2, c3;
    while (cin >> c1 >> c2 >> c3) {
        vector<int> cards(10);
        for (int i = 0; i < 10; i++) {
            cards[i] = i + 1;
            if (c1 == cards[i] || c2 == cards[i] || c3 == cards[i]) {
                cards[i] = 0;
            }
        }

        int cnt = 0, tc = c1 + c2;
        for (int i = 0; i < 10; i++) {
            if (cards[i] == 0) continue;
            if (cards[i] + tc <= 20) {
                cnt++;
            }
        }
        cout << (cnt >= 4 ? "YES" : "NO") << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<P> d(m);
  rep(i, m) { cin >> d[i].second >> d[i].first; }

  sort(a.begin(), a.end());
  sort(d.rbegin(), d.rend());

  int idx = 0;
  rep(i, m) {
    rep(j, d[i].second) {
      if (idx >= n) break;
      if (a[idx] < d[i].first) {
        a[idx] = d[i].first;
        ++idx;
      } else {
        break;
      }
    }
  }

  ll ans = 0;
  rep(i, n) ans += a[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4580
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000

main(){
    int n=in();
    int m=in();
    vec vis(n+1);
    vec cnt(n+1,1);
    vis[1]=1;
    rep(i,m){
        int x,y;cin>>x>>y;
        vis[y]|=vis[x];
        cnt[x]--;cnt[y]++;
        if(cnt[x]==0)vis[x]=0;
    }
    int ans=0;
    rep2(i,1,n)ans+=vis[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int a[3];
    int temp = 0;
    for(int i=0; i<3; i++){
        cin>>a[i];
    }
    for(int j=0;j<2;j++){
        if(a[j]>a[j+1]){
            temp = a[j];
            a[j] = a[j+1];
            a[j+1] = temp;
        }
    }
    if(a[0]>a[1]){
        temp = a[0];
        a[0] = a[1];
        a[1] = temp;
    }
    cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
   
}



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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    string s;
    cin >> s;
    rep(i, int(s.length())) {
        cout << 'x';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

int main(){
    SS(ll,a,b);
    ll sum=0,ans=0;
    if(b==1){
        cout<<ans<<endl;
        return 0;
    }
    sum+=a;
    ans++;
    if(sum>=b){
        cout<<ans<<endl;
        return 0;
    }
    for(;;){
        sum+=a-1;
        ans++;
        if(sum>=b){
            cout<<ans<<endl;
            return 0;
        }
    }
}    

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

int main(){
    long long N;
    cin >> N;

    long long a[N];
    REP(i, N) cin >> a[i];

    map<int, int> mp;
    REP(i, N) mp[a[i]] = 0;
    REP(i, N){
        mp[a[i]]++;
        if(mp[a[i]] == 2){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 11136
#include<stdio.h>

#define MAX_N 500001
#define INF (1<<30)

int cnt=0;
int L[MAX_N],R[MAX_N];

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

  L[n1]=INF;
  R[n2]=INF;

  i=0;
  j=0;

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

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

int main(void){

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

  mergeSort(A,0,n);

  for(i=0;i<n;i++){
    printf("%d%c",A[i],(i<n-1?' ':'\n'));
  }  
  printf("%d\n",cnt);
  
  return 0;
}


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

void Main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(s == u) a--;
    if(t == u) b--;
    cout << a << " " << b << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	int k, x;
	cin >> k >> x;
	cout << (500 * k >= x ? "Yes" : "No") << endl;
}


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

using namespace std;
using ll = long long;

int dfs(int n, int m, int q, vector<int> a, vector<int> b, vector<int> c, vector<int> d, vector<int> A) {
    int sum = 0;
    if(A.size() == n + 1) {
        for(int i = 0; i < q; ++i) {
            if(A[b[i]] - A[a[i]] == c[i]) sum += d[i];
        }
        return sum;
    }

    A.emplace_back(A.back());
    while(A.back() <= m) {
        sum = max(sum, dfs(n, m, q, a, b, c, d, A));
        A.back()++;
    }

    return sum;
}

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

    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(q), b(q), c(q), d(q);
    for(int i = 0; i < q; ++i) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    printf("%d\n", dfs(n, m, q, a, b, c, d, vector<int>(1, 1)));

    return 0;
}

Measured memory_bytes: 3676
//I don't want to do this....pls help!!
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define ed end()  
#define bg begin()
# define ld long double
#define ll long long
#define ub(v,a) upper_bound(all(v),a)
#define lb(v,a) lower_bound(all(v),a)
#define sz(a) (int)(a.size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tr(v,it) for(auto it=v.begin();it!=v.end();it++)
#define present(v,x) (v.find(x)!=v.end()) //set/map etc.
#define vpresent(v,x) (find(all(v),x)!=v.end()) // vector
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
typedef vector< long long > vll;
typedef vector<pair<ll,ll>> vp;
typedef vector< vll > vvll;
typedef pair< int,int > pi;
const long long max_sz = 1e5 + 1;
const long long mod = 1e9 + 7;
const long long MAXN = 4e18 + 1;
char flip(char k){ if(k=='0') return '1'; return '0'; }
ll sum_digit(ll n){ ll a=0,i; for(i=n;i>0;i=i/10){ a+=(i%10);} return a; }
ll gcd(ll a, ll b){if(b == 0) return a;return gcd(b, a%b);}
bool isPowerOfTwo(int n){if(n==0)return false;return (ceil(log2(n)) == floor(log2(n)));}
//modulo exponentiation
ll expo(ll a, ll b, ll m) 
{ 
    if (b == 0)return 1; 
    ll p = expo(a, b / 2, m) % m; 
    p = (p * p) % m; 
  
    return (b % 2 == 0) ? p : (a * p) % m; 
} 
/*void BFS(int v, vector<bool>& visited){
	queue<int> q;
	q.push(v);
	while(!q.empty()){
		int u = q.front();
		q.pop();
		cout<<u<<" ";
		visited[u]=1;
		for(auto i:adj[u]){
			if(!visited[i])q.push(i);
		}
	}
}*/
const int N=500023;
bool vis[N];
vll adj[N];

int main(){
                   // ios_base::sync_with_stdio(false);
                    //cin.tie(NULL);
                    //cout.tie(NULL);
 
                     ll t=1;
                   //  cin >> t;
                     
                     while (t--){
                             ll n;cin>>n;
                             map<ll,ll>m;
                             set<ll>s;
                             vll l(n);rep(i,n){ll x;cin>>x;m[x]++;s.insert(x);}
                             ll jhc=0;
                             for(auto i= s.bg;i!=s.ed;i++){
                                 auto j=i;j++;
                                 for(;j!=s.ed;j++){
                                     auto k=j;k++;
                                     for(;k!=s.ed;k++){
                                         if(*i + *j > *k){
                                             jhc+= m[*i]*m[*j]*m[*k];
                                         }
                                     }
                                 }
                             }
                             cout<<jhc<<endl;
                     }
                    cerr << endl
                                  << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
                      return 0;
}


Measured memory_bytes: 15584
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int A,B;
	cin>>A>>B;
	if(A<6)cout<<0<<endl;
	else if(A>12)cout<<B<<endl;
	else cout<<(int)B/2<<endl;
	
}

Measured memory_bytes: 3620
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    P = LIST()

    P.append(-1)
    cnt = 0
    for i in range(N):
        if P[i] == i + 1:
            cnt += 1
            P[i+1] = P[i]

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21340
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MultiWayIf #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Char8 as C
import Data.Complex
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace


------------------
-- #   Read   # --
------------------

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    [n,k] <- r'
    as <- r n
    
    res <- ((min k 100) `timesM` solve)  as
    putStrLn $ unwords $ map show $ U.toList res


f 0 = 0
f n = f (n-1) * 2 + 1

solve :: -- Int -> -- (UM.Vector Int, UM.Vector Int) ->
            U.Vector Int -> IO (U.Vector Int)
solve v = do
    let on  = U.imap (\i a -> max 1 ((i+1)-a)) v
        off = U.imap (\i a -> min (U.length v) (i+1+a)) v

    -- print on
    -- print off

    onI <- UM.replicate (U.length v) 0 :: IO (UM.IOVector Int)
    offI <- UM.replicate (U.length v) 0 :: IO (UM.IOVector Int)
    U.forM_ on  (\i -> UM.modify onI  succ (i-1) )
    U.forM_ off (\i -> UM.modify offI succ (i-1) )
    onIF <- U.freeze onI
    offIF <- U.freeze offI
    let difs = U.zipWith (-) (U.tail onIF) offIF
    return $ U.scanl' (+) (U.head onIF) difs

timesM 0 f x = return x
timesM n f x = do
    r <- f x
    timesM (n-1) f r



Measured memory_bytes: 17688
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
//int a[10000];
int main()
{
	long long a,b,c,m,n;
	cin>>a>>b>>c>>m>>n;
	int ans=0;
	if(a+b>=2*c)
	{
		if(m>=n)
		{
			ans+=(n*2*c);
			if(a>=2*c)ans+=((m-n)*2*c);
			else ans+=((m-n)*a);
		}
		else 
		{
			ans+=(m*2*c);
			if(b>=2*c)ans+=((n-m)*2*c);
			else ans+=((n-m)*b);
		}
	}
	else
	{
		if(m>=n)
		{
			ans+=(n*(a+b));
			if(a>=2*c)ans+=((m-n)*2*c);
			else ans+=((m-n)*a);
		}
		else 
		{
			ans+=(m*(a+b));
			if(b>=2*c)ans+=((n-m)*2*c);
			else ans+=((n-m)*b);
		}
    }
    cout<<ans<<endl;
    return 0;
 } 

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

class UnionFind:
    def __init__(self, n):
        self.root = [i for i in range(n + 1)]
        self.size = [1] * (n + 1)
    def find(self, x):
        y = self.root[x]
        if x == y:
            return x
        else:
            z = self.find(y)
            self.root[x] = z
            return z
    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        sx = self.size[rx]
        sy = self.size[ry]
        if rx == ry:
            return 0
        else:
            if sx >= sy:
                self.root[ry] = rx
                self.size[rx] = sx + sy
            else:
                self.root[rx] = ry
                self.size[ry] = sx + sy
        return sx * sy
    def check(self):
        print([self.find(i) for i in range(1, len(self.root))])

MOD = 10 ** 9 + 7
INF = 10 ** 18

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

uf = UnionFind(N)

for a, b in AB:
    uf.union(a, b)

cnt = [0] * (N + 1)
for i in range(1, N + 1):
    cnt[uf.find(i)] += 1
print(max(cnt))

Measured memory_bytes: 117876
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000;
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    ll n, m;
    cin >> n >> m;
    
    vvec G(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
    }
    ll minlen=INF;
    vec ans;
    rep(sv,n){
        vec dist(n,-1);
        dist[sv]=0;
        vec pre(n,-1);

        queue<int> q;
        q.push(sv);
        while(!q.empty()){
            int v=q.front();q.pop();
            for(auto u:G[v]){
                if(dist[u]==-1){
                    dist[u]=dist[v]+1;
                    pre[u]=v;
                    q.push(u);
                }
            }
        }
        rep(gv,n){
            if(sv==gv||dist[gv]==-1){
                continue;
            }
            for(auto u:G[gv]){
                if(u==sv){
                    vec tmp;
                    tmp.pb(sv);
                    ll now=gv;
                    while(now!=sv){
                        tmp.pb(now);
                        now=pre[now];
                    }
                    if(tmp.size()<minlen){
                        minlen=tmp.size();
                        ans=tmp;
                    }
                }
            }
        }
    }

    if(minlen==INF) cout<<-1<<endl;
    else{
        cout<<minlen<<endl;
        rep(i,ans.size()){
            cout<<ans[i]+1<<endl;
        }
    }
    
}

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

struct union_find{
	int N;
	vector<int> parent;
	vector<int> siz;

	union_find(int N) : parent(N), siz(N, 1){
		for (int i = 0; i < N; i++) parent[i] = i;
	}

	int root(int x){
		if(parent[x] == x) return x;
		else return parent[x] = root(parent[x]);
	}

	void merge(int x, int y){
		x = root(x), y = root(y);
		if(x == y) return;
		if(siz[x] < siz[y]) swap(x, y);
		parent[y] = x;
		siz[x] += siz[y];
		siz[y] = 0;
	}

	bool are_same(int x, int y){
		return root(x) == root(y);
	}

	int size(int x){
		return siz[root(x)];
	}
};

signed main(){
	int N, i, j;
	int M = 100000;
	scanf("%lld", &N);
	vector<int> x(N), y(N);
	vector<vector<int>> esx(M, vector<int>(0)), esy(M, vector<int>(0));
	for(i = 0; i < N; i++){
		scanf("%lld%lld", &x[i], &y[i]);
		x[i]--;
		y[i]--;
		esx[x[i]].push_back(y[i]);
		esy[y[i]].push_back(x[i]);
	}
	union_find ufx(M), ufy(M);
	for(i = 0; i < M; i++){
		for(j = 0; j < esx[i].size(); j++){
			ufy.merge(esx[i][0], esx[i][j]);
		}
	}
	for(i = 0; i < M; i++){
		for(j = 0; j < esy[i].size(); j++){
			ufx.merge(esy[i][0], esy[i][j]);
		}
	}
	set<pair<int, int>> st;
	int sum = 0;
	for(i = 0; i < N; i++){
		int rx = ufx.root(x[i]);
		int ry = ufy.root(y[i]);
		if(st.count(pair<int, int>(rx, ry)) == 0){
			sum += ufx.size(rx) * ufy.size(ry);
			st.insert(pair<int, int>(rx, ry));
		}
	}
	printf("%lld\n", sum - N);
	return 0;
}

Measured memory_bytes: 13440
#define _CRT_SECURE_NO_WARNINGS
#define MOD 1000000007
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <cmath>
#include <chrono>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,-1)

inline ll madd(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a + b) % MOD;
}
inline ll msub(ll a, ll b) {
	a %= MOD;b %= MOD;
	a += MOD;
	return (a - b) % MOD;
}
inline ll mmul(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a*b) % MOD;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % MOD;
		a = a * a % MOD;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= MOD;
	ll b = MOD, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= MOD;
	a *= minv(b);
	return a%MOD;
}



struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(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;
		}
		return x != y;
	}
	bool same(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)];
	}
};

/*int V;
vector<edge> G[MAX_V];
int d[MAX_V]:
void dijkstra(int s) {
priority_queue<P, vector<P>, greater<P>> q;
fill(d, d + V, INF);


}*/
#define MAX 200001

long long fac[MAX], finv[MAX], inv[MAX];

// 二項係数計算
long long COM(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(void) {
	int n,a,b;
	cin >> n;
	vector<vector<int>> connected(n+1);
	REP(i, n-1) {
		cin >> a >> b;
		connected[a].push_back(b);
		connected[b].push_back(a);
	}
	vector<int> c(n);
	REP(i, n) cin >> c[i];
	sort(c.begin(), c.end());
	int max_score = 0;
	REP(i, n - 1) max_score += c[i];
	cout << max_score << endl;
	stack<int> stack;
	vector<int> result(n+1);
	vector<bool> visited(n + 1);
	REP(i, n + 1) visited[i] = false;

	stack.push(1);
	int ind = n - 1;
	while (!stack.empty()) {
		int node = stack.top();
		visited[node] = true;
		stack.pop();
		for (int child : connected[node]) {
			if (visited[child]) continue;
			stack.push(child);
		}
		result[node] = c[ind];
		ind--;
	}
	REP(i,n) cout << result[i+1] << " ";
	return 0;
}

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

using namespace std;

int main(void)
{
	int sx, sy, tx, ty;
	vector <pair<int,int>> rec1, rec2;
	string s;
	cin >> sx >> sy >> tx >> ty;


	for (int i = 0; i < (ty - sy); i++)
	{
		s += 'U';
	}
	for (int i = 0; i < (tx + 1 - sx); i++)
	{
		s += 'R';
	}
	for (int i = 0; i < (ty - sy + 1); i++)
	{
		s += 'D';
	}
	for (int i = 0; i < (tx + 1 - sx); i++)
	{
		s += 'L';
	}
	s += 'U';
	for (int i = 0; i < (tx - sx); i++)
	{
		s += 'R';
	}
	for (int i = 0; i < (ty + 1 - sy); i++)
	{
		s += 'U';
	}
	for (int i = 0; i < (tx - sx + 1); i++)
	{
		s += 'L';
	}
	for (int i = 0; i < (ty + 1 - sy); i++)
	{
		s += 'D';
	}
	s += 'R';
	
	cout << s << endl;
	return 0;
}

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

using namespace std;

int N, A[100100][3];
int memo[100100][3];
const int INF = 1e9 + 7;
int dp(int n, int k) {
	if (n < 1) return 0;
	int &ans = memo[n][k];
	if (ans != -1) return ans;
	ans = -INF;
	for (int i = 0; i < 3; i++) {
		if (i == k) continue;
		ans = max(ans, dp(n - 1, i));
	}

	ans += A[n][k];

	return ans;
}
int main() {
	memset(memo, -1, sizeof(memo));
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i][0] >> A[i][1] >> A[i][2];
	}

	cout << max(dp(N, 0), max(dp(N, 1), dp(N, 2))) << endl;
	return 0;
}

Measured memory_bytes: 8832
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

const string YES = "YES";
const string NO = "NO";

int main()
{
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> a(M);
  std::vector<long long> b(M);
  vector<int> cost(N + 1, 0);
  for (int i = 0; i < M; i++)
  {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
    if (min(a[i], b[i]) == 1)
    {
      cost[max(a[i], b[i])]++;
    }
    else
    {
      cost[a[i]]++, cost[b[i]]++;
    }
  }
  bool flag = true;
  for (int i = 0; i <= N; ++i)
    if (cost[i] % 2 == 1)
      flag = false;
  cout << (flag ? YES : NO) << endl;

  return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

struct era{
	string name;
	int from,to;
};

main(){
	vector<era> m;
	int n,q;
	while(cin>>n>>q){
		if(n==0 && q==0)break;
		
		m.clear();
		for(int i=0;i<n;i++){
			string name;
			int from,to;
			cin>>name>>from>>to;
			from=to-from+1;
			era tera=(era){name,from,to};
			//cout<<tera.name<<" "<<tera.from<<" "<<tera.to<<endl;
			m.push_back(tera);
		}
		
		for(int i=0;i<q;i++){
			int que;
			cin>>que;
			int flag=0;
			for(int j=0;j<n;j++){
				if(m[j].from<=que && m[j].to>=que){
					cout<<m[j].name<<" "<<-m[j].from+1+que<<endl;
					flag=1;
					break;
				}
			}
			if(flag==0)puts("Unknown");
		}
	}
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define ll long long
#define INF LONG_LONG_MAX
#define pb push_back
#define mp make_pair
#define MAXN 1000009
#define MOD 1000000007
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
using namespace std;

int main(){
    int n;
    cin>>n;
    cout<<"ABC"<<n;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int n,x;

signed main()
{
    while(cin >> n >> x,!(n==0&&x==0))
    {
        int cnt =0;
        for(int i=1;i<=n-2;i++)
        {
            for(int j=i+1;j<=n-1;j++)
            {
                if(i==j)continue;
                for(int k=j+1;k<=n;k++)
                {
                    if(i==k||j==k)continue;
                    if(i+j+k==x)cnt++;

                }
            }
        }

        cout << cnt << endl;

        cnt =0;
    }
    return 0;
}


Measured memory_bytes: 3096
#include<iostream>

using namespace std;

int main(void) {
	int a;
	int b;
	int c;

	cin >> a >> b >> c;

	if (a < b && b < c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3108
using namespace std;

//#define fileio

#ifndef fileio
#include <iostream>
#endif
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>

typedef long long ll;

#ifdef fileio
ifstream cin;
ofstream cout;
#endif


template< int mod >
struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt& operator+=(const ModInt& p) {
        if ((x += p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt& operator-=(const ModInt& p) {
        if ((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt& operator*=(const ModInt& p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt& operator/=(const ModInt& p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt& p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt& p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt& p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt& p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt& p) const { return x == p.x; }

    bool operator!=(const ModInt& p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream& operator<<(ostream& os, const ModInt& p) {
        return os << p.x;
    }

    friend istream& operator>>(istream& is, ModInt& a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using mint = ModInt< 1000000007 >;


mint power(mint a, int b) {
    if (b == 0) return 1;
    mint y = power(a, b / 2);
    if (b % 2 == 0) return y * y;
    return y * y * a;
}




int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef fileio
    cin.open("Text.txt");
    cout.open("Output.txt");
#endif

    int n;
    cin >> n;

    cout << power(10, n) - power(9, n) - power(9, n) + power(8, n) << endl;

}


Measured memory_bytes: 3636