akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int M, K;
	cin >> M >> K;

	if ((1 << M) <= K) {
		cout << -1 << endl;
		return 0;
	}
	if(M==1 && K==1) {
		cout << -1 << endl;
		return 0;
	}
	else if(M==1&&K==0) {
		cout << "0 0 1 1" << endl;
		return 0;
	}
	else if (M == 0) {
		cout << 0<<" "<<0 << endl;
		return 0;
	}
	REP(i, 1 << M) {
		if (i == K)continue;
		cout << i << " ";
	}
	cout << K << " ";
	for (int i = 1<<M; i > 0; i--) {
		if (i-1 == K)continue;
		cout << i-1 << " ";
	}
	cout << K << endl;


	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;

using ll = long long;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

int main(){
  ll N;
  cin >> N;
  vector<ll> a(N), order(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  for(int i = 0; i < N; i++) order[a[i] - 1] = i;

  set<int> se;
  se.insert(-1);
  se.insert(N);

  ll ans = 0;
  for(int i = 0; i < N; i++){
    auto itr = se.lower_bound(order[i]);
    ll right = *itr - order[i];
    itr--;
    ll left = order[i] - *itr;
    ans += a[order[i]] * left * right;
    se.insert(order[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int64_t> l(n+1);
  l[0] = 2;
  l[1] = 1;
  for(int i = 2; i < n+1; i++){
    l[i] = l[i-1]+l[i-2];
  }
  cout << l[n] << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
int a[105];
double ans;
int main(){
	cin>>n;
	rep(i,n){
		cin>>a[i]; ans += (double)(1.0) / (double)(a[i]);
	}
	printf("%.12f\n",(double)(1.0) / ans);

}

Measured memory_bytes: 256
n = int(input())
xlst = list(map(int, input().split()))
m = int(input())
alst = list(map(int, input().split()))
for a in alst:
    if (a == n or xlst[a] - xlst[a - 1] > 1) and xlst[a - 1] < 2019:
        xlst[a - 1] += 1

print(*xlst, sep="\n")


Measured memory_bytes: 5612
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    string s = "";
    cin >> s;
    int cnt = 1;
    bool flag = true;
    for (int i=1; i<s.size(); i++) {
        if (flag) {
            if (s.at(i) == s.at(i-1)) {
                flag = false;
                cnt++;
                i++;
                if (i == s.size()) {
                    cnt--;
                }
            }
            else {
                cnt++;
                flag = true;
            }
        }
        else {
            cnt++;
            flag = true;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 644
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int a, b;

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

    if((a + b) % 2 == 0){
        printf("%d\n", (a+b) / 2);
    }else{
        printf("%d\n", (a+b) / 2 + 1);
    }

    return 0;
}

Measured memory_bytes: 1680
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <sstream>
#include <cstdlib>
using namespace std;
string str,ln;
int die[6]={0};
int i,n,v;
int DICE(){
	for(i=0;i<str.size();i++){
		if(str[i]=='E'){
			v=die[0];
			die[0]=die[3];
			die[3]=die[5];
			die[5]=die[2];
			die[2]=v;
		}else if(str[i]=='W'){
			v=die[0];
			die[0]=die[2];
			die[2]=die[5];
			die[5]=die[3];
			die[3]=v;
		}else if(str[i]=='N'){
			v=die[0];
			die[0]=die[1];
			die[1]=die[5];
			die[5]=die[4];
			die[4]=v;
		}else if(str[i]=='S'){
			v=die[0];
			die[0]=die[4];
			die[4]=die[5];
			die[5]=die[1];
			die[1]=v;
		}
	}
	return die[0];
}
int main(){
	for(i=0;i<6;i++){
		cin>>die[i];
	}
	getline(cin,ln);
	getline(cin,str);
	DICE();
	cout<<die[0]<<endl;
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
using namespace std; // 575

int main() {
	string S;
	cin >> S;
	int ans = 0, l=S.size();
	for (int i = 0;i < l;++ i) ans += S[i] + i & 1;
	cout << min(ans, l-ans);
	return 0;
}

Measured memory_bytes: 512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    long long N;
    cin >> N;

    vector<vector<long long>> F(N, vector<long long>(10));
    for (int i = 0; i < N; i++) for (int j = 0; j < 10; j++) cin >> F[i][j];

    vector<vector<long long>> P(N, vector<long long>(11));
    for (int i = 0; i < N; i++) for (int j = 0; j < 11; j++) cin >> P[i][j];

    long long ans = LONG_LONG_MIN;

    for (int bit = 0; bit < (1 << 10); bit++) {
        if (bit == 0) continue;
        long long sum = 0;
        for (int i = 0; i < N; i++) {
            int count = 0;
            for (int j = 0; j < 10; j++) if (F[i][j] && (bit & (1 << j))) count++;
            sum += P[i][count];
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;

}

































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> firstDigitMemo(10, 0);

    ll ans = 0;
    for(int i = 0; i < n - 2; i++){
        int c_i = s[i] - '0';
        if(firstDigitMemo[c_i] != 0){
            continue;
        }
        firstDigitMemo[c_i] = 1;
        vector<int> secondDigitMemo(10, 0);
        for(int j = i + 1; j < n - 1; j++){
            int c_j = s[j] - '0';
            if(secondDigitMemo[c_j] != 0){
                continue;
            }
            secondDigitMemo[c_j] = 1;
            vector<int> thirdDigitMemo(10, 0);
            for(int k = j + 1; k < n; k++){
                int c_k = s[k] - '0';
                if(thirdDigitMemo[c_k] != 0){
                    continue;
                }
                thirdDigitMemo[c_k] = 1;
                ans++;
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int K; cin >> K;
    string S; cin >> S;

    int len = S.length();
    if(len <= K){
        cout << S << endl;
    }else{
        cout << S.substr(0,K) << "..." << endl;
    }

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string, string>;
ll MOD = 1e9+7;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<set<int>> d(n);
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;b--;
        d[a].insert(b);
        d[b].insert(a);
    }
    ll size = 0;
    for(int i = 0; i < n; i++)
    {
        size += d[i].size();
    }
    size /= 2;
    if(size % 2 == 1)
    {
        cout << -1 << endl;
        return 0;
    }

    vector<vector<int>> ans(n);
    function<void(int, int)> dfs = [&](int now, int pre)
    {
        while(d[now].size())
        {
            int next = *d[now].begin();
            if(next == pre) continue;
            d[now].erase(next);
            d[next].erase(now);
            dfs(next, now);
        }
        int as = ans[now].size();
        if(pre == -1) return;
        if(as % 2 == 1)
        {
            ans[now].push_back(pre);
        }
        else
        {
            ans[pre].push_back(now);
        }
    };
    dfs(0, -1);
    for(int i = 0; i < n; i++)
    {
        for(int to : ans[i])
        {
            cout << i+1 << " " << to+1 << endl;
        }
    }
}



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

int main(){ 
  string s; cin >> s;
  
  for(int i = 0; i < (int)s.size(); i++){ 
    cout <<"x";
  }
  
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int cnt = 1;
		while(a != 0) {
			System.out.println("Case "+ cnt + ": " + a);
			a = sc.nextInt();
			cnt += 1;
		}
		sc.close();
	}

}



Measured memory_bytes: 42068
#include <stdio.h>
#include <string.h>
#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch=='A') return 1;
  if(ch=='C') return 2;
  if(ch=='G') return 3;
  if(ch=='T') return 4;
  else return 0;
}

long long getkey(char str[]){
  long long sum=0,p=1,i;

  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;

}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
  long long key,i,h;
  key=getkey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getkey(str);
  for(i=0; ;i++){
  h=(h1(key)+i*h2(key))%M;
  if(strcmp(H[h],str)==0) return 1;
  else if(strlen(H[h])==0){
    strcpy(H[h],str);
    return 0;
  }  
 }
  return 0;
}

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++) H[i][0]='\0';

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%s",com,str);
    if(com[0]=='i'){
      insert(str);
    }
    else{
      if(find(str)) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}



Measured memory_bytes: 16040
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

int n;
const int maxn = 2e5 + 5;

int cnt[maxn];
int a[maxn];

int main(){
    cin >> n;
    long long ans = 0;
    for(int i = 1;i <= n;i++){
        scanf("%d", &a[i]);
        ans += cnt[a[i]];
        cnt[a[i]]++;
    }
    for(int i = 1;i <= n;i++){
        long long tmp = ans;
        tmp -= (cnt[a[i]] - 1);
        printf("%lld\n", tmp);
    }
    return 0;
}


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

int hoge(int n){
    int sum = 0;
    while (n) {
        if (n % 2 == 0) {
            sum++;
        }
        n /=2;
    }
    return sum;
}

int main() 
{
    int N;
    cin >> N;
    
    int ans = 0;
    int sum = 0;
    for (int i = 1; i <= N; i++) {
        if (sum < hoge(i)) {
            sum = hoge(i);
            ans = i;
        }
    }
    if (ans == 0) {
        cout << N << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define INF 100000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<string> A(N);
    for (ll i = 0; i < N; ++i) {
        cin >> A.at(i);
    }
    vector<string> B(M);
    for (ll i = 0; i < M; ++i) {
        cin >> B.at(i);
    }
    for (ll i = 0; i <= N - M; ++i) {
        for (ll j = 0; j <= N - M; ++j) {
            if (A.at(i).at(j) == B.at(0).at(0)) {
                bool is_same = true;
                for (ll k = 0; k < M; ++k) {
                    for (ll l = 0; l < M; ++l) {
                        if (A.at(i + k).at(j + l) != B.at(k).at(l)) {
                            is_same = false;
                            break;
                        }
                    }
                    if (!is_same) {
                        break;
                    }
                }
                if (is_same) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  long a, b, c, d; cin >> a >> b >> c >> d;
  cout << max(a*c, max(a*d, max(b*c, b*d)));
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 1; I <= (N); ++I)
#define REPP(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORR(I, A, B) for (int I = (A); I >= (B); I--)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;

int main() {
    int n,m;
    cin >> n >> m;
    LL l = 1;
    LL r = n;
    REP(i,m) 
    {
        LL L, R;
        cin >> L >> R;
        l = max(l, L);
        r = min(R, r);
    }
    //cout << l << r << endl;
    cout << max(0LL, r - l + 1) << endl;
    return 0;
}


Measured memory_bytes: 384
import sys

sys.setrecursionlimit(100000)


def dfs1(v, p):
    val = 1
    pre_mul = [1]
    rev_mul = []
    for c in links[v]:
        if c == p:
            pre_mul.append(val)
            rev_mul.append(1)
            continue
        res = 1 + dfs1(c, v)
        val *= res
        val %= m
        pre_mul.append(val)
        rev_mul.append(res)
    dp[v] = val
    for i in range(len(rev_mul) - 2, -1, -1):
        rev_mul[i] *= rev_mul[i + 1]
        rev_mul[i] %= m
    rev_mul.append(1)
    pre_muls[v] = [pre_mul, rev_mul]
    return val


def dfs2(v, p, a):
    dp[v] = dp[v] * a % m
    pmv = pre_muls[v]
    for i, c in enumerate(links[v]):
        if c == p:
            continue
        pmc = pmv[0][i] * pmv[1][i + 1] % m
        pmc = pmc * a % m
        dfs2(c, v, pmc + 1)


n, m = map(int, input().split())
links = [[] for _ in range(n)]
dp = [0 for _ in range(n)]
pre_muls = [None for _ in range(n)]
for line in sys.stdin.readlines():
    x, y = map(int, line.split())
    x -= 1
    y -= 1
    links[x].append(y)
    links[y].append(x)
dfs1(0, None)
dfs2(0, None, 1)
print('\n'.join(map(str, dp)))


Measured memory_bytes: 180896
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int a = (int)(s[0] - '0');
    int b = (int)(s[1] - '0');
    int c = (int)(s[2] - '0');
    int d = (int)(s[3] - '0');
    if (a + b + c + d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    else if (a + b + c - d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    else if (a + b - c + d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    else if (a - b + c + d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    else if (a + b - c - d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    else if (a - b + c - d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    else if (a - b - c + d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    else if (a - b - c - d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=0;
    char pres='-';
    for(int i=0;i<n;i++){
        char s;
        cin>>s;
        if(pres!=s){
            pres=s;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def solve(plan, N):
    """

    :param plan: [time, x, y]
    :param N: number of plan
    :return: 'Yes' or 'No'
    """
    time = 0
    posi = [0,0]
    for i in range(N):
        next = plan[i][1:]
        dist = abs(next[0]-posi[0])+abs(next[1]-posi[1])
        if dist > plan[i][0] - time:
            return 'No'
        elif (plan[i][0] - time - dist) % 2 == 1 :
            return 'No'
        posi=next[:]
        time=plan[i][0]

    return 'Yes'

if __name__ == '__main__':
    N = int(input())

    plan = []
    for i in range(N):
        plan.append(list(map(int, input().split(' '))))

    plan.sort(key=lambda x: x[0])
    print(solve(plan, N))


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

int main(){
  int a,b,t;
  cin>>a>>b;
  if(a>b){t=a;a=b;b=t;}
  for(int i=a;i<=b;i++){
    if(i-a==b-i){
      cout<<i;
      return 0;
    }
  }
  
  cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 256
#include <stdio.h>

int s[1000000];
int main(void)
{
	int a;
	int i;
	int j;
	int k;
	int cnt = 0;
	
	for (i = 0; i < 1000000; i++) {
		s[i] = 1;
	}
	s[0] = 0;
	
	//?´???°?????????
	for (i = 2; i * i < 1000000; i++) {
		for (j = 2; i * j < 1000000; j++) {
			if (i % j == 0) {
				for (k = j; i * k < 1000000; k++) {
					 s[i * k] = 0;
				}
			}
		}
//		printf("%d", s[i]);
	}
	
	while (scanf("%d", &a) != EOF){
		cnt = 0;
		for (i = 2; i <= a; i++) {
			if (s[i] == 1) cnt++;
		}
		printf("%d\n", cnt);
	}
	
	return (0);
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
#define MAXN 10100
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int n, h, w, a[MAXN], g[200][200];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> h >> w >> n;
    for(int i = 0; i < n; i++){
    	cin >> a[i];
    }
    int p = 0;
    for(int i = 0; i < h; i++){
    	for(int j = 0; j < w; j++){
    		if(a[p] <= 0) p++;
    		a[p]--;
    		if(i % 2) g[i][j] = p + 1;
    		else g[i][w - j - 1] = p + 1;
    	}
    }
    for(int i = 0; i < h; i++){
    	for(int j = 0; j < w; j++){
    		cout << g[i][j] << " ";
    	}
    	cout << endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define ld              long double
#define fi              first
#define se              second
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define fo(i,n)         for(i=0; i<n; i++)
#define fo1(i,n)        for(i=1; i<=n; i++)
#define Fo(i,k,n)       for(i=k; k<=n?i<=n:i>=n; k<=n?i++:i--)
#define all(x)          x.begin(), x.end()
#define rall(x)         x.rbegin(), x.rend()
#define sortall(x)      sort(all(x))
#define sortrall(x)     sort(rall(x))
#define clr(x)          memset(x, 0, sizeof(x))
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define pii             pair<int, int>
#define mk(arr,n,type)  type *arr = new type[n];
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int, int>
#define umii            unordered_map<int, int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define trailzrobits(x) __builtin_ctzll(x)
#define leadzrobits(x)  __builtin_clzll(x)
#define paritybits(x)   __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       (x * y) / gcd(x, y)
#define mod             1000000007
#define endl            '\n'
#define PI              3.1415926535897932384626
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x
void __print(int32_t x) {cout<<x;}
void __print(int x) {cout<<x;}
void __print(ld x) {cout<<x;}
void __print(double x){cout<<x;}
void __print(float x){cout<<x;}
void __print(bool x) {cout<<(x?"true":"false");}
void __print(char x){cout <<'\''<<x<<'\'';}
void __print(const char *x){cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}void _print() {cout << "]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
#else 
#define dbg(x...)
#endif
int power(int base, int exp){ int res = 1; base %= mod; while(exp > 0){ if(exp & 1) res = (res * base) % mod; base = (base * base) % mod; exp = exp >> 1; } return res; }
int inv(int x){ return power(x, mod - 2) % mod; }
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




const int N = 1e6 + 6, M = N;
int i, j;

void solve(){
    
    int k; string s; cin>>k>>s;
    int n=s.size();
    if(k>=n) cout<<s<<endl;
    else {
        fo(i,k) cout<<s[i];
        cout<<"...";
    }
    
    
    
    
}




int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void){
    int A, B, C, X, c=0;
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
    scanf("%d", &X);

    for( int i=0; i<=A; i++ ){
        for( int j=0; j<=B; j++ ){
            for( int k=0; k<=C; k++ ){
                int ans = 500*i + 100*j + 50*k;
                if( ans==X ){
                    c++;
                }
            }
        }
    }

    printf("%d", c);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n,m,a[100006],s,i;
int main()
{
	cin>>n>>m;
	for(i=1;i<=m;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	if(s>n)cout<<-1;
	else cout<<n-s; 
	return 0;
}


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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 20437;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;


int main ()
{
  prep();
  string s;
  cin >> s;
  bool good = true;
  for (int i=0; i<s.size(); i++){
      char c = s[i];
      if (i%2 == 0){
          if (c == 'L'){
             good = false;
             break;
          }
      }else{
          if (c == 'R'){
              good = false;
              break;
          }
      }
  }
  if (good){
      cout << "Yes";
  }else{
      cout << "No";
  }
  return 0; 
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

const ll MAX_N=1e5,INF=1e12;

ll N,M;

struct edge{
	ll cst,to;
	edge(ll c=0,ll t=0):cst(c),to(t){}
};

vector<edge> G[MAX_N];
P pol[MAX_N];

bool flg[MAX_N];

int main(){
	cin>>N>>M;
	memset(flg,0,sizeof(flg));
	REP(i,M){
		ll u,v,s;
		cin>>u>>v>>s;
		u--;
		v--;
		G[u].push_back(edge(s,v));
		G[v].push_back(edge(s,u));
	}
	pol[0]=P(1,0);
	flg[0]=true;
	queue<ll> q;
	q.push(0);
	while(!q.empty()){
		ll v=q.front();
		q.pop();
		REP(i,G[v].size()){
			edge e=G[v][i];
			if (!flg[e.to]){
				flg[e.to]=true;
				pol[e.to]=P(-pol[v].first,e.cst-pol[v].second);
				q.push(e.to);
			}
		}
	}
	ll x=1,y=INF;
	REP(v,N){
		if (pol[v].first>0){
			x=max(x,(1-pol[v].second+pol[v].first-1)/pol[v].first);
		}else{
			y=min(y,(1-pol[v].second)/pol[v].first);
		}
		REP(i,G[v].size()){
			edge e=G[v][i];
			P p=P(pol[v].first+pol[e.to].first,pol[v].second+pol[e.to].second);
			if (p.first==0){
				if (p.second!=e.cst){
					x=1;
					y=0;
				}
			}else if ((e.cst-p.second)%2){
				x=1;
				y=0;
			}else{
				x=max(x,(e.cst-p.second)/p.first);
				y=min(y,(e.cst-p.second)/p.first);
			}
		}
	}
	cout<<max<ll>(0,y-x+1)<<endl;
	return 0;
}

Measured memory_bytes: 9856
import bisect

n = int(input())
l = sorted(map(int, input().split()))

ans = 0
for i in range(1, n):
    for j in range(i + 1, n):
        k = bisect.bisect_left(l, l[j] - l[i] + 1, 0, i)
        ans += max(0, i - k)
print(ans)

Measured memory_bytes: 44636
import scala.collection.mutable._
import io.StdIn.readLine

object Main extends App {
  val map = new HashMap[String,Int]
  val s = readLine.split(" ")
  s.foreach(e => {
    if(!map.contains(e)) map.put(e,1)
    else map.put(e,map(e)+1)
  })
  val maxF = map.maxBy(_._2)._1
  val maxL = s.map(e => (e.length, e)).max._2

  println(maxF + " " + maxL)
}


Measured memory_bytes: 43828
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
typedef long long ll;
using namespace std;
#define MX 1000000000
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> vec(N);
    for (ll i = 0; i < N; ++i)
        cin >> vec[i];
    sort(vec.begin(), vec.end());
    double ans = double(vec[0] + vec[1]) / 2;
    for (ll i = 2; i < N; ++i)
        ans = double(ans + vec[i]) / 2;
    cout << fixed << setprecision(15);
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>
int main(){
	int high[10],n=0;
	for(int a=0;a<10;++a)std::cin>>high[a];
	for(int a=0;a<10;++a)
		for(int b=0;b<10;++b)
			if(high[a]>high[b])n=high[a],high[a]=high[b],high[b]=n;
	for(int a=0;a<3;++a)std::cout<<high[a]<<std::endl;
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAXNAMELEN 100

struct music{
	char name[MAXNAMELEN+1];
	int time;
};

int main(){
	int n;
	char x[MAXNAMELEN+1];
	struct music *m;
	int i, j;
	int sum_time = 0;

	scanf("%d", &n);
	m = (struct music *)malloc(sizeof(struct music)*n);

	for(i=0; i<n; i++){
		scanf("%s %d", m[i].name, &(m[i].time));
	}

	scanf("%s", x);

	for(i=0; i<n; i++){
		if(strcmp(x, m[i].name) == 0){
			break;
		}
	}

	for(j=i+1; j < n; j++){
		sum_time += m[j].time;
	}

	printf("%d", sum_time);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int animal[100000011];
int main()
{
	int n;
	string s;
	cin >>n>>s;
	s=s+s;
	for(int i=0;i<2;i++)
	for(int j=0;j<2;j++)
	{
		animal[0]=i;
		animal[1]=j;
		for(int l=2;l<n+2;l++)
		{
			if(s[l-1]=='o'&&animal[l-1]==0)
			animal[l]=1-animal[l-2];
			if(s[l-1]=='o'&&animal[l-1]==1)
			animal[l]=animal[l-2];
			if(s[l-1]=='x'&&animal[l-1]==0)
			animal[l]=animal[l-2];
			if(s[l-1]=='x'&&animal[l-1]==1)
			animal[l]=1-animal[l-2];
		}
		if(animal[n]==animal[0]&&animal[n+1]==animal[1])
		{
			for(int i=0;i<n;i++)
			cout <<(animal[i]?"S":"W");
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 1052
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
   int N;
   char playlist[50][101];
   int playlist_time[50];
   char neoti[101];
   int ans = 0;
   scanf("%d\n",&N);
   for(int i = 0;i < N;i++){
      scanf("%s %d\n",playlist[i],&playlist_time[i]);
   }
   scanf("%s",neoti);
   //printf("%s\n",neoti);
   for(int i = 0;i < N;i++){
      if(!(strcmp(neoti,playlist[i]))){
         //printf("i:%d\n",i);
         if(i == N-1)
            break;
         for(int j = i+1;j < N;j++){
            ans += playlist_time[j];
            //printf("%s[%d]:%d\n",playlist[j],j,playlist_time[j]);
         }
         break;
      }
   }
   printf("%d\n",ans);
   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int n,k,r,s,p,i;
  ll ans=0;
  bool win[100005];
  string t;
  
  cin >> n >> k >> r >> s >> p >> t;
  
  for (i=0;i<n;i++){
    if (i<k || t[i]!=t[i-k] || (i>=k && t[i]==t[i-k] && !win[i-k])){
      win[i]=true;
      if (t[i]=='r') ans+=p;
      if (t[i]=='s') ans+=r;
      if (t[i]=='p') ans+=s;
    }else{
      win[i]=false;
    }
    
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 512
def comb(n, r, p):
    x, y = 1, 1
    for i in range(n, n - r, -1):
        x *= i
        y *= i + r - n
        x %= p
        y %= p
    return pow(y, p - 2, p) * x % p

x, y = map(int, input().split())
n = (x + y) // 3
p = 10 ** 9 + 7
if (x + y) % 3 == 0 and max(x, y) <= 2 * min(x, y):
    r = 0
    if x > y:
        x, y = y, x
    a = (2 * x - y) // 3
    r = min(a, n - a)
    print(comb(n, r, p))
else:
    print(0)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define maxn 101000

int main()
{
	int n,i;
	scanf("%d%d",&n,&i);
	printf("%d\n",n-i+1);
	return 0;
}


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

int main()
{
  long long int n,k,ans=0,mod=1e9+7;
  cin>>n>>k;
  long long int z=((n+1)*n)/2;
  for(long long int i=k;i<=n;i++)
  {
      ans=ans+(z-((i-1)*i)/2)-((n-i)*(n-i+1)/2)+1;
      ans=(ans)%mod;
  }

  cout<<ans+1;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n, p / 2);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret;
	}
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;
	
	vll A(N);
	ll x;
	std::cin >> A[0];
	x = A[0];
	rep(i, 1, N) {
		std::cin >> A[i];
		x ^= A[i];
	}

	rep(i, 0, N) {
		std::cout << (x ^ A[i]);
		if (i < N-1) {
			std::cout << " ";
		}
	}
	std::cout << endl;

	return 0;
}


Measured memory_bytes: 4840
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    char[] c = sc.next().toCharArray();
    int rCount = 0;
    int wCount = 0;
    for (int i = 0; i < n; i++) {
      if (c[i] == 'W') {
        wCount++;
      } else {
        rCount++;
      }
    }
    int left = 0;
    int right = n - 1;
    int count = 0;
    while (true) {
      if (c[left] == 'W') {
        while (true) {
          if (c[right] != 'R') {
            right--;
            if (left >= right) {
              break;
            }
          } else {
            count++;
            right--;
            break;
          }
        }
      }
      left++;
      if (left >= right) {
        break;
      }
    }
    System.out.println(Math.min(Math.min(wCount, rCount), count));
  }
}


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

using namespace std;

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

    int count = 0, AB = 0, A = 0, B = 0;

    for (int i = 0; i < N; i++){
        string s;
        cin >> s;
        for (int j = 0; j < s.length() - 2; j++){
            if (s[j] == 'A' && s[j+1] == 'B'){
                count ++;
            }
        }
        if (s[0] == 'B'){
            B++;
        }
        if (s[s.length() - 1] == 'A') {
            A++;
        }
        if (s[0] == 'B' && s[s.length() - 1] == 'A'){
            AB++;
        }
    }

    
    if (AB > 0){
        count += AB - 1;
        A -= AB;
        B -= AB;
        if (A != 0 || B != 0){
            if (A > B){
                count += B + 1;
            }else{
                count += A + 1;
            }
        }
    }else{
        if (A > B){
            count += B;
        }else{
            count += A;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
while True:
    h, w = map(int, input().split())
    if h == 0:
        break
    
    pattern1 = '#.' * (w // 2) + '#' * (w % 2)
    pattern2 = '.#' * (w // 2) + '.' * (w % 2)
    
    for i in range(h):
        if i % 2 == 0:
            print(pattern1)
        else:
            print(pattern2)
        
    print()


Measured memory_bytes: 5608
import java.util.*;

public class Main {

    static int N;
    static boolean[][] F;
    static int[][] P;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        F = new boolean[N+1][10];
        for (int n = 1; n <= N; n++) {
            for (int wm = 0; wm < 10 ; wm++) {
                F[n][wm] = sc.nextInt() == 1;
            }
        }

        P = new int[N+1][11];
        for (int n = 1; n <= N; n++) {
            for (int i = 0; i <= 10 ; i++) {
                P[n][i] = sc.nextInt();
            }
        }

        System.out.println( solve() );
    }

    private static int solve() {
        int ans = Integer.MIN_VALUE;
        for (int b = 1; b <= 1023; b++) {
            int profit = 0;
            for (int n = 1; n <= N; n++) {
                int cn = 0;
                for (int wm = 0; wm < 10; wm++) {
                    if( isOn(b, wm) && F[n][wm] ) {
                        cn++;
                    }
                }
                profit += P[n][cn];
            }

            ans = Math.max(profit, ans);
        }
        return ans;
    }

    private static boolean isOn(int b, int wm) {
        return (b & (1 << wm)) != 0;
    }
}


Measured memory_bytes: 26096
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 998244353;



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

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

string T;

int main(){
    cin>>T;
    REP( i, T.size() ){
        if( T[i] == '?' ) T[i] = 'D';
    }
    
    cout<<T<<endl;
}


Measured memory_bytes: 3348
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

typedef long long ll;
ll INF = 1000000010;
int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> hl = vector<ll>(n);

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

  vector<ll> dp = vector<ll>(n,INF);
  dp[0] = 0;
  for(int i=0;i<n;i++){
    for(int ki=1;ki<k+1;ki++){
      if(i+ki>n-1){
        break;
      }
      dp[i+ki] = min(dp[i+ki], dp[i]+abs(hl[i+ki]-hl[i]));
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define int long long 

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

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

  vi a(n), b(n);
  int sa = 0, sb = 0;
  rep(i, n){
    cin >> a[i];
    sa += a[i];
  }
  rep(i, n){
    cin >> b[i];
    sb += b[i];
  }

  if(sa > sb){
    cout << "No" << endl;
    return 0;
  }

  int cnta = 0, cntb = 0;
  rep(i, n){
    if(a[i] > b[i]){
      cnta += a[i]-b[i];
    }else if(a[i] < b[i]){
      cntb += (b[i]-a[i]+1)/2;
    }
  }

  if(cnta <= sb-sa and cntb <= sb-sa) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<string.h>
#include<set>
#include<functional>
using namespace std;

#define INF 1<<21
#define MOD 1000000007

int main() {
  int N;
  int W, H;
  int a, b;
  int S, T;
  int table[105][105];
  int maxx;
  while (1) {
	cin >> N;
	if (N == 0) {
	  return 0;
	}
	cin >> W >> H;
	memset(table, 0, sizeof(table));
	maxx = 0;
	for (int i = 0; i < N; i++) {
	  cin >> a >> b;
	  table[b][a] = 1;
	}
	cin >> S >> T;
	for (int i = 1; i <= H - T + 1; i++) {
	  for (int j =1 ; j <= W - S + 1; j++) {
		int cnt = 0;
		for (int k = i; k < i + T; k++) {
		  for (int l = j; l < j + S; l++) {
			if (table[k][l] == 1)cnt++;
		  }
		}
		maxx = max(cnt, maxx);
	  }
	}
	cout << maxx << endl;
  }
}

Measured memory_bytes: 3024
import java.util.Scanner;

public class Main {
	Scanner scan = new Scanner(System.in);
	void run() {
		int n = scan.nextInt();
		for (int i = 1; i <= n; i++) {
			int x = i;
			if(x % 3 == 0) {
				System.out.print(" " + i);
			} else {
				do {
					if(x % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					x /= 10;
				} while(x != 0);
			}
		}

		System.out.println();
	}

	public static void main(String[] args) {
		//TODO Auto-generated method stub
		new Main().run();
	}

}

Measured memory_bytes: 28924
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------
// handstand 2
int main(void) {
  ll n;
  cin >> n;

  ll c[10][10]={};

  ll ans=0;
  rep(i,n){
    ll k=i+1;
    int a, b;
    b = k%10;
    while(k>9){
      k/=10;
    }
    a = k;
    c[a][b]++;
  }
  rep(i,10){
    rep(j,10){
      ans+=c[i][j]*c[j][i];
    }
  }

  prt(ans);
}


Measured memory_bytes: 256
main = do
    week <- readLn
    print $ debt initDebt debtRate week

initDebt = 100000
debtRate = 1.05

debt :: Int -> Double -> Int -> Int
debt money rate week = foldl (\x -> upvalue.mult x) money $ replicate week rate
    where upvalue = (*1000).ceiling.(/1000)
          mult x y = (fromIntegral x)*y

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

const int N = 100005;

std::string s;
int n, head[N], tot, deg[N], ans = -2;
struct edge { int to, nxt; } e[N << 1];

void link(int x, int y) {
	e[++tot] = (edge) { y, head[x] }, head[x] = tot;
	e[++tot] = (edge) { x, head[y] }, head[y] = tot;
}

bool dfs0(int x, int f = 0) {
	bool sum = s[x] == 'W';
	for (int i = head[x]; i; i = e[i].nxt) if (e[i].to != f) {
		bool ret = dfs0(e[i].to, x);
		deg[x] ^= ret, sum |= ret;
	}
	ans += sum * 2;
	return deg[x] ^= sum, sum;
}

int val[N], p, max;
void dfs1(int x, int f = 0, int dep = 0) {
	dep += val[x];
	if (dep > max) p = x, max = dep;
	for (int i = head[x]; i; i = e[i].nxt)
		if (e[i].to != f) dfs1(e[i].to, x, dep);
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1, x, y; i < n; ++i)
		std::cin >> x >> y, link(x, y);
	std::cin >> s, s = "$" + s;
	int root = 0;
	for (int i = 1; i <= n; ++i)
		if (s[i] == 'W') root = i;
	if (!root) return std::cout << 0 << '\n', 0;
	if (std::count(s.begin(), s.end(), 'W') == 1)
		return std::cout << 1 << '\n', 0;
	dfs0(root), deg[root] ^= 1;
	for (int i = 1; i <= n; ++i) ans += deg[i] + (s[i] == 'W') & 1;
	for (int i = 1; i <= n; ++i) val[i] = (deg[i] + (s[i] == 'W') & 1) * 2;
	dfs1(root), dfs1(p);
	std::cout << ans - max << '\n';
	return 0;
}

Measured memory_bytes: 7784