akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

bool graph[8][8];

int dfs(int v, int N, bool visited[8]) {
  bool all_visited = true;
  for (int i = 0; i < N; i++) {
    if (visited[i] == false) {
      all_visited = false;
    }
  }
  if (all_visited) {
    return 1;
  }

  int ret = 0;
  for (int i = 0; i < N; i++) {
    if (graph[v][i] == false) {
      continue;
    }
    if (visited[i] == true) {
      continue;
    }
    visited[i] = true;
    ret += dfs(i, N, visited);
    visited[i] = false;
  }
  return ret;
}

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
  }
  bool visited[N];
  for (int i = 0; i < N; i++) {
    visited[i] = false;
  }
  visited[0] = true;
  cout << dfs(0, N, visited) << endl;
  return 0;
}

Measured memory_bytes: 3536
l,r = map(int,input().split())
L = l%2019
R = r%2019  #2019 = 3*673
N = r-l+1

if N >= 2019 or L>R:
    print(0)
else:
    ans = l*(l+1)%2019
    for i in range(L,R):  #この時点でL<Rは決定済み
        for j in range(i+1,R+1):
            ans = min(ans,(j*i)%2019)
        if ans == 0:
            break
    print(ans)

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

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

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

    for(int i=0; i<n; i++){
        cout << (total ^ a[i]) << " ";
    }
    cout << endl;
    return 0;
}

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

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

	int result;
	result = 0;

	result += x / 500 * 1000;
	result += x % 500 / 5 * 5;

	cout << result << '\n';

    return 0;
}


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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)

/*--------------------------------------------*/



int main(){
  string s;
  cin >> s;
  
  int n = s.size();
  
  rep(i,n){
    if(i%2 == 0){ //奇数番目
      if(!(s[i] == 'R' ||s[i] == 'U' ||s[i] == 'D')){
        cout << "No" << endl;
        return 0;
      }
    }else{
       if(!(s[i] == 'L' ||s[i] == 'U' ||s[i] == 'D')){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  cout << "Yes" << endl;
      
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int m,n;
    while(cin>>m>>n)
    {
        int flag=0;
        for(int x=0; x<=m; x++)
        {
            int fm=n-1000*m-9000*x;
            if(fm>=0&&fm%4000==0)
            {
                int y=fm/4000;
                int z=m-x-y;
                if(z<0||z>m)
                {
                    continue;
                }
                else
                {
                    flag=1;
                    printf("%d %d %d\n",x,y,z);
                    break;
                }
            }
        }
        if(!flag)
            printf("-1 -1 -1\n");
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector <pair<ll, ll>> a(N);
    for (int i = 0; i < N; i++) cin >> a[i].second >> a[i].first;
    sort(a.begin(), a.end());


    ll sum = 0;
    for (int i = 0; i < N; i++) {
        sum += a[i].second;
        if( sum > a[i].first ){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int inf = 5e18;  
const int mod1 = 998244353;
const int mod = 1e9 + 7;
const int nax = 55;
const int mxm = 3000;
int dp[nax][mxm],n,u,v,m,s,a,b,c[nax],d[nax];
vector<tuple<int,int,int>> adj[nax];
void dijkstra()
 {
  priority_queue<pair<pii,int>> q;
  q.push({{0,s},1});
  dp[1][s] = 0;
  while(!q.empty())
     {
      int node = q.top().ss;
      int time = -q.top().ff.ff;
      int coins = q.top().ff.ss;
      q.pop();
      for(auto x : adj[node])
         {
          int v,a,b;
          tie(v,a,b) = x;
          if(a<=coins && dp[v][coins - a] > dp[node][coins] + b)
             {
              dp[v][coins - a] = dp[node][coins] + b;
              q.push({{-dp[v][coins - a],coins - a},v});
             }
         }
      if(coins + c[node] < 3000 && dp[node][coins + c[node]] > dp[node][coins] + d[node])
         {
          dp[node][coins + c[node]] = dp[node][coins] + d[node];
          q.push({{-dp[node][coins + c[node]],coins + c[node]},node});
         }
     }
 }
void solve()
 {
  cin>>n>>m>>s;
  s = min(s,mxm-1);
  loop(i,0,m)
   {
    cin>>u>>v>>a>>b;
    adj[u].pb(tie(v,a,b));
    adj[v].pb(tie(u,a,b));
   }
  loop(i,1,n+1)
    cin>>c[i]>>d[i];
  loop(i,1,n+1)
   loop(j,0,mxm)
     dp[i][j] = inf;
  dijkstra();
  loop(i,2,n+1)
  {
   int ans = inf;
   loop(j,0,3000)
    ans = min(ans,dp[i][j]);
  cout<<ans<<END;
  }
 }
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
  solve();
  // cerr<<END<<1.0*clock()/CLOCKS_PER_SEC;
  return 0;
} 

Measured memory_bytes: 7508
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    if(a%n==0||a/n*n+n<=b)
        cout<<"OK";
    else
        cout<<"NG";
    return 0;
}


Measured memory_bytes: 3592
n, k, q = map(int,input().split())
ls = [0 for i in range(n)]

for i in range(q):
    a = int(input()) - 1
    ls[a] += 1

for i in range(n):
    if q - ls[i] >= k:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    double ans=0;
    for(int i=1;i<=a;i++){
        double temp=1.0/a;
        int now=i;
        while(now<b){
            now*=2;
            temp/=2;
        }
        ans+=temp;
    }
    cout<<setprecision(12);
    cout<<ans;
}

Measured memory_bytes: 3804
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <chrono>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <deque>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdarg.h>
#include <utility>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unisgned long long
#define ld long double
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))
#define pii pair<int, int>
#define tii triple<int, int, int>
#define e 1e-7
#define PI acos(-1)
#define sz(a) (int)(a.size())
#define inf 1e17
#define vi vector<int>
#define F first
#define S second
#define rng(x) for(int _ = 0; _ < (x); _++)
#define rngi(i, x) for(int i = 0; i < (x); i++)
#define rngsi(s, i, x) for(int i = (s); i <(x); i++)
#define int long long
#define problem ""

template<typename A, typename B, typename C>
struct triple{
    A X;
    B Y;
    C Z;
    triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
};
template<typename A, typename B, typename C>
triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0){
    return triple<A, B, C>(a, b, c);
}
template<typename A, typename B, typename C>
bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b){
    if (a.X != b.X)
        return a.X < b.X;
    if (a.Y != b.Y)
        return a.Y < b.Y;
    return a.Z < b.Z;
}
template<typename T, typename SS>
ostream& operator<<(ostream& ofs, const pair<T, SS>& p){
    ofs << "( " << p.F << " , " << p.S << " )";
    return ofs;
}
template<typename T>
void print(T a){
    for (auto i : a)
        cout << i << ' ';
    cout << '\n';
}
template<typename T>
T max(T a, T b, T c){
    return max(a, max(b, c));
}
template<typename T>
T min(T a, T b, T c){
    return min(a, min(b, c));
}
template<typename T, typename D>
D min(T a){
    return *min_element(all(a));
}
template<typename T, typename D>
D max(T a){
    return *max_element(all(a));
}
struct custom_hash{
    static uint64_t splitmix64(uint64_t x){
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void solve(){
    set<int> a;
    rng(3){int x; cin >> x; a.insert(x);}
    if(sz(a) != 2) cout<<"No\n"; else cout << "Yes\n";
};
signed main()
{
    if(0){
        freopen(problem".in", "r", stdin);
        freopen(problem".out", "w", stdout);
    }
    srand(time(NULL));
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int t = 1; //cin >> t;
    rng(t) solve();
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
const int mod = 998244353; //1e9+7;
struct Mint {
   int val;
   Mint inv() const {
       int tmp, a = val, b = mod, x = 1, y = 0;
       while(b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y);
       return Mint(x);
   }
public:
   Mint() :val(0) {}
   Mint(ll x) :val(x >= 0 ? x % mod : x % mod + mod) {}
   int mtoi() { return this->val; }
   Mint pow(ll t) { Mint res = 1; while(t){if(t&1)res *= *this;*this *= *this;t >>= 1;}return res; }
   Mint& operator+=(const Mint& x) { if ((val += x.val) >= mod) val -= mod; return *this; }
   Mint& operator-=(const Mint& x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; }
   Mint& operator*=(const Mint& x) { val = (ll)val * x.val % mod; return *this; }
   Mint& operator/=(const Mint& x) { return *this *= x.inv(); }
   bool operator==(const Mint& x) const { return val == x.val; }
   bool operator!=(const Mint& x) const { return val != x.val; }
   bool operator<(const Mint& x) const { return val < x.val; }
   bool operator<=(const Mint& x) const { return val <= x.val; }
   bool operator>(const Mint& x) const { return val > x.val; }
   bool operator>=(const Mint& x) const { return val >= x.val; }
   Mint operator+(const Mint& x) const { return Mint(*this) += x; }
   Mint operator-(const Mint& x) const { return Mint(*this) -= x; }
   Mint operator*(const Mint& x) const { return Mint(*this) *= x; }
   Mint operator/(const Mint& x) const { return Mint(*this) /= x; }
};
struct factorial {
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx) {
       Fact.resize(maxx+1,Mint(1)),Finv.resize(maxx+1); rep(i,0,maxx)Fact[i+1]=Fact[i]*Mint(i+1);
       Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*Mint(i);
   }
   Mint fact(int n,bool inv) { if(inv) return Finv[n]; else return Fact[n]; }
   Mint nPr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[n-r]; }
   Mint nCr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};
//template end



int main(){
   int n; cin>>n;
   vector<int> a(n);
   rep(i,0,n)cin>>a[i];
   int maxx=0;
   rep(i,0,n-1){
      chmax(maxx,a[i]-1);
      if(a[i+1]<maxx){
         printf("No\n"); return 0;
      }
   }
   printf("Yes\n");
   return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll llINF = 1LL << 60;
const int iINF = 1e8;

//---main---------------------------------------------
int main(){
    //main
    int K;
    cin >> K;
    string S(K,'a');
    cin >> S;

    if(S.size()>K){
        cout << S.substr(0,K) << "..." << endl;
    }else cout << S << endl;

    
    return 0;
}

Measured memory_bytes: 3564
#include<iostream>
#include<math.h>

using namespace std;

int main(){
    int N,D,count=0;
    cin>>N>>D;
    int X[N],Y[N];
    for(int i=1;i<=N;++i)cin>>X[i]>>Y[i];

        for(int i=1;i<=N;++i){
            double s=sqrt(pow(X[i],2)+pow(Y[i],2));
            if(s<=D)count++;
        }

    cout<<count;
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define endl '\n'

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int h[100005], dp[100005];

int main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> h[i];	
	dp[0] = INF;
	dp[1] = 0;
	for(int i=2;i<=n;i++)
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	cout << dp[n] << endl;

}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

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



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

	string s, t;
	cin >> s >> t;
	rep(i, s.size()) cout << s[i] << t[i];
	
	system("PAUSE");
}

Measured memory_bytes: 504
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;

  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest]) largest=r;

  if(largest!=i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(H<1) return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  if(key<A[i]) return;
  A[i]=key;
  while(i>1&&A[i/2]<A[i]){
    swap(A[i],A[i/2]);
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0]=='e'&&com[1]=='n') break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n",extract());
    }
  }
  return 0;
}



Measured memory_bytes: 6472
#include<iostream>
using  namespace std;
int moji(char);
int a(int);

int moji(char x){
  if(x=='m')  return 1000;
  else if(x=='c') return 100;
  else if(x=='x') return 10;
  else if(x=='i') return 1;
  else return 0;
}
int main(){
  int sum=0;
  string str;
  char dami,dami2;
  int n,f=0;
  cin>>n;
  for(int i=0;i<=n;i++){
    getline(cin,str);
    sum=0;
    for(int i=0;i<str.size();i++){
      if(str[i]>='0' && str[i]<='9'){ 
sum+=(str[i]-'0')*moji(str[i+1]);
 i++;
      }else{
 sum+=moji(str[i]);
      }
    }
    while(sum>0){
      f=1;
      sum-=a(sum);
    }
    if(f==1)  cout<<endl;
  }

  return 0;
}

  int a(int x){
    if(x/1000>0){
      if(x/1000>1)
	cout<<x/1000<<"m";
      else cout<<"m";
      return (x/1000)*1000;
    }
    else if(x/100>0){
      if(x/100>1) cout<<x/100<<"c";
      else cout<<"c";
      return (x/100)*100;
    }
    else if(x/10>0){
      if(x/10>1) cout<<x/10<<"x";
      else cout<<"x";
      return (x/10)*10;
    }
    else if(x>1) cout<<x<<"i";
    else cout<<"i";
    return x;
  }

Measured memory_bytes: 1204
from heapq import heappush, heappop
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
mi = min(N, K)

for l in range(mi+1):
    for r in range(mi-l+1):
        heap = []
        for x in V[:l]:
            heappush(heap, x)
        for x in V[N-r:]:
            heappush(heap, x)
        
        cnt = l + r
        while (len(heap) > 0) & (cnt < K):
            x = heappop(heap)
            if x > 0:
                heappush(heap, x)
                break
            cnt += 1
        
        ans = max(ans, sum(heap))
    
print(ans)

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

using namespace std;

const int INF = 1e9 + 5;

int main(){
    int n;
    scanf("%dj", &n);
    vector<int> h(n);

    for(int& x: h){
        scanf("%d", &x);
    }

    vector<int> dp(n, INF);

    dp[0] = 0;
    for(int i=0; i<n; i++){
        for(int j : {i + 1, i + 2}){
            if(j < n){
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }

    printf("%d\n", dp[n-1]);
}

Measured memory_bytes: 1024
#include <iostream>

long pow(long x, long y){
	if(y==0){
		return 1;
	}else if (y==1) {
		return x;
	}else if(y%2 == 0){
		long z = pow(x,y/2)%1000000007;
		return z*z%1000000007;

	}else{
		long z = pow(x,y/2)%1000000007;
		return (z*z%1000000007)*x%1000000007;
	}
}

int main(){
	long x , y;
	std::cin>>x>>y;
	std::cout<<pow(x,y)<<std::endl;
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	map<string, int> freq;
	
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		freq[s]++;
	}
	
	for(string a: {"AC", "WA", "TLE", "RE"}) {
		cout << a << " x " << freq[a] << "\n";
	}
}


Measured memory_bytes: 3520
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        //3つの配列aの宣言
        int[] a = new int[3];
        
        //３つの配列の入力
        for(int i = 0; i < a.length; i++) a[i] = sc.nextInt();
        
        //昇順にソート（並べ変える）
        Arrays.sort(a);
        
        //３つの配列の出力
        System.out.println(a[0] + " " + a[1] + " " + a[2]);

        
    }
}



/*覚えよう！！
 
〇import java.util.Arrays;は重要↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

・Arrays：ソート（並べ変え）や検索など、配列を操作するための機能

・並べ変えするとき
　import java.util.Arrays;を上に書く
　class Main内に Arrays.sort(a); と書く　←　このとき()内は配列の変数名
　
〇配列とは、同じ変数名に複数の値を入力できる箱

　※イメージ
    前回まで、a = 1, b = 2, c = 3など各変数名は1箱に値を代入できない
    今回の配列はa[0] = 1, a[1] = 2, a[2] = 3 のように変数名aは3つの箱に値を代入できる。
    注意：配列の箱は｢ 0 ｣から開始する
　　
*/
  
  
/*前回の内容！！


・複数のif(条件)：かつ｢ && ｣とまたは｢ || ｣の２つを使用する
　※かつ｢ && ｣：「真 && 真 = 真」, 「真 && 偽 = 偽」, 「偽 && 真 = 偽」 ,「偽 && 偽 = 偽」の4つの条件
　　または｢ || ｣：「真 && 真 = 真」, 「真 && 偽 = 真」, 「偽 && 真 = 真」 ,「偽 && 偽 = 偽」の4つの条件


・関係を比較する：if(条件式)
　例：if(2 < 3) この条件は｢真（成立）｣　→　何か命令があれば実行する
　　　if(5 < 3) この条件は｢偽（不成立）｣　→　何か命令があれば実行しない
　　　
・比較の条件式：等しいか比較｢==｣、等しくないか比較｢!=｣ 
　　　　　　　　大きいか比較｢<｣、小さいか比較｢>｣
　　　　　　　　以上の比較｢<=｣、以下の比較｢>=｣
 
 
・else；ifの条件以外の場合に使用する。
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else System.out.println("傘を持って行かない");
　
 
・else if：詳細な場合分けしたいときに使用
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else if(雨 == 午後から降るかも) System.out.println("念のため傘を持って行く");
　　　else System.out.println("傘を持って行かない");
 

 
・変数に計算結果を代入する：面積　＝　縦　×　横
　※計算は変数名でも数値でもいける
  
・四則演算：足し算｢＋｣、引き算｢－｣、掛け算｢＊｣、割り算｢／｣
　1 + 2 = 3;
　4 - 3 = 1;
　2 * 5 = 10;
　8 / 2 = 4;
  
・余りの計算：割り算の余り｢％｣
  5 % 3 = 2;
    
    
・printlnの複数表示：｢＋｣を使用
　例：println("Kobe" + "Kagikou"); = KobeKajikou
　　　println("明治 + 20 + "年"); = 明治20年　数値が入ってもOK！
  
  
  
・変数の宣言は｢型｣と｢変数名｣の２つ必要
　例：型＿変数名　→　int x;
　
・キーボードから入力するときは・・・｢ import java.util.Scanner; ｣ と ｢  Scanner sc = new Scanner(System.in) ; ｣が必要
  
・入力するとき・・・変数名 = sc.nextInt(); nextの後は型を書く、頭文字は大文字　
　※  scは変更しても大丈夫しかし全て変更後の文字に統一　例：nyuryoku
  
・println・・・画面に出力するときに使用
  
・文字列の表示・・・"〇〇〇の間に入力"ことが約束
  
*/



Measured memory_bytes: 26340
#include <stdio.h>
int main()
{
  int a[4][13],i,j,k,x,n;
  char m;
   
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      a[i][j]=0;
    }
  }
  
  scanf("%d",&n);
   
  for(k=0;k<n;k++){
    scanf(" %c%d",&m,&x);
    if(m=='S')a[0][x-1]=1;
    else if(m=='H')a[1][x-1]=1;
    else if(m=='C')a[2][x-1]=1;
    else if(m=='D')a[3][x-1]=1;
  }
    
   
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(a[i][j]==0){
    if(i==0)printf("S %d\n",j+1);
      else if(i==1)printf("H %d\n",j+1);
      else if(i==2)printf("C %d\n",j+1);
      else if(i==3)printf("D %d\n",j+1);
      }
    }
  }
  return 0;
}
 

 

Measured memory_bytes: 596
import sys
X, Y = list(map(int, input().split()))


sys.setrecursionlimit(10**8)

MOD = 10 ** 9 + 7


a = (2 * Y - X) / 3
b = (2 * X - Y) / 3

if a != int(a) or b != int(b):
    print(0)
    sys.exit(0)


def factorial(x, p):
    a = 1
    for i in range(1, x + 1):
        a *= i
        a %= p
    return a


def comb(a, b, p):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    c = 1
    c *= factorial(a, p)
    c *= pow(factorial(b, p), p - 2, p)
    c *= pow(factorial(a - b, p), p - 2, p)
    return c % p


print(comb(int(a+b), int(a), MOD))


Measured memory_bytes: 38512
#include<bits/stdc++.h>
	using namespace std;
	#define ll       long long
	#define ull       unsigned long long
	#define  sci(x)   scanf("%d", &x)
	#define  scl(x)   scanf("%lld", &x)
	#define  scd(x)   scanf("%lf", &x)
	#define l0(i,n)   for(ll i=0; i<n; i++)
	#define MAX                 100000


	int main ()
	{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		ll x,y;
		cin >> x >> y;
		if (y>=2*x && y<=4*x && y%2==0) cout << "Yes" << endl;
		else cout << "No" << endl;
		
		return 0;
	}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
    int a, b;
    std::cin >> a >> b;

    std::vector<int> vec(3);
    vec.at(0) = a + b;
    vec.at(1) = a - b;
    vec.at(2) = a * b;

    std::cout << *std::max_element(vec.begin(), vec.end()) << std::endl;

    return 0;
}

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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    ll cnt=0,ans=0;

    rep(i,s.size()){
        if(s[i]=='W')ans+=cnt;
        else cnt++;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3708
#include<stdio.h>

typedef struct card
{
  char type;
  int number[13];
}card;

int main()
{
  card arr[4];
  int n;
  char ty[2];
  int num;
  int count = 1;

  for(int i= 0; i<4; i++)
    {
      for(int j = 0; j<13; j++)
	{
	  arr[i].number[j] = count;
	  count++;
	}
      count = 1;
    }
  arr[0].type = 'S';
  arr[1].type = 'H';
  arr[2].type = 'C';
  arr[3].type = 'D';
  
  scanf("%d", &n);
  for(int i=0; i<2*n; i++)
    {
      scanf("%c %d", &ty, &num);
      for(int j = 0; j < 4; j++)
	{
	  if(arr[j].type == ty[0])
	    {
	      for(int k = 0; k < 13; k++)
		{
		  if(arr[j].number[k] == num)
		    {
		      arr[j].number[k] = 0;
		    }
		}
	    }
	}
    }


  
  for(int i = 0; i < 4; i++)
    {
      for(int j = 0; j < 13; j++)
	{
	  if(arr[i].number[j] != 0)
	    {
	      printf("%c %d\n", arr[i].type, arr[i].number[j]);
	    }
	}
    }
}



Measured memory_bytes: 2136
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import heapq

N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A = sorted(A)
F = sorted(F, reverse= True)
S = [(-A[i]*F[i], i) for i in range(N)]


def judge(s):
    global N, K
    ksum = 0
    for i in range(N):
        ksum += max(0, -(-(A[i] * F[i] - s) // F[i]))
    if ksum <= K:
        return True
    else:
        return False

lb = -1
ub = 10**13
while lb + 1 < ub:
    mid = (lb + ub) // 2
    if judge(mid):
        ub = mid
    else:
        lb = mid

print(ub)


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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

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

    vector<ll> a(n);
    vector<ll> num(100001,0);


    ll co=0;
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        if(a.at(i)>100000){
            co++;
        }else{
            num.at(a.at(i))++;
        }

    }

    for(int i=1;i<100001;i++){
        if(i<num.at(i)){
            co += num.at(i) - i;
        }else if(i>num.at(i)){
            co += num.at(i);
        }
    }

    cout<<co<<endl;

}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int a[3]={300000,200000,100000};
   long int x,y;
   cin>>x>>y;
   x--,y--;
   if(x==0&&y==0)
   cout<<"1000000";
   else
   {
      long long int ans=0;
      if(x<3)
      ans+=a[x];
      if(y<3)
      ans+=a[y];
      cout<<ans;
   }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<string>
using namespace std;

int main(){
    int A,B,X;
    cin>>A;
    cin>>B;
    X=A+B;
    if(A<9&&B<9&&X<17){
        cout<<"Yay!"<<endl;
    }
    else{
        cout<<":("<<endl;
    }
}


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

typedef long long ll;

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

    int a, b, c;
    cin >> a >> b >> c;

    cout << b + c - min(a, b + c) << endl;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import gcd, ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
# from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
c = 0
K = INT()
ans = 0
 
for i in range(1, K + 1):
    for j in range(1, K + 1):
        a = gcd(i, j)
        for k in range(1, K + 1):
            b = gcd(a, k)
            ans += b
print(ans)            
 

Measured memory_bytes: 10044
import bisect
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0          
for ai in range(n):
  for bi in range(ai+1,n):
    ci = bisect.bisect_left(l,l[ai]+l[bi])
    if ci>bi:
      ans += ci-bi-1
print(ans)

Measured memory_bytes: 9376
import java.util.*;

class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        final int R = Integer.parseInt(sc.next());
        final int S = Integer.parseInt(sc.next());
        final int P = Integer.parseInt(sc.next());
        final char T[] = sc.next().toCharArray();
        sc.close();

        List<Character> C = new ArrayList<>();
        Func1 func1 = new Func1() {
            @Override
            public char print(char c) {
                if (c=='r')
                    return 'p';
                else if (c=='s')
                    return 'r';
                else
                    return 's';
            }
        };
        Func2 func2 = new Func2() {
            @Override
            public int print(char c) {
                if (c=='r') {
                    return R;
                } else if (c=='s') {
                    return S;
                } else if (c=='p') {
                    return P;
                } else {
                    return 0;
                }
            }
        };
        for (char t : T) {
            C.add(func1.print(t));
        }
        for (int i=0; i<N-K; i++) {
            if (C.get(i)==C.get(i+K)) {
                C.set(i+K,'x');
            }
        }
        long sum = 0;
        for (char c : C) {
            sum += func2.print(c);
        }
        
        System.out.println(sum);
    }
    public interface Func1 {
        char print(char c);
    }
    public interface Func2 {
        int print(char c);
    }
}

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

using namespace std;

int N, mod = 1e9 + 7, s[100009], v[100009];
char sir[100009];

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int substract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}

int pow (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

/*void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i);
inv[lim] = pow (fac[lim], mod - 2);for (int i=lim - 1; i>=1; i--)inv[i] = mul (inv[i + 1], i + 1);}
int comb (int N, int K){int ans = mul (fac[N], inv[N - K]);ans = mul (ans, inv[K]);return ans;}*/

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d\n", &N);
scanf ("%s", sir + 1);
for (int i=1; i<=N; i++)
    if (sir[i] == 'o') s[i] = 0;
    else s[i] = 1;
for (int v1 = 0; v1 < 2; v1 ++)
    for (int v2 = 0; v2 < 2; v2 ++)
    {
        v[1] = v1, v[2] = v2;
        for (int i=3; i<=N; i++)
            v[i] = s[i - 1] ^ v[i - 1] ^ v[i - 2];
        if (s[N] != (v[1] ^ v[N - 1] ^ v[N])) continue;
        if (s[1] != (v[2] ^ v[N] ^ v[1])) continue;
        for (int i=1; i<=N; i++)
            if (v[i] == 0) printf ("S");
            else printf ("W");
        printf ("\n");
        return 0;
    }
printf ("-1\n");
return 0;
}


Measured memory_bytes: 1280
a, b, k = map(int, input().split())
x = min(a,b)
p = []
for i in range(x):
    if a % x == 0 and b % x == 0:
        p.append(x)
        x -= 1
    else:
        x -= 1
sum = sorted(p)[-k]
print(sum)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// sort struct

// https://atcoder.jp/contests/abc121/submissions/4519585
func main() {
	var n, m int
	fmt.Scan(&n, &m)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	es := make(entries, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())

		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())

		es[i].a = a
		es[i].b = b
	}
	sort.Sort(es)

	ans := 0
	num := 0
	for _, e := range es {
		if num+e.b < m {
			ans += e.a * e.b
			num += e.b
		} else {
			ans += (m - num) * e.a
			break
		}
	}
	fmt.Println(ans)
}

type entry struct {
	a, b int
}

type entries []entry

func (es entries) Len() int {
	return len(es)
}

func (es entries) Swap(i, j int) {
	es[i], es[j] = es[j], es[i]
}
func (es entries) Less(i, j int) bool {
	return es[i].a < es[j].a
}


Measured memory_bytes: 5100
// luogu-judger-enable-o2
#include <iostream>
#include <cstdio> 
using namespace std;
int main() {
	long long a, b;
	cin >> a >> b;
	if (a > 0)
		cout << "Positive";
	else if (a == 0 || (a < 0 && b>0))
		cout << "Zero";
	else if ((abs(b) - abs(a)) % 2 != 0)
		cout << "Positive";
	else
		cout << "Negative";
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
alist = list(map(int,input().split()))
memo = []
p = 1
vis = ['.']*n
while vis[p-1] == '.':
    memo.append(p)
    vis[p-1] = 'v'
    p = alist[p-1]

loop = memo.index(p)
if k < len(memo):
    print(memo[k])
else:
    print(memo[loop+(k-loop)%(len(memo)-loop)])


Measured memory_bytes: 32132
#include<bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ll long long int
#define ALL(x) x.begin(),x.end()
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;

/*--------------------template--------------------*/

int main() {
	cin >> n;
	REP(i, n) {
		cin >> k;
		v.push_back(k);
		sum = sum + v[i];
	}
	ll a = sum / n;
	(sum - a*n > (a + 1)*n - sum) ? w = a + 1 : w = a;
	REP(i, n) {
		ans = ans + (v[i] - w)*(v[i] - w);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <limits>
using namespace std;
typedef long long ll;
 
#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 FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
 
struct PrimeNumbers {
    vector<bool> sieve;
    vector<int> prime;
    PrimeNumbers(int n) : sieve(n+1,true) {
        sieve[0] = sieve[1] = false;
        for(long long i=2; i<sieve.size(); i++){
            if(sieve[i]){
                prime.push_back((int)i);
                for(long long j=i*i; j<sieve.size(); j+=i) {
                    sieve[j] = false;
                }
            }
        }
    }
    int size(void) { return (int)prime.size(); }
    int & operator [] (int n) { return prime[n]; }
    bool operator == (int n) { return sieve[n]; }
    bool operator != (int n) { return sieve[n]; }
};

int main() {

    int t;
    while(cin >> t) {
        PrimeNumbers p(t);
        cout << p.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 3668
str = gets.chomp!
str = str.split('')

alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

sub = alpha - str
if sub.length == 0 then
  puts "None"
else
  puts sub[0]
end

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

using namespace std;

typedef long long ll;

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

ll lcm(ll a, ll b){
  return ((a * b) / gcd( a, b));}

int main(){
  ll N,M; cin >> N >> M;
  string S,T; cin >> S >> T;
  ll L = lcm(N, M);
  ll g = gcd( N,M);
  ll a = N / gcd( N,M); ll b = M / gcd( N,M);
  
  bool flag = true; int x = 0;
  
while( x * a < N && x * b < M){
   if( S[ x * a] != T[x * b]){ flag = false;}
   x++;}

if( flag){ cout << L << endl;}
else{ cout << -1 << endl;}
  
 return 0;}
   

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;

vector<int> num;

long long sequence(int s1, long long c1, int s2, long long c2) {
  for (int i = 1; i < num.size(); i++) {
    if (s1 > 0) {
      if (s1 + num[i] >= 0) {
        c1 += 1 + num[i] + s1;
        s1 = -1;
      } else {
        s1 += num[i];
      }
    } else {
      if (s1 + num[i] <= 0) {
        c1 += 1 - num[i] - s1;
        s1 = 1;
      } else {
        s1 += num[i];
      }
    }
    if (s2 > 0) {
      if (s2 + num[i] >= 0) {
        c2 += 1 + num[i] + s2;
        s2 = -1;
      } else {
        s2 += num[i];
      }
    } else {
      if (s2 + num[i] <= 0) {
        c2 += 1 - num[i] - s2;
        s2 = 1;
      } else {
        s2 += num[i];
      }
    }
  }
  
  return min(c1, c2);
}

int main() {
  int n; scanf("%d", &n);
  
  num.resize(n);
  for (int i = 0; i < n; i++) scanf("%d", &num[i]);
  
  long long ans;
  
  if (num[0] == 0) {
    ans = sequence(1, 1, -1, 1);
  } else if (num[0] > 0) {
    ans = sequence(num[0], 0, -1, num[0] + 1);
  } else {
    ans = sequence(1, abs(num[0]) + 1, num[0], 0);
  }
  
  printf("%lld", ans);
}

Measured memory_bytes: 768
#include<vector>
#include<iostream>
#include<cstddef>
#include<algorithm>
#include<map>
using si = std::int32_t;
using ui = std::uint32_t;
using ull = std::uint64_t;

si main(){

	ui n;
	std::cin >> n;

	//std::vector<ull> an(n);
	std::map<ull, ull> mp;
	for( ui i{}; i < n; ++i )
	{
		ui t;
		std::cin >> t;
		++mp[t];
	}

	const bool check = [&]() {
			
		if( mp.find(0) != std::end(mp) && mp.size()==1 )//0がn個ある
			return true;

		else
			if( n % 3 != 0 || mp.size() > 3 || mp.size()==1 )//0がn個以外ではnは3の倍数でないと解がない + 多くとも3種類の数から数列はなる場合にのみ解がある。
				return false;

			else
			{

				auto it = std::begin( mp );

				auto check = true;
				
				if( mp.size() == 2)
					check = mp[0] * 2 == ( ++it )->second;//xが2*n/3個、0がn/3個ある

				else if( mp.size() == 3 )
				{
					auto n = it->first;
					auto c = it->second;
					auto p = [&]() {
						std::cout << " " << n << " " << c << "\n";
					};
					++it;
					while( it != std::end( mp ) )
					{
//						p();
						n ^= it->first;
						check &= c == it->second;
						++it;
					}
//					p();
					check &= n == 0;
				}
					//x1 と x2、x2とx3の個数が同じ
				return check;
			}
			
	}();


	std::cout << ( check ? "Yes" : "No" ) << "\n";

	return 0;
}

Measured memory_bytes: 5120
/* author   : mpily :-()
title : Competing.cpp
time :Sat May 30 13:38:34 2020

*/
#include<bits/stdc++.h>
using namespace std;
void solve(){
	string T;
	cin >> T;
	int n = int(T.size());
	for(int i = 0; i < n; ++i){
		if(T[i] == '?'){
			T[i] = 'D';
		}
	}
	cout << T;
}
int main(){
	int t;
	t = 1;
	while(t--){
		solve();
		cout << "\n";
	}
	return 0;
}	

Measured memory_bytes: 3692
#include <stdio.h>
#include <string.h>
int main()
{
	char str1[101], str2[101],str3[201];
	
	str3[0]='\0';

	scanf("%s %s", str1, str2);
	
	strcpy(str3,str1);
	
	strcat(str3,str1);
	
   // printf("%s\n",str1);
   // printf("%s\n",str3);

	if ( strstr(str3, str2) == NULL) {
	    printf("No\n");
	    
	    
	}
	else printf("Yes\n");
	
	return 0;
}


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

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

  n = n % 10;

  if(n == 3){
    cout << "bon" << endl;
  }
  else if(n == 0 || n == 1 || n == 6 || n == 8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }

  return 0; 
}


Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        if(a % 2 == 0)System.out.println(a);
        else System.out.println(a * 2);
    }
}


Measured memory_bytes: 22612
def solve():
    N = int(input())
    str_unions = sorted([sorted(input()) for _ in range(N)])
    ret = 0
    count_tmp = 1
    s_temp = []
    
    for s in str_unions:
        if s == s_temp:
            ret += count_tmp
            count_tmp += 1
        else:
            s_temp = s
            count_tmp = 1
    # print(str_unions)
    print(ret)

solve()

Measured memory_bytes: 25420
#include<iostream>
int main()
{
	int d, n;
	std::cin >> d >> n;
	switch (d)
	{
	case 0:
		if (n == 100)
		{
			std::cout << 101 << std::endl;
		}
		else
		{
			std::cout << n << std::endl;
		}
		break;
	case 1:
		if (n == 100)
		{
			std::cout << 10100 << std::endl;
		}
		else
		{
			std::cout << n * 100 << std::endl;
		}
		break;
	case 2:
		if (n == 100)
		{
			std::cout << 1010000 << std::endl;
		}
		else
		{
			std::cout << n * 10000 << std::endl;
		}
		break;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;


template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int q;
	cin>>q;
	vector<ll>cnt_m(n+1),cnt_c(n+1);
	rep(i,n){
		cnt_m[i+1]=cnt_m[i]+ll(s[i]=='M');
		cnt_c[i+1]=cnt_c[i]+ll(s[i]=='C');
	}
	while(q--){
		int k;
		cin>>k;
		vector<vector<ll>>dp(2,vector<ll>(4));
		dp[0][0]=1;
		rep(i,k){
			rep(j,4){
				dp[(i+1)%2][j]+=dp[i%2][j];
			}
			if(s[i]=='D'){
				dp[(i+1)%2][1]+=dp[i%2][0];
			}
			else if(s[i]=='M'){
				dp[(i+1)%2][2]+=dp[i%2][1];
			}
			else if(s[i]=='C'){
				dp[(i+1)%2][3]+=dp[i%2][2];
			}
			rep(j,4)dp[i%2][j]=0;
		}
		for(int i=k;i<n;++i){
			if(s[i-k]=='D'){
				dp[i%2][2]-=(cnt_m[i]-cnt_m[i+1-k]);
				dp[i%2][1]--;
			}
			rep(j,4){
				dp[(i+1)%2][j]+=dp[i%2][j];
			}
			if(s[i]=='D'){
				dp[(i+1)%2][1]+=dp[i%2][0];
			}
			else if(s[i]=='M'){
				dp[(i+1)%2][2]+=dp[i%2][1];
			}
			else if(s[i]=='C'){
				dp[(i+1)%2][3]+=dp[i%2][2];
			}
			rep(j,4)dp[i%2][j]=0;
		}
		cout<<dp[n%2][3]<<"\n";
	}
	
}

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


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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n) cin>>a[i];
    int pre=-999;
    rep(i,n) {
        if(pre<=a[i]-1) pre=a[i]-1;
        else if(pre<=a[i]) pre=a[i];
        else {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % moder;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


P dat[1000000];
int size_ = 1;
void init(int x) {
	while (size_ < x)size_ *= 2;
	//rep(i, 2 * size_ - 1)dat[i] = { ((int)(1) << 31) - 1,inf };
}
void eval(int k, int l, int r) {
	if (dat[k].second) {
		dat[k].first += dat[k].second / (r - l);
		if (r - l > 1) {
			dat[k * 2 + 1].second += dat[k].second / 2;
			dat[k * 2 + 2].second += dat[k].second / 2;
		}
		dat[k].second = 0;
	}
}
void update(int a, int b, int k, int x, int l, int r) {
	eval(k, l, r);
	if (r <= a || b <= l)return;
	if (a <= l && r <= b) {
		dat[k].second += x * (r - l);
		eval(k, l, r);
	}
	else {
		update(a, b, k * 2 + 1, x, l, (l + r) / 2);
		update(a, b, k * 2 + 2, x, (l + r) / 2, r);
		dat[k].first = min(dat[k * 2 + 1].first, dat[k * 2 + 2].first);
	}
}
int query(int a, int b, int k, int l, int r) {
	eval(k, l, r);
	if (r <= a || b <= l)return inf;
	if (a <= l && r <= b) {
		return dat[k].first;
	}
	int lv = query(a, b, k * 2 + 1, l, (l + r) / 2);
	int rv = query(a, b, k * 2 + 2, (l + r) / 2, r);
	return min(lv, rv);
}
signed main() {
	int n, q;
	cin >> n >> q;
	init(n);
	rep(i, q) {
		int a; cin >> a;
		if (!a) {
			int s, t, x; cin >> s >> t >> x;
			update(s, t + 1, 0, x, 0, size_);
		}
		else {
			int s, t; cin >> s >> t;
			cout << query(s, t + 1, 0, 0, size_) << endl;
		}
	}
}


Measured memory_bytes: 6220
from collections import deque

N, K = map(int, input().split())
adj = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)
mod = 10 ** 9 + 7

color = [-1] * (N+1)
color[1] = K
queue = deque()
queue.append(1)
while queue:
    v = queue.popleft()
    cnt = 1 if v == 1 else 2
    for child_cand in adj[v]:
        if color[child_cand] == -1:
            queue.append(child_cand)
            color[child_cand] = K - cnt
            cnt += 1
ans = 1
for i in range(1, N+1):
    ans = (ans * color[i]) % mod
print(ans)


Measured memory_bytes: 66080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int sf[1010];

int main() {
    int a, b, n;
    cin >> a >> b >> n;
    priority_queue< P, vector<P>, greater<P> > que;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        que.push({x, y});
    }
    while (que.size()) {
        P p = que.top(); que.pop();
        sf[p.first]++;
        sf[p.second]--;
    }
    int tmp = 0;
    rep(i, b) {
        tmp += sf[i];
        if (i >= a) {
            if (tmp >= 1) {
                cout << 1 << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
}

Measured memory_bytes: 3092
#include <cstdio>

long long f[100] = {2, 1}, x;

int main() {
    scanf("%lld", &x);
    for(int i = 2; i <= x; ++i)
        f[i] = f[i - 1] + f[i - 2];
    printf("%lld\n", f[x]);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void) {
	int n,i,max=-1000000,min=1000000;
	int a[10000];
	long long int sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]>max)
			max=a[i];
		if(a[i]<min)
			min=a[i];
		sum+=a[i];
	}
 	printf("%d %d %lld\n",min,max,sum);


	return 0;
}



Measured memory_bytes: 2100