akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define hell                         1000000007
#define M                            1000000007
#define Maxi                      10000000000000000
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
 
#define vll                          vector<ll>
#define vi                           vector<long long>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
//#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first  
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define dbg(x)                       cout << #x << " is " << x << endl;
#define endl                           '\n'
 //const ll infl=0x3f3f3f3f3f3f3f3fLL;

 #define pi                           3.141592653589793238
// Debug //
 
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

using namespace std;
//ll a[200005];



int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

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

    sort(all(v));

    for(i=n-1;i>=0;i--)
    {
        for(j=i-1;j>=0;j--)
        {
            ll x=lbnd(all(v),v[i]+v[j])-v.begin();
            ll y=n-x;
            ans+=n-1-i-y;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3676
//ALDS1_12B
#include <iostream>
using namespace std;

static const int MAX=100;
static const int INF=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

int dijkstra(){
 int minv;
 int d[MAX],color[MAX];
 for(int i=0;i<n;i++){
  d[i]=INF;
  color[i]=WHITE;
 }
 d[0]=0;
 color[0]=GRAY;
 while(true){
  minv=INF;
  int u=-1;
  for(int i=0;i<n;i++){
   if(minv>d[i] && color[i]!=BLACK){
    u=i;
    minv=d[i];
   }
  }
  if(u==-1) break;
  color[u]=BLACK;
  for(int v=0;v<n;v++){
   if(color[v]!=BLACK && M[u][v]!=INF){
    if(d[v]>d[u]+M[u][v]){
     d[v]=d[u]+M[u][v];
     color[v]=GRAY;
    }
   }
  }
 }
 for(int i=0;i<n;i++){
  cout<<i<<" "<<(d[i]==INF ? -1:d[i])<<endl;
 }
} 

int main(){
 cin>>n;
 for(int i=0;i<n;i++){
  for(int j=0;j<n;j++){
   M[i][j]=INF;
  }
 }
 int k,c,u,v;
 for(int i=0;i<n;i++){
  cin>>u>>k;
  for(int j=0;j<k;j++){
   cin>>v>>c;
   M[u][v]=c;
  }
 }
 dijkstra();
 return 0;
}

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

int main() {
  string s;
  cin >> s;
  int count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '2') count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
	int N, T, c;
	cin >> N >> T;
	int MIN, max_profit = 0, count = 0;
	cin >> MIN;
	rep(i, N - 1){
		cin >> c;
		if(max_profit == c - MIN)
			count++;
		else if(max_profit < c - MIN){
			count = 1;
			max_profit = c - MIN;
		}
		MIN = min(MIN, c);
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())

limit=int(m**(1/2))+1

divisors=[]
for d in range(1,limit):
    if m%d==0:
        divisors.append(d)
        divisors.append(m//d)

divisors.sort()
ans=1

for d in divisors:
    if n*d<=m:
        ans=d
print(ans)


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N; cin >> N;
	vector<int> A(N);

	REP(i,N) cin >> A[i];

	bool dec = false;
	bool inc = false;
	int ans = 0;

	FOR(i,1,N){
		if(A[i] == A[i-1]) continue;
		else if(A[i] > A[i-1] and !dec) inc = true;
		else if(A[i] < A[i-1] and !inc) dec = true;
		else if(A[i] > A[i-1] and dec){
			ans++;
			inc = false;
			dec = false;
		}else if(A[i] < A[i-1] and inc){
			ans++;
			inc = false;
			dec = false;
		}
	}
	ans++;
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>
#include <functional>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846264338327950L

int main() {
	int x, n, ans = 100, diff=100;
	cin >> x >> n;
	vector<int> p(100), memo(102,0);
	rep(i, n) {
		cin >> p[i];
		memo[p[i]] = 1;
	}

	if (n == 0) {
		cout << x << endl;
		return 0;
	}

	for(int i=0;i<=101;i++) {
		if (memo[i]==0) {
			if (diff > abs(i - x)) {
				diff = abs(i - x);
				ans = i;
			}
			else if (diff == abs(i - x)) {
				ans = min(ans, i);
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

// 多次元 mul_array<int, 1, 2, 3> a
template <typename T, std::size_t... Ns>
struct index_reverse_for_array;
template <typename T, std::size_t N, std::size_t... Ns>
struct index_reverse_for_array<T, N, Ns...> { using type = std::array< typename index_reverse_for_array<T, Ns...>::type, N>; };
template <typename T, std::size_t N>
struct index_reverse_for_array<T, N> { using type = std::array<T, N>; };
template <class T, std::size_t... Ns> using mul_array = typename index_reverse_for_array<T, Ns...>::type;

// デバッグ用 dump マクロ
template <int N, int S> constexpr void temp_dump_split(const char *s, int i) { }
template <int N, int S, class V, class... Vs> constexpr void temp_dump_split(const char *s, int i, V v, Vs... vs) {
    if (i == S || s[i] == ',') { std::cerr << " = " << v << std::endl; temp_dump_split<N, S, Vs...>(s, i+1, vs...); return; }
    else if (s[i] != ' ') { cerr << s[i]; temp_dump_split<N, S, V, Vs...>(s, i+1, v, vs...); }
    else temp_dump_split<N, S, V, Vs...>(s, i+1, v, vs...);
}
template <std::size_t S, class... Ts>
static constexpr void temp_dump(const char (&s)[S], Ts... vs) { temp_dump_split<sizeof...(Ts), S, Ts...>(s, 0, vs...); }
#define dump(...) temp_dump(#__VA_ARGS__, __VA_ARGS__)

int main() {
    //cout << fixed << setprecision(10);

    //cout.setf(ios::right, ios::adjustfield);
    //cout.fill('0');
    //cout << setw(2) << "" << endl;

    string t, b;
    cin >> t >> b;

    constexpr uint64_t MOD = 1000000007;

    vector<uint64_t> dp(b.size() + 1, 0);
    dp[0] = 1;

    for (int i = 0; i < t.size(); i++) {
        for (int j = dp.size() - 1; j > 0; j--) {
            if (t[i] == b[j-1])
                dp[j] = (dp[j] + dp[j-1]) % MOD;
            else
                dp[j] = dp[j];
        }
    }

    cout << dp[dp.size() - 1] << endl;

    return 0;
}

//cout << 1["hello"] << endl;




Measured memory_bytes: 3216
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

	double v_max;
	v_max = (L / 3.0)*(L / 3.0)*(L / 3.0);

	printf("%.8f", v_max);
	return 0;
}

Measured memory_bytes: 3724
#include <cstdio>
using namespace std;

int main(){
    int i, a[3];
    int five = 0, seven = 0;
    scanf("%d %d %d", &a[0], &a[1], &a[2]);

    for (i = 0; i < 3; i++) {
        if (a[i] == 5)  five++;
        if (a[i] == 7)  seven++;
    }
    
    if (five == 2 && seven == 1)    puts("YES\n");
    else    puts("NO\n");

    return (0);
}

Measured memory_bytes: 128
n = int(input())
i = 1

while (i <= n):
    x = i
    if (x % 3 == 0):
        print(' ' + str(i), end = '')
        i += 1
        continue
    if (x % 10 == 3):
        print(' ' + str(i), end = '')
        i += 1
        continue
    x //= 10
    while (x):
        if (x % 10 == 3):
            print(' ' + str(i), end = '')
            break
        x //= 10
    i += 1
print()


Measured memory_bytes: 5868
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static long Calc(long n, long m) {
        if (m < 2) return 0;

        if (n == 0) {
            var a = m / 4;
            if (a == 0) return 0;
            return Calc(a, m - a * 2);
        }

        long lo = 0;
        long hi = n;
        long max = 0;
        while (lo <= hi) {
            long mid = (lo + hi) / 2;

            if (mid * 2 <= m) {
                max = Math.Max(max, mid);
                lo = mid + 1;
            }
            else {
                hi = mid - 1;
            }
        }

        return max + Calc(n - max, m - max * 2);
    }

    static void Main() {
        var nm = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long n = nm[0], m = nm[1];
        Console.WriteLine(Calc(n, m));
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  int A,B,C;
  str S1,S2,S3;
  vector<int>N(3);
  cin>>A;
  cout<<"ABC"<<A<<endl;
}


Measured memory_bytes: 256
#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 a,b,c; cin >> a >> b >> c;
	if (a <= c && c <= b){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dp[110][110] = {};
int main()
{
    int r, c; cin >> r >> c;
    int m[r+1][c+1] = {};
    rep(i, r){
        string s;cin >> s;
        rep(j, c){
            if(s[j]=='#') m[i][j]=1;
        }
    }
    rep(i, r) rep(j, c) dp[i][j] = INF;
    dp[0][0] = m[0][0];
    rep(i, r) rep(j, c){
        int cost = 0;
        if(m[i][j] == 0 && m[i+1][j] == 1) cost = 1;
        chmin(dp[i+1][j], dp[i][j]+cost);
        cost = 0;
        if(m[i][j] == 0 && m[i][j+1] == 1) cost = 1;
        chmin(dp[i][j+1], dp[i][j]+cost);
    }

    pr(dp[r-1][c-1]);
    return 0;}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

int main(void) {
    char a;
    cin >> a;

    if ('A' <= a && a <= 'Z') cout << "A" << endl;
    else cout << "a" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;

int main(void)
{
    sync;
    int n,m;
    cin>>n>>m;
    int res=n*(n-1)/2;
    res+=m*(m-1)/2;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

long long int mod = 998244353;
long long *power_3, *power_2;

long long Mod(long long b) {
    b %= mod;
    return b >= 0 ? b : b + mod;
}

const int N = 310;
long long dp[N][N * N][2];

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

    power_3 = (long long *)malloc((sizeof(long long) * (n + 1)));
    power_2 = (long long *)malloc((sizeof(long long) * (n + 1)));
    power_3[0] = 1;
    power_2[0] = 1;
    for (int i = 1; i <= n; i++) {
        power_3[i] = Mod(3 * power_3[i - 1]);
        power_2[i] = Mod(2 * power_2[i - 1]);
    }

    long long total_cnt = Mod(power_3[n]);

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

    long long R_max = 0;
    dp[0][0][0] = 1;
    dp[0][0][1] = 1;
    for (int i = 0; i < n; i++) {
        R_max += a[i];
        for (int r = 0; r <= R_max; r++) {
            dp[i + 1][r][1] = Mod(2 * dp[i][r][1]);
            dp[i + 1][r][0] = Mod(dp[i][r][0]);
            if (r >= a[i]) {
                dp[i + 1][r][1] = Mod(dp[i + 1][r][1] + dp[i][r - a[i]][1]);
                dp[i + 1][r][0] = Mod(dp[i + 1][r][0] + dp[i][r - a[i]][0]);
            }
        }
    }

    long long ans = total_cnt;
    for (int i = (R_max + 1) / 2; i <= R_max; i++) {
        ans = Mod(ans - Mod(3 * dp[n][i][1]));
    }
    if (R_max % 2 == 0) {
        ans = Mod(ans + Mod(3 * dp[n][R_max / 2][0]));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 448256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

using Weight = int;
struct Edge {
	int src, dst, id; Weight weight;
	Edge() {}
	Edge(int s, int d, int id, Weight w) : src(s), dst(d), id(id), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

struct UnionFind {
	vector<int> par;
	int cnt;
	UnionFind(int size_) : par(size_, -1), cnt(size_) {}
	void unite(int x, int y) {
		if((x = find(x)) != (y = find(y))) {
			if(par[y] < par[x]) swap(x, y);
			par[x] += par[y]; par[y] = x; cnt--;
		}
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	int size(int x) { return -par[find(x)]; }
	int size() { return cnt; }
};

int N, M;
bool operator < (const Edge &e, const Edge &f) { return e.weight < f.weight; }
pair<Weight, Edges> kruskal(Edges es) {
	UnionFind uf(N);
	Weight total = 0; Edges T;
	for(auto &e : es)if(!uf.same(e.src, e.dst)) {
		T.push_back(e); total += e.weight; uf.unite(e.src, e.dst);
	}
	return make_pair(total, T);
}

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

	while(cin >> N >> M) {
		vector<Edge> es(M);
		for(int i = 0; i < M; i++) {
			int a, b, w;
			cin >> a >> b >> w;
			a--, b--;
			es[i] = Edge(a, b, i, w);
		}
		sort(es.begin(), es.end());

		int req = 0, total = 0;
		auto res = kruskal(es);
		for(Edge& e : res.second) {
			Edges es2;
			for(int i = 0; i < M; i++) {
				if(es[i].id == e.id) continue;
				es2.push_back(es[i]);
			}
			auto res2 = kruskal(es2);
			if(res2.second.size() != N - 1 || res.first < res2.first) {
				req++;
				total += e.weight;
			}
		}

		cout << req << " " << total << endl;
	}
}

Measured memory_bytes: 5400
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<utility>
#include<iterator>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
//#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
#define ff(a,n) for(ll i=a;i<n;i++)
#define cY cout<<"YES\n"
#define cN cout<<"NO\n"
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define sc second
#define fs first
#define c(a) cout<<a<<endl

void solve()
{
	ll x, k, d; cin>>x>>k>>d;
	x=abs(x);
	ll y=min(x/d, k); x=x-(y*d);
	k-=y;
	if(k%2==0)		
	cout<<x;
	else cout<<abs(x-d);
}

int main()
{
	solve();
}
/*


1000000000000000 1000000000000000 1000000000000000

*/


Measured memory_bytes: 3640
#! /usr/bin/env python3

def main():
    N = int(input())
    S = input()
    q = set(S)
    ans = 0
    for i in range(1, N):
        a = set(S[:i])
        b = set(S[i:])
        cnt = 0
        for j in q:
            if j in a and j in b : cnt += 1
        ans = max(cnt, ans)
    print(ans)
main()

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

long long int N, ans;
vector<long long> A;

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld", &ans);
        A.push_back(ans);
    }
    partial_sum(A.begin(), A.end(), A.begin());
    ans = 300000000000000;
    auto it = A.begin() + 1, ed = A.end() - 1, a = A.begin(), b = it + 1;
    for(; it + 1 != ed; ++it){
        while(a + 1 != it){
            if(*a < *it - * (a + 1)){
                ++a;
            }else{
                break;
            }
        }
        if(b == it)++b;
        while(b + 1 != ed){
            if(*b - *it < *ed - * (b + 1)){
                ++b;
            }else{
                break;
            }
        }
        ans = min<long long>(ans, max<long long>({*a, *it - *a, *b - *it, A[N - 1] - *b}) - min<long long>({*a, *it - *a, *b - *it, A[N - 1] - *b}));
    }
    cout << ans << endl;
    return 0;
}

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

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    ll t = 0;
    while(a < b){
        if(a < 0) a++, t += c;
        else if(a == 0) a++, t += d+e;
        else a++, t += e;
    }
    cout << t << "\n";
    return 0;
}



Measured memory_bytes: 3088
// AOJ ITP2_10_A Bit Operation I
// 2019.3.8 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

unsigned in()   // 非負整数の入力
{
	unsigned n = 0;
	int c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void outb(unsigned n)   // 非負整数の2進数表示、最後に改行あり
{
	int i;
	char ob[40];

	i = 0; while (i < 32) ob[i++] = (n & 1) + '0', n >>= 1;
	while (i--) pc(ob[i]);
	pc('\n');
}

int main()
{
	unsigned x;

	x = in();
	outb(x);
	outb(~x);
	outb(x << 1);
	outb(x >> 1);
	return 0;
}


Measured memory_bytes: 2084
using System;

namespace _2012
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                int ret = int.MaxValue;
                for (int i = 0; Math.Pow(i,3) <= n; i++)
                {
                    int x = n - (int)Math.Pow(i,3);
                    int a = (int)Math.Floor(Math.Sqrt(x));
                    ret = Math.Min(ret,i + a + (x - a * a));
                }
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 9572
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));

#define MAX_V 10

struct edge { int to, cost; }; //cost >= 0

int V, E, r; //頂点数、辺数、始点
vector<edge>G[MAX_V]; //グラフ情報
int d[MAX_V]; //最短距離

signed main() {
	cin >> V >> E;
	rep(i, E) {
		int s, t;
		edge e;
		cin >> s >> t;
		s--; t--;
		e.to = t;
		e.cost = 1;
		G[s].push_back(e);
		e.to = s;
		e.cost = 1;
		G[t].push_back(e);
	}
	vector<int>v(V - 1);
	rep(i, V - 1)v[i] = i + 1;
	int ans = 0;
	do {
		bool can = true;
		int nv = 0;
		for (int j = 0; j < V - 1; j++) {
			bool isOK = false;
			int next = v[j];
			for (int i = 0; i < G[nv].size(); i++) {
				edge e = G[nv][i];
				if (e.to == next)isOK = true;
			}
			if (!isOK)can = false;
			nv = next;
		}
		if (can)ans++;
	} while (next_permutation(v.begin(), v.end()));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359



int main() {
	string N;
	cin >> N;
	if (N[0] == N[2]) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;

	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
const ll MOD = 1e9 + 7;

int main()
{
    int s, w; cin >> s >> w;

    cout << ((s <= w) ? "unsafe" : "safe") << endl;
 
    return 0;
}



Measured memory_bytes: 3584
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using System.Text;

namespace abc154
{
    class Program
    {
        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc154C();
        }
        public static void solve_abc154C()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Array.Sort(a);
            bool ok = true;
            for (int i = 0; i < n - 1; i++)
            {
                if (a[i] == a[i + 1])
                {
                    ok = false;
                    break;
                }
            }
            if (ok)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }

        public static void solve_abc154B()
        {
            string str = Console.ReadLine();
            StringBuilder newStr = new StringBuilder();
            for (int i = 0; i < str.Length; i++) 
            {
                newStr.Append("x");
            }
            Console.WriteLine(newStr.ToString());
        }

        public static void solve_abc154A()
        {
            string[] color = Console.ReadLine().Split();
            int[] number = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            string rm = Console.ReadLine();

            if (rm == color[0])
            {
                number[0]--;
                Console.WriteLine("{0} {1}", number[0], number[1]);
            }
            else
            {
                number[1]--;
                Console.WriteLine("{0} {1}", number[0], number[1]);
            }
        }
    }
}


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

using namespace std;

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

	long long N;

	cin >> N;

	vector<long long> dvs;
	for (int i = 1; i <= N / i; i++) {
		if (N % i == 0) {
			if (i > 1)
				dvs.push_back(i);
			if (i != N / i)
				dvs.push_back(N / i);
		}
	}

	long long ans = 0;
	for (const auto & x : dvs) {
		if (N / (x - 1) == N % (x - 1))
			ans += x - 1;
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <stack>
using namespace std;
#define N 10003
#define PI 3.14159265358979323
#define INF 0x3f3f3f3f
#define MOD 100000007
#define ll long long
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
int n,a[N];
int gp[11];
int W,H;
int cnt=0;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int us[11];
void dfs ( int x )
{
	int i;
	int nx,ny;
	i=1;
	while ( i<10&&(us[x+i]==1||gp[x+i]<=gp[x]) )
	i++;
	
	if ( x+i<10&&gp[x+i]>gp[x]&&us[x+i]==0 )
	{
		us[x+i]=1;
		dfs(x+i);
	}

}

//template < class T> void read ( T &x ){	char c;int sign=1;x=0;while ( c=getchar(),(c>'9'||c<'0')&&c!='-') ;if ( c=='-' ){sign=-1;}else x=c-'0';while ( c=getchar(),c<='9'&&c>='0' ){x=x*10+c-'0';}x=x*sign;}
int main ( )
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int i,j;
	int f;
	cin>>n;
	while (n-- )
	{
		f=0;
		memset ( us,0,sizeof(us));
		for ( i=0;i<10;i++ )
		{
			cin>>gp[i];
		}
		cnt=0;
		
		for ( i=0;i<10;i++ )
		{
			if ( us[i]==0 )
			{
				cnt++;
				us[i]=1;
				dfs(i);
			}
		}
		
		if ( cnt==2 )
		f=1;
		
		
		if ( f )
		printf("YES\n");
		else
		printf("NO\n");
		
		//printf( "%d\n",cnt); 
		
	} 
	
	return 0;
}
	



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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n; cin>>n;
  int p = n/2;
  if(n%2) p++;
  long double ans = (p*1.0)/n;
  cout<<ans<<endl;
}



Measured memory_bytes: 256
N = int(input())
v = list(map(int, input().split()))
d_ki = {0 : 0, -1 : 0}
d_gu = {-2 : 0, -3 : 0}
for i in range(N):
    if i % 2 == 0:
        if v[i] not in d_ki:
            d_ki[v[i]] = 1
        else:
            d_ki[v[i]] += 1
    else:
        if v[i] not in d_gu:
            d_gu[v[i]] = 1
        else:
            d_gu[v[i]] += 1
ki = sorted(d_ki.items(), key=lambda x : x[1], reverse=True)
gu = sorted(d_gu.items(), key=lambda x : x[1], reverse=True)
ans = 0
for i in range(2):
    for j in range(2):
        if ki[i][0] == gu[j][0]:
            continue
        ans = max(ans, ki[i][1] + gu[j][1])
print(N - ans)

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

#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define pb push_back

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

template<typename T> using V = vector<T>;

const int MAXN = 2e3 + 10;
const ll MOD = 1e9 + 7;
ll f[MAXN], invf[MAXN];

ll binpow(ll a, ll b, const ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int mod_inverse(int x, const int m = MOD) {
	return binpow(x, m - 2, m);
}

ll nCr(int n, int r) {
	if(r > n)
		return 0;
	ll ans = f[n];
	ans = (ans * invf[r]) % MOD;
	ans = (ans * invf[n - r]) % MOD;
	return ans;
}

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	int N, K; cin >> N >> K;
	int R = N - K, B = K;
	f[0] = f[1] = 1;
	for(int i = 2; i < MAXN; ++i)
		f[i] = (f[i - 1] * i) % MOD;
	invf[MAXN - 1] = mod_inverse(f[MAXN - 1]);
	for(int i = MAXN - 2; i >= 0; --i) 
		invf[i] = (invf[i + 1] * (i + 1)) % MOD;
	for(int i = 1; i <= K; ++i) {
		ll ans = nCr(R + 1, i);
		ans = (ans * nCr(B - 1, i - 1)) % MOD;
		cout << ans << '\n';
	}
	return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

#define fcout(n) std::cout << std::fixed << std::setprecision((n))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::pair<int,int> PII;

typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector<PII> VPII;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef long long Weight;
const Weight WEIGHT_INF = std::numeric_limits<Weight>::max()/4;

struct Edge {
    int src, dst;
    Weight weight;
};
bool operator<(const Edge& a, const Edge& b) {
    return (a.weight < b.weight);
};
bool operator>(const Edge& a, const Edge& b) {
    return (a.weight > b.weight);
};
typedef std::vector<Edge> Edges;
typedef std::vector<Edges> Graph;

std::vector<std::vector<Weight>> g;
std::vector<std::vector<int>> trace;
void warshallFloyd() {
    int n = g.size();
    trace.resize(n, std::vector<int>(n, -1));
    REP(k, n) REP(i, n) REP(j, n) {
        if(g[i][k] == WEIGHT_INF || g[k][j] == WEIGHT_INF){
            continue;
        }
        g[i][j] = std::min(g[i][j], g[i][k] + g[k][j]);
    }
}

int N, M, R;
VI r;
int main() {
    std::cin >> N >> M >> R;
    r.resize(R);
    REP(i, R) {
        std::cin >> r[i];
        --r[i];
    }
    g.resize(N, std::vector<Weight>(N, WEIGHT_INF));

    int a, b, c;
    REP(i, M) {
        std::cin >> a >> b >> c;
        --a, --b;
        g[a][b] = c;
        g[b][a] = c;
    }

    warshallFloyd();

    int ans = std::numeric_limits<int>::max();
    SORT(r);
    do {
        int sum = 0;
        for(int i=0; i<R-1; ++i) {
            sum += g[r[i]][r[i+1]];
        }
        ans = std::min(ans, sum);
    }while(std::next_permutation(ALL(r)));

    std::cout << ans << std::endl;
}

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

const int nm = 1e5;
int n, q, k;
long long d[nm];
vector<pair<int, int>> g[nm];

void dfs(int v, int p) {
	for (auto &e : g[v]) {
		if (e.first == p)
			continue;
		d[e.first] = d[v] + e.second;
		dfs(e.first, v);
	}
}

int main() {
	cin >> n;
	for (int i = 0, a, b, c; i < n - 1; i++) {
		cin >> a >> b >> c, a--, b--;
		g[a].emplace_back(b, c);
		g[b].emplace_back(a, c);
	}
	cin >> q >> k, k--;
	d[k] = 0, dfs(k, -1);
	for (int i = 0, x, y; i < q; i++) {
		cin >> x >> y, x--, y--;
		cout << d[x] + d[y] << endl;
	}

}


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

int main(){
 
 string ans="";

 ll n;
 cin>>n;

 while(n)
 {
     n=n-1;
     ans.push_back('a'+n%26);
     n/=26;

 }
reverse(ans.begin(),ans.end());
 cout<<ans;

    return 0;
}
    

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

int main() {
    string s;
    cin >> s;
    int L,R;
    L = (s.at(0)-'0')*10 + (s.at(1)-'0');
    R = (s.at(2)-'0')*10 + (s.at(3)-'0');
    string ans;
    if(R >= 1 && R <= 12) ans = "YYMM";
    if(L >= 1 && L <= 12) ans = "MMYY";
    if(L>=1&&L<=12){
        if(R>=1&&R<=12) ans = "AMBIGUOUS";
    }
    if(L == 0 || L > 12){
        if(R == 0 || R > 12) ans = "NA";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		List<String> list = new ArrayList<>(N);
		
		String fast = sc.next();
		list.add(fast);
		
		char last = fast.charAt(fast.length() - 1);
		for (int i = 1; i < N; i++) {
			String w = sc.next();
			if (list.contains(w)) {
				System.out.println("No");
				return;
			}
			list.add(w);
			
			char last_c = w.charAt(w.length() - 1);
			if (last != w.charAt(0)) {
				System.out.println("No");
				return;
			}
			
			last = last_c;
		}
		
		System.out.println("Yes");
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 100005;
int ran[MAX_N],par[MAX_N];
set<int> s;

void init()
{
	rep(i,MAX_N)
	{
		ran[i] = 1;
		par[i] = i;
	}
}

int find(int x)
{
	if (par[x] == x) return x;
	return par[x] = find(par[x]);
}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (ran[x] > ran[y]) swap(x,y);
	par[x] = y;
	ran[y]++;
	return;
}

int main()
{
	init();
	int N,M;
	cin >> N >> M;
	rep(i,M)
	{
		int x,y,z;		
		cin >> x >> y >> z;
		x--; y--;
		unite(x,y);
	}
	rep(i,N)
	{
		s.insert(find(i));
	}
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    string s;
    lint k;
    cin >> s >> k;
    int n = s.length();
    s = s + "#";
    int flag = 0;
    vector<int> d;
    for (int i = 0; i < n; i++) {
        if (s[i] == s[i + 1]) {
            flag++;
        } else {
            d.push_back(flag + 1);
            flag = 0;
        }
    }
    if (d.size() == 1) {
        cout << n * k / 2 << endl;
        return 0;
    } else {
        lint ans = 0;
        for (int i = 1; i < d.size() - 1; i++) {
            ans += d[i] / 2;
        }
        ans *= k;
        ans += d[0] / 2 + d[d.size() - 1] / 2;
        if (s[0] == s[n - 1]) {
            ans += (d[0] + d[d.size() - 1]) / 2 * (k - 1);
        } else {
            ans += (d[0] / 2 + d[d.size() - 1] / 2) * (k - 1);
        }
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cstdlib>
#define for(i,a,b) for(i=a;i<b;i++)	
#define MM 1001
int xJ[MM][MM],xO[MM][MM],xI[MM][MM];
int yJ[MM][MM],yO[MM][MM],yI[MM][MM];
char put[MM][MM];
using namespace std;
int main(void)
{
	int n,m,i,j,k,qs,a,b,c,d,sum1,sum2,sum3;

	//??\???
	cin>>m>>n>>k;
	for(i,0,m) cin>>put[i];
	
	for(i,0,m) for(j,0,n) xJ[i][j]=0,xO[i][j]=0,xI[i][j]=0;
	for(i,0,m) for(j,0,n) yJ[i][j]=0,yO[i][j]=0,yI[i][j]=0;
	
	//?¨???????????´????
	for(i,0,m) {
		for(j,0,n) {
			if(put[i][j]=='J') {
				if(j!=0)xJ[i][j]=xJ[i][j-1]+1;
				else xJ[i][j]++;
			}
			else if(j!=0)xJ[i][j]+=xJ[i][j-1];
			if(put[i][j]=='O') {
				if(j!=0)xO[i][j]=xO[i][j-1]+1;
				else xO[i][j]++;
			}
			else if(j!=0)xO[i][j]+=xO[i][j-1];
			if(put[i][j]=='I') {
				if(j!=0) xI[i][j]=xI[i][j-1]+1;
				else xI[i][j]++;
			}
			else if(j!=0)xI[i][j]+=xI[i][j-1];
		}
	}
	
	//?¨??´???????????????????????´????
	for(i,0,n) {
		for(j,0,m) {
			if(j!=0) {
				yJ[j][i]=xJ[j][i]+yJ[j-1][i];
				yO[j][i]=xO[j][i]+yO[j-1][i];
				yI[j][i]=xI[j][i]+yI[j-1][i];
			}
			else {
				yJ[j][i]=xJ[j][i];
				yO[j][i]=xO[j][i];
				yI[j][i]=xI[j][i];
			}
		}
	}
	
	//??????????????\?????????????????????
	sum1=0;sum2=0;sum3=0;
	for(i,0,k) {
		cin>>a>>b>>c>>d;a--;b--;c--;d--;
		if(a==0&&b==0) {
			sum1=yJ[c][d];
			sum2=yO[c][d];
			sum3=yI[c][d];
		}
		else {
			sum1=yJ[c][d]-(yJ[a-1][d]+yJ[c][b-1])+yJ[a-1][b-1];
			sum2=yO[c][d]-(yO[a-1][d]+yO[c][b-1])+yO[a-1][b-1];
			sum3=yI[c][d]-(yI[a-1][d]+yI[c][b-1])+yI[a-1][b-1];
		}
		cout<<sum1<<" "<<sum2<<" "<<sum3<<endl;
	}
}
		
	

Measured memory_bytes: 27212
#include <cstdio>

void print_array(int* a, int n) {
    printf("%d", a[0]);
    for (int i=1; i<n; i++) { printf(" %d", a[i]); }
    printf("\n");
}

int bubbleSort(int* a, int n) {
    int count = 0;
    bool flag = true;
    while (flag) {
        flag = false;
        for (int j = n-1; j > 0; j--) {
            if (a[j] < a[j-1]) {
                int tmp = a[j];
                a[j] = a[j-1];
                a[j-1] = tmp;
                flag = true;
                count++;
            }
        }
    }
    return count;
}

int main() {
    int n;
    scanf("%d", &n);

    int* a = new int[n];
    scanf("%d", &a[0]);
    for (int i=1; i<n; i++) { scanf(" %d", &a[i]); }

    int count = bubbleSort(a, n);
    print_array(a, n);
    printf("%d\n", count);

    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define ui64 unsigned long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define mod 998244353LL

#define maxn 1000005
#define log 20

char s[maxn] ;

int main()
{
    scanf("%s",s) ;

    for(int i=0 ; s[i]!='\0' ; i++)
    {
        if(s[i]=='?') s[i] = 'D' ;
    }

    printf("%s\n",s) ;

    return 0 ;
}


Measured memory_bytes: 3880
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    a_list.sort(reverse=True)
    ans = 0
    for i in range(N):
        ans += a_list[2 * i + 1]
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39516
import sys
h, w = map(int, sys.stdin.readline().split())
dp = [[0] * w for _ in range(h)]
G = [[int(j) for j in sys.stdin.readline().split()] for _ in range(h)]
for x in range(h):
    dp[x][0] = 1 if G[x][0] == 0 else 0
for y in range(w):
    dp[0][y] = 1 if G[0][y] == 0 else 0
for i in range(1, h):
    for j in range(1, w):
        if(G[i][j] == 0):
            dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1
print(max([max(item) for item in dp])**2)

Measured memory_bytes: 57788
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,a,b=map(int,input().split())
    def modinv(a, mod):
        b,u,v = mod,1,0
        while b:
            t=a//b
            a-=t*b
            a,b=b,a
            u-=t*v
            u,v=v,u
        u%=mod
        if u < 0:
            u+=mod
        return u
    
    def COM(N,k):
        tmp=1
        k=min(k,N-k)
        for i in range(N,N-k,-1):
            tmp*=i
            tmp%=MOD
        for i in range(1,k+1):
            tmp*=modinv(i,MOD)
            tmp%=MOD
        return tmp
            
    ans=pow(2,N,MOD)-1-COM(N,a)-COM(N,b)
    while ans<0:
        ans+=+MOD
    print(ans)
    

if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
  int n;
  int ans=0;
  cin >> n;
  vector<int> tako(n);
  for(int i=0;i<n;i++){
    cin >> tako.at(i);
  }
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      ans = ans + tako.at(i)*tako.at(j);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
L,R=map(int,input().split())
if R-L>=2019:
    minimum=0
else:
    left,right=L%2019,R%2019
    minimum=2018**2
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            minimum=min(minimum,i*j%2019)
print(minimum)

Measured memory_bytes: 3060
import java.util.Scanner;

class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a == 5 || a == 7 && b == 5 || b == 7 && c == 5 || c == 7) {
            if (a + b + c == 17) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21588
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a, b,c,d;
	cin>>a>>b>>c>>d;
	if((abs(a-b)<=d  && abs(b-c)<=d) || abs(a-c)<=d ){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
from heapq import heapify, heappop, heappush
Ncase = int(input())
for case in range(Ncase):
  N = int(input())
  ans = 0
  Left = [];Right = []
  for i in range(N):
    K,L,R = map(int,input().split())
    if L > R:
      Left.append((K-1,L-R))
      ans += R
    elif R > L:
      if K != N: #K=Nの時はどこにおいても左と判定される。
        Right.append((N-1-K,R-L))
      ans += L
    else:
      ans += L
  Left.sort(reverse=True);Right.sort(reverse=True) #Kの小さい順、左にいたときのプラス分が大きい順に並んだ
  #print(Left,Right)
  now = 0
  PQ = []
  for loc in reversed(range(N)):
    #print(now,Left[now][0],loc)
    while now < len(Left) and Left[now][0] == loc:
      heappush(PQ,-Left[now][1])
      now += 1
      if now >= len(Left):
        break
    if PQ:
      plus = -heappop(PQ)
      ans += plus
  
  now = 0
  PQ = []
  for loc in reversed(range(N)):
    while now < len(Right) and Right[now][0] == loc:
      heappush(PQ,-Right[now][1])
      now += 1
      if now >= len(Right):
        break
    if PQ:
      plus = -heappop(PQ)
      ans += plus
  print(ans)

Measured memory_bytes: 97080
#include <stdio.h>
#define N 4004
typedef long long LL;

int sl[N][3], sr[N][3], f[N][3] = {0};
char a[N], p[128], c, b, d;

int main()
{		
	int n, i, j, k, i1, i2, t;
	LL ans = 0;	
	
	scanf("%d%s", &n, a + 1);
	p['R'] = 0, p['G'] = 1, p['B'] = 2;
	sl[0][0] = sl[0][1] = sl[0][2] = 0;
	
	for(j = 0, i = 1; i <= n; j = i++){
		f[i][a[i] = p[a[i]]] = 1;
		for(k = 0; k < 3; k++){
			sl[i][k] = sl[j][k] + f[i][k];
		}
	}
	t = n + 1;
	sr[t][0] = sr[t][1] = sr[t][2] = 0;
	for(j = t, i = n; i > 0; j = i--){
		for(k = 0; k < 3; k++){
			sr[i][k] = sr[j][k] + f[i][k];
		}
	}
	for(i = 2; i < n; i++){
		c = a[i], i1 = i - 1, i2 = i + 1;
		if(c == 0) ans += sl[i1][1] * sr[i2][2] + sl[i1][2] * sr[i2][1];
		else if(c == 1) ans += sl[i1][0] * sr[i2][2] + sl[i1][2] * sr[i2][0];
		else ans += sl[i1][0] * sr[i2][1] + sl[i1][1] * sr[i2][0];
		for( ; i1 > 0 && i2 <= n; i1--, i2++){
			b = a[i1], d = a[i2];
			if(b != c && b != d && c != d) ans--;
		}
	}
	printf("%lld\n", ans);
			
	return 0;
}

Measured memory_bytes: 1872
import java.util.*;
public class Main {
    public static void main (String[] args) {
        Scanner inp = new Scanner (System.in);
        int[] mount = new int[10];
        for (int i=0;i<mount.length;i++) {
            mount[i] = inp.nextInt();
        }
        Arrays.sort(mount);
        System.out.println(mount[9]);
        System.out.println(mount[8]);
        System.out.println(mount[7]);
    }
}

Measured memory_bytes: 26160
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

import numpy as np

def solve():
    n = II()
    A = np.array(LI())
    # print([bin(a) for a in A])
    mod = 1000000007
    ans = 0
    for i in range(0, 61):
        # i桁目が1の個数を数える
        x = np.count_nonzero(A & 1)
        y = n - x       # i桁目が0の個数
        # print(i, x, y)
        # XORなので x*y 通りの組み合わせ
        ans = ans + pow(2, i) * x * y % mod
        A = A >> 1
    print(ans % mod)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 48860
#include <bits/stdc++.h>
#define ll long long

using namespace std;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
  ll n;
  cin >> n;
  vector<ll> d = divisor(n);
  if(d.size() % 2)
    cout << d.at(d.size() / 2) * 2 - 2 << endl;
  else
    cout << d.at(d.size() / 2) + d.at(d.size() / 2 - 1) - 2 << endl;
}

Measured memory_bytes: 384