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

template <class T>
inline void read(T &x) {
	static char ch; 
	static bool opt; 
	while (!isdigit(ch = getchar()) && ch != '-'); 
	x = (opt = ch == '-') ? 0 : ch - '0'; 
	while (isdigit(ch = getchar()))
		x = x * 10 + ch - '0'; 
	if (opt)
		x = ~x + 1; 
}

template <class T>
inline void putint(T x) {
	static char buf[45], *tail = buf; 
	if (!x)
		putchar('0'); 
	else {
		if (x < 0)
			putchar('-'), x = ~x + 1; 
		for (; x; x /= 10) *++tail = x % 10 + '0'; 
		for (; tail != buf; --tail) putchar(*tail); 
	}
}

template <class T>
inline bool tense(T &x, const T &y) {
	return y < x ? x = y, true : false; 
}

template <class T>
inline bool relax(T &x, const T &y) {
	return x < y ? x = y, true : false; 
}

template <class T>
inline T getAbs(const T &x) {
	return x < 0 ? -x : x; 
}

typedef long long s64; 
typedef long double ld; 
typedef std::vector<int> vi; 
typedef std::pair<int, int> pii; 
#define mp(x, y) std::make_pair(x, y)

std::map<pii, int> cnt; 

int main() {
#ifdef orzczk
	freopen("a.in", "r", stdin); 
#endif

	int n; 

	scanf("%d", &n); 
	while (n--) {
		double x; 
		scanf("%lf", &x); 

		s64 cur = (s64)(x * 1e9 + 0.5); 

		int a = 0, b = 0; 
		while (cur % 2 == 0) cur /= 2, ++a; 
		while (cur % 5 == 0) cur /= 5, ++b;  

		++cnt[pii(a, b)]; 
	}

	s64 res = 0; 
	for (auto a : cnt)
		for (auto b : cnt) {
			if (a.first.first + b.first.first >= 18 && a.first.second + b.first.second >= 18) {
				if (a.first == b.first) {
					res += 1LL * a.second * (a.second - 1); 
				} else {
					res += 1LL * a.second * b.second; 
				} 
			}
		}
	
	std::cout << res / 2 << '\n'; 

	return 0; 
}

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

int main(){
	int n,a,b,p;
	cin>>n>>a>>b;
	int A=0,B=0,C=0;
	for(int i=0;i<n;i++){
		cin>>p;
		if(p<=a) A++;
		else if(p<=b) B++;
		else C++;
	}
	cout<<min(A,min(B,C))<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main (String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = (a + b) / 2;
    
    if ((a + b) % 2 == 0) {
      System.out.println(x);
    } else {
      System.out.println(x + 1);
    }
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  rep(i,12)
  {
    if(i==4)
    {
      cout << " ";
    }
    cout << S[i];
    if(i==11)
    {
      cout << endl;
    }
  }
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a;cin>>a;
    cout<<"ABC"<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <list>
using namespace std;
int ax[200005];
list<int> l;

int main()
{
    int n,i,a;
    bool flag = 1;
    list<int>::iterator p;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&ax[i]);
    }
    for(i=0;i<n;i++){
        if(flag)l.push_front(ax[i]);
        else l.push_back(ax[i]);
        flag = !flag;
    }
    if(!flag){
        for(p=l.begin();p!=l.end();p++)printf("%d ",*p);
    }
    else{
        for(p=l.end();p!=l.begin();)printf("%d ",*(--p));
    }
    return 0;
}


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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll n;
    cin >> n;
    vector<ll> v(n);
    for (ll i = 0;i < n;i++){
        cin >> v[i];
    }

    vector<pair<ll,ll>> even(100005);
    vector<pair<ll,ll>> odd(100005);

    for (ll i = 0; i < 100005; i++){
        even[i] = make_pair(0,i);
        odd[i] = make_pair(0,i);
    }

    for (ll i = 0; i < n; i++){
        if (i%2 == 0){
            even[v[i]].first++;
        }
        else{
            odd[v[i]].first++;
        }
    }

    sort(even.begin(), even.end());
    reverse(even.begin(), even.end());
    sort(odd.begin(), odd.end());
    reverse(odd.begin(), odd.end());

    ll ans = 0;
    if (even[0].second != odd[0].second){
        ans = n - even[0].first - odd[0].first;
    }
    else{
        ans = min((n - even[0].first - odd[1].first),(n - even[1].first - odd[0].first));
    }

    cout << ans << endl;

}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline vi32 plist(i32 n) { vi32 f(n, 1); f[0] = f[1] = 0; repi(i, 2, n) for (int j = i * 2; j < n; j += i) f[j] = 0; return f; }
inline bool isprime(i32 n) { if (n < 2) return 0; for (i32 i = 2; i * i <= n; i++) if (n % i == 0) return 0; return 1; }
template<class T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<class T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<class T> inline bool amax(T &x, T y) { if (x >= y) return 0; x = y; return 1; }
template<class T> inline bool amin(T &x, T y) { if (x <= y) return 0; x = y; return 1; }
template<class T> inline i64 lbi(vector<T> &v, T e) { return lower_bound(all(v), e) - v.begin(); }
template<class T> inline i64 ubi(vector<T> &v, T e) { return upper_bound(all(v), e) - v.begin(); }
template<class T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }

vector<vi32> calcNext(const string &s) {
  int n = s.size();
  // 文字cが存在しないときのインデックスはn
  // 文字列の長さがnなので、nは範囲外を表すものとして最適なのかも
  vector<vi32> res(n + 1, vi32(26, n));
  rrep(i, n) {
    rep(j, 26) res[i][j] = res[i + 1][j];
    res[i][s[i] - 'a'] = i;
  }
  return res;
}

int main() {
  ioinit();
  string s;
  cin >> s;
  int n = s.size();
  auto next = calcNext(s);
  vi32 dp(n + 1, bit(30));
  dp[n] = 1;
  rrep(i, n) rep(j, 26) {
    if (next[i][j] == n) {
      dp[i] = 1;
    } else {
      amin(dp[i], dp[next[i][j] + 1] + 1);
    }
  }
  string ans = "";
  int i = 0;
  while (i < n) {
    rep(j, 26) {
      if (next[i][j] == n || dp[next[i][j] + 1] + 1 == dp[i]) {
        ans += 'a' + j;
        i = next[i][j] + 1;
        break;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,a,b; cin>>n>>a>>b;
	cout << min(n*a,b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main(void){
  vector<int> sum(3);
  for(int i = 0 ; i < 3; i++){
    cin >> sum.at(i);
  }
  sort(sum.begin(),sum.end());
  cout << sum.at(0) + sum.at(1);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000009
using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++)cin >> a[i];
	int sum=0,ans=INF;
	for(int i=-100; i<=100; i++){
		sum=0;
		for(int j=0; j<n; j++){
			sum+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,sum);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int n;
  cin >> n;
  ll ans = 0;
  REP(i,1,n + 1)REP(j,1,n + 1)REP(k,1,n + 1)ans += gcd(i,gcd(j,k));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3676
#include<stdio.h>
#include<string.h>
int main(){
	unsigned char s[200];
	char p[100],s2[100];
	scanf("%s %s",s,p);
	strcpy(s2,s);
	strcat(s,s2);
	if(strstr(s,p)==NULL){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<vl> mat;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const double PI = 4*atan(1);
const ll INF = 1e18;
const int MX = 100001;

int N, a[1000];
pair<ll,pi> dp[1000][1000];
pair<ll,pi> ori = {-INF,{-1,-1}}, bes = ori;
vi ans;
vl cur;

void rem(int x) {
    ans.pb(x+1);
    if (x == 0 || x == sz(cur)-1) cur.erase(cur.begin()+x);
    else {
        ll z = cur[x+1]+cur[x-1];
        cur[x] = z;
        cur.erase(cur.begin()+x+1);
        cur.erase(cur.begin()+x-1);
    }
}

void divi(int l, int r, int pre) {
    if (l == r) return;
    pi x = dp[r-l][l].s;
    divi(l,l+x.f,pre);
    divi(l+x.f+1,r-x.s-1,pre+1);
    divi(r-x.s,r,pre+2);
    rem(pre+1);
}

void solve() {
    pi l = {bes.s.s,bes.s.s+bes.s.f};
    F0R(i,l.f) rem(0);
    F0R(i,N-1-l.s) rem(sz(cur)-1);
    divi(l.f,l.s,0);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    F0R(i,N) cin >> a[i];
    for (int i = 0; i < N; i += 2) F0R(j,N-i) {
        dp[i][j] = ori;
        if (i == 0) dp[i][j] = {a[j],{-1,-1}};
        else {
            pair<ll,int> cur = {-INF,-1};
            for (int k = i-2; k >= 0; k -= 2) {
                cur = max(cur,mp(dp[i-k-2][j+k+2].f,i-k-2));
                dp[i][j] = max(dp[i][j],mp(dp[k][j].f+cur.f,mp(k,cur.s)));
            }
        }
        bes = max(bes,mp(dp[i][j].f,mp(i,j)));
    }
    F0R(i,N) cur.pb(a[i]);
    solve();
    assert(cur[0] == bes.f);
    cout << bes.f << "\n";
    cout << sz(ans) << "\n";
    for (int i: ans) cout << i << "\n";
}

// read the question correctly (is y a vowel?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
double total_odd_number(int n)
{
    if(n%2==0) return n/2;
    else return (n/2)+1;
}
int main(void)
{
    double n;
    cin>>n;
    double s = total_odd_number(n);
    cout<<fixed<<setprecision(10)<<s/n<<endl;

    return 0;
}


Measured memory_bytes: 3744
import sys

def main():
    sinputl = sys.stdin.readline

    num_card, num_gate = [int(x) for x in sinputl().split()]
    input = [[int(x) for x in sinputl().split()] for _ in range(num_gate)]

    card = [1, num_card]

    for gate in input:
        card[0] = max(card[0], gate[0])
        card[1] = min(card[1], gate[1])

    print(max(card[1] - card[0] + 1, 0))


if __name__ == "__main__":
    main()


Measured memory_bytes: 21148
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #ifdef ONLINE_JUDGE
        #pragma GCC target ("avx512f")
    #else
        #pragma GCC target ("avx")
    #endif
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

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

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int x;
signed main(){
    cin >> x;
    FOR(a,-1000,1001){
        FOR(b,-1000,1001){
            auto fx = a*a*a*a*a - b*b*b*b*b;
            if (fx == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int n;
    cin>>n;
    vector<ll> a(n);

    map<ll,ll> m;
    rep(i,n){
        cin>>a[i];
        m[a[i]]++;
    }

    ll sum=0;
    for(auto e : m){
        sum+=e.second*(e.second-1)/2;
    }
    rep(i,n){
        ll x=m[a[i]];
        ll ans=sum-(x*(x-1)/2-(x-1)*(x-2)/2);
        cout<<ans<<endl;
    }

}



Measured memory_bytes: 12688
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l;
    cin>>n>>l;
    string s[n];
    for(int i=0;i<n;i++)
        cin>>s[i];

    sort(s,s+n);
    for(int i=0;i<n;i++)
        cout<<s[i];

    return 0;
}

Measured memory_bytes: 3628
/**
 * Title:
 * Url:
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
    int n, m; cin >> n >> m;
    vector<int> s(n, -1);
    for(int i=0; i<m; i++) {
        int si, ci; cin >> si >> ci;
        if(s[n-si]==-1) {
            s[n-si] = ci;
        } else {
            if(s[n-si]!=ci) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    if(n==1) {
        if(s[0]==-1) {
            cout << 0 << endl;
            return 0;
        }
        cout << s[0] << endl;
        return 0;
    }
    for(int i=0; i<n; i++) {
        if(i==0) {
            if(s[n-i-1]==0) {
                cout << -1 << endl;
                return 0;
            } else if(s[n-i-1]==-1) {
                cout << 1;
            } else {
                cout << s[n-i-1];
            }
        } else {
            if(s[n-i-1]==-1) {
                cout << 0;
            } else {
                cout << s[n-i-1];
            }
        }        
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,m,l;
    int i,j,k;
    int a[110][110],b[110][110];
    long c[110][110]={0};
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
            scanf("%d",&a[i][j]);
    for(j=0;j<m;j++)
        for(k=0;k<l;k++)
            scanf("%d",&b[j][k]);
    for(i=0;i<n;i++)
        for(j=0;j<l;j++)
            for(k=0;k<m;k++)
                c[i][j]+=a[i][k]*b[k][j];
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            printf("%ld",c[i][j]);
            if(j<l-1)
                printf(" ");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 800
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    long long int a;
    std::deque<long long int> deq;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    int count=0;
    int flag=2;
    for (int i=1;i<n;i++) {
        if (flag==0) {
            if (deq[i-1]>deq[i]) {
                flag=2;
                count++;
            }
        } else if (flag==1) {
            if (deq[i-1]<deq[i]) {
                flag=2;
                count++;
            }
        } else {
            if (deq[i-1]<deq[i]) {
                flag=0;
            } else if (deq[i-1]>deq[i]) {
                flag=1;
            }
        }
    }
    cout<<count+1<<endl;
}

Measured memory_bytes: 4448
void main() {
	readln;
	(a => a[$-1] - a[0])(readAs!(int[]).sort()).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define INF 1000000000

ll modInverse(ll a, ll m);
ll gcd(ll a, ll b);
ll power(ll x, unsigned ll y, unsigned ll m);
ll logint(ll x,ll y);


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

ll power(ll x, unsigned ll y, unsigned ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
}

ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        // q is quotient
        ll q = a / m;
        ll t = m;

        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;

        // Update y and x
        y = x - q * y;
        x = t;
    }

    // Make x positive
    if (x < 0)
       x += m0;

    return x;
}

void pairsort(ll a[],ll b[], ll n)
{
    pair<ll, ll> pairt[n];

    // Storing the respective array
    // elements in pairs.
    for (ll i = 0; i < n; i++)
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }

    // Sorting the pair array.
    sort(pairt, pairt + n);

    // Modifying original arrays
    for (ll i = 0; i < n; i++)
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}

ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<x;i++)
    {
        if(x<=a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
//ll v[500001], siz[500001];
//vector<ll>ve(0);
ll dp[1001][1001];
char ar[1001][1001];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    ll n, m;
    cin>>n>>m;
    REP(i, 0, n){
        REP(j, 0, m){
            cin>>ar[i][j];
        }
    }
    dp[0][0]=1;
    REP(j, 1, m){
        if(ar[0][j] == '#'){
                dp[0][j]=0;
        }
        else{
            dp[0][j] = dp[0][j-1];
        } 
    }
    REP(i, 1, n){
        REP(j, 0, m){
            if(ar[i][j] == '#'){
                dp[i][j]=0;
            }
            else{
                dp[i][j] = dp[i-1][j]%M;
                if(j == 0){continue;}
                dp[i][j] = (dp[i][j]+dp[i][j-1])%M;
            }
        }
    }
    cout<<dp[n-1][m-1]%M;
}


Measured memory_bytes: 9088
{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap.Strict    as M
import           Data.Sequence         ((<|), (><), (|>))
import qualified Data.Sequence         as S

import           Data.Array.IArray
import           Data.Array.MArray
import           Data.Array.IO

readi :: B.ByteString -> Int
readi bs | Just (n, _) <- B.readInt bs = n

calcDepth :: Int -> Array Int Int -> Int
calcDepth n pary = go 0 n
  where
    go !d !m
        | p == -1   = d
        | otherwise = go (d+1) p
      where
        p = pary ! m

printList :: [Int] -> IO ()
printList [] = putStr "[]"
printList (x:xs) = putStr ("[" ++ show x) >> go xs >> putStr "]"
  where
    go []     = return ()
    go (y:ys) = putStr (", " ++ show y) >> go ys

main :: IO ()
main = do
    n <- readLn :: IO Int
    let f (i:_:cs) = (i, cs)
    xss <- fmap (f . fmap readi . B.words) . B.lines <$> B.getContents
    -- xss :: [(Int, [Int])]

    paryM <- newArray (0, n-1) (-1) :: IO (IOArray Int Int)
    forM_ xss $ \(i, cs) -> do
        forM_ cs $ \c -> do
            writeArray paryM c i

    pary <- freeze paryM :: IO (Array Int Int)
    let cary = array (0, n-1) xss :: Array Int [Int]

    forM_ [0 .. n-1] $ \i -> do
        let parent = pary ! i
        let children = cary ! i
        putStr $ "node " ++ show i ++ ": "
        putStr $ "parent = " ++ (show parent) ++ ", "
        putStr $ "depth = " ++ (show $ calcDepth i pary) ++ ", "
        let ntype = case () of
                _ | parent == -1  -> "root"
                  | null children -> "leaf"
                  | otherwise     -> "internal node"
        putStr $ ntype ++ ", "
        printList children
        putStrLn ""



Measured memory_bytes: 48640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n;
    cin>>n;
    int ma=1e9;
    vector<int> b(n-1);
    for(int i=0;i<n-1;++i)cin>>b[i];
    int ans=0;
    for(int i=0;i<n-2;++i){
        ans+=min(b[i],b[i+1]);
    }
    ans+=min(ma,b[0]);
    ans+=min(b[n-2],ma);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  ll ans = 0;
  for (int i = 1; i < N+1; i++){
    if(i%3 == 0 || i%5 == 0){
      continue;
    }
    else{
      ans += i;
    }
  }
  cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  map<long long, long long> mp;

  for (int i = 0; i < N; i++) {
    long long a;
    cin >> a;
    mp[a]++;
  }

  int ans = 0;
  for (auto x : mp) {
    if (x.first > x.second) {
      ans += x.second;
    }
    if (x.first < x.second) {
      ans += (x.second - x.first);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6272
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[][] paper = new int[10][10];
        int max = 0;
        int counter = 0;
        
        for (int i = 0; i < paper.length; i++) {
            for (int j = 0; j < paper[i].length; j++) {
                paper[i][j] = 0;
            }
        }
        
        while (scanner.hasNext()) {
            String strLine = scanner.nextLine();
            String[] str = strLine.split(",");
            
            int x = Integer.parseInt(str[0]);
            int y = Integer.parseInt(str[1]);
            int size = Integer.parseInt(str[2]);

            paper[x][y]++;
            if (isInsidePaper(x, y-1)) paper[x][y-1]++;
            if (isInsidePaper(x-1, y)) paper[x-1][y]++;
            if (isInsidePaper(x+1, y)) paper[x+1][y]++;
            if (isInsidePaper(x, y+1)) paper[x][y+1]++;

            if (size >= 2) {
                if (isInsidePaper(x-1, y-1))    paper[x-1][y-1]++;
                if (isInsidePaper(x+1, y-1))    paper[x+1][y-1]++;
                if (isInsidePaper(x-1, y+1))    paper[x-1][y+1]++;
                if (isInsidePaper(x+1, y+1))    paper[x+1][y+1]++;
            }
            
            if (size == 3) {
                if (isInsidePaper(x, y-2))    paper[x][y-2]++;
                if (isInsidePaper(x-2, y))    paper[x-2][y]++;
                if (isInsidePaper(x+2, y))    paper[x+2][y]++;
                if (isInsidePaper(x, y+2))    paper[x][y+2]++;
            }
        }
        for (int i = 0; i < paper.length; i++) {
            for (int j = 0; j < paper[i].length; j++) {
                if (paper[i][j] == 0) {
                    counter++;
                } else {
                    if (paper[i][j] > max) max = paper[i][j];
                }
            }
        }
        System.out.println(counter);
        System.out.println(max);
    }
    
    public static boolean isInsidePaper(int x, int y) {
        if (x >= 0 && x <= 9 && y >= 0 && y <= 9) {
            return true;
        } else {
            return false;
        }
    }
}

Measured memory_bytes: 17380
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 998244353;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum,ans;
ll a,b,c,d,e,f,g,h,w,v;
ll x[800005],y[800005],z[900005];
char s[500][500];

int main(){	
	cin>>n;
	for(i=0;i<n;i++){
		cin>>s[i];
	}
	bool dame=false;
	for(i=0;i<n-1;i++){
		m = strlen(s[i]);
		if(s[i][m-1]!=s[i+1][0]){
			dame = true;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(i==j)continue;
			if(strlen(s[i])!=strlen(s[j]))continue;
			bool flag = false;
			for(k=0;k<strlen(s[i]);k++){
				if(s[i][k]!=s[j][k])flag = true;
			}
			if(!flag)dame = true;
		}
	}
	if(dame){
		p("No");
	}else{
		p("Yes");
	}
	
	return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <string>
#include <sstream>
#include <cstring>
#include <cmath>

using namespace std;

#ifdef DEBUG
#define LOG(args) cout << args << "\n"
#define debug(x) x
#else
#define LOG(args)
#define debug(x)
#endif

#define vi vector<int>
#define ii pair<int, int>
#define vii vector< ii >
#define vvi vector< vi >
#define mp make_pair
#define pb push_back
#define ms(x, v) memset(x, v, sizeof(x))
#define all(x) x.begin(), x.end()
#define REP(x, n) for(int x = 0; x < n; x++)
#define REPV(x, v, n) for(int x = v; x < n; x++)
#define REVE(x, n) for(int x = n; x >= 0; x--)

typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	string str;
	cin >> str;
	if(str == "RRR") cout << "3\n";
	else if(str == "RRS" || str == "SRR") cout << "2\n";
	else if(str.find("R") != string::npos) cout << "1\n";
	else cout << "0\n";
	return 0;
}


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

long long N, M;
long long H[100005];
long long A[100005];
long long B[100005];
bool good[100005];

int main(){
	cin >> N >> M;
	for(long long i = 0; i < N; i++) {
		cin >> H[i];
		good[i] = true;
	}
	for(long long i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
	}

	for(long long i = 0; i < M; i++) {
		if(H[A[i]] < H[B[i]]) {
			good[A[i]] = false;
		} else if (H[A[i]] == H[B[i]]) {
			good[A[i]] = false;
			good[B[i]] = false;
		} else {
			good[B[i]] = false;
		}
	}

	long long ans = 0;
	for(long long i = 0; i < N; i++) {
		if(good[i]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 6028
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const num = Number(lines.shift());
  const str = lines.shift();

  if (str.length <= num) {
    console.log(str);
    return;
  }

  console.log(str.substr(0, num) + "...");
});


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


def solve(A: int, B: int, M: int, a: "List[int]", b: "List[int]", x: "List[int]", y: "List[int]", c: "List[int]"):
    # sort_a = sorted(enumerate(a),key=lambda x: x[1])
    MINB = min(b)
    # print(sort_a)
    waribiki = [[] for _ in range(A)]
    for i in range(M):
        waribiki[x[i]-1].append((y[i]-1,c[i]))
    
    answer = 10**18

    for i in range(A):
        aa = a[i]
        for b_idx,cc in waribiki[i]:
            answer = min(aa+b[b_idx]-cc,answer)
        
        answer = min(aa+MINB,answer)
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    b = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(A, B, M, a, b, x, y, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42400
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

fn main() {
    input!{
      a: usize,
      b: usize,
      c: usize,
    }
    println!("{}", min(c, b/a));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
constexpr LL inv(LL x, LL m) { return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
constexpr LL mpow(LL a, LL k, LL m) { LL r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }

const int N = 3005, M = 1e9 + 7;
int n, q, A[N], X[N], Y[N], F[N][N];
int div2(int x) { return 1LL * x * (M + 1) /  2 % M; }
int mmul(int a, int b) { return 1LL * a * b % M; }
int madd(int a, int b) { return (a + b) % M; }

int main() {
    scanf("%d%d", &n, &q);
    FI(i, 1, n) scanf("%d", A + i);
    FI(i, 1, n) FI(j, 1, n) if (A[i] > A[j]) F[i][j] = 1;
    FI(tt, 1, q) {
        int x, y;
        scanf("%d%d", &x, &y);
        int tx[N], fx[N];
        FI(i, 1, n) {
            if (i == x || i == y) continue;
            tx[i] = div2(madd(F[i][x], F[i][y]));
            fx[i] = div2(madd(F[x][i], F[y][i]));
        }
        FI(i, 1, n) {
            if (i == x || i == y) continue;
            F[i][x] = F[i][y] = tx[i];
            F[x][i] = F[y][i] = fx[i];
        }
        F[x][y] = F[y][x] = div2(madd(F[x][y], F[y][x]));
    }
    int tt = mpow(2, q, M);
    int ans = 0;
    FI(i, 1, n) FI(j, i + 1, n) {
        ans = madd(ans, int(1LL * tt * F[i][j] % M));
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 35456
def main():
  n,k,*t=map(int,open(0).read().split())
  e=[set()for _ in[0]*n]
  for a,b in zip(t[::2],t[1::2]):
    e[a-1]|={b-1}
    e[b-1]|={a-1}
  c,q=k,[0]
  while q:
    v=q.pop()
    for i,w in enumerate(e[v],1):
      c=c*(k-i-(v>0))%(10**9+7)
      e[w]-={v}
      q+=w,
  print(c)
main()

Measured memory_bytes: 49216
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[5],s,ss;
bool d[5];
char c[5];
void DFS(int k)
{
	if(k>3&&s==7)
	{	
		if(ss==0)
		{
			printf("%d",a[0]);
			for(int i=1;i<k;i++)
			{
				printf("%c%d",c[i],a[i]);
			}
			printf("=7\n");
		}
		ss++;
		return;
	}
	if(k>3)return;
	for(int i=0;i<2;i++)
	{
		if(i==0)
		{
			s-=a[k];
			c[k]='-';
			DFS(k+1);
			s+=a[k];
		}
		else 
		{
			s+=a[k];
			c[k]='+';
			DFS(k+1);
			s-=a[k];
		}
	}
}
int main()
{
    int n;
	scanf("%d",&n);
	a[3]=n%10;
	a[2]=n/10%10;
	a[1]=n/100%10;
	a[0]=n/1000;
	s=a[0];
	ss=0;
	DFS(1);
    return 0;
}

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

const int N = 1e5+5;
int n, m, a, b;
vector<int> mm[N];
int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
 // freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
  cin >> n >> m;
  multiset<int> s;
  for(int i = 0; i < n; ++i){
    cin >> a >> b;
    mm[a].push_back(b);
  }
  long long ans = 0;
  for(int i = 1; i <= m; ++i){
    sort(mm[i].begin(), mm[i].end(), greater<int>());
    for(int j = 0; j < (int)mm[i].size(); ++j){
      s.insert(mm[i][j]);
    }
    if(s.size()) {
      auto it = s.end();
      --it;
      ans += *it;
      s.erase(it);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 7808
def inpl():
    return list(map(int, input().split()))


N, X, Y = inpl()
X -= 1
Y -= 1
ans = {i: 0 for i in range(N)}
for i in range(N):
    for j in range(i + 1, N):
        c = min(j - i, abs(i - X) + 1 + abs(j - Y), abs(i - Y) + 1 + abs(j - X))
        ans[c] += 1

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


Measured memory_bytes: 48732
#include <iostream>                                          
using namespace std;                                         
                                                             
int main(void) {                                             
  int H, W;                                                  
  while (true) {                                             
    cin >> H >> W;                                           
    if (H==0 && W==0) {                                      
      break;                                                 
    }                                                        
    for (int i=0; i<H; i++) {                                
      for (int j=0; j<W; j++) {                              
        if (i==0 || i==H-1 || j==0 || j==W-1) {              
          cout << "#" << flush;                              
        } else {                                             
          cout << "." << flush;                              
        }                                                    
      }                                                      
      cout << endl;                                          
    }                                                        
    cout << endl;                                            
  }                                                          
  return 0;                                                  
}                                     

Measured memory_bytes: 3116
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    n = ii()
    cnt = 0
    flag = False
    for i in range(n):
        a,b = mi()
        if a==b:
            cnt+=1
            if cnt == 3:
                flag = True
        else:
            cnt=0
    if flag:
        print(yes)
    else:
        print(no)


main()


Measured memory_bytes: 10016
#include<iostream>
#include<cstdio>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
    double x1, x2, y1, y2;
    double dist;
    cin >> x1 >> y1 >> x2 >> y2;
    
    double distx = fabs(x2-x1);
    double disty = fabs(y2-y1);
    dist = sqrt(pow(distx,2) + pow(disty,2)) * 1.0;
    
    printf("%.5f", dist);
    
    return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std ;
int main () {
int A , B , K ; cin >> A >> B >> K ;
for ( int i = min (A , B ); i >= 1; --i ) {
if ( A % i == 0 && B % i == 0) {
--K ;
if ( K == 0) {
cout << i << endl ;
return 0;
}
}
}
assert ( false );
}

Measured memory_bytes: 3604
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

t = input()
print(t.replace("?","D"))


Measured memory_bytes: 69712
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		long maxvalue = (long) Integer.MAX_VALUE;

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		ArrayList<Long> inputList = new ArrayList<Long>();
		ArrayList<Long> dp = new ArrayList<Long>();

		sc.nextLine();

		inputList.add((long) 0);
		for (int i = 0; i < n; i++) {
			inputList.add(sc.nextLong());
		}

		dp.add(maxvalue);
		for (int i = 0; i < n; i++) {
			dp.add(maxvalue);
		}

		dp.set(1, (long) 0);
		for (int j = 1; j < n; j++) {
			// 1つ先に進む
			if (j + 1 <= n) {
				dp.set(j + 1, Math.min(dp.get(j + 1), Math.abs(inputList.get(j) - inputList.get(j + 1)) + dp.get(j)));
			}

			// 2つ先に進む
			if (j + 2 <= n) {
				dp.set(j + 2, Math.min(dp.get(j + 2), Math.abs(inputList.get(j) - inputList.get(j + 2)) + dp.get(j)));
			}
		}

		System.out.println(dp.get((int) n));

	}
}


Measured memory_bytes: 62884
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

k = inp[0]
ans = 0
(1..k).each do |i1|
  (1..k).each do |i2|
    (1..k).each do |i3|
      ans += i1.gcd(i2).gcd(i3)
    end
  end
end
p ans

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

int main() {
  string s;
  cin >> s;
  int n = s.size();

  bool r = s[0] == '1' && s[n - 1] == '0';
  for (int i = 1; i <= n / 2; i++) {
    r &= s[i - 1] == s[n - i - 1];
  }
  if (!r) {
    cout << -1 << endl;
    return 0;
  }

  vector<pair<int, int>> v;
  int t = 1;
  for (int i = 2; i <= n; i++) {
    v.push_back({t, i});
    if (s[i - 2] == '1') {
      t = i;
    }
  }

  for (auto e : v) {
    cout << e.first << " " << e.second << endl;
  }
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main{

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

        // input
        final int NUM = scan.nextInt();
        final int DIMENSION = scan.nextInt();
        int[][] points = new int [NUM][DIMENSION];
        for(int i = 0; i < NUM; i++){
            for(int j = 0; j < DIMENSION; j++){
                points[i][j] = scan.nextInt();
            }
        }

        // search
        int count = 0;
        for(int i = 0; i < NUM - 1; i++){
            for(int j = i + 1; j < NUM; j++){
                double sum = 0.0;
                for(int k = 0; k < DIMENSION; k++){
                    sum += Math.pow(points[i][k] - points[j][k] , 2);
                }
                sum = Math.sqrt(sum);
                if(sum == (int)sum){
                    count++;
                }
            }
        }

        // answer
        System.out.println(count);

    }
}

Measured memory_bytes: 22996
s = [int(i) for i in input().split(" ")]
count = 0

if s[0] < s[1]:
    for i in range(s[0], s[1]):
        if i == s[2]:
            print("Yes")
            count = 1
            break

else:
    for i in range(s[1], s[0]):
        if i == s[2]:
            print("Yes")
            count = 1
            break

if count == 0:
    print("No")





Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(c-a+b,0);
    
    
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  ll ans = 0;
  if(n > m) swap(n, m);
  if(n > 2 && m > 2) ans += (ll)(n-2) * (m-2);
  if(n == 1 && m == 1) ans = 1;
  else if(n == 1) ans = m - 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,D = map(int,input().split())
ans = (N-1) // (2*D+1) + 1
print(ans)

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


void solve(long long A, long long B){
    int ans = 0, i = 0;
    while (ans < B)
    {
        ans = A + (A - 1) * (i - 1);
        i++;
    }
    cout << i - 1 << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3640
require 'set'; require 'prime'
INF=Float::INFINITY
n = gets.chomp.to_i
ab = n.times.map{gets.split.map(&:to_i)}

cur = 0
ab.sort_by{|a,b| b}.each do |a, b|
  if cur + a <= b
    cur += a
  else
    puts 'No'
    exit
  end
end

puts 'Yes'

Measured memory_bytes: 22776