akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=1e9+7;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;
    //resize is very useful!
    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);//diff means dist from prev parent
            diff_weight[x] += diff_weight[par[x]];// diff means dist from pres parent
            return par[x] = r;
        }
    }

    Abel weight(int x) {//distant from root[x] required
        root(x);//x and root[x] are connected
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);//x and y to root[x]and root[y] are connected
    }

    bool merge(int x, int y, Abel w) {//w means distant between x and y
        w += weight(x);//w means distant berween root x and y
        w -= weight(y);//w means distant between root x and root y
        x = root(x); y = root(y);//x->root[x],y->root[y]
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);//if diff x means dist from prev parent, no problem!
    }
//diff type are templated    
};

int main(){
    int n,m;
    cin>>n>>m;
    UnionFind<int> uf(n);

    rep(i,m){
        int l,r,d;
        cin>>l>>r>>d;
        --l,--r;
        if(uf.issame(l,r)){
            if(abs(uf.diff(l,r))!=d){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else uf.merge(l,r,d);
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif
vector<vector<P>> graph;
vector<bool> ans;

void dfs(ll u, ll pre, ll len) {
    ans[u] = len % 2 == 0;
    for (P p: graph[u]) {
        ll v = p.first;
        ll w = p.second;
        if (v == pre) continue;
        dfs(v, u, len + w);
    }
}

void solve() {
    ll N;
    cin >> N;
    ans.resize(N, false);
    graph.resize(N);
    rep(i, N - 1) {
        ll u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        graph[u].push_back(make_pair(v, w));
        graph[v].push_back(make_pair(u, w));
    }
    dfs(0, -1, 0);
    rep(i, N) {
        cout << (ans[i] ? 0 : 1) << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 9344
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}

struct Sieve {
    Sieve(int n) : l(n + 1, 0) {
        for (int i = 2; i <= n; i++) {
            if (!l[i]) p.push_back(l[i] = i);
            for (int q : p) {
                if (int j = i * q; j <= n && q <= l[i]) l[j] = q; else break;
            }
        }
    }
    bool is_prime(int i) {
        return l[i] == i;
    }
    vector<int> l, p;
};

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

    vector<int> a(k + 1);
    for (int i = 1; i <= k; i++) {
        a[i] = powmod(k / i, n);
    }

    Sieve si(k);
    for (int p : si.p) {
        for (int i = 1; i * p <= k; i++) {
            a[i] -= a[i * p];
            if (a[i] < 0) a[i] += P;
        }
    }

    ll r = 0;
    for (int i = 1; i <= k; i++) {
        r += (ll)a[i] * i % P;
    }
    r %= P;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 4252
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

template<typename T>
vector <T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

unordered_map<int, unordered_map<string, int>> memo;
int N;
int mod = 1e9 + 7;

bool ok(string str) {
    if (str.find("AGC") != string::npos) return false;
    if (str.find("ACG") != string::npos) return false;
    if (str.find("GAC") != string::npos) return false;
    if (str[0] == 'A' && str[2] == 'G' && str[3] == 'C') return false;
    if (str[0] == 'A' && str[1] == 'G' && str[3] == 'C') return false;

    return true;
}

int dfs(int pos, string cur) {
    if (memo.count(pos) && memo[pos].count(cur)) return memo[pos][cur];
    if (pos == N) return 1;

    string sub = cur.substr(1, 3);
    char cand[] = {'A', 'G', 'C', 'T'};
    int res = 0;
    REP(i, 4) {
        if (ok(sub + cand[i])) {
            res += dfs(pos + 1, sub + cand[i]);
            res %= mod;
        }
    }

    return memo[pos][cur] = res;
}

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

    cin >> N;
    cout << dfs(0, "TTTT") << endl;

    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    VI a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end());
    double ans = 0;
    ans =(a.at(0) + a.at(1)) / 2.0;
    if(n > 2){
        for(int i = 2; i < n; i++){
            ans = (ans + a.at(i)) / 2.0;
        }  
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
def gcd(a, b):
    if a<b: a, b = b, a
    while a%b:
        a, b = b, a%b
    return b

def main():
    a, b, c, d = map(int, input().split())
    ans = b - a + 1
    if a%c: ans -= b//c-a//c
    else: ans -= b//c+1-a//c

    if a%d: ans -= b//d-a//d
    else: ans -= b//d+1-a//d

    sks = (c*d) // gcd(c, d)
    if a%sks: ans += b//sks-a//sks
    else: ans += b//sks+1-a//sks
    print(ans)

if __name__=="__main__": main()


Measured memory_bytes: 3064
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

number_dict = {}
for h in range(H):
    for w in range(W):
        number_dict[A[h][w]] = (w+1, h+1)
        
        
number = [0 for _ in range(H*W+1)]
for i in range(H*W):
    now = H * W - i
    
    if now + D > H * W:
        pass
    
    else:
        number[now] = number[now + D] + abs(number_dict[now+D][0] - number_dict[now][0]) + abs(number_dict[now+D][1] - number_dict[now][1])
       

for i in range(Q):
    res = number[LR[i][0]] - number[LR[i][1]]
            
    print(res)
        



Measured memory_bytes: 48176
#include <iostream>
using namespace std;
int main(){

	int i,m,f,r;
	char x;


	for(i=0;i<50;i++)
	{
		cin>>m>>f>>r;
		if(m==-1 && f==-1 && r==-1)break;

		if(m==-1 || f==-1 ||m+f<30){
			x='F';
		}
		else if(m+f>=80)x='A';
		else if(m+f>=65 && m+f<80)x='B';
		else if(m+f>=50 && m+f<65 || r>=50)x='C';
		else if(m+f>=30 && m+f<50)x='D';
		
		cout<<x<<endl;
		
	}
	return 0;
}





Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int n;
   cin >> n;
   int y = 0;
   int c = 0;
  
  for (int i = 0; i < n; i++) {
   int a,b;
   cin >> a >> b;
   c = b-a+1;
   y = y + c;
}
  cout << y << endl;
  
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string S;
	cin >> S;
	const int L = S.length();

	int ans = 0;
	for (int i = 0; i < L / 2; ++i) {
		if (S[i] != S[L - 1 - i]) {
			++ans;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>


using namespace std;
#define MAX 100000

int main(){
    int a, b;

    scanf("%d%d", &a, &b);

    if (15 == a + b){
        printf("+");
    }
    else if (15 == a * b){
        printf("*");
    }
    else {
        printf("x");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
vector<int> lj[yuzu|10];
typedef int fuko[yuzu|10];
fuko d1,d2;
int n=read();

void dfs(int u,int fa,int *d){
d[u]=d[fa]+1;
for (int i:lj[u]) if (i^fa) dfs(i,u,d);
}

int main(){
int i,u,v;
for (i=1;i<n;++i){
  u=read(),v=read();
  lj[u].push_back(v);
  lj[v].push_back(u);
  }
dfs(1,0,d1),dfs(n,0,d2);
int cnt=0;
for (i=1;i<=n;++i) cnt+=d1[i]<=d2[i];
puts(cnt*2<=n?"Snuke":"Fennec");
}

Measured memory_bytes: 11136
#include <stdio.h>
#define True 1
#define False 0

int main(){
    int a, b, result;
    char op;
    while (True){
        scanf("%d %c %d", &a, &op, &b);
        if (op == '?'){
            break;
        }
        if (op == '+'){
            result = a + b;
        }
        else if (op == '-'){
            result = a - b;
        }
        else if (op == '*'){
            result = a * b;
        }
        else if (op == '/'){
            result = a / b;
        }
        printf("%d\n", result);
    }
    return 0;
    
}


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

typedef long long ll;
typedef vector<long long> vecll;
typedef vector<string> vecstr;

#define rep0(i, n) for(ll i=0; i<(ll)(n); i++)
#define rep1(i, n) for(ll i=1; i<=(ll)(n); i++)
#define rep(i, a, b) for(ll i=(ll)a; i<=(ll)(b); i++)
#define rep0r(i, n) for(ll i=(ll)(n)-1; i>=0; i--)
#define rep1r(i, n) for(ll i=(ll)(n); i>0; i--)
#define repr(i, a, b) for(ll i=(ll)b; i>=(ll)(a); i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a * b / __gcd(a, b)
#define len(x) x.size()
#define Sort(x) sort(x.begin(), x.end())
#define rSort(x) sort(x.begin(), x.end(), greater<ll>())

const ll mod_const = 1000000007;

ll modpow(ll a, ll n, ll m) {
    ll result = 1;
    while(n > 0) {
        if(n&1) {
            result = result * a % m;
        }

    a = a * a % m;
    n >>= 1;
    }

    return result;
}

ll modinv(ll a, ll n) {
    if(a <= 1) {
        return 1;
    } else {
        return  n - modinv(n%a, n) * (n/a) % n;
    }
}

ll comb(ll n, ll r, ll m = mod_const) {
    vecll fac = {1, 1};
    vecll inv ={1, 1};
    vecll facinv = {1 , 1};

    rep(i, 2, n) {
        fac.push_back(fac[i-1] * i % m);
        inv.push_back(modinv(i, m));
        facinv.push_back(facinv[i-1] * inv[i] % m);
    }

    if (n<r || n<0 || r<0) {
        return 0;
    } else {
        return fac[n] * (facinv[r] * facinv[n-r] % m) % m;
    }
}
void solve() {
    ll n, k;
    cin >> n >> k;
    ll d[110];
    ll a[110][110];

    ll o[n][k];
    rep0(i, n) {
        rep0(j, k) {
            o[i][j] = 0;
        }
    }

    rep0(i, k) {
        cin >> d[i];

        rep0(j, d[i]) {
            cin >> a[i][j];
            o[a[i][j]-1][i] = 1;
        }
    }

    ll cnt = 0;
    rep0(i, n) {
        bool f = true;
        rep0(j, k) {
            if(o[i][j] == 1) {
                f = false;
            }
        }

        if(f) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#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 print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int x,a,b; cin >> x >> a >> b;
	cout << (abs(a-x) > abs(b-x)? 'B' : 'A') << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    ios_base::sync_with_stdio(false);
    int a, b, i;
    cin >> a >> b;
    if ( a <= b)
    {
        for (i = 0; i < b; i ++)
        {
            cout << a;
        }
    }
    else
    {
        for (i = 0; i < a; i ++)
        {
            cout << b;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,res,a[N];
signed main()
{
    n=read();
    for(ri int i=1;i<=n;i++) a[i]=read();
    sort(a+1,a+1+n);
    int now=n;
    while(now)
    {
        if(now==1)
        {
            res+=a[now], now--;
            continue;
        }
        if(now==2)
        {
            res+=a[now]-a[now-1];
            now-=2; continue;
        }
        res+=a[now]-a[now-1];
        now-=2;
    }
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3732
#include<math.h>
#include<iostream>
using namespace std;
int main(){
  int n,t,a,h,i,ans;
  double a1,h1,t1,min=1000000.0,t2;
  cin >> n >> t >> a;
  t1=t,a1=a;
  for(i=1;i<=n;i++){
    cin >> h;
    h1=h;
    t2=t1-h1*0.006;
    if(fabs(a1-t2)<min){
      min=fabs(a1-t2);
      ans=i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import copy
h,w,k = map(int,input().split())
c= [[0] * w for i in range(h)]
for i in range(h):
  l = list(input())
  for j in range(w):
    if l[j]=="#":
      c[i][j]=1
cc = 0
for bit in range(2**(h+w)):
  temp = copy.deepcopy(c)
  for i in range(h):
    if ((bit >> (i+w)) & 1):
      temp[i][:]=[0]*w
  for j in range(w):
    if ((bit >> j) & 1):
      for i in range(h):
        temp[i][j]=0
  temp_c = 0
  for i in range(h):
    for j in range(w):
      if temp[i][j]==1 : temp_c+=1
  if temp_c==k : cc+=1
print(cc)

Measured memory_bytes: 9224
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
signed main() {
	ll n, m, a = 0, b = 0, cnt = 0, ans = INF;
	string s, t; cin >> s;
	for (int h = 2; h < s.size(); h++) {
		a = 0;
		a += (ll)(s[h - 2] - '0') * 100;
		a += (ll)(s[h - 1] - '0') * 10;
		a += (ll)(s[h] - '0');
		ans = min(ans, abs(a - 753));
	}
	cout << ans << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n; cin >> n;
    n--;
    vector<string> ans;
    queue<string> q1;
    q1.push("a");
    rep(i,n){
        queue<string> q2;
        while(!q1.empty()){
            string st=q1.front(); q1.pop();
            int ma=0;
            rep(j,st.size()) chmax(ma,(st[j]-'a'));
            char a='a';
            rep(j,ma+2){
                q2.push(st+a);
                a++;
            }
        }
        q1=q2;
    }
    while(!q1.empty()){
        ans.pb(q1.front()); q1.pop();
    }
    
    sort(ALL(ans));
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
}


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

int main(){
	int N[5],i;
	int flg;
	
	
	//入力
	for ( i = 0;i<6;i++){
		cin >> N[i];
	}
	
	//計算
	
	if(N[4] - N[0] <= N[5] ){
		cout << "Yay!" << endl;
	}else{
		cout << ":(" << endl;
	}

	return 0;
}

Measured memory_bytes: 768
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define P 1000000007
#define N 200010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,m,f[N],fac[N],inv[N];
int ksm(int a,int k)
{
	int s=1;
	for (;k;k>>=1,a=1ll*a*a%P) if (k&1) s=1ll*s*a%P;
	return s;
}
int Inv(int a){return ksm(a,P-2);}
int C(int n,int m){if (m>n) return 0;return 1ll*fac[n]*inv[m]%P*inv[n-m]%P;}
signed main()
{
	n=read(),m=read();
	fac[0]=fac[1]=1;for (int i=1;i<=n+m;i++) fac[i]=1ll*fac[i-1]*i%P;
	inv[0]=inv[1]=1;for (int i=2;i<=n+m;i++) inv[i]=P-1ll*(P/i)*inv[P%i]%P;
	for (int i=2;i<=n+m;i++) inv[i]=1ll*inv[i-1]*inv[i]%P;
	for (int i=m;i<n+m;i++)
	{
		int p=1ll*C(i-1,m-1)*Inv(ksm(2,i))%P;
		f[1]=(f[1]+1ll*(i-m)*Inv(i-1)%P*p)%P;
		f[i]=(f[i]+P-1ll*(i-m)*Inv(i-1)%P*p%P)%P;
		f[i+1]=(f[i+1]+p)%P;
	}
	for (int i=n;i<n+m;i++)
	{
		int p=1ll*C(i-1,n-1)*Inv(ksm(2,i))%P;
		f[1]=(f[1]+1ll*(n-1)*Inv(i-1)%P*p)%P;
		f[i]=(f[i]+P-1ll*(n-1)*Inv(i-1)%P*p%P)%P;
		f[i]=(f[i]+p)%P;
		f[i+1]=(f[i+1]+P-p)%P;
	}
	//白球是在第i次被拿完的 之前黑白球都存在 则每次拿黑白球概率均等 其概率为C(i-1,m-1)/2^i
	//考虑该情况下第j次拿黑球的概率 显然第i次不可能
	//对j<i和j>i分别考虑
	//j<i时，概率为(i-m)/(i-1)
	//j>i时，概率为1
	//若白球是最后一次被拿完的 再考虑黑球是什么时候被拿完的
	//类似 
	for (int i=1;i<=n+m;i++) f[i]=(f[i]+f[i-1])%P;
	for (int i=1;i<=n+m;i++) printf("%d\n",f[i]);
	return 0;
	//NOTICE LONG LONG!!!!!
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000007

signed main(){
    gok
   int a,b;
   cin>>a>>b;
  // if(a>b)
    //swap(a,b);
   int pp1 = ((a*200)/8 + 1)/2;
   int pp2 = ((b*20) + 1)/2;
  // cout<<pp<<endl;
   int bb1 = (double)(pp1*0.1);
   int bb2 = (pp2*0.08);
   //cout<<bb<<endl;
   if(b==bb1)
    cout<<pp1;
    else if(a==bb2)
        cout<<pp2;
   else
    cout<<-1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Postdocs | diff Postdocs.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Postdocs.cpp && ./a.out

/*

 5/30/2020

 5:03-

 */

string T;
int N;

void solve() {
  N=SZ(T);
  string res=T;
  REP(i,N)if(res[i]=='?') res[i]='D';
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>T;
  solve();

  return 0;
}


Measured memory_bytes: 3772
//
//  main.cpp
//  A
//
//  Created by 岡本 朋大 on 2019/06/02.
//  Copyright © 2019年 岡本　朋大. All rights reserved.
//

#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main(){
    int N,A,B,C,D;
    string str;
    cin >> N >> A >> B >> C >> D;
    cin >> str;
    bool can_jump = true;
    bool can_overtake = false;
//    bool left_C = false;
    int count = 0;
//    if(A < C < B < D){
    if(C < B){
        can_overtake = true;
        for(int i = A; i < C - 1;i++ ){
            if(str[i] == '#' && str[i+1] == '#'){
                can_jump = false;
                break;
            }
        }
        for(int i = B; i < D - 1;i++ ){
            if(str[i] == '#' && str[i+1] == '#'){
                can_jump = false;
                break;
            }
        }
    }
//    else if(A < B < C < D){
    else if(B < C && C < D){
        can_overtake = true;
        for(int i = A; i < D - 1;i++ ){
            if(str[i] == '#' && str[i+1] == '#'){
                can_jump = false;
                break;
            }
        }
    }
//    else if(A < B < D < C){
    else if(D < C){
        for(int i = A; i < C - 1;i++ ){
            if(str[i] == '#' && str[i+1] == '#'){
                can_jump = false;
                break;
            }
        }
        for(int i = B -2; i < D - 1; i++){
            if(str[i] == '.' && str[i+1] == '.' && str[i+2] == '.'){
                can_overtake = true;
//                count++;
 //               if(str[i-1] == '#' && i == C) left_C = true;
            }
        }
 //       if(count == 1 && left_C == true) can_overtake = false;
    }
//    can_jump = false;
    if (can_jump == true && can_overtake == true) cout <<"Yes" << endl;
    else cout <<"No" << endl;
}


Measured memory_bytes: 644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace CompetitiveProgramming
{
  class Solve
  {
    public Solve() {
      int N = Scanner.nextInt();
      int K = Scanner.nextInt();

      List<List<int>> e = new List<List<int>>();

      for (int i = 0; i < N; i++) 
      {
        e.Add(new List<int>());
      }
      for (int i = 0; i < N - 1; i++) 
      {
        int A = Scanner.nextInt() - 1;
        int B = Scanner.nextInt() - 1;
        e[A].Add(B);
        e[B].Add(A);
      }


      int maxDist = K / 2;
      var ans = Int32.MaxValue;
      for (int i = 0; i < N; i++)
      {
        if (K % 2 == 0) 
        {
          ans = Math.Min(ans, dfs(i, -1, 0, maxDist, e));
        }
        else
        {
          foreach (var j in e[i]) 
          {
            ans = Math.Min(ans, dfs(i, j, 0, maxDist, e) + dfs(j, i, 0, maxDist, e));
          }
        }
      }

      Console.WriteLine(ans);
    }

    int dfs(int cur, int prev, int dist, int maxDist, List<List<int>> e) 
    {
      int ret = (dist > maxDist) ? 1 : 0;
      foreach( var next in e[cur]) {
        if (next == prev)
        {
          continue;
        }
        ret += dfs(next, cur, dist + 1, maxDist, e);
      }

      return ret;
    }
  }

  class Program
  {
    static void Main(string[] args)
    {
        new Solve();
    }
  }

  public class Pair<T, U>
  {
    public Pair()
    {

    }
    public Pair(T first, U second)
    {
      this.first = first;
      this.second = second;
    }
    public T first { get; set; }
    public U second { get; set; }
  }

  class Scanner
  {
    private static List<string> buf = new List<string>();

    private static void next()
    {
      if (buf.Count == 0)
      {
        buf = Console.ReadLine().Split().ToList();
      }
    }

    private static string pop()
    {
      string ret = buf[0];
      buf.RemoveAt(0);
      return ret;
    }

    public static int nextInt()
    {
      next();
      return int.Parse(pop());
    }
    public static long nextLong()
    {
      next();
      return long.Parse(pop());
    }
    public static string nextString()
    {
      next();
      return pop();
    }
    public static double nextDouble()
    {
      next();
      return double.Parse(pop());
    }
  }
}


Measured memory_bytes: 3928
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
double dp[303][303][303];
bool viz[303][303][303];
int v[4], n, x;
inline double solve(int a, int b, int c){
    if (a == 0 && b == 0 && c == 0)
        return 0.0;
    if (viz[a][b][c])
        return dp[a][b][c];
    double ex(n);
    if (a) ex += solve(a - 1, b, c) * a;
    if (b) ex += solve(a + 1, b - 1, c) * b;
    if (c) ex += solve(a, b + 1, c - 1) * c;
    viz[a][b][c] = 1;
    dp[a][b][c] = ex / static_cast<double>(a + b + c);
    return dp[a][b][c];
}
int main() {
    DAU
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> x, ++v[x];
    cout << fixed << setprecision(10) << solve(v[1], v[2], v[3]);
    PLEC
}


Measured memory_bytes: 243968
#include<iostream>
#include<vector>
using namespace std;
int main(){
  vector<int> hit_anss;
  vector<int> bolor_anss;
  int nums_a[4],nums_b[4];
  while(cin>>nums_a[0]>>nums_a[1]>>nums_a[2]>>nums_a[3]){
    int hit=0,bolor=0;
    for(int i=0;i<4;i++){
      cin>>nums_b[i];
    }
    //hit????¢????
    for(int i=0;i<4;i++){
      if(nums_a[i]==nums_b[i])hit++;
    }
    //bolor????¢????
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        if(i==j)continue;
        if(nums_a[i]==nums_b[j]){
          bolor++;
          break;
        }
      }
    }
    hit_anss.push_back(hit);
    bolor_anss.push_back(bolor);
  }
  for(int i=0;i<hit_anss.size();i++){
    cout<<hit_anss[i]<<' '<<bolor_anss[i]<<endl;
  }
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int main()
{
    int i,j;
    LLI H;

    scanf("%lld", &H);
    LLI a = 1;
    LLI ans = 0;
    while(H)
    {
        ans += a;
        H >>= 1;
        a <<= 1;
    }
    printf("%lld\n", ans);

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 (ll)1 << 60
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, m, f[110000], ans = 1, now;
vector<ll> s;
ll po(ll a, ll b) {
	a %= MOD;
	ll res = 1;
	while (b > 0) {
		if (b % 2 == 1)res = res * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}
	return res;
}
ll com(ll n, ll r) {
	return f[n] * po(f[r] * f[n - r], 1e9 + 5) % MOD;
}
int main() {
	f[0] = 1;
	REP(i, 101010)f[i + 1] = f[i] * (i + 1) % MOD;
	cin >> n >> m;
	now = m;
	for (ll i = 2; i < sqrt(m); i++)
	{
		if (m % i == 0) {
			ll st = 0;
			while (now % i == 0) {
				st++;
				now /= i;
			}
			s.push_back(st);
		}
	}
	if (now > 1)s.push_back(1);
	REP(i, s.size()) {
		ans *= com(s[i] + n - 1, s[i]);
		ans %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;

int main() {
    
    
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == 'x')
        {
            count++;
        }
    }
    
    if (count > 7)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }
    
    return 0;
}

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

using namespace std;

int main() {
    int X, A, B;

    cin >> X >> A >> B;

    if (B <= A) {
        cout << "delicious" << endl;
    } else if ((A + X + 1) > B) {
        cout << "safe" << endl;
    } else if ((A + X + 1) <= B) {
        cout << "dangerous" << endl;
    }

    return 0;
}

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

int main()
{
  int N;
  cin >> N;
  int a[N + 1], b[N + 1], c[N + 1];

  for (int i = 1; i <= N; i++)
  {
    cin >> a[i] >> b[i] >> c[i];
  }

  /* i日目にaをしたときの累積最大幸福度がh[i][0] */

  int h[N + 1][3];
  h[1][0] = a[1];
  h[1][1] = b[1];
  h[1][2] = c[1];
  for (int i = 2; i <= N; i++)
  {
    h[i][0] = a[i] + max(h[i - 1][1], h[i - 1][2]);
    h[i][1] = b[i] + max(h[i - 1][2], h[i - 1][0]);
    h[i][2] = c[i] + max(h[i - 1][0], h[i - 1][1]);
  }

  cout << max(h[N][0], max(h[N][1], h[N][2])) << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

typedef vector<vector<pair<ll,int>>> wgraph;
typedef pair<ll,int> pli;
 
vector<ll> bfs(wgraph v,int x){
  priority_queue<pli,vector<pli>,greater<pli>> q;
  vector<ll> dist(v.size(),longinf);
  dist[x]=0;
  q.push({0LL,x});
  
  while(q.size()){
    pli p=q.top(); q.pop();
    ll d=p.F, now=p.S;
    if(dist[now]<d){ continue; }
    for(auto to:v[now]){
      if(dist[to.S]>d+to.F){
        dist[to.S] = d+to.F;
        q.push({dist[to.S], to.S});
      }
    }
  }
  return dist;
}

int main(){
  int n,m,s,t;
  cin >> n >> m;
  wgraph v(n*3+10);
  rep(i,m){
    int a,b; cin >> a >> b; a--; b--;
    v[a].push_back({1,b+n});
    v[a+n].push_back({1,b+2*n});
    v[a+2*n].push_back({1,b});
  }
  cin >> s >> t; s--; t--;
  vector<ll> dist=bfs(v,s);
  ll ans = dist[t];
  if(ans==longinf){ans=-1;}else{ans/=3;}
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35456
n, q = list(map(int, input().split()))
s =  input()
a = [0]*n

for i in range(1, n):
  a[i]+=a[i-1]
  if s[i-1:i+1]=="AC":
      a[i]+=1

  #if s[i-1] == "A":
  #  if s[i] == "C":
  #    a[i] = a[i-1]+1
  #else:
  #  a[i] = a[i-1]

#print(a)
for i in range(q):
  b, c = list(map(int, input().split()))
  print(a[c-1]-a[b-1])

Measured memory_bytes: 9364
import java.util.Scanner;

public class Main {

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

        double d;
        if (N%2 == 0) {
            d = (double)(N/2)/N;
        } else {
            d = (double) ((N + 1) / 2) / N;
        }

        sc.close();

        System.out.println(String.format("%.10f", d));
    }
}

Measured memory_bytes: 23764
#include<iostream>

using namespace std;

 
long long a, b, k, cnt;
 
int main() 
{
	cin >> a >> b >> k;
	long long i;
	for (i = min(a, b); i >= 1; i--) 
	{
		if (a % i == 0 && b % i == 0) 
		{
			cnt++;
			if (cnt == k)
				break;
		}
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
N,A,B=map(int,input().strip().split(" "))

Sum=0


for i in range(N+1):
    keta=0
    l = [int(x) for x in list(str(i))]
    for j in range(len(l)):
        keta+=l[j]

    if(keta>=A and keta<=B):
        Sum+=i
    
print(Sum)
        


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

int K =0;
const int MAXN = 1e5+10;
long long int A[MAXN];

int main(){
	scanf("%d",&K);
	for(int k=0;k<K;k++){
		scanf("%lld",&A[k]);
	}
	long long int usmin =2;
	long long int usmax =2;
	for(int i=K-1;i>=0;i--){
		int pro = A[i];
		if(usmin%A[i]!=0)	usmin = usmin/A[i]*A[i]+A[i];
		usmax = (usmax/A[i]+1)*A[i]-1;
	}
	if(usmin>usmax)	printf("-1\n");
	else{
		printf("%lld %lld\n",usmin,usmax);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a=0;
  int b=0;
  int x=0;
  int y=0;
  cin >> a >> b;
  
  y = (a+b)%2;
  x = (a+b)/2+y;
  cout << x << endl;
}

Measured memory_bytes: 256
import std.stdio,std.string,std.conv;

int main()
{
	string s;
	int a[10];
	while((s = readln.chomp).length != 0)
	{
		foreach(i;0..10)
		{
			a[i] = s[i] - '0';
		}

		for(int i=9;i>=0;i--)
		{
			foreach(j;0..i)
			{
				a[j] = (a[j]+a[j+1]) % 10;
			}
		}
		a[0].writeln;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;

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

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

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;
  int sl = s.length();
  REP(i, sl) {
    if((i + 1) % 2 == 1) {
      if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
# Aizu Problem 0296: A Fat Wallet

import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input5.txt", "rt")

c1, c5, c10, c50, c100, c500 = [int(_) for _ in input().split()]
S = c1 + 5 * c5 + 10 * c10 + 50 * c50 + 100 * c100 + 500 * c500
print(1 if S >= 1000 else 0)

Measured memory_bytes: 7824
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop,heappush
from copy import deepcopy

n = int(readline())
lr = list(map(int,read().split()))


hq_left = []
hq_right = []

for i in range(n):
    l,r = lr[i*2:i*2+2]
    heappush(hq_left,(-1*l,i))
    heappush(hq_right,(r,i))

hq_left_origin = deepcopy(hq_left)
hq_right_origin = deepcopy(hq_right)

done = [0] * n
ans = -1*10**5
now = 10**5
while(len(hq_left)>0)&(len(hq_right)>0):
    while(hq_left):
        l,ind_l = hq_left[0]
        l *= -1
        if(done[ind_l] == 1):
            heappop(hq_left)
        else:
            break
    else:
        break

    while(hq_right):
        r,ind_r = hq_right[0]
        if(done[ind_r] == 1):
            heappop(hq_right)
        else:
            break
    else:
        break

    if( l-now > now-r):
        if(l > now):
            ans += l-now
            now = l
        done[ind_l] = 1
        heappop(hq_left)
    else:
        if(now > r):
            ans += now-r
            now = r
        done[ind_r] = 1
        heappop(hq_right)

ans += abs(now)

ans2 = -1*10**5
now = -1 * 10**5
hq_left = deepcopy(hq_left_origin)
hq_right = deepcopy(hq_right_origin)
done = [0] * n

while(len(hq_left)>0)&(len(hq_right)>0):
    while(hq_left):
        l,ind_l = hq_left[0]
        l *= -1
        if(done[ind_l] == 1):
            heappop(hq_left)
        else:
            break
    else:
        break

    while(hq_right):
        r,ind_r = hq_right[0]
        if(done[ind_r] == 1):
            heappop(hq_right)
        else:
            break
    else:
        break

    if( l-now > now-r):
        if(l > now):
            ans2 += l-now
            now = l
        done[ind_l] = 1
        heappop(hq_left)
    else:
        if(now > r):
            ans2 += now-r
            now = r
        done[ind_r] = 1
        heappop(hq_right)

ans2 += abs(now)


print(max(ans,ans2))

Measured memory_bytes: 136140
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int b[n - 1];
    int ans = 0;
    for(int i = 0; i < n - 1; i++) {
        cin >> b[i];
        if(i == 0)
            ans += b[i];
        else
            ans += min(b[i - 1], b[i]);
        if(i == n - 2)
            ans += b[i];
    }
    cout << ans << endl;
}

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

int main(){

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

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

    return 0;
}

Measured memory_bytes: 12964
#include<stdio.h>

#define NUM 16
int main(){
  int A,B,l,s;
  scanf("%d%d", &A, &B);
  l = (A>=B)? A: B;
  s = (A< B)? A: B;
  if(l <= NUM/2 && s <= NUM/2) printf("Yay!\n");
  else printf(":(\n");
  
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int n, i, j, u, v, k, A[100][100];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      A[i][j] = 0;
    }
  }
  
  for(i = 0; i < n; i++){
    scanf("%d %d", &u, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &v);
      A[u - 1][v - 1] = 1;
    }
  }

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

  return 0;
}

Measured memory_bytes: 636
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());
    loop {
        let h:i32 = scan.next();
        let w:i32 = scan.next();
        if h == 0 && w == 0 { break; }
        for i in 0..h {
            for j in 0..w {
                if (i+j) & 1 == 0 {
                    write!(out, "#").ok();
                } else {
                    write!(out, ".").ok();
                }
            }
            writeln!(out).ok();
        }
        writeln!(out).ok();
    }
}


Measured memory_bytes: 5028
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long n = scanner.nextLong();
        final long a = scanner.nextLong();
        final long b = scanner.nextLong();

        if ((a + b) % 2 == 0) {
            System.out.println((b - a) / 2);
            return;
        }

        if (a - 1 < n - b) {
            System.out.println(a + (b - a - 1) / 2);
        } else {
            System.out.println(n - b + 1 + (b - a - 1) / 2);
        }
    }
}


Measured memory_bytes: 22612
#define _CRT_SECURE_NO_DEPRECATE  
#define _CRT_NONSTDC_NO_DEPRECATE

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cctype>
#include <numeric>
#include <cstring>
#include <bitset>
#include <complex>
#include <complex>

using namespace std;

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    //os << "{ ";
    for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); ++it)
        os << "" << *it << "" << (it + 1 == v.end() ? "" : " ");
    //os << " }";
    return os;
}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(ull i=(a); i<(ull)(b); i++)
#define rep(i,b) loop(i,0,b)
#define iter(i,c) for(auto it=c.begin(); it!=c.end(); ++it)
#define pb push_back
#define mp make_pair
string const resstr[] = { "Impossible", "Possible", "No", "Yes" };

typedef complex<int> point;

inline bool in(point const& p, int w, int h){
    return p.real() < w+1 && p.imag() < h+1 && 0 < p.real() && 0 < p.imag();
}

int main(){
    int w, h;
    while (cin >> w >> h && w + h){
        point p(1, 1);
        point dir(0, 1);
        while (1){
            string s;
            cin >> s;
            char c = s[0];
            if (c == 'F'){
                int k; cin >> k;
                rep(i, k){
                    if (in(p + dir, w, h)) p += dir;
                }
            }
            else if (c == 'B'){
                int k; cin >> k;
                rep(i, k){
                    if (in(p - dir, w, h)) p -= dir;
                }
            }
            else if (c == 'R'){
                dir /= point(0, 1);
            }
            else if (c == 'L'){
                dir *= point(0, 1);
            }
            else{
                break;
            }
            //cout << p.real() << " " << p.imag() << endl;
        }
        cout << p.real() << " " << p.imag() << endl;
    }
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

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

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

  int n;
  cin >> n;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  map<int64, int> count_map;
  for (int64 x : xs) {
    count_map[x]++;
  }

  int64 ans = 0;
  for (const auto& p : count_map) {
    if (p.second >= 4) {
      UpdateMax(ans, p.first * p.first);
    }
  }

  vector<int64> ys;
  for (const auto& p : count_map) {
    if (p.second >= 2) {
      ys.push_back(p.first);
    }
  }
  sort(ys.begin(), ys.end());
  reverse(ys.begin(), ys.end());
  if (ys.size() >= 2) UpdateMax(ans, ys[0] * ys[1]);
  cout << ans << endl;
}

Measured memory_bytes: 7296