akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9+3;
const ll INF = 1e18+3;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

const int MAX_V = 50;
struct edge{int to, id;};
vector<edge> es[MAX_V];
bool flag;
ll path;

void dfs(int now, int g, int pre){
    if(now == g){
        flag = true;
    }
    else{
        for(auto &e: es[now]){
            if(e.to == pre) continue;
            dfs(e.to, g, now);
            if(flag){
                path |= 1LL<<e.id;
                break;
            }
        }
    }
}

int main(){
    int N;
    cin >> N;
    rep(i, N-1){
        int u, v; cin >> u >> v; u--, v--;
        es[u].eb((edge){v, i});
        es[v].eb((edge){u, i});
    }
    int M;
    cin >> M;
    ll edges[M];
    rep(i, M){
        int u, v; cin >> u >> v; u--, v--;
        flag = false, path = 0;
        dfs(u, v, -1);
        edges[i] = path;
    }
    ll ans = 0;
    rep(i, 1<<M){
        int n = __builtin_popcount(i);
        ll all = 0;
        rep(j, M) if(i & (1<<j)) all |= edges[j];
        int k = __builtin_popcountll(all);
        if(n&1) ans -= 1LL<<(N-1-k);
        else ans += 1LL<<(N-1-k);
    }
    cout << ans << endl;
}

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

using P = pair<int, int>;

#define N 100004

vector<int> g[N], g0[N];

vector<int> vs;
int lab[N], prv[N];

void dfs(int v, int p) {
  prv[v] = p;
  vs.push_back(v);
  lab[v] = vs.size();
  for(int w : g[v]) {
    if(w == p) {
      continue;
    }
    if(lab[w]) {
      if(lab[v] < lab[w]) {
        g0[v].push_back(w);
      }
      continue;
    }
    dfs(w, v);
  }
}

int used[N], ap[N];
vector<P> bs;
vector<int> aps;
void construct(int n) {
  dfs(0, -1);

  used[0] = 1;
  bool first = true;
  for(int u : vs) {
    if(!used[u]) {
      // (u, p) is a bridge
      int p = prv[u];
      bs.push_back(u < p ? P(u, p) : P(p, u));
      if(g[u].size() > 1) ap[u] = 1;
      if(g[p].size() > 1) ap[p] = 1;
    }
    bool cycle = false;
    for(int v : g0[u]) {
      int w = v;
      while(w != u && !used[w]) {
        used[w] = 1;
        w = prv[w];
      }
      if(w == u) {
        cycle = true;
      }
    }
    if(cycle) {
      if(!first) ap[u] = 1;
      first = false;
    }
  }
  for(int i=0; i<n; ++i) {
    if(ap[i]) aps.push_back(i);
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  for(int i=0; i<m; ++i) {
    int a, b; cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  construct(n);
  sort(bs.begin(), bs.end());
  for(P &e : bs) {
    cout << e.first << " " << e.second << endl;
  }
  return 0;
}


Measured memory_bytes: 9500
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        String s = sc.next();
        int len = s.length();
        pw.println(s.charAt(len-1) != 's' ? s+"s" : s+"es");
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int x,y;
    cin >> x >> y;
    cout << x+y/2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,s,e) for(ll i=s;i<e;++i)

int main()
{
    ll a;
    long double b;
    cin >> a >> b;

    ll ans=(a*(ll)(b*100+0.5))/100;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll a,b,k;
  cin >> a >> b >> k;
  for(int i=0;i<k;i++){
    if(i%2==0){
      b+=a/2;
      a/=2;
    }else{
      a+=b/2;
      b/=2;
    }
  }
  cout << a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define I insert
#define bull bool
#define Max(a,b) ((b<a)?a:b)
#define Min(a,b) ((a<b)?a:b)

const LL N = 200005, mod = 1000000007;

using namespace std;

LL n, m, i, j, k, l, r, t, ans = -mod;
pair < LL, LL > p[N];
vector < LL > v;

LL getint(){
	char c = getchar();
	LL t = 0;
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)){
		t = (t << 3) + (t << 1);
		t += c - '0';
		c = getchar();
	}
	return t;
}


int main(){
	/*/
	freopen ( "detectivein.txt", "r", stdin);
	freopen ( "detectiveout.txt", "w", stdout);
	/**/
	cin >> n >> k;
	if ( k > (n-1) * (n-2) / 2 ){
		cout << "-1\n";
		return 0;
	}
	for ( i = 1; i < n; ++i ){
		p[m] = MP(i, n);
		m++;
	}
	t = (n - 1) * (n - 2) / 2;
	for ( i = 1; i < n; ++i ){
		for ( j = i + 1; j < n; ++j ){			
			if ( t == k ) break;
			t--;
			p[m] = MP(i, j);
			m++;
		}
		if ( t == k ) break;
	}
	if ( t != k ){
		cout << "-1\n";
		return 0;		
	}
	cout << m << endl;
	for ( i = 0; i < m; ++i ){
		cout << p[i].F << " " << p[i].S << endl;
	}
	
	return 0;
}
/**/
//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O       O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE

Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N):
  ans += B[A[i]-1]
  if i >= 1:
    if A[i]-A[i-1] == 1:
      ans += C[A[i]-2]
print(ans)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	int cnt = 0;
	int day = 15 - s.size();
	rep(i, 0, s.size()) {
		if (s[i] == 'o')++cnt;
	}
	if (8 - cnt <= day)cout << "YES" << "\n";
	else cout << "NO" << "\n";

	return 0;
}

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

using namespace std;

vector<int> a;
stack<int> b, c;

bool dfs(int i)
{
	if (i == 10) return true;

	bool res1 = false, res2 = false;

	if (b.empty() || b.top() < a[i]) {
		b.push(a[i]);
		res1 = dfs(i + 1);
		b.pop();
	}

	if (c.empty() || c.top() < a[i]) {
		c.push(a[i]);
		res2 = dfs(i + 1);
		c.pop();
	}

	return res1 || res2;
}

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

	while (n--) {
		a.clear();
		while (b.size()) b.pop();
		while (c.size()) c.pop();

		for (int i = 0; i < 10; ++i) { int v; cin >> v; a.push_back(v); }

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

Measured memory_bytes: 1212
def partition(A,p,r):
    x = A[r]
    i = p-1
    # iは必ず1ずつ増える、jでx以下の要素を検出し、iの位置に持って行く
    for j in range(p,r):
        if A[j] <= x:
            i += 1
            A[i],A[j] = A[j],A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i+1

N = int(input())
B = list(map(int,input().split()))
b = partition(B,0,N-1)
#print(b)
B_str = list(map(str,B))
B_str[b] = '[' + B_str[b] +']'
print(' '.join(B_str))



Measured memory_bytes: 16584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

bool kaibun(string s){
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-1-i]) return false;
    }
    return true;
}

int main(){
    string s;
    cin>>s;
    int N=s.size();
    
    if(kaibun(s) && kaibun(s.substr(0,(N-1)/2)) && kaibun(s.substr((N+3)/2-1,N-1))) cout << "Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

s = sum([a[i] if i % 2 == 0 else -a[i] for i in range(n)])
print(s, end="")
for i in range(n - 1):
    s = 2 * a[i] - s
    print(" " + str(s), end="")
print()


Measured memory_bytes: 14092
#include<stdio.h>
#include<string.h>
int main(){
	int k;
	char kata[255];
	scanf("%d",&k);
	getchar();
	
	scanf("%[^\n]", &kata);
	int s = strlen(kata);
	
	for(int i= 0; i < k && kata[i] != '\0'; i++){
		printf("%c", kata[i]);
	}
	if(s>k){
		printf("...");
	}
	return 0;
}

Measured memory_bytes: 1700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int N =s.nextInt();
        int T = s.nextInt();
        int cnt=0;
        while (T-- > 0){
               cnt+=s.nextInt();
        }
        if(cnt > N)
            System.out.println(-1);
        else
            System.out.println(N-cnt);
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 27220
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int main(){
	
	int n;
	cin >> n;
	while(n--){
		int l = 0, r = 0;
		bool flag = true;
		rep(i, 10){
			int a;
			cin >> a;
			if(a > l) l = a;
			else if(a > r) r = a;
			else flag = false;
		}
		if(flag) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    long long l;
    long long r;
    cin >>l>>r;
    long long la=min(r%2019,l%2019);
    long long ra=max(r%2019,l%2019);
    long long ans=2020;
    if (r/2019-l/2019>=1 || r%2019==0 || l%2019==0) ans=0;
    for (long long i =la;i<ra;i++){
        for(long long j =i+1;j<=ra;j++){
             ans=min(ans,i*j%2019);
        }
    }
    cout <<ans;
}

Measured memory_bytes: 256
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    A,B=MI()
    if A%3==0 or B%3==0 or(A+B)%3==0:
        print("Possible")
    else:
        print("Impossible")
        

main()



Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
     #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.size();++i) sum+=s[i]-'0';
    int num=stoi(s);
    (num%sum==0)?cout<<"Yes":cout<<"No";
   return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	cin >> N;
	string res = "Three";
	REP(i, N) {
		char S;
		cin >> S;
		if (S == 'Y') res = "Four";
	}
	cout << res << "\n";

	return 0;
}

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

using namespace std;
#define ll long long
const int N=2005,INF=1e9;
bool vis[N],stk[N];
int in[N];
stack<int>st;
vector<int>adj[N];
int t=0;
vector<int>ans;
void solve(int u)
{
    ans.push_back(u);
    int mx=-1,e;
    for(auto v:adj[u])
        if(stk[v])
        {
            if(in[v]>mx)
            {
                mx=in[v];
                e=v;
            }
        }
    if(e!=ans[0])solve(e);
}
void dfs(int u)
{
    vis[u]=1;
    stk[u]=1;
    in[u]=t++;
    st.push(u);
    int mx=-1,e;
    for(auto v:adj[u])
        if(stk[v])
        {
            if(in[v]>mx)
            {
                mx=in[v];
                e=v;
            }
        }
    if(mx!=-1)
    {
        solve(e);
        cout<<ans.size()<<'\n';
        for(auto x:ans)
            cout<<x<<'\n';
        exit(0);

    }
    for(auto v:adj[u])
        if(!vis[v])
            dfs(v);

    stk[u]=0;
    st.pop();
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
    }
    for(int i=1;i<=n;i++)
    {
        memset(vis,0,sizeof vis);
        t=0;
        dfs(i);
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    vector<int> a(5);
    rep(i,5){
        cin>>a.at(i);
        if(a.at(i)==0) cout<<i+1;
    }
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,k; cin >> n >> k;
    ll ans = n%k;
    cout << min(ans,k-ans) << endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N, T, A; cin >> N >> T >> A;
    vi H(N); REP(i, N) cin >> H[i];
    vector<float> temperature(N);
    REP(i, N) temperature[i] = T - (float)H[i]*0.006;

    int ans = 0;
    REP(i, N)
    {
        if(abs(temperature[ans]-A) > abs(temperature[i]-A)) ans = i;
    }

    cout << ans + 1 << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	
	string n;
	cin >> n;
	if (n[0] == '9' || n[1] == '9'){
		cout << "Yes" << endl;
	}
	else{ cout << "No" << endl; }

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
  ll n,k;//,ans1=1,ans2=1;
  cin>>n>>k;
  
  vll a(n);
  rep(i,n)cin>>a.at(i);
  /*
  rep(i,k)ans1*=a.at(i);
  ans2=ans1;
  
  rep2(i,k,n){
      ans2/=a.at(i-k);
      ans2*=a.at(i);
      
      if(ans2>ans1)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
      
      ans1=ans2;
  }
  */
   rep2(i,k,n){
       if(a.at(i-k)<a.at(i))cout<<"Yes"<<endl;
       else cout<<"No"<<endl;
       
   }
  
  
}



Measured memory_bytes: 4840
#ifdef __GNUC__ 
#include <bits/stdc++.h>
auto & inputdatastream = std::cin;
#else
std::ifstream inputdatastream;
#endif
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/preprocessor.hpp>
#include <boost/mpl/int.hpp>

using namespace std;
#define ALL(v) std::begin(v),std::end(v)
#define RALL(v) std::rbegin(v),std::rend(v)
using u6 = std::uint64_t;
using u3 = std::uint32_t;
constexpr u6 moduloNo = 1'000'000'000 + 7; //' 1e9 + 7
#define DEFVALUE1(r,type,name) type name;
#define DEFINIT0(r,type,name) in >> name;
#define DEFINIT1(r,size,name) name.resize(size);
#define DEFINITER template <typename T, typename In> void init(const T &, In &) {}
#define DEF_TYPEEXTSELECTOR(fnext,tpl)BOOST_PP_IF(BOOST_PP_TUPLE_ELEM(0, fnext)  ,BOOST_PP_TUPLE_ELEM(2, fnext),BOOST_PP_TUPLE_ELEM(0, tpl) )
#define DEFVALUEIMPL(r,fnext,tpl) BOOST_PP_LIST_FOR_EACH(BOOST_PP_TUPLE_ELEM(1,fnext),DEF_TYPEEXTSELECTOR(fnext,tpl), BOOST_PP_TUPLE_TO_LIST(BOOST_PP_TUPLE_POP_FRONT(tpl)))
#define DEFVALUES(expr) DEFIMPL(expr,0,DEFINIT0,0,_)
#define DEFIMPL(expr,deftypeindex,initcode,c,ext)																									\
	BOOST_PP_SEQ_FOR_EACH(DEFVALUEIMPL,(0,DEFVALUE1,_),BOOST_PP_VARIADIC_SEQ_TO_SEQ(expr))															\
			template <typename In> decltype(auto) init(boost::mpl::int_<deftypeindex> ,In & in){													\
				BOOST_PP_SEQ_FOR_EACH(DEFVALUEIMPL,(c,initcode,ext),BOOST_PP_VARIADIC_SEQ_TO_SEQ(expr));return in;}
#define DEFVECS(size,expr)  DEFIMPL(expr,1,DEFINIT1,1,size)
#define DEFSTRUCT(name,...) struct name{DEFINITER;__VA_ARGS__ ;friend std::istream & operator>>(std::istream & in,name & target){				\
	target.init(boost::mpl::int_<0> (),in);target.init(boost::mpl::int_<1>() ,in);return in;} }

template <typename T>
struct invecT {
	decltype(auto) begin()const {
		return std::istream_iterator<T>(inputdatastream);
	}
	decltype(auto) end()const {
		return std::istream_iterator<T>();
	}
};
template <typename T>invecT<T> invec;

DEFSTRUCT(datatype,
	DEFVALUES((int, x, y, z))
);


struct Calc {
	DEFINITER;
	/*******************************************************************************/
	DEFVALUES(
		(int,N,M)
	);
	DEFVECS(N+1 , (vector<int>, v));
	auto calc() {
		int dup = 0;
		vector<int> updateindex;
		auto fn=[&,this](int c) {
			if (!v[c])v[c] = c;
			do{
				updateindex.push_back(c);
				c = v[c]; 
			} while (v[c] != c);
			return c;
		};
		for (auto d : invec<datatype>) {
			int l=fn(d.x);int r= fn(d.y);
			int minval=l;
			if (l == r)++dup;
			else if (l < r)updateindex.push_back(r);
			else { updateindex.push_back(l); minval = r; }
			for (auto i : updateindex)v[i] = minval;
			updateindex.clear();
		}
		return N-M+dup;
	}
	/*******************************************************************************/
};
Calc calc;

int main() {
	ios::sync_with_stdio(false);cin.tie(0);
#ifndef __GNUC__ 
	inputdatastream.open("inputdata.txt");
#endif
	calc.init(boost::mpl::int_<0>(),inputdatastream);
	calc.init(boost::mpl::int_<1>(),inputdatastream);
	cout << calc.calc() << endl;
}


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

int main(){
  int K,N;
  cin >> K >> N;
  vector<int> A(N);
  vector<int> a(N);

  for(int i=0;i<N;i++){
    cin >> A.at(i);
    if(i>0){
	  a.at(i)=A.at(i)-A.at(i-1);
    }
  }
  a.at(0)=K-A.at(N-1)+A.at(0);
  sort(a.begin(),a.end());
  cout << K-a.at(N-1) << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl v(n),s(n);
	map<ll,ll> mp;
	rep(i,n)cin>>v[i],s[i]=v[i],mp[v[i]]++;
	ll ans=*max_element(all(v));
	sort(rall(s));
	ll sec=0;
	rep(i,n){
		if(s[0]!=s[i]){
			sec=s[i];
			break;
		}
	}
	rep(i,n){
		ll ot=ans;
		if(v[i]==ans&&mp[ans]==1)ot=sec;
		cout<<ot<<"\n";
	}
}


Measured memory_bytes: 12160
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 1; i <= n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

ll N;

int main() {
    cin >>N;

    ll ans =0;
    REP(i, N) {
        string s = to_string(i);
        if (s.size() %2==1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math
import itertools
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
k = int(input())
count = 0
list_k = [i for i in range(1,k+1)]

#case すべて同じ数字の場合
count += k*(k + 1)/2
#case 2つ同じ数字の場合
combi2 = itertools.combinations(list_k,2)
for x in list(combi2):
  count += math.gcd(x[0],x[1]) * 6
#case すべて異なる数字の場合
combi3 = itertools.combinations(list_k,3)
for x in list(combi3):
  count += gcd(x[0],x[1],x[2]) * 6
print(int(count))

Measured memory_bytes: 102856
n,m=map(int, input().split())
List=list(map(int, input().split()))
d=[0]*n*9+[-1]*n*9
#print(d)
for i in range(1, n+1):
    d[i]=max(d[i-int("0255456376"[a])]*10+a for a in List)
print(d[n])


Measured memory_bytes: 56444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)


int main(){
  int  n;
  cin >> n ;
  vector<char> s(n);
 rep(i,n) cin >> s.at(i);
  ll cntr=0;
  ll cntg=0;
  ll cntb=0;
  rep(i,n){
    if(s.at(i)=='R')cntr++;
    else if(s.at(i)=='G')cntg++;
    else if(s.at(i)=='B')cntb++;
  }
  VI r(cntr);
  VI g(cntg);
  VI b(cntb);
  ll cntrr=0;
  ll cntgg=0;
  ll cntbb=0;
  set<int> rr;
  set<int> bb;
  set<int> gg;
  rep(i,n){
    if(s.at(i)=='R'){
      r.at(cntrr)=i;
      rr.insert(i);
      cntrr++;
    }
    else if(s.at(i)=='G'){
      g.at(cntgg)=i;
      gg.insert(i);
      cntgg++;
    }
    else if(s.at(i)=='B'){
      b.at(cntbb)=i;
      bb.insert(i);
      cntbb++;
    }
  }
  ll sum=0;
  rep(i,cntr){
	rep(j,cntg){
     
        if(bb.count(2*g.at(j)-r.at(i)))sum++;
        if(bb.count(2*r.at(i)-g.at(j)))sum++;  
        if((r.at(i)+g.at(j))%2==0){
          if(bb.count((r.at(i)+g.at(j))/2))sum++;
        }
    }
  }
  
  
   cout << cntr*cntg*cntb-sum << endl;
    
          
   
}
  

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MAX = 123456;

long long fac[MAX], finv[MAX], inv[MAX];

inline void mod_add(long long &x, long long y) {
	x += y;
	if(x >= mod) x -= mod;
}

inline void mod_sub(long long &x, long long y) {
	x -= y;
	if(x < 0) x += mod;
}

inline long long mod_mul(long long x, long long y) {
	return (long long) (x % mod * y % mod);
}

inline long long mod_inv(long long x) {
	x %= mod;
	if(x < 0) x += mod;
	long long y = mod, u = 0, v = 1;
	while(y) {
		long long t = y / x;
		y -= t * x; swap(x, y);
		u -= t * v; swap(u, v);
	}
	if(u < 0) u += mod;
	return u;
}

inline long long mod_pow(long long x, long long y) {
	long long res = 1;
	while(y) {
		if(y & 1) res = mod_mul(res, x);
		x = mod_mul(x, x);
		y >>= 1;
	}
	return res;
}

inline void pre_mod_nCk() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i = 2; i < MAX; i++) {
		fac[i] = mod_mul(fac[i - 1], i);
		inv[i] = mod - mod_mul(inv[mod % i], mod / i);
		finv[i] = mod_mul(finv[i - 1], inv[i]);
	}
}

inline long long mod_nCk(int n, int k) {
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return mod_mul(fac[n], mod_mul(finv[k], finv[n - k]));
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 
	pre_mod_nCk();
	int n, m;
	cin >> n >> m;
	if(m == 1) {
		cout << 1 << '\n';
		return 0;
	}
	map<int, int> mp;
	for(int i = 2; i * i <= m; i++) {
		while(m % i == 0) {
			m /= i;
			mp[i]++;
		}
	}
	long long ans = 1;
	if(m != 1) mp[m]++;
	for(auto i : mp) {
		int num = i.second;
		ans = ans * mod_nCk(num + n - 1, num) % mod;
	}
	cout << ans << endl;

	return 0;	
}


Measured memory_bytes: 3200
A, B, C, X, Y = map( int, input().split() )

if A + B > 2 * C:
  m = min( X, Y )
  print( min( 2 * C * m + ( X - m ) * A + ( Y - m ) * B, 
              2 * C * m + ( X - m ) * 2 * C + ( Y - m ) * 2 * C ) )
else:
  print( X * A + Y * B )

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BTripleDots solver = new BTripleDots();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTripleDots {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int k = in.nextInt();
            String s = in.next();
            if (s.length() <= k)
                out.println(s);
            else
                out.println(s.substring(0, k) + "...");

        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main() {
  int N, K;
  cin >> N >> K;

  int move_d = 0;
  for (int i=0; i<N; i++) {
    int xi;
    cin >> xi;

    move_d += min(xi, K-xi);
  }
  cout << move_d*2 << endl;
}

Measured memory_bytes: 256
N = int(input())
A= list(map(int, input().split()))
minus = 0
A_abs = []
for i in range(N):
    A_abs.append(abs(int(A[i])))
    if(A[i] < 0):
        minus += 1

if minus % 2 == 0:
    print(sum(A_abs))
else:
    print(sum(A_abs) - 2*min(A_abs))

Measured memory_bytes: 14284
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
int A[999999], W[999999];
long long merge_and_count(int l, int r) { // range [l,r)
	if (l+1 >= r) return 0; // empty
	if (l+2 == r) { // [l,r) == [l,l+1] 要素2つだけ
		if (A[l] <= A[l+1]) return 0; // 逆転はなし
		std::swap(A[l], A[l+1]);
		return 1; // 逆転一つ
	}
	int m = (l+r)/2; // [l,r) == [l,m) + [m,r)
	long long cl = merge_and_count(l, m); // 左半分を再帰的に数える
	long long cr = merge_and_count(m, r); // 右半分を再帰的に数える
	long long c = 0; // 左と右を混ぜるときの逆転数
	int i=l, j=m; // iは[l,m)を動き, jは[m,r)を動いて、
	int k=l; // 小さいものから W[k] に書き込む
	while (i<m && j<r) { // A[i]とA[j]を比べながら進む
		if (A[i] <= A[j]) W[k++] = A[i++]; // 左半分の方が小さく逆転なし
		else {
			W[k++] = A[j++];
			c += m-i; // 左半分の方が大きい、左半分で未処理の要素だけ飛び越える
		}
	}
	while (i<m) W[k++] = A[i++]; // 左半分が余った場合
	while (j<r) W[k++] = A[j++]; // 右半分が余った場合
	//assert(k == r);
	std::copy(W+l, W+r, A+l);
	return cl + cr + c;
}

// cpp_binarysearch (C) @cielavenir under Boost Software License.
// returns the smallest value satisfying the predicate.

#include <functional>
template<typename T,typename F=std::function<bool(T)>>
T binarysearch(T lo,T hi,const T eps,const F &predicate){
	T r=hi+eps;
	for(;lo<hi+eps;){
		T mi=eps!=1||(lo<0)==(hi<0) ? lo+(hi-lo)/2 : (lo<-hi) ? -((-lo-hi-1)/2+1) : (lo+hi)/2;
		if(predicate(mi)){
			r=mi;
			hi=mi-eps;
		}else{
			lo=mi+eps;
		}
	}
	return r;
}

int main(){
	int T,i,N;
	scanf("%d",&N);std::vector<int>v(N);for(T=i=0;i<N;i++){scanf("%d",&v[i]);if(v[i]>T)T=v[i];}
	printf("%d\n",-1+binarysearch(0,T,1,[&](int m){
		A[0]=0;//v[0]>=m?1:-1;
		for(i=1;i<=N;i++)A[i]=A[i-1]+(v[i-1]>=m?1:-1);
		return merge_and_count(0,N+1)>=((long long)(N+1)*(N+0)+4)/4;
	}));
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

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

  ll ans = 0;
  // reverse(s.begin(), s.end());
  rep(i, 1 << (s.size() - 1)){
    ll tmp = (s[0]-'0');
    // cout << tmp << endl;
    // cout << " " << endl;
    rep(j, s.size() - 1){
      // tmp += (s[j]-'0');
      // ten *= 10;
      if (i>>j&1) {
        ans += tmp;
        tmp = s[j+1] - '0';
        // ten = 1;
        // tmp = 0;
      }
      else{
        tmp *= 10;
        tmp += (s[j+1]-'0');
      }
      // cout << tmp << endl;
    }
    ans += tmp;
    // cout << " " << endl;
  }
  // rep(i, s.size()) cout << s[i]-'0' << endl;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <cmath>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    rep(i,N){
        cin>>A.at(i);
    }
    long int count=0;
    rep(i,N-1){
        if(A.at(i+1)<A.at(i)){
            count+=A.at(i)-A.at(i+1);
            A.at(i+1)=A.at(i);
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3912
from collections import deque
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
edges = [[]for _ in range(n)]
dinp = [0]*n
for _ in range(m):
    x, y = list(map(lambda x: int(x)-1, input().split()))
    edges[x].append(y)
    dinp[y] += 1

queue = deque([])
for i in range(n):
    if dinp[i] == 0:
        queue.append(i)

toposorted = []
while queue:
    v = queue.popleft()
    toposorted.append(v)
    for v2 in edges[v]:
        dinp[v2] -= 1
        if dinp[v2] == 0:
            queue.append(v2)

dist = [0]*n
for i in range(n):
    v = toposorted[i]
    for v2 in edges[v]:
        if dist[v2] <= dist[v]-1:
            continue
        dist[v2] = dist[v]-1
print(-min(dist))


Measured memory_bytes: 62496
#include <bits/stdc++.h>
#define maxn 200010
#define modn 1000000007
int fac[maxn],inv[maxn],n,a,b,c,x,y,i,ans=0;
int power(int x,int y)
{
	int s=1,i=x;
	for (;y;y>>=1)
	{
		if (y&1) s=1LL*s*i%modn;
		i=1LL*i*i%modn;
	}
	return s;
}
int C(int n,int m)
{
	return 1LL*fac[n]*inv[m]%modn*inv[n-m]%modn;
}
int main()
{
	scanf("%d%d%d%d",&n,&a,&b,&c);
	x=1LL*a*power(a+b,modn-2)%modn;
	y=(1-x+modn)%modn;
	fac[0]=1;
	for (i=1;i<=n*2;i++)
		fac[i]=1LL*fac[i-1]*i%modn;
	inv[n*2]=power(fac[n*2],modn-2);
	for (i=n*2-1;i>=0;i--)
		inv[i]=1LL*inv[i+1]*(i+1)%modn;
	for (i=0;i<n;i++)
		ans=(1LL*ans+1LL*C(n+i-1,i)*power(x,n)%modn*power(y,i)%modn*(n+i)%modn+1LL*C(n+i-1,i)*power(x,i)%modn*power(y,n)%modn*(n+i)%modn)%modn;
	ans=100LL*ans%modn*power(a+b,modn-2)%modn;
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    vector<int> ans(N,0);
    for(int i=0; i<M; i++){
        int a;
        cin >> a;
        for(int j=0; j<N; j++){
            if(A[j]<=a){
                ans[j]++;
                break;
            }
        }
    }
    int mx = 0;
    int id;
    for(int i=0; i<N; i++){
        if(mx < ans[i]){
            mx = ans[i];
            id = i;
        }
    }
    cout << id+1 << "\n";
    return 0;

}



Measured memory_bytes: 3204
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final int MOD = 1000000007;
        final Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        final int[] a = new int[N+1];
        for (int i = 0; i < M; i++) {
            a[scanner.nextInt()] = -1;
        }
        a[0] = 1;
        for (int i = 0; i < a.length; i++) {
            if (a[i] == -1) continue;
            if (i+1 < a.length && a[i+1] != -1)
                a[i + 1] = (a[i] + a[i + 1]) % MOD;
            if (i+2 < a.length && a[i+2] != -1) {
                a[i + 2] = (a[i] + a[i + 2]) % MOD;
            }
        }
        System.out.println(a[N] % MOD);
    }
}


Measured memory_bytes: 50552
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

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

int main() {
	string t;
	cin >> t;
	int n = t.size();
	rep(i, n) {
		if (t[i] == '?') {
			if (i == 0) {
				t[i] = 'D';
				continue;
			}
			else if (t[i - 1] == 'P') {
				t[i] = 'D';
				continue;
			}
			else t[i] = 'D';
		}
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}
int last_digit(int n)
{
    int ans = 0;
    while (n != 0)
    {
        ans = n % 10;
        n /= 10;
    }
    return ans;
}
int main()
{
    ll x;
    cin >> x;
    if (x >= 30)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
}

Measured memory_bytes: 3632
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let o : String= read();
    let e : String = read();
    let e = if e.len() < o.len(){
        e + " "
    } else {
        e
    };
    let mut ans : String = o.chars().zip(e.chars())
        .flat_map(|(x,y)| vec![x,y]).collect();
    println!("{}",ans );
}

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

int main()
{
	int q, a, b;
	string str, com;
	cin >> str >> q;
	while (q--) {
		cin >> com;
		if (com == "print") {
			cin >> a >> b;
			cout << str.substr(a, b - a + 1) << endl;
		}
		else if (com == "reverse") {
			string tmp = str;
			cin >> a >> b;
			for (int i = 0; i + a <= b; i++) {
				str[a + i] = tmp[b - i];
			}
		}
		else {
			string tmp;
			cin >> a >> b >> tmp;
			for (int i = 0; i + a <= b; i++) {
				str[a + i] = tmp[i];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 100003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
#define sp " "
#define zero (ll)0
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
void READ(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        v.pb(a) ;
    }
}
void PRINT(vll &v , ll a = 0)
{
    //ll a ;
    for(ll i=a ; i<v.size() ; i=i+1)
    {
        v[i] = max((ll)0,v[i]);
        cout<<v[i]<<" " ;
    }
    cout<<"\n" ;
}
/*vbool isprime(N,true);
vll spf(N,0);
vll prime;
void sieve()
{
    isprime[0] = isprime[1] = false;
    for(ll i = 2 ; i<N ; i++)
    {
        if(isprime[i])
        {
            for(ll j=2*i ; j<N ; j+=i)
            {
                isprime[j] = false;
                if(spf[j]==0)
                {
                    spf[j] = i;
                }
            }
            prime.pb(i);
        }
    }
}*//*
ll nck(ll n , ll k ,ll m=1e18+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}*//*
long long power(long long k , long long n , long long m=mod)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}*/
ll n,m,k,l,r;
bool ok = false;
ll dp[N][6];
int main()
{
    FastIO ;
    PRECISION ;
    ll a,b,c,d,i,j,t,x,y,z;//,x1,y1,z1,e,f;
    ll p,q,r,u,w ;
    char ch,chr ;
    string str,st,str1,str2,str3,str4;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    cin>>n;
    c = 0;
    rep(i,1,n+1)
    {
        if(i%3==0 || i%5==0)
        {
            continue;
        }
        c+=i;
    }
    cout<<c;
}

Measured memory_bytes: 3624