akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>

using namespace std;

long long get(long long a, int x) {
    int i;
    
    for (i = 0; i < x; i++) a /= 3;
    
    return a;
}

long long get2(long long a, int x) {
    int i;
    
    for (i = 0; i < x; i++) a *= 3;
    
    return a;
}

long long calc(long long a, long long b, long long c, long long d) {
    int i;
    
    for (i = 29; i >= 0; i--) {
        long long pa = get(a, i);
        long long pb = get(b, i);
        long long pc = get(c, i);
        long long pd = get(d, i);
        
        if (pa == pc && pa % 3 == 1 && abs(pb - pd) >= 2) {
            long long x, y;
            
            x = get2(pa, i) - 1;
            y = get2(pa + 1, i);
            
            return min(abs(a - x) + abs(c - x), abs(a - y) + abs(c - y)) + abs(b - d);
        } else if (pb == pd && pb % 3 == 1 && abs(pa - pc) >= 2) {
            long long x, y;
            
            x = get2(pb, i) - 1;
            y = get2(pb + 1, i);
            
            return min(abs(b - x) + abs(d - x), abs(b - y) + abs(d - y)) + abs(a - c);
        }
    }
    
    return abs(a - c) + abs(b - d);
}

int main() {
    int q, i;
    
    scanf("%d", &q);
    
    for (i = 0; i < q; i++) {
        long long a, b, c, d;
        
        scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
        
        printf("%lld\n", calc(a - 1, b - 1, c - 1, d - 1));
    }
    
    return 0;
}


Measured memory_bytes: 256
<?php


$input1 = readline();
$parts = explode(" ", $input1);

$number = $parts[1];


$input2 = readline();

$numbers = explode(" ", $input2);

$diff = 0;

for ($i = 0; $i < count($numbers); $i++)
{
	if ($numbers[$i] + $numbers[$i+1] > $number)
	{
		$diff += $numbers[$i] + $numbers[$i+1]  - $number; 
		$numbers[$i+1] -= $numbers[$i] + $numbers[$i+1]  - $number; 
	}
}

echo $diff . "\n";

Measured memory_bytes: 30400
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=200,M=1e5;
int w,h,tot,ne[M],he[M],t[M],cur[M],cc[M],d[M],cnt[M];
void ad(int x,int y,int z)
{
	tot++;
	ne[tot]=he[x];
	he[x]=tot;
	t[tot]=y;
	cc[tot]=z;
	tot++;
	ne[tot]=he[y];
	he[y]=tot;
	t[tot]=x;
	cc[tot]=0;
}
int sap(int x,int flow)
{
	if (x==w*h+2) return flow;
	int cost=0;
	int i=cur[x];
	while (i)
	{
		if (cc[i]&&d[t[i]]+1==d[x]) 
		{
			int tmp=sap(t[i],min(cc[i],flow-cost));
			cost=cost+tmp;
			cc[i]=cc[i]-tmp;
			cc[i^1]=cc[i^1]+tmp;
			if (cost==flow||d[w*h+1]>w*h+2) return cost;
		}
		i=ne[i];
	}
	cur[x]=he[x];
	if (cnt[d[x]]==1) d[w*h+1]=w*h+3;
	cnt[d[x]]--;
	d[x]++;
	cnt[d[x]]++;
	return cost;
}
int main()
{
	tot++;
	int sx,sy,tx,ty;
	scanf("%d%d",&w,&h);
	char ch=getchar();
	for (int i=1;i<=w;i++) for (int j=1;j<=h+1;j++) 
	{
		char ch=getchar();
		if (ch=='S') 
		{
			sx=i;
			sy=j;
		}
		if (ch=='T')
		{
			tx=i;
			ty=j;
		}
		if (ch=='o')
		{
			ad(i,j+w,1);
			ad(j+w,i,1);
		}
	}
	if (sx==tx||sy==ty) 
	{
		puts("-1");
		return 0;
	}
	ad(w*h+1,sx,100000);
	ad(w*h+1,sy+w,100000);
	ad(tx,w*h+2,100000);
	ad(ty+w,h*w+2,100000);
	cnt[0]=h*w+2;
	int ans=0;
	while (d[w*h+1]<=w*h+2) ans+=sap(w*h+1,100000);
	printf("%d\n",ans);
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#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 (int i = 0; i < (n); ++i)
#define POW_10_5 100000
#define POW_10_9 1000000000
#define MOD 1000000007
#define INF (numeric_limits<int>::max()/2)
#define int long long

typedef pair<int, int> Pair;
typedef unordered_map<int, int> Hash;

// ---
int N;
int x[8], y[8];

int factorial[9];

double Ans() {
  factorial[0] = 1;
  FOR(i, 1, 8) {
    factorial[i] = factorial[i-1] * i;
  }

  double a = 0.0;
  REP(i, N) {
    FOR(j, i+1, N-1) {
      a += hypot(x[i] - x[j], y[i] - y[j]) * factorial[N-1] * 2;
    }
  }

  return a / factorial[N];
}

signed main() {
  cin >> N;
  REP(i, N) { cin >> x[i] >> y[i]; }

  auto ans = Ans();

  printf("%.10lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.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{
		printf("a < b\n");
	}
	return 0;
}


Measured memory_bytes: 2036
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m = sc.nextLong()
  if (n == 1 && m == 1) {
    println(1)
  } else if (n == 1) {
    println(m - 2)
  } else if (m == 1) {
    println(n - 2)
  } else {
    println((n-2) * (m-2))
  }
}


Measured memory_bytes: 55232
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define st first
#define nd second

using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set =
	tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
#define shandom_ruffle random_shuffle
 
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;

const int kMaxN = 512;

int n;
int dist[kMaxN][kMaxN];
bool occupied[kMaxN][kMaxN];

int dr[4] = {-1, 0, 1, 0};
int dc[4] = {0, -1, 0, 1};

void Recompute(int sr, int sc) {
	queue<pii> q;
	q.push({sr, sc});

	while (!q.empty()) {
		auto [r, c] = q.front();
		q.pop();
		for (int i = 0; i < 4; ++i) {
			int nr = r + dr[i];
			int nc = c + dc[i];
			if (nr < 0 || nc < 0 || nr >= n || nc >= n) { continue; }
			int cand = dist[r][c] + occupied[r][c];
			if (dist[nr][nc] > cand) {
				debug() << imie(nr) << imie(nc) << imie(dist[nr][nc]) << imie(r) << imie(c);
				dist[nr][nc] = cand;
				q.push({nr, nc});
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(11);
	cerr << fixed << setprecision(6);

	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			dist[i][j] = min({i, j, n-i-1, n-j-1});
			occupied[i][j] = true;
		}
	}

	ll ans = 0;

	for (int i = 0; i < n * n; ++i) {
		int who;
		cin >> who;
		--who;
		int row = who / n;
		int col = who % n;
		ans += dist[row][col];
		occupied[row][col] = false;
		Recompute(row, col);
	}

	cout << ans << "\n";
}


Measured memory_bytes: 4912
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

bool is_palindrome(string s) {
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

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

    string S;
    cin >> S;
    bool yes = is_palindrome(S);
    yes &= is_palindrome(S.substr(0, S.size() / 2));
    yes &= is_palindrome(S.substr(S.size() / 2 + 1, S.size() / 2));
    cout << (yes ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <stack>
#include <map>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long> da(n);
    for(int i=0;i<n;i++){
        cin >> da[i];
    }
    vector<vector<long long>> dp(n,vector<long long> (n,0));
    for(int i=0;i<n;i++){
        dp[i][i]=da[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n-i-1;j++){
            dp[j][i+j+1]=max(da[j]-dp[j+1][i+j+1],da[i+j+1]-dp[j][i+j]);
        }
    }
    cout << dp[0][n-1] << endl;
}


Measured memory_bytes: 70784
#include <iostream>
#include <cmath>

using namespace std;

int count_div(int num) {
	int res = 0;
	while (num%100 == 0) {
		++res;
		num /= 100;
	}
	return res;
}

int main(void) {
	int D,N;
	cin >> D >> N;
	int count = 0;
	bool find = false;
	for (int i = 1; !find; ++i) {
		if (count_div(i) == D) {
			++count;
			if (count == N) {
				cout << i << endl;
				find = true;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main()
{
	int n, k,ans;
	int d[10];
	cin >> n >> k;
	int i,j,flag;
	for (i = 0; i < k; i++){
		cin >> d[i];
	};
	for (i = 0; i < 10 * n; i++){
		ans = n + i;
		flag = 0;
		if (ans <= 9){
			for (j = 0; j < k; j++){
				if (ans == d[j]){
					flag = 1;
					break;
				};
			};
			if (flag == 0){
				break;
			};
		}
		else if (ans <= 99){
			for (j = 0; j < k; j++){
				if (ans%10 == d[j]||ans/10==d[j]){
					flag = 1;
					break;
				};
			};
			if (flag == 0){
				break;
			};
		}
		else if (ans <= 999){
			for (j = 0; j < k; j++){
				if (ans%10 == d[j]||(ans%100)/10==d[j]||ans/100==d[j]){
					flag = 1;
					break;
				};
			};
			if (flag == 0){
				break;
			};
		}
		else if (ans <= 9999){
			for (j = 0; j < k; j++){
				if (ans % 10 == d[j] || (ans % 100) / 10 == d[j] || (ans % 1000) / 100 == d[j] || ans / 1000 == d[j]){
					flag = 1;
					break;
				};
			};
			if (flag == 0){
				break;
			};
		}
		else if (ans <= 99999){
			for (j = 0; j < k; j++){
				if (ans % 10 == d[j] || (ans % 100) / 10 == d[j] || (ans % 1000) / 100 == d[j] || (ans % 10000) / 1000 == d[j] || ans / 10000 == d[j]){
					flag = 1;
					break;
				};
			};
			if (flag == 0){
				break;
			};
		};
	};
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
N = int(input())
if 400 <= N and N <= 599:
    print(8)
elif 600 <= N and N <= 799:
    print(7)
elif 800 <= N and N <= 999:
    print(6)
elif 1000 <= N and N <= 1199:
    print(5)
elif 1200 <= N and N <= 1399:
    print(4)
elif 1400 <= N and N <= 1599:
    print(3)
elif 1600 <= N and N <= 1799:
    print(2)
elif 1800 <= N and N <= 1999:
    print(1)

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

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<double> VD;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};
#define PI 3.141592653589793238

ll N, A, B;
VL h;

bool check(ll k) {
    VL tmp = h;
    REP(i, N) tmp[i] -= B * k;
    ll cnt = 0;
    REP(i, N) {
        if(tmp[i] > 0) {
            cnt += (tmp[i] + (A - B - 1)) / (A - B);
        }
    }
    return cnt <= k;
}

signed main() {
    cin >> N >> A >> B;
    ll lb = 0, ub = INF;
    h.resize(N);
    REP(i, N) cin >> h[i];
    while(ub - lb > 1) {
        ll mid = (ub + lb) / 2;
        if(check(mid))
            ub = mid;
        else
            lb = mid;
    }
    cout << ub << "\n";
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//printf("%d", n);
//printf("%d", sum);
//scanf("%d", &n);
//scanf("%c", &c);
//scanf("%lf", &d);

#define NUM (10000)

int main(int argc, char** argv){
    int N, K;
    vector<ll> H;
    scanf("%d", &N);
    scanf("%d", &K);

    rep(i, N){
        ll t;
        scanf("%lld", &t);
        H.push_back(t);
    }

    if(N <= K){
        printf("0\n");
        return 0;
    }

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

    rep(j, K){
        H.pop_back();
    }

    ll sum = 0;
    auto it = H.begin();
    auto end = H.end();
    while(it != end){
        sum += *it;
        it++;
    }

    printf("%lld\n", sum);

    return 0;
}





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

int main()
{
    int n;
    int ans = 0;
    cin >> n;
    int a[100001] = {0};
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        a[x]++;
    }
    for(int i = 2; i < 100001; i++){
        ans = max(ans,a[i-2]+a[i-1]+a[i]);
    }
    cout << ans;
}

Measured memory_bytes: 640
n,k = gets.split.map(&:to_i)
hs = readlines.map(&:to_i)
hs.sort!

mindiff = 10**9

0.upto(n-1) do |i|
  next unless hs[i+k-1]
  d = hs[i+k-1] - hs[i]
  mindiff = d if d < mindiff
end

puts mindiff

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

using namespace std;

int main() {
    //forItachi
    int n;
    int arr[200002];
    cin>>n;
    int i;
    for(i=0;i<n;i++){
        int x;
        cin>>x;
        arr[i] = x;
    }
    int min,count = 0;
    for(i=0;i<n;i++){
        if(i==0){
            min = arr[i];
            count++;
        }
        else{
            if(arr[i]<=min){
                count++;
                min = arr[i];
            }
        }
        
    }
    cout<<count<<endl;
    
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a,b,c;
int main(){
	scanf("%lld%lld%lld",&a,&b,&c);
    printf("%lld",a+b+c-max(a,max(b,c)));
}

Measured memory_bytes: 128
a, b, c, d = map(int, input().split())
aoki = c
taka = a
for i in range(max((c // b)+1, (a // d)+1)):
    aoki -= b
    taka -= d
    if aoki <= 0:
        print("Yes")
        break
    elif taka <=0:
        print("No")
        break

Measured memory_bytes: 9184
#include<cstdio>
#include<cstring>


int main(){
    char str[1001];

    while(1){
       scanf("%s", str);
       if(str[0]=='0') break;
       int Sum=0;
       for(int i=0;i<strlen(str);i++){
          Sum+=(str[i]-'0');
    }
    printf("%d\n",Sum);
}
return 0;
}


Measured memory_bytes: 2668
#include <stdio.h>

int digit(int nb)
{
 int sum = 0;
 while (1)
 {
  sum += nb % 10;
  if (nb < 10)
   break;
  nb /= 10;
 }
 return (sum);
}

int main(void)
{
 int N ,a, b;
 scanf("%d%d%d",&N,&a,&b);
 int i = 1, sum = 0;
 while (i <= N)
 {
  if (digit(i) >= a && digit(i) <= b)
      sum += i;
  i++;
 }
 printf("%d\n", sum);
 return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    for (int i = n; i <= 999 ; i++)
    {
        int a = i/100;
        int b = i/10 - a*10;
        int c = i%10;
        if (a == b && b == c)
        {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]


res=[0]*N        
for x in range(0,N):
    for y in range(x,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        r=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        res[r]=res[r]+1
        if(x>y):
            res[r]=res[r]-1


for i in range(1,N):
    print(res[i])


Measured memory_bytes: 3444
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_C&lang=jp
// Recursion / Divide and Conquer - Koch Curve

#define SUBMIT

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <limits>
#include <numeric>
#include <set>
#include <cmath>

using namespace std;
using i64 = long long;

class point {
public:
    point(double x, double y) : x_(x), y_(y) {}

    double x() const noexcept { return x_; }

    double y() const noexcept { return y_; }

private:
    double x_;
    double y_;
};

void koch(const point &p1, const point &p2, int n) {
    if (n == 0) return;

    // 1:2に内分する点s
    point s((2 * p1.x() + 1 * p2.x()) / 3, (2 * p1.y() + 1 * p2.y()) / 3);
    // 2:1に内分する点t
    point t((1 * p1.x() + 2 * p2.x()) / 3, (1 * p1.y() + 2 * p2.y()) / 3);

    point r(t.x() - s.x(), t.y() - s.y());

    auto sixty_rad = M_PI * 60.0 / 180.0;
    auto cos60 = cos(sixty_rad);
    auto sin60 = sin(sixty_rad);

    point u(s.x() + r.x() * cos60 - r.y() * sin60,
            s.y() + r.x() * sin60 + r.y() * cos60);

    koch(p1, s, n - 1);
    cout << s.x() << " " << s.y() << endl;
    koch(s, u, n - 1);
    cout << u.x() << " " << u.y() << endl;
    koch(u, t, n - 1);
    cout << t.x() << " " << t.y() << endl;
    koch(t, p2, n - 1);
}

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

    // koch
    point p1(0.0, 0.0);
    point p2(100.0, 0.0);
    cout << fixed << setprecision(8);
    cout << p1.x() << " " << p1.y() << endl;
    koch(p1, p2, n);
    cout << p2.x() << " " << p2.y() << endl;

    return 0;
}


Measured memory_bytes: 3232
/* AUTHOR: Naman */
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define IOS     ios_base::sync_with_stdio(0); cin.tie(NULL);
const ll N=2*1e6+1;
// whose product are less than N 
int countOrderedPairs(int N) 
{ 
	// Initialize count to 0 
	int count_pairs = 0; 

	// count total pairs 
	for (int i = 1; i <= sqrt(N - 1); ++i) { 
		for (int j = i; j * i < N; ++j) 
			++count_pairs; 
	} 

	// multiply by 2 to get ordered_pairs 
	count_pairs *= 2; 

	// subtract redundant pairs (a, b) where a==b. 
	count_pairs -= int(sqrt(N - 1)); 

	// return answer 
	return count_pairs; 
} 

int main() {
	IOS
    ll t=1;
	//cin>>t;	
	
	for(ll _=1;_<=t;_++)
	{
	   //cout<<"Case #"<<_<<": ";
	    ll i,n;	
	    ll ct=0;
	    cin>>n;
	    
	    cout<<countOrderedPairs(n);
	    
	   
	   
	   


	   cout<<endl;
	   
	}
	
    
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  int score = 0;
  REP(i, N){
    if(S[i] == 'L'){
      if(i == 0) continue;
      if(S[i] == S[i-1]){
        score++;
      }
    }
    else if(S[i] == 'R'){
      if(i == N-1) continue;
      if(S[i] == S[i+1]){
        score++;
      }
    }
  }
  cout << min(score+2*K, N-1) << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	ins(a,b);
	ini(c,d);
	ins(x);
	if(a == x){out(c-1,d);}
	else{out(c,d-1);}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a;
	cin>>a;
	V<char> b(a);
	fo(i,a)
	cin>>b[i];
	int c=0;
	fo(i,a){
		if(b[i]=='Y')
			c=1;
	}
	if(c)
		cout<<"Four"<<endl;
	else
		cout<<"Three"<<endl;
}

Measured memory_bytes: 256
int_list = []

P, Q, R = list(map(int, input().split()))

a0 = P + Q
int_list.append(a0)
a1 = Q + R
int_list.append(a1)
a2 = P + R
int_list.append(a2)
a3 = Q + R
int_list.append(a3)
a4 = R + P
int_list.append(a4)
a5 = P + Q
int_list.append(a4)

print(min(int_list))


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnLngs();
        var A = _[0]; var B = _[1]; var C = _[2]; var K = _[3];
        if (A >= K)
        {
            print(K);
        }
        else if (A + B >= K)
        {
            print(A);
        }
        else
        {
            var min = K - A - B;
            print(A - min);
        }
    }

    public static long SumAtoB(long a, long b) { var length = b - a + 1; return (a + b) * (length / 2) + (length % 2 == 1 ? (a + b) / 2 : 0); }
    public static long PowLite(long n, long p, int mod = (int)1e9 + 7) { long ans = 1; long now = n; for (; p > 0; p >>= 1) { if ((p & 1) == 1) { ans *= now; ans %= mod; } now *= now; now %= mod; } return ans; }
    public static void print(object obj) { Console.WriteLine(obj); }
    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
    public static List<T[]> AllPermutation<T>(params T[] array) where T : IComparable { var a = new List<T>(array).ToArray(); var res = new List<T[]>(); res.Add(new List<T>(a).ToArray()); var n = a.Length; var next = true; while (next) { next = false; int i; for (i = n - 2; i >= 0; i--) { if (a[i].CompareTo(a[i + 1]) < 0) break; } if (i < 0) break; var j = n; do { j--; } while (a[i].CompareTo(a[j]) > 0); if (a[i].CompareTo(a[j]) < 0) { var tmp = a[i]; a[i] = a[j]; a[j] = tmp; Array.Reverse(a, i + 1, n - i - 1); res.Add(new List<T>(a).ToArray()); next = true; } } return res; }
}


Measured memory_bytes: 27492
#include<stdio.h>
int main(void){
	int ans,kane,i,otu;

	while(1){
		scanf("%d",&kane);
		if(!kane) break;
		otu=1000-kane;
		ans=0;

		for(i=0;;i++){
			if((otu-500)>=0){
				otu-=500;
				ans+=1;
			}else if((otu-100)>=0){
				otu-=100;
				ans+=1;
			}else if((otu-50)>=0){
				otu-=50;
				ans+=1;
			}else if((otu-10)>=0){
				otu-=10;
				ans+=1;
			}else if((otu-5)>=0){
				otu-=5;
				ans+=1;
			}else if((otu-1)>=0){
				otu-=1;
				ans+=1;
			}else break;
		}

		printf("%d\n",ans);
	}
	return 0;
}

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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    while(cin >> a >> b){
        if((a^b)&1){
            cout<<"IMPOSSIBLE"<<endl;
        }
        else{
            cout<<(a+b)/2<<endl;
        }
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int fa[101010],A[101010],n,m;
int fin(int x){
	if (fa[x]==x) return x;
	fa[x]=fin(fa[x]);
	return fa[x];
}
void Merge(int x,int y){
	int f1=fin(x),f2=fin(y);
	if (f1==f2) return;
	
	fa[f1]=f2;
}
int main(){
	scanf("%d %d",&n,&m);
	int i,x,y,ans=0;
	for (i=1;i<=n;i++) scanf("%d",&A[i]),fa[i]=i;
	for (i=1;i<=m;i++){
		scanf("%d %d",&x,&y);
		Merge(x,y);
	}
	for (i=1;i<=n;i++)
		if (fin(A[i])==fin(i)) ans++;
	cout<<ans;
}

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

using namespace std;

int n,q;
string s;
int BIT[27][500001];

void update(int x,int y,int val)
{
	for(;x<=500000;x+=x&(-x))
		BIT[y][x] += val;
}

int query(int x,int y)
{
	int ans = 0;
	for(;x>0;x-=x&(-x))
		ans += BIT[y][x];
	return ans;
}

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

	cin >> n >> s >> q;
	s = '*' + s;
	for (int i=1;i<=n;i++)
		update(i,s[i] - 'a' + 1,1);
	while(q--)
	{
		int type;
		cin >> type;
		if (type == 1)
		{
			int pos; char c;
			cin >> pos >> c;
			update(pos,s[pos] - 'a' + 1,-1);
			update(pos,c - 'a' + 1,1);
			s[pos] = c;
		}
		else
		{
			int l,r;
			cin >> l >> r;
			int cnt = 0;
			for (int i=1;i<=26;i++)
				if (query(r,i) - query(l-1,i))
					cnt++;
			cout << cnt << '\n';						
		}
	}
}

Measured memory_bytes: 51760
N, K = map(int, input().split())
*A, = map(int, input().split())
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
g = A[0]
for i in range(1, N):
    g = gcd(g, A[i])

print('POSSIBLE' if K <= max(A) and K % g == 0 else 'IMPOSSIBLE')

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

// D
// =
// 25
//  なら Christmas, 
// D
// =
// 24
//  なら Christmas Eve, 
// D
// =
// 23
//  なら Christmas Eve Eve, 
// D
// =
// 22
//  なら Christmas Eve Eve Eve と出力するプログラムを作ってください。

signed main() {
  int D;
  cin >> D;
  if (D == 25) {
    puts("Christmas");
  }
  if (D == 24) {
    puts("Christmas Eve");
  }
  if (D == 23) {
    puts("Christmas Eve Eve");
  }
  if (D == 22) {
    puts("Christmas Eve Eve Eve");
  }

  return 0;
}

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

typedef long long ll;
const ll MOD = 1e9+7;

ll f(ll x){
    if(x<0)return 0LL;
    if(x%4==1)return 1;
    if(x%4==2)return x+1;
    if(x%4==3)return 0;
    return x;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll a,b;
    cin>>a>>b;

    cout<<(f(b)^f(a-1));

    return 0;
}


Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
X=int(input())


ans=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k == X:
                ans+=1

print(ans)


Measured memory_bytes: 3060
#include <iostream>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << #x << " = " << (x) << endl;

using namespace std;

int main(){
	int n, a[100005], ok, ng, q, k[200005], mid;
	cin >> n;
	REP(i,n){
		scanf("%d", &a[i]);
	}
	cin >> q;
	REP(i,q){
		scanf("%d", &k[i]);
	}
	
	
	REP(i,q) {
		bool found = false;
		ok = 0;
		ng = n;
		while (abs(ng - ok) > 1) {
			mid = (ng + ok) / 2;
//			printf("[%d, %d) mid = %d\n", ok, ng, mid);
			bool is_ok = false;
			
			// ここに書く
			if (a[mid]<=k[i]){
				is_ok = true;
			}else{
				is_ok = false;
			}
			
			if (is_ok) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		cout << (a[ok]==k[i]) << endl;
	}
	
	
	return 0;
}



Measured memory_bytes: 4384
def prime(n):
    for i in range(2,n):
        if n%i == 0:
            return False
    return True

def main():
    n = int(input())

    f = 1
    for i in range(1,n+1):
        f *= i

    p = []
    for i in range(2,n):
        if prime(i):
            p.append(i)
    P = len(p)

    ans = set()
    for i in range(P):
        x = p[i]**74
        if f%x == 0:
            ans.add(x)

        for j in range(P):
            if i == j:
                continue

            x = p[i]**24 * p[j]**2
            if f%x == 0:
                ans.add(x)

            x = p[i]**14 * p[j]**4
            if f%x == 0:
                ans.add(x)

            for k in range(P):
                if i == k or j == k:
                    continue

                x = p[i]**4 * p[j]**4 * p[k]**2
                if f%x == 0:
                    ans.add(x)

    print(len(ans))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
// #define ll long long
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {

  double w, h, x, y;
  cin >> w >> h >> x >> y;

  if ((w/2) == x && (h/2) == y){
    cout << w*h/2.0 << " " << 1 << endl;
  }else{
    cout << w*h/2.0 << " " << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 888
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=53};

struct Edge{ int nxt,to,id; } bow[N*2];
int head[N],tot_e;
il void add(int x,int y,int z){
	tot_e++;
	bow[tot_e<<1]=(Edge){head[x],y,z};
	bow[tot_e<<1|1]=(Edge){head[y],x,z};
	head[y]=(head[x]=tot_e<<1)|1;
}

int num[N];
int t,cur;
bool ok;
void dfs(int u,int fa){
	if( u==t ){ ok=1; return; }
	each(i,u){
		int v = bow[i].to;
		if( v==fa ) continue;
		dfs(v,u);
		if( ok ){
			num[bow[i].id] |= 1<<cur;
			return;
		}
	}
}

ll f[N][1<<20];

int main(){
	int n=ci();
	rep(i,1,n-1){
		int x=ci(), y=ci();
		add(x,y,i);
	}
	int m=ci();
	rep(i,0,m-1){
		cur = i;
		ok = 0;
		int x=ci(), y=ci();
		t=y;
		dfs(x,0);
	}
	int full = (1<<m)-1;
	f[0][0] = 1;
	rep(i,1,n-1){
		rep(S,0,full){
			f[i][S] += f[i-1][S];
			f[i][S|num[i]] += f[i-1][S];
		}
	}
	printf("%lld\n",f[n-1][full]);
	return 0;
}


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

int main(){
  int H, W, N;cin>>H>>W>>N;
  int r, c;cin>>r>>c;
  string S, T;cin>>S>>T;

  int left=0, right=W+1;
  int upper=0, lower=H+1;
  bool ans=true;

  if(S[N-1]=='L') left++;
  if(S[N-1]=='R') right--;
  if(S[N-1]=='U') upper++;
  if(S[N-1]=='D') lower--;

  for (int i=N-2;i>=0;--i){
    if(T[i]=='R') left=max(0, left-1);
    if(T[i]=='L') right=min(W+1, right+1);
    if(T[i]=='D') upper=max(0, upper-1);
    if(T[i]=='U') lower=min(H+1, lower+1);

    if(S[i]=='L') left++;
    if(S[i]=='R') right--;
    if(S[i]=='U') upper++;
    if(S[i]=='D') lower--;

    if(left+1>=right) ans=false;
    if(upper+1>=lower) ans=false; 
  }

  if(left>=c||right<=c|| upper>=r|| lower<=r) ans=false;

  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;
 
int n, a[300005];
lint l[300005], r[300005];
 
int main(){
	scanf("%d",&n);
	for(int i=1; i<=3*n; i++) scanf("%d",&a[i]);
	priority_queue<int, vector<int>, greater<int> > pq;
	priority_queue<int> pq2;
	lint sum = 0;
	for(int i=1; i<=3*n; i++){
		sum += a[i];
		pq.push(a[i]);
		while(pq.size() > n){
			sum -= pq.top();
			pq.pop();
		}
		l[i] = sum;
	}
	sum = 0;
	for(int i=3*n; i; i--){
		sum += a[i];
		pq2.push(a[i]);
		while(pq2.size() > n){
			sum -= pq2.top();
			pq2.pop();
		}
		r[i] = sum;
	}
	lint ret = -1e18;
	for(int i=n; i<=2*n; i++){
		ret = max(ret, l[i] - r[i+1]);
	}
	cout << ret << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int k; 
	string s, ans = "";
	cin >> k >> s;
	if (s.size() <= k) cout << s << "\n";
	else {
		for (int i = 0; i < k; i++) {
			ans += s[i];
		}
		cout << ans.append("...") << "\n";
	}
	return 0;
}


Measured memory_bytes: 3632
N = int(input())
ST = [[0,0,1] for _ in range(N)]
for i in range(N-1):
  ST[i] = list(map(int, input().split()))

for i in range(N):
  ans = 0
  for j in range(i,N):
    if ans < ST[j][1]:
      ans = ST[j][1] + ST[j][0]
    else:
      ans = ((ans - ST[j][1] + ST[j][2] -1)//ST[j][2])*ST[j][2] + ST[j][1] + ST[j][0]
  print(ans)

Measured memory_bytes: 43244
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
  string s;
  string c, p = "";
  int ans = 0;
  
  cin >> s;
  for(int i  = 0; i < s.size(); i++){
    c += s.at(i);
    if(c == p){
      continue;
    }
    else{
      p = c;
      c = "";
      ans++;
    }
  }
  cout << ans << endl;
  
}

      
      

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

int main()
{
	unsigned long long N, M;
	cin >> N >> M;

	auto sum = 0ull;
	vector<unsigned long long> rem(N);
	for (auto i = 0ull; i < N; ++i)
	{
		unsigned long long A;
		cin >> A;
		sum += A;
		rem[i] = sum % M;
	}

	sort(rem.begin(), rem.end());
	auto left = 0ull;
	auto result = 0ull;
	for (auto i = 0ull; i < N;)
	{
		while (i < N && rem[left] == rem[i])
		{
			++i;
		}

		auto num = i - left;
		if (rem[left] == 0)
		{
			result += num;
		}
		result += num * (num - 1) / 2;

		left = i;
	}

	cout << result << endl;

	return 0;
}


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

ll g1(ll n, int p) {
  if (n == 0) return 0;
  return n/p + g1(n/p, p);
}

ll g2(ll n, int p) {
  if (n % 2 == 1) {
    return g1(n, p) - g2(n-1, p);
  }

  ll res = g1(n/2, p);
  if (p == 2) res += n/2;
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll ans = min(g2(n, 2), g2(n, 5));
  cout << ans << endl;
  return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};



signed main()
{   
    gearup;
    ll n,k; cin >> n >>k;
    map<ll,ll> mp;
    rep(i,k){
        ll d; cin >> d;
        rep(j,d){
            ll a;cin >> a;a--;
            mp[a]++;
        }
    }
    ll res = 0;
    rep(i,n){
        if(mp[i] == 0)res++;
    }
    out(res);
}


Measured memory_bytes: 3660
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>

#define rep(i, s, n) for (int i = s; i < (int)(n); i++)
using namespace std;
// using ll = long long int;

void inv(vector<int>& v) {
    int length = v.size();
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}
void inv(vector<int>& v, int length) {
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}

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

    int smax = 0;
    int slength = (int)s.size();
    rep(i, 0, slength) {
        int index = i;
        int cnt = 0;
        while (index < slength) {
            if (s[index] == 'A' || s[index] == 'C' || s[index] == 'G' ||
                s[index] == 'T') {
                index++;
                smax = max(smax, ++cnt);
            } else {
                break;
            }
        }
    }
    cout << smax << endl;
    return 0;
}


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

int main(){
  long long N,K;
  cin >> N >> K;
  vector<long long> x(N),y(N),X(N),Y(N);
  for(int i=0;i<N;i++){cin >> x[i] >> y[i]; X[i]=x[i]; Y[i]=y[i];}
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  long long ans=4000000000000000000;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=0;k<N;k++){
        for(int l=k+1;l<N;l++){
          long long cnt=0;
          for(int m=0;m<N;m++){
            if(x[i]<=X[m] && X[m]<=x[j] && y[k]<=Y[m] && Y[m]<=y[l]){cnt++;}
          }
          if(cnt>=K){ans=min(ans,(x[j]-x[i])*(y[l]-y[k]));}
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>


int n, s;
long long dp[11][1001];


int main(){
    for(int i = 0; i < 11; i++){ std::fill(dp[i], dp[i] + 1001, 0); }
    dp[0][0] = 1;

    for(int i = 0; i <= 100; i++){
        for(int j = 9; j >= 0; j--){
            for(int k = 0; k + i <= 1000; k++){
                if(!dp[j][k]) continue;

                dp[j + 1][k + i] += dp[j][k];
            }
        }
    }

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

        printf("%lld\n", dp[n][s]);
    }

    return 0;
}

Measured memory_bytes: 2796
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <limits.h>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    
    int a,b,c;
    
    cin >> a;
    cin >> b;
    cin >> c;
    
    cout << (( a <= c && b >= c ) ? "Yes" : "No") << endl;
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256